Class: Opsmgr::ErrandRunner
- Inherits:
-
Object
- Object
- Opsmgr::ErrandRunner
- Defined in:
- lib/opsmgr/errand_runner.rb
Instance Method Summary collapse
-
#initialize(bosh_command:, environment_name:, logger:, product_name:, errand_name:, download_logs:) ⇒ ErrandRunner
constructor
A new instance of ErrandRunner.
- #run_errand ⇒ Object
Constructor Details
#initialize(bosh_command:, environment_name:, logger:, product_name:, errand_name:, download_logs:) ⇒ ErrandRunner
Returns a new instance of ErrandRunner.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/opsmgr/errand_runner.rb', line 6 def initialize(bosh_command:, environment_name:, logger:, product_name:, errand_name:, download_logs:) @bosh_command = bosh_command @environment_name = environment_name @logger = logger @product_name = product_name @errand_name = errand_name @download_logs = download_logs ? "--download-logs" : "" @bosh_command_runner = Opsmgr::BoshCommandRunner.new( bosh_command: @bosh_command, logger: @logger ) end |
Instance Method Details
#run_errand ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/opsmgr/errand_runner.rb', line 20 def run_errand deployments_output = begin @bosh_command_runner.run_and_capture_output('deployments') rescue RuntimeError raise 'bosh deployments failed' end bosh_deployment = deployments_output[/#{@product_name}-[0-9a-f]{8,}/] fail 'Deployment not found' if bosh_deployment.nil? deployment_file = "#{ENV.fetch('TMPDIR', '/tmp')}/#{environment_name}.yml" begin @bosh_command_runner.run( "-n download manifest #{bosh_deployment} #{deployment_file}" ) rescue RuntimeError raise 'bosh download manifest failed' end begin @bosh_command_runner.run( "-d #{deployment_file} run errand #{@errand_name} #{@download_logs}" ) rescue RuntimeError raise "Errand #{@errand_name} failed" end end |