Class: Cnvrg::ConnectJobSsh
- Inherits:
-
Object
- Object
- Cnvrg::ConnectJobSsh
- Defined in:
- lib/cnvrg/connect_job_ssh.rb
Instance Method Summary collapse
-
#initialize(job_id) ⇒ ConnectJobSsh
constructor
A new instance of ConnectJobSsh.
- #run_portforward_command(pod_name, port, kubeconfig, namespace, internal_port) ⇒ Object
- #start(username, password, no_auth, port: nil) ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(job_id) ⇒ ConnectJobSsh
Returns a new instance of ConnectJobSsh.
3 4 5 6 7 8 9 10 11 |
# File 'lib/cnvrg/connect_job_ssh.rb', line 3 def initialize(job_id) home_dir = File.('~') config = YAML.load_file(home_dir+"/.cnvrg/config.yml") @owner = config.to_h[:owner] @job_id = job_id rescue => e @owner = "" Cnvrg::Logger.log_info("cnvrg is not configured") end |
Instance Method Details
#run_portforward_command(pod_name, port, kubeconfig, namespace, internal_port) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/cnvrg/connect_job_ssh.rb', line 21 def run_portforward_command(pod_name, port, kubeconfig, namespace, internal_port) command = "kubectl" if kubeconfig.present? command = "kubectl --kubeconfig=#{kubeconfig}" end bashCommand = "#{command} -n #{namespace} port-forward #{pod_name} #{port}:#{internal_port}" puts("\nrunning command #{bashCommand}") `#{bashCommand}` end |
#start(username, password, no_auth, port: nil) ⇒ Object
13 14 15 |
# File 'lib/cnvrg/connect_job_ssh.rb', line 13 def start(username, password, no_auth, port: nil) Cnvrg::API_V2.request("#{@owner}/job_ssh/#{@job_id}/start" , 'POST', {username: username, password: password, no_auth: no_auth, port: port}) end |