Class: DTK::Client::Commands::Common::CreateTarget

Inherits:
Base
  • Object
show all
Defined in:
lib/commands/common/thor/create_target.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from DTK::Client::Commands::Common::Base

Instance Method Details

#execute(type, option_list) ⇒ Object

option_list is of form [:provider!, :region, :keypair, :security_group!] indcating what is optional and what is required



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/commands/common/thor/create_target.rb', line 22

def execute(type, option_list)
  # we use :target_id but that will return provider_id (another name for target template ID)
  target_name = retrieve_arguments([:option_1])
  iaas_properties = iaas_properties(type,option_list)
  provider = iaas_properties.delete(:provider)
  post_body = {
    :type             => type.to_s,
    :provider_id      => provider,
    :iaas_properties  => iaas_properties
  }

  # cleanup for target name not being sterilazied correctly
  post_body.merge!(:target_name => target_name.split(' ').first) if target_name

  post 'target/create', post_body
end