Class: VagrantPlugins::Skytap::Action::CreateEnvironment

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-skytap/action/create_environment.rb

Overview

Creates an environment from the template URL present in the config file. Stores the new environment URL in the environment properties.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ CreateEnvironment

Returns a new instance of CreateEnvironment.



45
46
47
48
49
# File 'lib/vagrant-skytap/action/create_environment.rb', line 45

def initialize(app, env)
  @app = app
  @env = env
  @logger = Log4r::Logger.new("vagrant_skytap::action::create_environment")
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



43
44
45
# File 'lib/vagrant-skytap/action/create_environment.rb', line 43

def env
  @env
end

Instance Method Details

#call(env) ⇒ Object



51
52
53
54
55
56
57
58
59
60
# File 'lib/vagrant-skytap/action/create_environment.rb', line 51

def call(env)
  vm = API::Vm.fetch(env, vm_url)
  environment = API::Environment.create!(env, [vm])
  env[:environment] = environment
  environment.properties.write('url' => environment.url)
  env[:machine].id = environment.vms.first.id
  environment.wait_until_ready

  @app.call(env)
end

#vm_urlObject



62
63
64
# File 'lib/vagrant-skytap/action/create_environment.rb', line 62

def vm_url
  env[:machine].provider_config.vm_url
end