Class: VagrantPlugins::VCloud::Action::IsLastVM
- Inherits:
-
Object
- Object
- VagrantPlugins::VCloud::Action::IsLastVM
- Defined in:
- lib/vagrant-vcloud/action/is_last_vm.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ IsLastVM
constructor
A new instance of IsLastVM.
Constructor Details
#initialize(app, env) ⇒ IsLastVM
Returns a new instance of IsLastVM.
5 6 7 |
# File 'lib/vagrant-vcloud/action/is_last_vm.rb', line 5 def initialize(app, env) @app = app end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vagrant-vcloud/action/is_last_vm.rb', line 9 def call(env) cfg = env[:machine].provider_config cnx = cfg.vcloud_cnx.driver vapp_id = env[:machine].get_vapp_id test_vapp = cnx.get_vapp(vapp_id) if test_vapp[:vms_hash].count == 1 # Set the result to be true if the machine is running. env[:result] = true else env[:result] = false end # Call the next if we have one (but we shouldn't, since this # middleware is built to run with the Call-type middlewares) @app.call(env) end |