class Bosh::Cli::Command::JobManagement

Constants

FORCE
SKIP_DRAIN

Public Instance Methods

recreate_job(job = '*', index_or_id = nil) click to toggle source
# File lib/cli/commands/job_management.rb, line 47
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 38
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 14
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 25
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

change_job_state(state, job, index_or_id = nil) click to toggle source
# File lib/cli/commands/job_management.rb, line 53
def change_job_state(state, job, index_or_id = nil)
  auth_required
  manifest = parse_manifest(state)
  job_state = JobState.new(self, manifest, skip_drain: skip_drain?)
  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 69
def force?
  !!options[:force]
end
hard?() click to toggle source
# File lib/cli/commands/job_management.rb, line 61
def hard?
  !!options[:hard]
end
hard_and_soft_options_allowed?(operation) click to toggle source
# File lib/cli/commands/job_management.rb, line 91
def hard_and_soft_options_allowed?(operation)
  operation == :stop || operation == :detach
end
parse_manifest(operation) click to toggle source
# File lib/cli/commands/job_management.rb, line 77
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 73
def skip_drain?
  !!options[:skip_drain]
end
soft?() click to toggle source
# File lib/cli/commands/job_management.rb, line 65
def soft?
  !!options[:soft]
end