Class: VagrantPlugins::Abiquo::Actions::CreatevApp
- Inherits:
-
Object
- Object
- VagrantPlugins::Abiquo::Actions::CreatevApp
- Includes:
- Helpers::Abiquo
- Defined in:
- lib/vagrant_abiquo/actions/create_vapp.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ CreatevApp
constructor
A new instance of CreatevApp.
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) ⇒ CreatevApp
Returns a new instance of CreatevApp.
9 10 11 12 13 |
# File 'lib/vagrant_abiquo/actions/create_vapp.rb', line 9 def initialize(app, env) @app = app @machine = env[:machine] @logger = Log4r::Logger.new('vagrant::abiquo::create_vapp') end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/vagrant_abiquo/actions/create_vapp.rb', line 15 def call(env) if @machine.provider_config.class == VagrantPlugins::Abiquo::Config client = env[:abiquo_client] pconfig = @machine.provider_config @logger.info "Checking vApp '#{pconfig.virtualappliance}'" @logger.info "Looking up VDC '#{pconfig.virtualdatacenter}'" vdc = get_vdc(client, pconfig.virtualdatacenter) raise Abiquo::Errors::VDCNotFound, vdc: pconfig.virtualdatacenter if vdc.nil? vapp = get_vapp(vdc, pconfig.virtualappliance) if vapp.nil? @logger.info "vApp '#{pconfig.virtualappliance}' does not exist, creating." create_vapp(client, vdc, pconfig.virtualappliance) end end @app.call(env) end |