class Opsmgr::ErrandRunner
Attributes
bosh_command[R]
download_logs[R]
environment_name[R]
errand_name[R]
logger[R]
product_name[R]
Public Class Methods
new(bosh_command:, environment_name:, logger:, product_name:, errand_name:, download_logs:)
click to toggle source
# 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
Public Instance Methods
run_errand()
click to toggle source
# 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