Class: VagrantPlugins::Abiquo::Actions::Deploy
- Inherits:
-
Object
- Object
- VagrantPlugins::Abiquo::Actions::Deploy
- Includes:
- Vagrant::Util::Retryable, Helpers::Abiquo
- Defined in:
- lib/vagrant_abiquo/actions/deploy.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ Deploy
constructor
A new instance of Deploy.
-
#recover(env) ⇒ Object
Both the recover and terminate are stolen almost verbatim from the Vagrant AWS provider up action.
- #terminate(env) ⇒ Object
Methods included from Helpers::Abiquo
#apply_state, #attach_net, #create_vapp, #create_vm, #deploy, #get_network, #get_template, #get_vapp, #get_vdc, #get_vm, #poweroff, #poweron, #reset, #update, #vapp_name
Constructor Details
#initialize(app, env) ⇒ Deploy
Returns a new instance of Deploy.
10 11 12 13 14 15 |
# File 'lib/vagrant_abiquo/actions/deploy.rb', line 10 def initialize(app, env) @app = app @machine = env[:machine] @env = env @logger = Log4r::Logger.new('vagrant::abiquo::deploy') end |
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/vagrant_abiquo/actions/deploy.rb', line 17 def call(env) client = env[:abiquo_client] vm = get_vm(client, @machine.id) # Deploying VM env[:ui].info I18n.t('vagrant_abiquo.info.deploy') task = deploy(client, vm) if task.state == 'FINISHED_SUCCESSFULLY' # Deploy successfully completed env[:ui].info I18n.t('vagrant_abiquo.info.deploycompleted') # wait for ssh to be ready retryable(:tries => 120, :sleep => 10) do next if env[:interrupted] raise 'not ready' if !@machine.communicate.ready? end # Find its IP vm = vm.link(:edit).get ip = vm.link(:nic0).title env[:ui].info I18n.t('vagrant_abiquo.info.vm_ip', :ip => ip) @machine.id = vm.url else # Deploy failed env[:ui].error I18n.t('vagrant_abiquo.info.deployfailed') end @app.call(env) end |
#recover(env) ⇒ Object
Both the recover and terminate are stolen almost verbatim from the Vagrant AWS provider up action
50 51 52 53 54 55 56 |
# File 'lib/vagrant_abiquo/actions/deploy.rb', line 50 def recover(env) return if env['vagrant.error'].is_a?(Vagrant::Errors::VagrantError) if @machine.state.id != :not_created terminate(env) end end |
#terminate(env) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/vagrant_abiquo/actions/deploy.rb', line 58 def terminate(env) destroy_env = env.dup destroy_env.delete(:interrupted) destroy_env[:config_validate] = false destroy_env[:force_confirm_destroy] = true env[:action_runner].run(Actions.action_destroy, destroy_env) end |