lib/vagrant-skytap/action.rb in vagrant-skytap-0.1.8 vs lib/vagrant-skytap/action.rb in vagrant-skytap-0.1.9

- old
+ new

@@ -7,13 +7,11 @@ include Vagrant::Action::Builtin # This action is called to halt the remote machine. def self.action_halt Vagrant::Action::Builder.new.tap do |b| - b.use ConfigValidate - b.use InitializeAPIClient - b.use FetchEnvironment + b.use action_fetch_environment b.use Call, ExistenceCheck do |env1, b1| case result = env1[:result] when :missing_environment, :missing_vm, :no_vms b1.use MessageNotCreated else @@ -24,13 +22,11 @@ end # This action is called to suspend the remote machine. def self.action_suspend Vagrant::Action::Builder.new.tap do |b| - b.use ConfigValidate - b.use InitializeAPIClient - b.use FetchEnvironment + b.use action_fetch_environment b.use Call, ExistenceCheck do |env1, b1| case result = env1[:result] when :missing_environment, :missing_vm, :no_vms b1.use MessageNotCreated else @@ -41,13 +37,11 @@ end # This action is called to terminate the remote machine. def self.action_destroy Vagrant::Action::Builder.new.tap do |b| - b.use ConfigValidate - b.use InitializeAPIClient - b.use FetchEnvironment + b.use action_fetch_environment b.use Call, ExistenceCheck do |env, b1| case existence_state = env[:result] when :missing_environment, :no_vms b1.use MessageNotCreated b1.use DeleteEnvironment @@ -77,13 +71,11 @@ end # This action is called when `vagrant provision` is called. def self.action_provision Vagrant::Action::Builder.new.tap do |b| - b.use ConfigValidate - b.use InitializeAPIClient - b.use FetchEnvironment + b.use action_fetch_environment b.use Call, ExistenceCheck do |env, b1| case result = env[:result] when :missing_environment, :missing_vm, :no_vms b1.use MessageNotCreated next @@ -113,36 +105,30 @@ # This action is called to read the SSH info of the machine. The # resulting state is expected to be put into the `:machine_ssh_info` # key. def self.action_read_ssh_info Vagrant::Action::Builder.new.tap do |b| - b.use ConfigValidate - b.use InitializeAPIClient - b.use FetchEnvironment + b.use action_fetch_environment b.use ReadSSHInfo end end # This action is called to read the state of the machine. The # resulting state is expected to be put into the `:machine_state_id` # key. def self.action_read_state Vagrant::Action::Builder.new.tap do |b| - b.use ConfigValidate - b.use InitializeAPIClient - b.use FetchEnvironment + b.use action_fetch_environment #TODO:NLA Can this whole action be removed? b.use ReadState end end # This action is called to SSH into the machine. def self.action_ssh Vagrant::Action::Builder.new.tap do |b| - b.use ConfigValidate - b.use InitializeAPIClient - b.use FetchEnvironment + b.use action_fetch_environment b.use Call, ExistenceCheck do |env1, b1| case result = env1[:result] when :missing_environment, :missing_vm, :no_vms b1.use MessageNotCreated else @@ -152,13 +138,11 @@ end end def self.action_ssh_run Vagrant::Action::Builder.new.tap do |b| - b.use ConfigValidate - b.use InitializeAPIClient - b.use FetchEnvironment + b.use action_fetch_environment b.use Call, ExistenceCheck do |env1, b1| case result = env1[:result] when :missing_environment, :missing_vm, :no_vms b1.use MessageNotCreated else @@ -183,19 +167,16 @@ end end def self.action_resume Vagrant::Action::Builder.new.tap do |b| - Vagrant::Action::Builder.new.tap do |b| - b.use InitializeAPIClient - b.use FetchEnvironment - b.use Call, IsSuspended do |env, b1| - if env[:result] - b1.use MessageResuming - b1.use RunVm - b1.use WaitForCommunicator - end + b.use action_fetch_environment + b.use Call, IsSuspended do |env, b1| + if env[:result] + b1.use MessageResuming + b1.use RunVm + b1.use WaitForCommunicator end end end end @@ -207,13 +188,11 @@ # with a single REST call. def self.action_create Vagrant::Action::Builder.new.tap do |b| b.use HandleBox - b.use ConfigValidate - b.use InitializeAPIClient - b.use FetchEnvironment + b.use action_fetch_environment b.use Call, ExistenceCheck do |env, b1| case result = env[:result] when :missing_environment b1.use CreateEnvironment b1.use MessageEnvironmentUrl @@ -275,13 +254,11 @@ end end def self.action_reload Vagrant::Action::Builder.new.tap do |b| - b.use ConfigValidate - b.use InitializeAPIClient - b.use FetchEnvironment + b.use action_fetch_environment b.use Call, ExistenceCheck do |env, b1| case env[:result] when :missing_environment, :missing_vm, :no_vms b1.use MessageNotCreated else @@ -291,9 +268,17 @@ # before calling run_vm, because the default # behavior is to treat the VMs as powered off. b1.use action_run_vm end end + end + end + + def self.action_fetch_environment + Vagrant::Action::Builder.new.tap do |b| + b.use ConfigValidate + b.use InitializeAPIClient + b.use FetchEnvironment end end # The autoload farm action_root = Pathname.new(File.expand_path("../action", __FILE__))