Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

vagrant up powers on already running vm? #51

Closed
StefanScherer opened this issue May 10, 2014 · 4 comments
Closed

vagrant up powers on already running vm? #51

StefanScherer opened this issue May 10, 2014 · 4 comments
Assignees
Labels
Milestone

Comments

@StefanScherer
Copy link
Contributor

Just another strange situation. I have powered up two of four VM's in a vApp.
Then checking with status and vcloud-status to see starting point as shown below.
After that another vagrant up shows me already running messages, but also a Powering up message for the two already running boxes.

Could we skip this Powering on if box is already running?
I think, host names or other guest customization steps could be skipped in this situation?

$ vagrantd status
000.000 START: vagrant status --debug
000.000 LOGFILE: 28-vagrant-status.log
004.561    
004.598    
006.022    
007.236    
009.129    
010.301    
013.059 Current machine states:
013.104 
013.104 console-vm                running (vcloud)
013.104 sender-vm                 running (vcloud)
013.104 receiver-vm               not created (vcloud)
013.104 spooler-vm                not created (vcloud)
013.104 
013.104 This environment represents multiple VMs. The VMs are all listed
013.104 above with their current state. For more information about a specific
013.104 VM, run `vagrant status NAME`.
013.105 EXITCODE: 0


$ vagrantd vcloud-status --all
000.000 START: vagrant vcloud-status --all --debug
000.000 LOGFILE: 30-vagrant-vcloud-status-all.log
008.040 +------------------------------------+-----------------------------------------------+
008.041 |                Vagrant vCloud Director Status : https://roecloud001                |
008.041 +------------------------------------+-----------------------------------------------+
008.041 | Organization Name                  | SS                                            |
008.041 | Organization vDC Name              | SS-VDC                                        |
008.041 | Organization vDC ID                | ea5a7837-1f8f-4e5b-8b75-511a7869995f          |
008.041 | Organization vDC Network Name      | SS-INTERNAL                                   |
008.041 | Organization vDC Edge Gateway Name | SS-EDGE                                       |
008.041 | Organization vDC Edge IP           | 10.100.50.4                                   |
008.041 +------------------------------------+-----------------------------------------------+
008.041 | vApp Name                          | performance-stefan-stefans-mac.local-6c66c223 |
008.041 | vAppID                             | c7473bca-947a-4c1c-a69c-0c89c40ab23b          |
008.041 | -> sender-vm                       | 7a2c097d-63ed-405a-ae57-862a142481d4          |
008.041 | -> console-vm                      | 6a62e91f-dd2a-4ff0-8e32-590342e34431          |
008.041 +------------------------------------+-----------------------------------------------+
012.375 
012.376 +------------------------------------+-------------------------------------------------------+---------+
012.418 |                                 Vagrant vCloud Director Network Map                                  |
012.418 +------------------------------------+-------------------------------------------------------+---------+
012.418 | VM Name                            | Destination NAT Mapping                               | Enabled |
012.418 +------------------------------------+-------------------------------------------------------+---------+
012.418 | sender-vm                          | 10.100.50.4:2215 -> 10.115.4.6:2215 -> 172.16.32.3:22 | true    |
012.418 | console-vm                         | 10.100.50.4:2214 -> 10.115.4.6:2214 -> 172.16.32.2:22 | true    |
012.418 +------------------------------------+-------------------------------------------------------+---------+
012.419 | Network Name                       | Source NAT Mapping                                    | Enabled |
012.419 +------------------------------------+-------------------------------------------------------+---------+
012.419 | VM1-extern                         | 10.115.4.6 -> 10.100.50.4                             | true    |
012.419 +------------------------------------+-------------------------------------------------------+---------+
012.419 | Rule# - Description                | Firewall Rules                                        | Enabled |
012.419 +------------------------------------+-------------------------------------------------------+---------+
012.419 | 1 - (Allow Vagrant Communications) | allow SRC:Any:Any to DST:10.100.50.4:Any              | true    |
012.419 +------------------------------------+-------------------------------------------------------+---------+
012.419 EXITCODE: 0



$ vagrantd up
000.000 START: vagrant up --debug
000.000 LOGFILE: 31-vagrant-up.log
001.020 Bringing machine 'console-vm' up with 'vcloud' provider...
001.021 Bringing machine 'sender-vm' up with 'vcloud' provider...
001.022 Bringing machine 'receiver-vm' up with 'vcloud' provider...
001.023 Bringing machine 'spooler-vm' up with 'vcloud' provider...
013.020    
013.035    
013.035 ==> console-vm: VM is already running
014.275    
014.287    
014.288 ==> console-vm: Powering on VM...
039.154    
039.167    
039.167 ==> sender-vm: VM is already running
040.362    
040.403    
040.403 ==> sender-vm: Powering on VM...
058.302 ==> receiver-vm: Adding VM to existing vApp...
059.410    
059.463    
073.842    
073.855    
081.076 ==> receiver-vm: Powering on VM...
@StefanScherer
Copy link
Contributor Author

Seems to be this code here:

      # This action starts a VM, assuming it is already imported and exists.
      # A precondition of this action is that the VM exists.
      def self.action_start
        Vagrant::Action::Builder.new.tap do |b|
          b.use ConfigValidate
          b.use ConnectVCloud
          b.use Call, IsRunning do |env, b2|
            # If the VM is running, then our work here is done, exit
            if env[:result]
              b2.use MessageAlreadyRunning
              next
            end
          end
          b.use Call, IsPaused do |env, b2|
            if env[:result]
              b3.use Resume
              next
            end
          end
          b.use PowerOn
        end
      end

The both next commands propably should be return to return from the function.

@StefanScherer
Copy link
Contributor Author

I'm wrong. A 'return' would hurt more. I have read through some docs and especially Mitchs middleware https://github.com/mitchellh/middleware/blob/master/user_guide.md

All the functions in action.rb build a stack that will be called afterwards. So we have to move the PowerOn inside some if/else block like other plugins do.

I have compared vagrant-aws and vagrant-azure which both also work in parallel mode as well. That would be a good starting point to clean up this action.rb.

@tsugliani
Copy link
Collaborator

Hi @StefanScherer

Can you test this patch ?

screenshot 2014-05-11 16 47 43

I think our reasoning is too complex for this task, Resume and PowerOn actions on vCloud Director is the same exact action so I simplified it, and it seems working for me.

Thanks in advance,

@tsugliani tsugliani added the bug label May 11, 2014
@tsugliani tsugliani added this to the v0.3.2 milestone May 11, 2014
@tsugliani tsugliani self-assigned this May 11, 2014
@StefanScherer
Copy link
Contributor Author

Hi @tsugliani,

yes, this works fine. Second vm is started, first one (already) running ist skipped.

StefanScherer added a commit to StefanScherer/vagrant-vcloud that referenced this issue May 16, 2014
* upstream/develop:
  Debug formatting fixes, avoid unwanted \n
  Rubocop fixes
  Fixes frapposelli#51 - Do not PowerOn already Powered On machines, and simplify action_start
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants