
    $                         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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\R4                  5      rg)zCBase class for commands copying files from and to virtual machines.    )absolute_import)division)unicode_literals)FilesCompleter)actions)base)flags)
iap_tunnel)scope)	ssh_utils)ip)ssh)log)
properties)retryc                   |   ^  \ rS rSrSr\U 4S j5       rSSSSSS\R                  R                  4U 4S jjr
SrU =r$ )BaseScpHelper&   z>Copy files to and from Google Compute Engine virtual machines.c                 4  > [         [        [        ]  U 5        U R                  S[        SSSS9  U R                  SSSS	9  U R                  S
[
        R                  " [        R                  R                  R                  5      S[        R                  -   S9  g)zPSet up arguments for this command.

Args:
  parser: An argparse.ArgumentParser.
sourceszSpecifies the files to copy.z[[USER@]INSTANCE:]SRC+)	completerhelpmetavarnargsdestinationz-Specifies a destination for the source files.z[[USER@]INSTANCE:]DEST)r   r   z--zonez1The zone of the instance to copy files to/from.

)actionr   N)superr   Argsadd_argumentr   r   StorePropertyr   VALUEScomputezoner	   ZONE_PROPERTY_EXPLANATION)parser	__class__s    3lib/googlecloudsdk/command_lib/compute/scp_utils.pyr   BaseScpHelper.Args)   s     
-,V4
 +'   <(  *
 $$Z%6%6%>%>%C%CDC--.  0    FNc
                   > Uc  [         R                  R                  n[        [        U ]  U5        [        R                  R                  UR                  5      n
UR                   Vs/ s H"  n[        R                  R                  U5      PM$     nn[        R                  R                  XSS9  U
R                  =(       d    US   R                  nU
R                  (       d  U H	  nXl        M     [        R                  " U5      u  pSnSnSnUR                   n[        R"                  " 5       nSnU(       a#  [$        R&                  " X(UR(                  5      nGO[*        R,                  R/                  UR(                  /[0        R2                  R4                  UR6                  UR8                  [*        R:                  " U5      S9S   nU R=                  UU5      nU R?                  UUR@                  5      nURB                  (       a  SnOSn[        RD                  " SS9Ul!        URF                  (       a  SUl$        OqU RJ                  RM                  5       RO                  SS9n[        RP                  " UUURB                  UUUUUR                   RR                  S	9nURB                  Ul!        URT                  (       d  URV                  (       a6  [        RX                  " URZ                  UR6                  UR\                  5      n[        R^                  " U5      nURF                  (       dM  U(       d  U RJ                  R`                  nU Rc                  [        Rd                  " U5      URf                  5      n[$        Rh                  " X(U[        Rj                  " USS
95      nU(       a  [        Rd                  " U5      Ul        OTU	[l        Rn                  Rp                  L a  [        Rr                  " U5      Ul        O[        Rt                  " U5      Ul        [        R                  " XUUUXVUUUUS9nURv                  (       aH  [x        Rz                  R}                  SR                  UR                  U R                  5      5      5        gU[         R                  R                  :w  a  [        R                  " U5        URF                  =(       a    [        S U 5       5      (       + nU(       + =(       aJ    UR                  (       + =(       a2    [        R                  R                  R                  R                  5       nURF                  (       d  URH                  (       a  SnOU R                  UURB                  WWUS9nU(       aR  [        R                  " UUUUUS9n [x        R                  R}                  S5         U R                  U R                  US9  U	[l        Rn                  Rp                  L a  U R                  WR\                  UUUU5        UR                  U R                  US9  gs  snf ! [        R                   a    [        R                  " 5       ef = f)a`  SCP files between local and remote GCE instance.

Run this method from subclasses' Run methods.

Args:
  compute_holder: The ComputeApiHolder.
  args: argparse.Namespace, the args the command was invoked with.
  on_prem: bool, Whether to connect to an on-prem IP.
  port: str or None, Port number to use for SSH connection.
  recursive: bool, Whether to use recursive copying using -R flag.
  compress: bool, Whether to use compression.
  extra_flags: [str] or None, extra flags to add to command invocation.
  release_track: obj, The current release track.
  ip_type: IpTypeEnum, Specify using internal ip or external ip address.

Raises:
  ssh_utils.NetworkError: Network issue which likely is due to failure
    of SSH key propagation.
  ssh.CommandError: The SSH command exited with SSH exit code, which
    usually implies that a connection problem occurred.
NT)single_remoter   )scope_listerF)warn_on_account_user)include_comment)username_requestedmessages)no_raise)	identity_file	cert_fileoptions	recursivecompressportextra_flagsiap_tunnel_argsidentity_list c              3   Z   #    U  H!  oS :H  =(       d    UR                  S5      v   M#     g7f)z-iz-i=N)
startswith).0fs     r(   	<genexpr>'BaseScpHelper.RunScp.<locals>.<genexpr>   s#     JkI4e!44ks   )+)
expiration)r8   z!Waiting for SSH key to propagate.)putty_force_connect)Qr   ReleaseTrackGAr   r   Runr   FileReferenceFromPathr   r   
SCPCommandVerifyremoter   GetSSHKeyExpirationFromArgsclientOsloginStater
   CreateOnPremSshTunnelArgshostinstance_flagsSSH_INSTANCE_RESOLVERResolveResourcescompute_scope	ScopeEnumZONEr$   	resourcesGetInstanceZoneScopeListerGetInstance
GetProjectprojectuserGetDefaultSshUsernameplainoslogin_enabledkeysGetPublicKeyToEntryGetOsloginStater1   third_party_userrequire_certificatesCertFileFromComputeInstancenameidWriteSecurityKeyskey_file	GetConfigHostKeyAliasstrict_host_key_checkingCreateSshTunnelArgsGetExternalInterfacer   
IpTypeEnumINTERNALGetInternalIPAddressGetExternalIPAddressdry_runr   outPrintjoinBuildenvConfirmSecurityKeyStatusanyoslogin_2fa_enabledr   r"   rD   GetBoolEnsureSSHKeyExistsCreateSSHPollerstatusPollr   WaitExceptionNetworkErrorPreliminarilyVerifyInstance)"selfcompute_holderargson_premr8   r6   r7   r9   release_trackip_typedstsrcsrcsrL   rC   expiration_microsr3   identity_file_listr5   compute_clientoslogin_stater4   r:   instance_refinstancer\   r0   
public_keycmdprompt_for_passwordrD   keys_newly_addedpollerr'   s"                                    r(   RunScpBaseScpHelper.RunScpD   s0   > ''**m	-"4(



$
$T%5%5
6C7;||D|C&&s+|DD NN$48ZZ)47>>F::#
  %.$I$I$$O!JMG
 $**N$$&MI"<<
v{{,o $99JJ;;-

!
!
&
&
))

"
"%@@ K   !"l !!.,?h0D0DEg	!"//TJ	(-%YY++-55d5K
++KK1#**335 $((

(
(M,N,N33LL,++X[[
	
 00?ZZ!)),,-..!7!7!A!%!>!>@ #66
|

(
(D
ACo 
,,X6bmm,,,44X>44X>
..)9d(	*C ||	ggmmCHHSYYtxx012
 )),,,((7 	

 	KJkJJJ    	@111	@!!55==? 
 zz]2200

++

 1 ! (()8tEf 
jj:;'HH 3 	 	5 "--(((
 &&x{{FM'.0CE GG/  1W E~    '$$&&'s   ))Y Y *Y/ )__name__
__module____qualname____firstlineno____doc__staticmethodr   r   rq   EXTERNALr   __static_attributes____classcell__)r'   s   @r(   r   r   &   sE    F0 0: ]]++r1 r1r*   r   N)r   
__future__r   r   r   argcomplete.completersr   googlecloudsdk.callioper   r   "googlecloudsdk.command_lib.computer	   r
   r   rU   r   ,googlecloudsdk.command_lib.compute.instancesrR   #googlecloudsdk.command_lib.util.sshr   r   googlecloudsdk.corer   r   googlecloudsdk.core.utilr   BaseSSHCLIHelperr   r   r*   r(   <module>r      sO     J &  ' 1 + ( 4 9 E 8 P 2 3 # * *P1I.. P1r*   