
    [                        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S.rSSS.rSSS.r\
R&                  \
R(                  " \
R*                  R,                  \
R*                  R.                  \
R*                  R0                  5       " S S\
R2                  5      5       5       r\\l        g)z,Command for attaching a disk to an instance.    )absolute_import)division)unicode_literals)base_classes)
csek_utils)instance_utils)base)scope)flagsz
Read-only.zRead-write.)rorwSCSINVME)r   r   a  
        *{command}* is used to attach a disk to an instance. For example,

          $ gcloud compute instances attach-disk example-instance --disk DISK --zone us-central1-a

        attaches the disk named 'DISK' to the instance named
        'example-instance' in zone ``us-central1-a''.

        After you create and attach a new disk to an instance, you must
        [format and mount](https://cloud.google.com/compute/docs/disks/add-persistent-disk#formatting)
        the disk so that the operating system can use the available storage
        space.
        You can attach an existing non-boot disk to more than one instance. For
        more information, see
        [Share a disk between VMs](compute/docs/disks/add-persistent-disk#use_multi_instances).
        ad  
        To attach a disk named 'my-disk' as a boot disk to an instance named
        'my-instance', run:

          $ {command} my-instance --disk=my-disk --boot

        To attach a device named 'my-device' for read-only access to an
        instance named 'my-instance', run:

          $ {command} my-instance --device-name=my-device --mode=ro
        )DESCRIPTIONEXAMPLESc                   4    \ rS rSrSr\S 5       rS rS rSr	g)
AttachDiskE   zAttach a disk to an instance.c                 v   [         R                  R                  U 5        U R                  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  U R                  S[
        SS9  [         R                  " U 5        U R                  SSSSS9  [        R                  " U SS9  g )Nz--device-namea
  An optional name that indicates the disk name the guest operating system will see. (Note: Device name does not correspond to mounted volume name). Must match the disk name if the disk is going to be mounted to a container with --container-mount-disk (alpha feature).)helpz--diskz/The name of the disk to attach to the instance.T)r   requiredz--moder   zSpecifies the mode of the disk.)choicesdefaultr   z--boot
store_truez/Attach the disk to the instance as a boot disk.)actionr   z--interfacez,
        The interface of the disk.
        )r   r   z--force-attachFa    Attach the disk to the instance even if it is currently attached to another
  instance. The attachment will succeed even if detaching from the previous
  instance fails at first. The server will continue trying to detach the disk from
  the previous instance in the background.)r   r   r   )flags_about_creation)	r   INSTANCE_ARGAddArgumentadd_argumentMODE_OPTIONSPD_INTERFACE_OPTIONSAddDiskScopeFlagr   AddCsekKeyArgs)parsers    ,lib/surface/compute/instances/attach_disk.pyArgsAttachDisk.ArgsK   s    	""6*
8  : >  
 .	  0 >  @
 $   
6"
.	  / f5A    c                     UR                   S:X  a  [        R                  R                  nO[        R                  R                  n[
        R                  " XR                  UR                  UR                  U5      $ )Nregional)

disk_scopecompute_scopes	ScopeEnumREGIONZONEr   ParseDiskResourcediskprojectzone)self	resourcesargsinstance_refr
   s        r%   ParseDiskRefAttachDisk.ParseDiskRef}   s^    *$&&--e&&++e++99l22L4E4EuN Nr(   c                    [         R                  " U R                  5       5      nUR                  n[        R
                  R                  XR                  [        R                  " U5      S9nU R                  UR                  X5      nUR                  S:X  a+  UR                  R                  R                  R                  nO*UR                  R                  R                  R                  nU R                  5       [         R                  R"                  [         R                  R$                  4;   n[&        R(                  R+                  X5      n[&        R,                  " XUR.                  5      n	UR                  R                  UR0                  UUR3                  5       UR                  R                  R4                  R6                  U	S9n
UR8                  (       ak  UR8                  S:X  a+  UR                  R                  R:                  R<                  nO*UR                  R                  R:                  R>                  nXl        UR@                  (       a  UR@                  U
l         UR                  RC                  URE                  5       URF                  U
URH                  S9nURJ                  (       a  URJ                  Ul&        URO                  UR.                  RP                  SU4/5      $ )N)scope_listerr   )
deviceNamemodesourcetypediskEncryptionKeyr   )instancer2   attachedDiskr3   r   ))r   ComputeApiHolderReleaseTrackclientr   r   ResolveAsResourcer5   GetInstanceZoneScopeListerr8   r=   messagesAttachedDiskModeValueValuesEnum
READ_WRITE	READ_ONLYr	   ALPHABETAr   CsekKeyStoreFromArgsMaybeLookupKeyMessageapitools_clientdevice_nameSelfLinkTypeValueValuesEnum
PERSISTENT	interfaceInterfaceValueValuesEnumr   r   boot!ComputeInstancesAttachDiskRequestNamer2   r3   force_attachforceAttachMakeRequests	instances)r4   r6   holderrE   r7   disk_refr=   allow_rsa_encrypted	csek_keysdisk_key_or_noneattached_diskrW   requests                r%   RunAttachDisk.Run   sT   **4+<+<+>?F]]F%%7755f= 8 ?L   !1!14FHyyD__))==HHd__))==GGd++-$2C2C2I2I262C2C2H2H2J J''00KI!77	8>8N8NP OO00##  "__))==HH* 1 ,M ~~	6	!OO00IINN	OO00IINN	 )yy99moo??""$$$"	 @  G  --g!7!7!A!A<!(!*  + , ,r(    N)
__name__
__module____qualname____firstlineno____doc__staticmethodr&   r8   rg   __static_attributes__ri   r(   r%   r   r   E   s'     &/B /BbN0,r(   r   N)rn   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   r   googlecloudsdk.callioper	   "googlecloudsdk.command_lib.computer
   r,   ,googlecloudsdk.command_lib.compute.instancesr   r    r!   DETAILED_HELPUniverseCompatibleReleaseTracksrD   GArN   rM   SilentCommandr   detailed_helpri   r(   r%   <module>r|      s    3 &  ' 7 5 9 ( F > 
   
#> $++00$2C2C2I2IKm,## m,K m,` )
 r(   