Class: VagrantPlugins::Abiquo::Actions::DeletevApp
- Inherits:
-
Object
- Object
- VagrantPlugins::Abiquo::Actions::DeletevApp
- Includes:
- Helpers::Abiquo
- Defined in:
- lib/vagrant_abiquo/actions/delete_vapp.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ DeletevApp
constructor
A new instance of DeletevApp.
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) ⇒ DeletevApp
Returns a new instance of DeletevApp.
9 10 11 12 13 |
# File 'lib/vagrant_abiquo/actions/delete_vapp.rb', line 9 def initialize(app, env) @app = app @machine = env[:machine] @logger = Log4r::Logger.new('vagrant::abiquo::delete_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 |
# File 'lib/vagrant_abiquo/actions/delete_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) unless vapp.nil? || vapp.link(:virtualmachines).get.count > 0 @logger.info "vApp '#{pconfig.virtualappliance}' is empty, deleting." vapp.delete end end @app.call(env) end |