Class: VagrantPlugins::VCloud::Action::IsCreated

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-vcloud/action/is_created.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ IsCreated

Returns a new instance of IsCreated.



5
6
7
8
# File 'lib/vagrant-vcloud/action/is_created.rb', line 5

def initialize(app, env)
  @app = app
  @logger = Log4r::Logger.new('vagrant_vcloud::action::is_created')
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/vagrant-vcloud/action/is_created.rb', line 10

def call(env)
  vapp_id = env[:machine].get_vapp_id

  if vapp_id.nil?
    @logger.warn('vApp has not been created')
    env[:result] = false
  else
    @logger.info("vApp has been created and ID is: [#{vapp_id}]")

    vm_id = env[:machine].id
    if vm_id
      @logger.info("VM has been added to vApp and ID is: [#{vm_id}]")
      env[:result] = true
    else
      @logger.warn('VM has not been added to vApp')
      env[:result] = false
    end

  end

  @app.call env
end