lib/vagrant-vcenter/action.rb in vagrant-vcenter-0.3.2 vs lib/vagrant-vcenter/action.rb in vagrant-vcenter-0.3.3

- old
+ new

@@ -21,28 +21,29 @@ def self.action_reload Vagrant::Action::Builder.new.tap do |b| b.use ConfigValidate b.use ConnectvCenter + b.use InventoryCheck b.use Call, IsCreated do |env, b2| unless env[:result] b2.use MessageNotCreated next end b2.use action_halt b2.use action_start - b2.use DisconnectvCenter end end end # 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 ConnectvCenter + b.use InventoryCheck 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 @@ -59,20 +60,28 @@ end def self.action_halt Vagrant::Action::Builder.new.tap do |b| b.use ConnectvCenter + b.use InventoryCheck + + # If the VM suspend, Resume first b.use Call, IsPaused do |env, b2| b2.use Resume if env[:result] - b2.use PowerOff + + # Only halt when VM is running. + b2.use Call, IsRunning do |env2, b3| + b3.use PowerOff if env2[:result] + end end end end def self.action_suspend Vagrant::Action::Builder.new.tap do |b| b.use ConnectvCenter + b.use InventoryCheck b.use Call, IsRunning do |env, b2| # If the VM is stopped, can't suspend if !env[:result] b2.use MessageCannotSuspend else @@ -83,20 +92,22 @@ end def self.action_resume Vagrant::Action::Builder.new.tap do |b| b.use ConnectvCenter + b.use InventoryCheck b.use Resume end end def self.action_destroy Vagrant::Action::Builder.new.tap do |b| b.use Call, DestroyConfirm do |env, b2| if env[:result] b2.use ConfigValidate b2.use ConnectvCenter + b2.use InventoryCheck b2.use Call, IsCreated do |env2, b3| unless env2[:result] b3.use MessageNotCreated next end @@ -108,17 +119,19 @@ end else b2.use MessageWillNotDestroy end end + # b.use DisconnectvCenter end end def self.action_provision Vagrant::Action::Builder.new.tap do |b| b.use ConfigValidate b.use ConnectvCenter + b.use InventoryCheck b.use Call, IsCreated do |env, b2| unless env[:result] b2.use MessageNotCreated next end @@ -134,10 +147,11 @@ # key. def self.action_read_ssh_info Vagrant::Action::Builder.new.tap do |b| b.use ConfigValidate b.use ConnectvCenter + b.use InventoryCheck b.use ReadSSHInfo end end # This action is called to read the state of the machine. The @@ -145,18 +159,20 @@ # key. def self.action_read_state Vagrant::Action::Builder.new.tap do |b| b.use ConfigValidate b.use ConnectvCenter + b.use InventoryCheck b.use ReadState end end def self.action_ssh Vagrant::Action::Builder.new.tap do |b| b.use ConfigValidate b.use ConnectvCenter + b.use InventoryCheck b.use Call, IsCreated do |env, b2| unless env[:result] b2.use MessageNotCreated next end @@ -167,10 +183,11 @@ def self.action_ssh_run Vagrant::Action::Builder.new.tap do |b| b.use ConfigValidate b.use ConnectvCenter + b.use InventoryCheck b.use Call, IsCreated do |env, b2| unless env[:result] b2.use MessageNotCreated next end @@ -180,13 +197,13 @@ end def self.action_up Vagrant::Action::Builder.new.tap do |b| b.use ConfigValidate - b.use ConnectvCenter b.use Call, IsCreated do |env, b2| b2.use HandleBox unless env[:result] end + b.use ConnectvCenter b.use InventoryCheck b.use Call, IsCreated do |env, b2| b2.use BuildVM unless env[:result] end b.use action_start