Class: Bosh::Cli::Command::Ssh

Inherits:
Base show all
Defined in:
lib/cli/commands/ssh.rb

Constant Summary

Constants inherited from Base

Base::DEFAULT_DIRECTOR_PORT

Instance Attribute Summary

Attributes inherited from Base

#args, #exit_code, #info, #options, #out, #runner, #work_dir

Instance Method Summary collapse

Methods inherited from Base

#add_option, #blob_manager, #blobstore, #cache_dir, #config, #confirmed?, #credentials, #deployment, #director, #initialize, #interactive?, #logged_in?, #non_interactive?, #progress_renderer, #redirect, #release, #remove_option, #run_nested_command, #show_current_state, #target, #target_name, #verbose?

Methods included from Bosh::Cli::CommandDiscovery

#desc, #method_added, #option, #register_command, #usage

Methods included from DeploymentHelper

#build_manifest, #cancel_deployment, #deployment_changed?, #inspect_deployment_changes, #job_exists_in_deployment?, #job_unique_in_deployment?, #jobs_and_indexes, #prepare_deployment_manifest, #prompt_for_errand_name, #prompt_for_job_and_index

Constructor Details

This class inherits a constructor from Bosh::Cli::Command::Base

Instance Method Details

#cleanup(*args) ⇒ Object


71
72
73
74
75
76
77
78
79
80
81
# File 'lib/cli/commands/ssh.rb', line 71

def cleanup(*args)
  job, index, args = JobCommandArgs.new(args).to_a
  if args.size > 0
    err("SSH cleanup doesn't accept any extra args")
  end

  manifest = prepare_deployment_manifest(show_state: true)

  say("Cleaning up ssh artifacts from #{job}/#{index}")
  director.cleanup_ssh(manifest.name, job, "^#{SSH_USER_PREFIX}", [index])
end

#scp(*args) ⇒ Object


51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/cli/commands/ssh.rb', line 51

def scp(*args)
  job, index, args = JobCommandArgs.new(args).to_a
  upload           = options[:upload]
  download         = options[:download]
  if (upload && download) || (upload.nil? && download.nil?)
    err('Please specify either --upload or --download')
  end

  manifest = prepare_deployment_manifest(show_state: true)

  if args.size != 2
    err('Please enter valid source and destination paths')
  end
  say("Executing file operations on job #{job}")
  perform_operation(upload ? :upload : :download, manifest.name, job, index, args)
end

#shell(*args) ⇒ Object


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cli/commands/ssh.rb', line 21

def shell(*args)
  if args.size > 0
    job, id, command = JobCommandArgs.new(args).to_a
  else
    command    = ''
    job, id = prompt_for_job_and_index
  end

  manifest = prepare_deployment_manifest(show_state: true)

  if command.empty?
    setup_interactive_shell(manifest.name, job, id)
  else
    say("Executing '#{command.join(' ')}' on #{job}/#{id}")
    perform_operation(:exec, manifest.name, job, id, command)
  end
end