Class: Vcloud::Launcher::Launch

Inherits:
Object
  • Object
show all
Defined in:
lib/vcloud/launcher/launch.rb

Defined Under Namespace

Classes: MissingConfigurationError, MissingPreambleError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLaunch

Returns a new instance of Launch.



10
11
12
# File 'lib/vcloud/launcher/launch.rb', line 10

def initialize
  @config_loader = Vcloud::Core::ConfigLoader.new
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/vcloud/launcher/launch.rb', line 8

def config
  @config
end

Instance Method Details

#run(config_file = nil, cli_options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vcloud/launcher/launch.rb', line 14

def run(config_file = nil, cli_options = {})
  set_logging_level(cli_options)
  @config = @config_loader.load_config(config_file, Vcloud::Launcher::Schema::LAUNCHER_VAPPS)

  validate_config

  config[:vapps].each do |vapp_config|
    Vcloud::Core.logger.info("Provisioning vApp #{vapp_config[:name]}.")
    begin
      vapp = ::Vcloud::Launcher::VappOrchestrator.provision(vapp_config)
      #methadone sends option starting with 'no' as false.
      vapp.power_on unless cli_options["dont-power-on"]
      Vcloud::Core.logger.info("Provisioned vApp #{vapp_config[:name]} successfully.")
    rescue RuntimeError => e
      Vcloud::Core.logger.error("Failure: Could not provision vApp: #{e.message}")
      break unless cli_options["continue-on-error"]
    end

  end
end

#set_logging_level(cli_options) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/vcloud/launcher/launch.rb', line 35

def set_logging_level(cli_options)
  if cli_options[:verbose]
    Vcloud::Core.logger.level = Logger::DEBUG
  elsif cli_options[:quiet]
    Vcloud::Core.logger.level = Logger::ERROR
  else
    Vcloud::Core.logger.level = Logger::INFO
  end
end