
                         ~   S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSK	Jr  SS	KJr  SS	KJr  SS
KJr  S r\R&                  " \R(                  R*                  5       " S S\R,                  5      5       r\R&                  " \R(                  R0                  5       " S S\5      5       rSSS.\l        g)z+Command to SCP to/from a Cloud TPU VM Node.    )absolute_import)division)unicode_literals)FilesCompleter)base)flags)	ssh_utils)ssh)
propertiesc                     U R                  SSSS9  U R                  S[        SSSS	9  U R                  S
SSS9  U R                  SSSS9  U R                  SSSS9  g)z>Additional flags and positional args to be passed to *scp(1)*.z
--scp-flagappendzR      Additional flags to be passed to *scp(1)*. This flag may be repeated.
      )actionhelpsourceszSpecifies the files to copy.z[[USER@]INSTANCE:]SRC+)	completerr   metavarnargsdestinationz-Specifies a destination for the source files.z[[USER@]INSTANCE:]DEST)r   r   z	--recurse
store_truezUpload directories recursively.z
--compresszEnable compression.N)add_argumentr   )parsers    &lib/surface/compute/tpus/tpu_vm/scp.py
AddSCPArgsr      s    
   	)%   	:&  (
 	,-N  P 	<.C  E    c                   6    \ rS rSrSrSrSr\S 5       rS r	Sr
g)Scp;   .Copy files to and from a Cloud TPU VM via SCP.Fc                     [         R                  R                  U5        [        R                  " XR
                  U R                  5        [        U5        [        R                  " USSS9  g)zPSet up arguments for this command.

Args:
  parser: An argparse.ArgumentParser.
tpuscp)resource_typeoperation_typeN)
r	   BaseSSHCLIHelperArgstpu_ssh_utilsAddTPUSSHArgs_ENABLE_IAP_ENABLE_BATCHINGr   r   AddZoneFlag)clsr   s     r   r&   Scp.ArgsC   sL     ##F+9M9MNv	fE%Hr   c                    [         R                  R                  UR                  5      nUR                   Vs/ s H"  n[         R                  R                  U5      PM$     nn[         R
                  R                  XBSS9  UR                  =(       d    US   R                  nUR                  nUR                  (       d  U H	  nXSl        M     SnUR                  (       d  Sn[         R                  " SS9Ul	        UR                  c6  [        R                  R                  R                  R                  SS9Ul        S /n[         R"                  " UUU R%                  5       U R&                  UUSUUU5
        Sn	U R&                  (       aA  US   (       a7  [         R(                  " UR*                  [-        US   R.                  5      5      n	[         R0                  " XU	5        g s  snf )NT)single_remoter   F)warn_on_account_user)required   )r
   FileReferenceFromPathr   r   
SCPCommandVerifyremotehostuserGetDefaultSshUsernamezoner   VALUEScomputeGetr'   PrepareNodeForSCPReleaseTrackr*   ParseBatchSize
batch_sizelen
worker_ipsSCPIntoPreppedNodes)
selfargsdstsrcsrcsr7   tpu_nameusername_requestedprepped_nodescp_batch_sizes
             r   RunScp.RunO   s   



$
$T%5%5
6C7;||D|C&&s+|DDNN$48ZZ)47>>F{{H::#
  ;; --4Hfk yy##++0044d4Cdi6L##	 Na$33
//3|A99:n %%l.IM Es   )G& N)__name__
__module____qualname____firstlineno____doc__r)   r*   classmethodr&   rO   __static_attributes__rQ   r   r   r   r   ;   s,    6 +	I 	I(Jr   r   c                        \ rS rSrSrSrSrSrg)ScpAlphaz   z6Copy files to and from a Cloud TPU VM via SCP (Alpha).TrQ   N)rR   rS   rT   rU   rV   r)   r*   rX   rQ   r   r   rZ   rZ   z   s    >+r   rZ   r   a%  
        To copy a file (for example, a text file in the local home directory) to
        a Cloud TPU VM, run:

            $ {command} ~/my-file my-tpu:

        To copy a file into all workers in a Cloud TPU VM, run:

            $ {command} ~/my-file my-tpu: --worker=all

        To copy a file from a Cloud TPU VM to the home directory of the local
        computer, run:

            $ {command} my-tpu:~/my-file ~/

        To copy all files in a folder to a Cloud TPU VM, run:

            $ {command} ~/my-folder/ my-tpu: --recurse
        )briefEXAMPLESN)rV   
__future__r   r   r   argcomplete.completersr   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer   r	   .googlecloudsdk.command_lib.compute.tpus.tpu_vmr
   r'   #googlecloudsdk.command_lib.util.sshgooglecloudsdk.corer   r   ReleaseTracksr@   GACommandr   ALPHArZ   detailed_helprQ   r   r   <module>rj      s    2 &  ' 2 ( 4 8 O 3 *E8 D%%(();J$,, ;J *;J| D%%++,s  - 	9		 r   