
    #                     F   d Z ddlmZ ddlmZ ddlmZ ddlZddlmZ ddlm	Z	 ddl
mZ  e	j                  e	j                  j                  e	j                  j                   e	j                  j"                        e	j$                   G d	 d
e	j&                                      Zy)z.Command for SSHing into a started workstation.    )absolute_import)division)unicode_literalsN)workstations)base)flagsc                   ,    e Zd ZdZed        Zd Zd Zy)StartaJ  SSH into a running workstation.

  SSH into a running workstation.

  Note that arguments for the `NO_PROXY` environment variable must be FQDNs.

  ## EXAMPLES

    To ssh into a running workstation, run:

      $ {command} WORKSTATION

    To specify the workstation port, run:

      $ {command} WORKSTATION --port=22

    To ssh into a running workstation with a username, run:

      $ {command} WORKSTATION --user=my-user

    To run a command on the workstation, such as getting a snapshot of the
    guest's process tree, run:
      $ {command} WORKSTATION --command="ps -ejH"
  c                     t        j                  |        t        j                  |        t        j                  |        t        j                  |        t        j
                  |        y )N)workstations_flagsAddWorkstationResourceArgAddPortFieldAddLocalHostPortFieldAddCommandFieldAddSshArgsAndUserField)parsers    lib/surface/workstations/ssh.pyArgsz
Start.Args:   sH    008##F+,,V4&&v.--f5    c                      y)NzSworkstations.projects.locations.workstationClusters.workstationConfigs.workstations )selfs    r   
CollectionzStart.CollectionB   s    `r   c                    |j                   |_        t        j                  | j	                               }|j
                  j                  j                          |j                  j                          d|_
        t        j                  |j                  |df      }d|_        |j                          |j                  j!                          |j                  r|j#                  |       y y )NFT)targetargs)portworkstation_portr   WorkstationsReleaseTrackCONCEPTSworkstationParsethreading_eventcleartcp_tunnel_open	threadingThreadStartTcpTunneldaemonstartwaitSsh)r   r   clientts       r   Runz	Start.RunE   s     IID&&t'8'8':;F
 	MM##%
  ""F 5 5T4LIAAHGGI
!jj r   N)__name__
__module____qualname____doc__staticmethodr   r   r0   r   r   r   r
   r
      s&    
2 6 6ar   r
   )r4   
__future__r   r   r   r'   #googlecloudsdk.api_lib.workstationsr   googlecloudsdk.callioper   'googlecloudsdk.command_lib.workstationsr   r   ReleaseTracksr    GABETAALPHADefaultUniverseOnlyCommandr
   r   r   r   <module>r@      s    5 &  '  < ( O $++00$2C2C2I2I 9DLL 9 9r   