Class: Vagrant::Node::ClientController
- Inherits:
-
Object
- Object
- Vagrant::Node::ClientController
- Defined in:
- lib/vagrant-node/clientcontroller.rb
Class Method Summary collapse
- .authorized?(token, challenge) ⇒ Boolean
-
.backup_log(vmname = nil) ⇒ Object
BACKUP LOG METHOD ###############.
-
.box_add(box, url, user = "guest", pass = "--no-pass") ⇒ Object
end.
-
.box_delete(box, provider) ⇒ Object
BOX DELETE METHOD #####################.
-
.cleardownloadboxes ⇒ Object
CLEAR BOX DOWNLOADS METHOD ##################.
-
.config_show ⇒ Object
CONFIG SHOW METHOD #####################.
-
.config_upload(cfile) ⇒ Object
CONFIG UPLOAD METHOD #####################.
- .execute_queued ⇒ Object
-
.listboxes ⇒ Object
BOX LIST METHOD #######################.
-
.listdownloadboxes ⇒ Object
BOX DOWNLOADS METHOD ##################.
-
.nodeinfo ⇒ Object
NODE INFO (CPU,MEMORY) ################.
-
.operation_queued(id) ⇒ Object
OPERATION METHODS #######################.
- .operation_queued_last ⇒ Object
-
.password_change(new_password) ⇒ Object
NODE PASSWORD CHANGE ###################.
- .send_challenge ⇒ Object
-
.vm_add(config, rename) ⇒ Object
VIRTUAL MACHINE ADD METHOD ###############.
-
.vm_confirmed_destroy(vmname) ⇒ Object
VIRTUAL MACHINE DESTROY METHOD ###############.
-
.vm_delete(vmname, remove = false) ⇒ Object
VIRTUAL MACHINE DELETE METHOD ###############.
-
.vm_halt(vmname, force) ⇒ Object
VIRTUAL MACHINE HALT METHOD #################.
-
.vm_info(vmname) ⇒ Object
VIRTUAL MACHINE INFO METHOD ###############.
-
.vm_provision(vmname) ⇒ Object
VIRTUAL MACHINE PROVISION METHOD ##################.
-
.vm_resume(vmname) ⇒ Object
VIRTUAL MACHINE RESUME METHOD ##################.
-
.vm_snapshot_delete(vmname, snapshot_id) ⇒ Object
VIRTUAL MACHINE SNAPSHOT DELETE METHOD #############.
-
.vm_snapshot_restore(vmname, snapshot_id) ⇒ Object
VIRTUAL MACHINE SNAPSHOT RESTORE METHOD #############.
-
.vm_snapshot_take(vmname, name, desc = " ") ⇒ Object
VIRTUAL MACHINE SNAPSHOT TAKE METHOD #############.
-
.vm_snapshot_take_file(vmname) ⇒ Object
VIRTUAL MACHINE BACKUP TAKE METHOD #############.
-
.vm_snapshots(vmname = nil) ⇒ Object
VIRTUAL MACHINE SNAPSHOT LIST METHOD #############.
-
.vm_ssh_config(vmname) ⇒ Object
VIRTUAL MACHINE SSHCONFIG## ###############.
-
.vm_status(vmname = nil, verbose = true) ⇒ Object
VIRTUAL MACHINE STATUS METHOD ###############.
-
.vm_suspend(vmname) ⇒ Object
VIRTUAL MACHINE SUSPEND METHOD ##################.
-
.vm_up(vmname) ⇒ Object
VIRTUAL MACHINE UP METHOD ##################.
Class Method Details
.authorized?(token, challenge) ⇒ Boolean
59 60 61 62 63 |
# File 'lib/vagrant-node/clientcontroller.rb', line 59 def self.(token,challenge) ensure_environment @pw.(token,challenge) end |
.backup_log(vmname = nil) ⇒ Object
BACKUP LOG METHOD ###############
FIXME No está controlado el que el parámetro sea nil
979 980 981 982 983 984 985 986 987 988 989 990 |
# File 'lib/vagrant-node/clientcontroller.rb', line 979 def self.backup_log(vmname=nil) ensure_environment #begin @db.get_backup_log_entries(vmname) # rescue => e # puts e.message # end end |
.box_add(box, url, user = "guest", pass = "--no-pass") ⇒ Object
end
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
# File 'lib/vagrant-node/clientcontroller.rb', line 284 def self.box_add(box,url,user="guest",pass="--no-pass") @env.boxes.all.each do |box_name,provider| if box_name==box raise RestException.new(500,"There is a box with the same name") end end command_block = Proc.new { #ensure_environment boxes = [] boxes <<{:name=>box} #Adding the box to the list @db.add_box_download_info(box,url) #If the box is downloading or there isn't any box return if (!@db.is_box_downloading) # Get the provider if one was set provider = nil begin copy_db = @db.clone #boxes <<{:name=>box} provider=nil force = true # Always overwrite box if exists insecure = true #Don't validate SSL certs #Calling original box add action @env.action_runner.run(BoxAddAction, { :box_provider => provider, :box_force => force, :box_download_insecure => insecure, :db => copy_db, }) rescue =>e puts e. end boxes end } method("execute_queued").call(&command_block); end |
.box_delete(box, provider) ⇒ Object
BOX DELETE METHOD #####################
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/vagrant-node/clientcontroller.rb', line 178 def self.box_delete(box,provider) ensure_environment boxes = [] bbox = @env.boxes.find(box,provider.to_sym) if (bbox) get_vms("").each do |machine| if (!machine.box.nil? && machine.box.name==box) raise RestException.new(500,"The box can't be deleted because the virtual machine '#{machine.name.to_s}' is using it") end end boxes << bbox.name bbox.destroy! else raise RestException.new(404,"The box '#{box}' does not exist") end boxes end |
.cleardownloadboxes ⇒ Object
CLEAR BOX DOWNLOADS METHOD ##################
136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/vagrant-node/clientcontroller.rb', line 136 def self.cleardownloadboxes ensure_environment @db.clear_box_downloads true end |
.config_show ⇒ Object
CONFIG SHOW METHOD #####################
996 997 998 999 1000 |
# File 'lib/vagrant-node/clientcontroller.rb', line 996 def self.config_show ensure_environment file = @env.root_path+"Vagrantfile" end |
.config_upload(cfile) ⇒ Object
CONFIG UPLOAD METHOD #####################
1005 1006 1007 1008 1009 1010 1011 1012 1013 |
# File 'lib/vagrant-node/clientcontroller.rb', line 1005 def self.config_upload(cfile) ensure_environment f = File.new(@env.root_path+"Vagrantfile", "w") f.write(cfile) f.close true end |
.execute_queued ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/vagrant-node/clientcontroller.rb', line 31 def self.execute_queued ensure_environment #Generating a random identifier for process rpid=rand(1000000) pid = fork do begin @db.create_queued_process(rpid) res = yield @db.set_queued_process_result(rpid,res.to_json) rescue Exception => e @db.set_queued_process_error(rpid,e) end end rpid end |
.listboxes ⇒ Object
BOX LIST METHOD #######################
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/vagrant-node/clientcontroller.rb', line 152 def self.listboxes ensure_environment boxes = @env.boxes.all.sort fboxes = Array.new #From version 1.6.5 (I'think) the box array is different from previous ones boxes.each do |entry| if entry.size==3 fboxes << {"name" => entry[0],"provider" => entry[2]} else fboxes << {"name" => entry[0],"provider" => entry[1]} end end fboxes end |
.listdownloadboxes ⇒ Object
BOX DOWNLOADS METHOD ##################
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/vagrant-node/clientcontroller.rb', line 113 def self.listdownloadboxes ensure_environment downloads = @db.get_box_download fdownloads = Array.new downloads.each do |row| fdownloads << {"box_name" => row["box_name"],"box_url" => row["box_url"],"box_progress" => row["download_progress"],"box_remaining" => row["download_remaining"],"download_status" => row["download_status"]} end fdownloads end |
.nodeinfo ⇒ Object
NODE INFO (CPU,MEMORY) ################
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/vagrant-node/clientcontroller.rb', line 69 def self.nodeinfo #usw = Usagewatch begin Facter.loadfacts mem_values = Util::HwFunctions.get_mem_values disk_values = Util::HwFunctions.get_disk_values result=Hash[Facter.to_hash.map{|(k,v)| [k.to_sym,v]}] #Overriding memory values of Facter result[:memorysize] = (mem_values[0] / 1024.0).round(2) #Converting to GB and rounding result[:memoryfree] = (mem_values[1] / 1024.0).round(2) #Converting to GB result[:memorysize_mb] = mem_values[0] result[:memoryfree_mb] = mem_values[1] result[:cpuaverage] = Sys::CPU.load_avg; #result[:diskusage] = usw.uw_diskused result[:diskusage] = disk_values result[:vagrant_version] = Vagrant::VERSION result rescue Exception => e raise RestException.new(500,"Error gathering node hardware information") end end |
.operation_queued(id) ⇒ Object
OPERATION METHODS #######################
1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 |
# File 'lib/vagrant-node/clientcontroller.rb', line 1018 def self.operation_queued(id) ensure_environment result = @db.get_queued_process_result(id) raise RestException.new(404,"The operation ID: #{id} not found") if (result.size==0) opres = Array.new aux=result.first opres[0]=aux["operation_status"] opres[1]=aux["operation_result"] opres end |
.operation_queued_last ⇒ Object
1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 |
# File 'lib/vagrant-node/clientcontroller.rb', line 1043 def self.operation_queued_last ensure_environment opres = Array.new result=@db.get_queued_last result.each do |row| aux=Array.new aux[0]=row["operation_status"] aux[1]=row["operation_result"] opres << aux end opres end |
.password_change(new_password) ⇒ Object
NODE PASSWORD CHANGE ###################
968 969 970 971 972 973 |
# File 'lib/vagrant-node/clientcontroller.rb', line 968 def self.password_change(new_password) ensure_environment @db.node_password_set(new_password,true) true end |
.send_challenge ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/vagrant-node/clientcontroller.rb', line 51 def self.send_challenge challenge = SecureRandom.urlsafe_base64(nil, false) = SecureRandom.urlsafe_base64(nil, false) {:cookie => , :challenge => challenge} end |
.vm_add(config, rename) ⇒ Object
VIRTUAL MACHINE ADD METHOD ###############
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 |
# File 'lib/vagrant-node/clientcontroller.rb', line 423 def self.vm_add(config,rename) ensure_environment begin path="/tmp/conf."+Time.now.to_i.to_s f = File.new(path, "w") f.write(config) f.close cm = ConfigManager.new(@env.root_path+"Vagrantfile") cmtmp = ConfigManager.new(path) current_vms = @env.machine_names cmtmp.get_vm_names.each do |key| if current_vms.include?(key) raise RestException.new(406,"There is a remote VM with the same name: \"#{key}\"") if rename=="false" cmtmp.rename_vm(key,"#{key}_1") end end cm.insert_vms_sexp(cmtmp.extract_vms_sexp) rescue => e raise e ensure File.delete(path) end end |
.vm_confirmed_destroy(vmname) ⇒ Object
VIRTUAL MACHINE DESTROY METHOD ###############
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 |
# File 'lib/vagrant-node/clientcontroller.rb', line 483 def self.vm_confirmed_destroy(vmname) ensure_environment machine_names = [] #begin get_vms(vmname.to_sym).each do |machine| machine_names << machine.name machine.action(:destroy, :force_confirm_destroy => true) end machine_names #rescue => e # return nil #end end |
.vm_delete(vmname, remove = false) ⇒ Object
VIRTUAL MACHINE DELETE METHOD ###############
466 467 468 469 470 471 472 473 474 475 476 477 |
# File 'lib/vagrant-node/clientcontroller.rb', line 466 def self.vm_delete(vmname,remove=false) ensure_environment cm = ConfigManager.new(@env.root_path+"Vagrantfile") self.vm_confirmed_destroy(vmname) if remove!=false cm.delete_vm(vmname) true end |
.vm_halt(vmname, force) ⇒ Object
VIRTUAL MACHINE HALT METHOD #################
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 |
# File 'lib/vagrant-node/clientcontroller.rb', line 507 def self.vm_halt(vmname,force) force=(force=="true")?true:false; command_block = Proc.new { begin machine_names = [] get_vms(vmname).each do |machine| machine.action(:halt, :force_halt => force) machine_names << {"vmname" => machine.name.to_s, "provider" => machine.provider_name.to_s, "status" => machine.state.short_description} end raise RestException.new(404,"The machine #{vmname} does not exist") if (machine_names.empty?) machine_names rescue Exception => e aux=get_vms(vmname) machine=aux[0] raise RestException.new(404,"The machine #{vmname} does not exist") if (aux.empty?) raise VMActionException.new(machine.name.to_s,machine.provider_name.to_s,e.) if (!machine.nil?) end } method("execute_queued").call(&command_block); #rescue => e # return nil #end end |
.vm_info(vmname) ⇒ Object
VIRTUAL MACHINE INFO METHOD ###############
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 |
# File 'lib/vagrant-node/clientcontroller.rb', line 548 def self.vm_info(vmname) raise RestException.new(500,"The VM Name can't be emtpy") if vmname.empty? ensure_environment #execute("snapshot",self.uuid,"showvminfo",name) machines=get_vms(vmname) raise RestException.new(404,"The machine #{vmname} does not exist") if (machines.empty?) info = Hash.new if (machines[0].id!=nil) machines[0].provider.driver.execute("showvminfo",machines[0].id,"--machinereadable").split("\n").each do |line| if (line =~ /^(.*?)=\"(.*?)\"$/) || (line =~ /^(.*?)=(.*?)$/) info[$1]=$2 end end end info end |
.vm_provision(vmname) ⇒ Object
VIRTUAL MACHINE PROVISION METHOD ##################
864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 |
# File 'lib/vagrant-node/clientcontroller.rb', line 864 def self.vm_provision(vmname) #ensure_environment command_block = Proc.new { machine_names = [] # Por ahora no dejo que el vmname esté vacío para realizar la operación sobre todas las vm raise RestException.new(404,"Virtual Machine not specified") if (vmname==nil ||vmname.empty?) #begin #Provisioning get_vms(vmname).each do |machine| machine_names << machine.name machine.action(:provision) end raise RestException.new(404,"The machine #{vmname} does not exist") if (machine_names.empty?) machine_names } method("execute_queued").call(&command_block); end |
.vm_resume(vmname) ⇒ Object
VIRTUAL MACHINE RESUME METHOD ##################
655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 |
# File 'lib/vagrant-node/clientcontroller.rb', line 655 def self.vm_resume(vmname) command_block = Proc.new { #ensure_environment begin machine_names = [] #Launching machines get_vms(vmname).each do |machine| machine.action(:resume) machine_names << {"vmname" => machine.name.to_s, "provider" => machine.provider_name.to_s, "status" => machine.state.short_description} end raise RestException.new(404,"The machine #{vmname} does not exist") if (machine_names.empty?) machine_names rescue Exception => e aux=get_vms(vmname) machine=aux[0] raise RestException.new(404,"The machine #{vmname} does not exist") if (aux.empty?) raise VMActionException.new(machine.name.to_s,machine.provider_name.to_s,e.) if (!machine.nil?) end } method("execute_queued").call(&command_block); end |
.vm_snapshot_delete(vmname, snapshot_id) ⇒ Object
VIRTUAL MACHINE SNAPSHOT DELETE METHOD #############
778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 |
# File 'lib/vagrant-node/clientcontroller.rb', line 778 def self.vm_snapshot_delete(vmname,snapshot_id) ensure_environment #begin raise RestException.new(404,"Virtual Machine not specified") if (vmname==nil ||vmname.empty?) get_vms(vmname).each do |machine| env = { :machine => machine, :machine_action => SnapshotAction::DELETE, :snapshot_id => snapshot_id, } # # res = @env.action_runner.run(SnapshotAction,env) # return res[:delete_snapshot] # end # # rescue => e # puts e.message # # return nil # end end |
.vm_snapshot_restore(vmname, snapshot_id) ⇒ Object
VIRTUAL MACHINE SNAPSHOT RESTORE METHOD #############
815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 |
# File 'lib/vagrant-node/clientcontroller.rb', line 815 def self.vm_snapshot_restore(vmname,snapshot_id) command_block = Proc.new { #ensure_environment raise RestException.new(404,"Virtual Machine not specified") if (vmname==nil ||vmname.empty?) restore_results = {} get_vms(vmname).each do |machine| prev_state=machine.state.id #First, ensure that the machine is in a proper state #to restore the snapshot (save, poweroff) machine.action(:suspend) if prev_state==:running #Now the machine is ready for restoration env = { :machine => machine, :machine_action => SnapshotAction::RESTORE, :snapshot_id => snapshot_id } res = @env.action_runner.run(SnapshotAction,env) #Now restore the vm to the previous state if running machine.action(:up) if prev_state==:running restore_results[machine.name.to_sym]=res[:restore_result] end restore_results } method("execute_queued").call(&command_block); end |
.vm_snapshot_take(vmname, name, desc = " ") ⇒ Object
VIRTUAL MACHINE SNAPSHOT TAKE METHOD #############
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 |
# File 'lib/vagrant-node/clientcontroller.rb', line 726 def self.vm_snapshot_take(vmname,name,desc=" ") command_block = Proc.new { #ensure_environment raise RestException.new(404,"Virtual Machine not specified") if (vmname==nil ||vmname.empty?) machine = get_vms(vmname) raise RestException.new(404,"Virtual Machine not found") if (machine.empty?) env = { :machine => machine.first, :machine_action => SnapshotAction::TAKE, :snapshot_name => name, :snapshot_desc => desc } res = @env.action_runner.run(SnapshotAction,env) res[:last_snapshot] # get_vms(vmname).each do |machine| # env = # { # :machine => machine, # :machine_action => SnapshotAction::TAKE, # :snapshot_name => name, # :snapshot_desc => desc # } # # res = @env.action_runner.run(SnapshotAction,env) # # return res[:last_snapshot] # # end } method("execute_queued").call(&command_block); end |
.vm_snapshot_take_file(vmname) ⇒ Object
VIRTUAL MACHINE BACKUP TAKE METHOD #############
922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 |
# File 'lib/vagrant-node/clientcontroller.rb', line 922 def self.vm_snapshot_take_file(vmname) ensure_environment current_machine = nil t = Time.now.strftime "%Y-%m-%d %H:%M:%S" begin machines=get_vms(vmname) return [404,"Virtual Machine not found"] if machines.empty? machines.each do |machine| current_machine = machine.name.to_s env = { :machine => machine, :machine_action => SnapshotAction::BACKUP, :path => @env.data_dir } @db.add_backup_log_entry(t,current_machine,BACKUP_IN_PROGRESS) res = @env.action_runner.run(SnapshotAction,env) if res[:bak_filename] == SnapshotAction::ERROR @db.update_backup_log_entry(t,current_machine,BACKUP_ERROR) return [500,"Internal Error"] if res[:bak_filename] == SnapshotAction::ERROR else @db.update_backup_log_entry(t,current_machine,BACKUP_SUCCESS) return [200,res[:bak_filename]] end end rescue => e @db.update_backup_log_entry(t,current_machine,BACKUP_ERROR) return [500,"Internal Error"] end end |
.vm_snapshots(vmname = nil) ⇒ Object
VIRTUAL MACHINE SNAPSHOT LIST METHOD #############
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 |
# File 'lib/vagrant-node/clientcontroller.rb', line 691 def self.vm_snapshots(vmname=nil) ensure_environment #begin snapshots = {} get_vms(vmname).each do |machine| env = { :machine => machine, :machine_action => SnapshotAction::LIST } res = @env.action_runner.run(SnapshotAction,env) snapshots[machine.name.to_sym]=res[:snapshots_list] end snapshots # rescue => e # puts e.message # # return nil # end end |
.vm_ssh_config(vmname) ⇒ Object
VIRTUAL MACHINE SSHCONFIG## ###############
896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 |
# File 'lib/vagrant-node/clientcontroller.rb', line 896 def self.vm_ssh_config(vmname) ensure_environment #Ensure vmname exists and it is not empty return nil if vmname.empty? #begin info = Array.new get_vms(vmname).each do |machine| info << machine.ssh_info end info[0] # rescue => e # puts e.message # return nil #end end |
.vm_status(vmname = nil, verbose = true) ⇒ Object
VIRTUAL MACHINE STATUS METHOD ###############
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 |
# File 'lib/vagrant-node/clientcontroller.rb', line 580 def self.vm_status(vmname=nil,verbose=true) ensure_environment begin status = Array.new if (verbose==true || verbose=="true") get_vms(vmname).each do |machine| status << {"name" => machine.name.to_s, "status" => machine.state.short_description, "provider" => machine.provider_name} end else @env.machine_names.each do |machine| status << {"name" => machine.to_s} end end status rescue Exception => e raise e end end |
.vm_suspend(vmname) ⇒ Object
VIRTUAL MACHINE SUSPEND METHOD ##################
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 |
# File 'lib/vagrant-node/clientcontroller.rb', line 613 def self.vm_suspend(vmname) command_block = Proc.new { #ensure_environment begin machine_names = [] #Suspendiing machines get_vms(vmname).each do |machine| machine.action(:suspend) machine_names << {"vmname" => machine.name.to_s, "provider" => machine.provider_name.to_s, "status" => machine.state.short_description} end raise RestException.new(404,"The machine #{vmname} does not exist") if (machine_names.empty?) machine_names rescue Exception => e aux=get_vms(vmname) machine=aux[0] raise RestException.new(404,"The machine #{vmname} does not exist") if (aux.empty?) raise VMActionException.new(machine.name.to_s,machine.provider_name.to_s,e.) if (!machine.nil?) end } method("execute_queued").call(&command_block); end |
.vm_up(vmname) ⇒ Object
VIRTUAL MACHINE UP METHOD ##################
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
# File 'lib/vagrant-node/clientcontroller.rb', line 361 def self.vm_up(vmname) command_block = Proc.new { machine_names = [] begin = {} [:parallel] = true #Launching machines @env.batch([:parallel]) do |batch| get_vms(vmname).each do |machine| batch.action(machine, :up, ) machine_names << {"vmname" => machine.name.to_s, "provider" => machine.provider_name.to_s, "status" => "running"} end end raise RestException.new(404,"The machine #{vmname} does not exist") if (machine_names.empty?) machine_names rescue Exception => e aux=get_vms(vmname) machine=aux[0] raise RestException.new(404,"The machine #{vmname} does not exist") if (aux.empty?) raise VMActionException.new(machine.name.to_s,machine.provider_name.to_s,e.) if (!machine.nil?) end } method("execute_queued").call(&command_block) end |