lib/vagrant-vcloud/action.rb in vagrant-vcloud-0.4.4 vs lib/vagrant-vcloud/action.rb in vagrant-vcloud-0.4.6

- old
+ new

@@ -18,14 +18,25 @@ b.use Call, IsCreated do |env, b2| unless env[:bridged_network] b2.use HandleNATPortCollisions b2.use ForwardPorts end + cfg = env[:machine].provider_config + if cfg.power_on.nil? || cfg.power_on == true + if cfg.ssh_enabled.nil? || cfg.ssh_enabled == true + b2.use WaitForCommunicator, [:starting, :running] + end + end + b2.use Provision + if cfg.power_on.nil? || cfg.power_on == true # can't ssh if not on + if cfg.ssh_enabled.nil? || cfg.ssh_enabled == true # can't sync if ssh is disabled + if cfg.sync_enabled.nil? || cfg.sync_enabled == true + b2.use SyncFolders + end + end + end end - b.use WaitForCommunicator, [:starting, :running] - b.use Provision - b.use SyncFolders end end def self.action_reload Vagrant::Action::Builder.new.tap do |b| @@ -57,21 +68,32 @@ end end end end - def self.action_halt + def self.action_poweroff Vagrant::Action::Builder.new.tap do |b| b.use ConfigValidate b.use ConnectVCloud b.use Call, IsPaused do |env, b2| b2.use Resume if env[:result] end b.use PowerOff end end + def self.action_halt + Vagrant::Action::Builder.new.tap do |b| + b.use ConfigValidate + b.use ConnectVCloud + b.use Call, IsPaused do |env, b2| + b2.use Resume if env[:result] + end + b.use ShutDown + end + end + def self.action_suspend Vagrant::Action::Builder.new.tap do |b| b.use ConnectVCloud b.use Call, IsRunning do |env, b2| # If the VM is stopped, can't suspend @@ -103,19 +125,19 @@ next end b3.use Call, IsRunning do |env3, b4| # If the VM is running, must power off - b4.use action_halt if env3[:result] + b4.use action_poweroff if env3[:result] end b3.use Call, IsLastVM do |env3, b4| if env3[:result] # Check if the network is bridged - b4.use Call, IsBridged do |env4, b5| - # if it's not, delete port forwardings. - b5.use UnmapPortForwardings unless env4[:bridged_network] - end + # b4.use Call, IsBridged do |env4, b5| + # # if it's not, delete port forwardings. + # b5.use UnmapPortForwardings unless env4[:bridged_network] || env4[:advanced_network] + # end b4.use PowerOffVApp b4.use DestroyVApp else b4.use DestroyVM end @@ -284,9 +306,11 @@ action_root.join('read_ssh_info') autoload :ReadState, action_root.join('read_state') autoload :Resume, action_root.join('resume') + autoload :ShutDown, + action_root.join('shut_down') autoload :Suspend, action_root.join('suspend') autoload :SyncFolders, action_root.join('sync_folders') autoload :UnmapPortForwardings,