Class: Vcloud::Launcher::Launch
- Inherits:
-
Object
- Object
- Vcloud::Launcher::Launch
- Defined in:
- lib/vcloud/launcher/launch.rb
Defined Under Namespace
Classes: MissingConfigurationError, MissingPreambleError
Instance Attribute Summary collapse
-
#cli_options ⇒ Object
readonly
Returns the value of attribute cli_options.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(config_file, cli_options = {}) ⇒ Launch
constructor
A new instance of Launch.
- #run ⇒ Object
Constructor Details
#initialize(config_file, cli_options = {}) ⇒ Launch
Returns a new instance of Launch.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/vcloud/launcher/launch.rb', line 10 def initialize(config_file, = {}) config_loader = ::Vcloud::Core::ConfigLoader.new @cli_options = set_logging_level @config = config_loader.load_config(config_file, Vcloud::Launcher::Schema::LAUNCHER_VAPPS) ignore_unspecified_machines validate_config end |
Instance Attribute Details
#cli_options ⇒ Object (readonly)
Returns the value of attribute cli_options.
8 9 10 |
# File 'lib/vcloud/launcher/launch.rb', line 8 def @cli_options end |
#config ⇒ Object (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 ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/vcloud/launcher/launch.rb', line 22 def run @config[:vapps].each do |vapp_config| Vcloud::Core.logger.info("Provisioning vApp #{vapp_config[:name]}.") begin if ["dry-run"] # rubocop:disable Style/UselessAssignment vapp = ::Vcloud::Launcher::VappOrchestrator.provision(vapp_config, true) # rubocop:enable Style/UselessAssignment else vapp = ::Vcloud::Launcher::VappOrchestrator.provision(vapp_config) vapp.power_on unless ["dont-power-on"] if ["post-launch-cmd"] run_command(vapp_config, ["post-launch-cmd"]) end end Vcloud::Core.logger.info("Provisioned vApp #{vapp_config[:name]} successfully.") rescue RuntimeError => e Vcloud::Core.logger.error("Failure: Could not provision vApp: #{e.}") break unless ["continue-on-error"] end end end |