Class: Cnvrg::JobSsh
Instance Method Summary
collapse
banner, subcommand_prefix
Instance Method Details
#start(job_id) ⇒ Object
8
9
10
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
|
# File 'lib/cnvrg/job_ssh.rb', line 8
def start(job_id)
Cnvrg::CLI.new.log_start(__method__, args, options)
@job_ssh = ConnectJobSsh.new(job_id)
@job_ssh.start(options['username'], options['password'])
pod_name = nil
namespace = "cnvrg"
ssh_ready = false
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"]
ssh_ready = true
else
puts("Failed to start ssh")
break
end
end
if pod_name.blank? or password.blank? 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}")
@job_ssh.run_portforward_command(pod_name, options["port"], options["kubeconfig"], namespace)
end
|