class Bosh::Cli::Command::JobManagement

Constants

CANARIES
FORCE
MAX_IN_FLIGHT
SKIP_DRAIN

Public Instance Methods

recreate_job(job = '*', index_or_id = nil) click to toggle source
# File lib/cli/commands/job_management.rb, line 58
def recreate_job(job = '*', index_or_id = nil)
  change_job_state(:recreate, job, index_or_id)
end
restart_job(job = '*', index_or_id = nil) click to toggle source
# File lib/cli/commands/job_management.rb, line 47
def restart_job(job = '*', index_or_id = nil)
  change_job_state(:restart, job, index_or_id)
end
start_job(job = '*', index_or_id = nil) click to toggle source
# File lib/cli/commands/job_management.rb, line 19
def start_job(job = '*', index_or_id = nil)
  change_job_state(:start, job, index_or_id)
end
stop_job(job = '*', index_or_id = nil) click to toggle source
# File lib/cli/commands/job_management.rb, line 32
def stop_job(job = '*', index_or_id = nil)
  if hard?
    change_job_state(:detach, job, index_or_id)
  else
    change_job_state(:stop, job, index_or_id)
  end
end

Private Instance Methods

canaries() click to toggle source
# File lib/cli/commands/job_management.rb, line 92
def canaries
  options[:canaries]
end
change_job_state(state, job, index_or_id = nil) click to toggle source
# File lib/cli/commands/job_management.rb, line 64
def change_job_state(state, job, index_or_id = nil)
  auth_required
  manifest = parse_manifest(state)
  options = {skip_drain: skip_drain?}
  options[:canaries] = canaries if canaries
  options[:max_in_flight] = max_in_flight if max_in_flight

  job_state = JobState.new(self, manifest, options)
  status, task_id, completion_desc = job_state.change(state, job, index_or_id, force?)
  task_report(status, task_id, completion_desc)
end
force?() click to toggle source
# File lib/cli/commands/job_management.rb, line 84
def force?
  !!options[:force]
end
hard?() click to toggle source
# File lib/cli/commands/job_management.rb, line 76
def hard?
  !!options[:hard]
end
hard_and_soft_options_allowed?(operation) click to toggle source
# File lib/cli/commands/job_management.rb, line 114
def hard_and_soft_options_allowed?(operation)
  operation == :stop || operation == :detach
end
max_in_flight() click to toggle source
# File lib/cli/commands/job_management.rb, line 96
def max_in_flight
  options[:max_in_flight]
end
parse_manifest(operation) click to toggle source
# File lib/cli/commands/job_management.rb, line 100
def parse_manifest(operation)
  manifest = prepare_deployment_manifest(show_state: true)

  if hard? && soft?
    err('Cannot handle both --hard and --soft options, please choose one')
  end

  if !hard_and_soft_options_allowed?(operation) && (hard? || soft?)
    err("--hard and --soft options only make sense for 'stop' operation")
  end

  manifest
end
skip_drain?() click to toggle source
# File lib/cli/commands/job_management.rb, line 88
def skip_drain?
  !!options[:skip_drain]
end
soft?() click to toggle source
# File lib/cli/commands/job_management.rb, line 80
def soft?
  !!options[:soft]
end