Class: Cnvrg::JobSsh
Instance Method Summary
collapse
banner, subcommand_prefix
Instance Method Details
#start(job_id) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/cnvrg/job_ssh.rb', line 11
def start(job_id)
no_auth = options["no_auth"]
Cnvrg::CLI.new.log_start(__method__, args, options)
@job_ssh = ConnectJobSsh.new(job_id)
@job_ssh.start(options['username'], options['password'], no_auth, port: options['internal_port'])
pod_name = nil
namespace = "cnvrg"
ssh_ready = false
internal_port = options['internal_port']
while not ssh_ready
resp = @job_ssh.status()
status = resp["ssh_status"]
if status == "in_progress"
puts("Waiting for ssh to start ...")
sleep(3)
next
elsif status == "finished"
password = resp["password"]
username = resp["username"]
pod_name = resp["pod_name"]
namespace = resp["namespace"]
internal_port = resp["port"] || internal_port
ssh_ready = true
else
puts("Failed to start ssh")
break
end
end
if pod_name.blank? or (password.blank? and !no_auth) or username.blank?
puts("Failed to get required params")
return
end
puts("In order to connect to your job, define your ssh connection with the following params:")
puts("host: 127.0.0.1")
puts("port: #{options["port"]}")
puts("username: #{username}")
puts("password: #{password}") unless no_auth
@job_ssh.run_portforward_command(pod_name, options["port"], options["kubeconfig"], namespace, internal_port)
end
|