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

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

Constant Summary collapse

SSH_USER_PREFIX =
"bosh_"
SSH_DSA_PUB =
File.expand_path("~/.ssh/id_dsa.pub")
SSH_RSA_PUB =
File.expand_path("~/.ssh/id_rsa.pub")

Constants inherited from Base

Base::DEFAULT_DIRECTOR_PORT

Instance Attribute Summary

Attributes inherited from Base

#args, #options, #out, #runner, #work_dir

Instance Method Summary collapse

Methods included from DeploymentHelper

#deployment_changed?, #inspect_deployment_changes, #prepare_deployment_manifest

Methods included from VersionCalc

#major_version, #minor_version, #version_cmp, #version_greater, #version_less, #version_same

Methods inherited from Base

#add_option, #blob_manager, #blobstore, #cache, #config, #confirmed?, #deployment, #director, #exit_code, #initialize, #interactive?, #logged_in?, #non_interactive?, #password, #redirect, #release, #remove_option, #target, #target_name, #task_report, #username, #verbose?

Methods included from Bosh::Cli::CommandDiscovery

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

Constructor Details

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

Instance Method Details

#cleanup(*args) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/cli/commands/ssh.rb', line 59

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

  manifest_name = prepare_deployment_manifest["name"]

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

#scp(*args) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/cli/commands/ssh.rb', line 42

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

  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, job, index, args)
end

#shell(*args) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/cli/commands/ssh.rb', line 19

def shell(*args)
  job, index, command = parse_args(args)

  if command.empty?
    if index.nil?
      err("Can't run interactive shell on more than one instance")
    end
    setup_interactive_shell(job, index)
  else
    say("Executing `#{command.join(" ")}' on #{job}/#{index}")
    perform_operation(:exec, job, index, command)
  end
end