Class: VagrantPlugins::Deltacloud::Action::CreateServer

Inherits:
AbstractAction
  • Object
show all
Includes:
Vagrant::Util::Retryable
Defined in:
lib/vagrant-deltacloud-provider/action/create_server.rb

Instance Method Summary collapse

Methods inherited from AbstractAction

#call

Constructor Details

#initialize(app, _env, resolver = ConfigResolver.new, utils = Utils.new) ⇒ CreateServer

Returns a new instance of CreateServer.



18
19
20
21
22
23
# File 'lib/vagrant-deltacloud-provider/action/create_server.rb', line 18

def initialize(app, _env, resolver = ConfigResolver.new, utils = Utils.new)
  @app = app
  @logger = Log4r::Logger.new('vagrant_deltacloud::action::create_server')
  @resolver = resolver
  @utils = utils
end

Instance Method Details

#execute(env) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/vagrant-deltacloud-provider/action/create_server.rb', line 25

def execute(env)
  @logger.info 'Start create server action'

  options = {
    hardware_profile: @resolver.resolve_hardware_profile(env),
    image: @resolver.resolve_image(env),
    networks: @resolver.resolve_networks(env),
    volumes: @resolver.resolve_volumes(env),
    public_key_name: @resolver.resolve_public_key(env),
    security_groups: @resolver.resolve_security_groups(env),
    user_data: env[:machine].provider_config.user_data,
    metadata: env[:machine].provider_config.
  }

  server = create_server(env, options)
  server_id = server.id

  # Store the ID right away so we can track it
  env[:machine].id = server_id
  env[:deltacloud_client] = Deltacloud::DeltacloudClient.instance

  waiting_for_server_to_be_built(env, server_id)
  attach_volumes(env, server_id, options[:volumes]) unless options[:volumes].empty?

  @app.call(env)
end