
    xe             	          S r SSKJr  SSKJr  SSKJr  SSKrSSKrSSKrSSK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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/r/Sr0SSS.r1S S!/r2S S!/r3S"r4S#r5S$r6S%r7S&r8\ Rr                  " S'S(\Rt                  S)\0S*9r;\ Rr                  " S'S(S+\Rt                  S)\0S,9r<\ Rr                  " S'S-\Rt                  S)\0S.S/9r=\ Rr                  " S'S-\Rt                  S)\ R`                  S.S/9r>\ Rr                  " S'S(\Rt                  S)\ R`                  S+S/9r?\ R                  R                  S'\"R                  R                  S)05      rDS0 rES1 rFS2 rGS3 rHSS4 jrISS5 jrJSS6 jrKSS7 jrLS8 rMS9 rNS: rO    SS; jrPS< rQS= rRS> rSS? rTS@ rUSA rVSB rWSC rXSD rYSE rZSF r[SSG jr\   SSH jr]SSI jr^SJ r_             SSK jr`SL raSM rbSN rcSO rd     SSP jreSQ rfSR rgSS rhSST jri     SSU jrjSV rkSW rlSX rmSY rnSZ roS[ rpS\ rq         SS] jrrS^ rsSS_ jrtSS` jruSSa jrvSb rwSSc jrxSSd jrySSe jrzSSf jr{Sg r|SSh jr}Si r~Sj rSSk jrSSl jrSm rSn r   SSo jrSp rSSq jrSSr jrSSs jrSSt jrSSu jrSv rSw rSx rSy rSz rS{ rS| rS} rS~ rS rSS jrS rS rS rS rS rS rS rS rS rSS jr   SS jrS r   S SS jjrS rS rS rSS jrS rSS jrSS jrS rS r  SS jrS rS rS rS rSS jrS rSS jrS rSS jrS rS rS rS rS rS rS rSS jrS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rg)z8Flags and helpers for the compute VM instances commands.    )absolute_import)division)unicode_literalsN)	constants)containers_utils)
csek_utils)
disks_util)image_utils)	kms_utils)utils)service)apis)actions)arg_parsers)base)
exceptions)
completers)flags)scope)resource_args)	arg_utils)labels_util)log)
properties)	resourcesa  If not specified, you might be prompted to select a zone (interactive mode
only). `gcloud` attempts to identify the appropriate zone by searching for
resources in your currently active project. If the zone cannot be determined,
`gcloud` prompts you for a selection with all available Google Cloud Platform
zones.

To avoid prompting when this flag is omitted, the user can set the
``compute/zone'' property:

  $ gcloud config set compute/zone ZONE

A list of zones can be fetched by running:

  $ gcloud compute zones list

To unset the property, run:

  $ gcloud config unset compute/zone

Alternatively, the zone can be stored in the environment variable
``CLOUDSDK_COMPUTE_ZONE''.
zThe instances should be migrated to a new host. This will temporarily impact the performance of instances during a migration event.z#The instances should be terminated.)MIGRATE	TERMINATENVMESCSIz3name=NAME [mode={ro,rw}] [device-name=DEVICE_NAME] zKname=NAME [mode={ro,rw}] [device-name=DEVICE_NAME] [scope={zonal,regional}]aE      table(
      name,
      zone.basename(),
      machineType.machine_type().basename(),
      scheduling.preemptible.yesno(yes=true, no=''),
      networkInterfaces[].networkIP.notnull().list():label=INTERNAL_IP,
      networkInterfaces[].accessConfigs[0].natIP.notnull().list()      :label=EXTERNAL_IP,
      status
    )a+  table(
            name,
            zone.basename(),
            networkInterfaces[].stackType.notnull().list(),
            networkInterfaces[].ipv6AccessConfigs[0].externalIpv6.notnull().list():label=EXTERNAL_IPV6,
            networkInterfaces[].ipv6Address.notnull().list():label=INTERNAL_IPV6)a      table(
      name,
      zone.basename(),
      machineType.machine_type().basename(),
      scheduling.preemptible.yesno(yes=true, no=''),
      networkInterfaces.internal_ip():label=INTERNAL_IP,
      external_ip():label=EXTERNAL_IP,
      status
    )instanceinstance_namecompute.instances)resource_namename	completerzonal_collectionzone_explanationF)r#   r$   requiredr%   r&   r'   instance_namesT)r#   r$   r%   r&   r'   pluralc                 "   U (       d  gU R                  S5      (       d  gU S    Vs/ s HD  nUR                  S5      (       d  M  US   S   R                  S5      (       d  M9  US   S   S   PMF     nnU S    Vs/ s Hp  nUR                  S5      (       d  M  US   S   R                  S5      (       d  M9  US   S   R                  S5      (       d  MW  US   S   S    S	US   S   S    3PMr     nnS
R                  X#-   5      $ s  snf s  snf )zFTransforms an instance resource to collect IPv4 and IPv6 external IPs. networkInterfacesaccessConfigsr   natIPipv6AccessConfigsexternalIpv6externalIpv6PrefixLength/
getjoin)resourceripv4_external_ipsipv6_external_ipss       9lib/googlecloudsdk/command_lib/compute/instances/flags.pyTransformInstanceExternalIpr=      sE   		)	*	* +,,!	
	 %$%o$6q$9$=$=g$F %aG$,   +,,!	
"	# m 
 
#
'
'
7 m 
 
#
'
'(B
C	 m		">	231Q7J5KA5NOi5j4kl,   
$8	99
s)   DD#D;DD7DDc                 @   U (       d  gU  Vs/ s H   nUR                  S5      (       d  M  US   PM"     nnU  Vs/ s H@  nUR                  S5      (       d  M  UR                  S5      (       d  M3  US    SUS    3PMB     nnSR                  X#-   5      $ s  snf s  snf )zWTransforms a list of network interface resources to collect IPv4 and IPv6 internal IPs.r,   	networkIPipv6AddressinternalIpv6PrefixLengthr3   r4   r5   )r8   r9   ipv4_internal_ipsipv6_internal_ipss       r<   TransformInstanceInternalIprD      s    	 !	
{	 an   !	
}	 <"#%%(B"C <=	!A89:;  
 
$8	99
s   B	BBB0Bc                 8    [         R                  " [        U 5      $ N)	functoolspartialInstanceZoneScopeLister)compute_clients    r<   GetInstanceZoneScopeListerrK      s    			2N	CC    c                    U R                   nUS   n[        R                  R                  R                  R                  SS9nU R                  R                  SUR                  SR                  U5      U[        R                  S94n/ nU R                  U/US9n/ n	U(       ay  [        R                  " SR                  U5      5        [        R                  R!                  S	R                  S
R#                  U5      5      5        [$        R&                  " X5      n	OU(       dj  [        R                  " SR                  U5      5        [        R                  R!                  SR                  U5      5        [$        R&                  " X5      n	O`U HZ  n
[(        R*                  R-                  U
R.                  SSU0S9nU	R1                  UR3                  UR5                  5       S95        M\     [6        R8                  R:                  U	0$ )z3Scope lister for zones of underspecified instances.r   Tr(   AggregatedListzname eq ^{0}$)filterproject
maxResults)errors_to_collectz+Errors fetching filtered aggregate list:
{}z2Error fetching possible zones for instance: [{0}]., z+Unable to find an instance with name [{0}].zcompute.zonesrQ   
collectionparams)r$   )messagesr   VALUEScorerQ   Getapitools_client	instances%ComputeInstancesAggregatedListRequestformatr   MAX_RESULTS_PER_PAGEMakeRequestsr   debugstatusPrintr7   zones_serviceListcore_resourcesREGISTRYParsezoneappendZoneNamecompute_scope	ScopeEnumZONE)rJ   _underspecified_namesrX   r!   rQ   requesterrorsmatching_instanceszonesirj   s               r<   rI   rI      s   $$(&q)-""**...='++557G;;'..}= %:: < <='
 &%22G9EK 3 M
%II<CCFKLJJ<CCII*+	-. ~7EII<CCFKLJJ5<<]KM~7E$$**
&&_i5I + Kdll8==diik=23   
!
!
&
&	..rL   c           	      X    [         R                  " SS[        R                  U S[        S9$ )Nr    z--next-hop-instancer"   )r#   r$   r%   r(   r&   r'   )compute_flagsResourceArgumentcompute_completersInstancesCompleterZONE_PROPERTY_EXPLANATIONrN   s    r<   InstanceArgumentForRouter~      s-    		'	' "55*0
2 2rL   c           
      x    [         R                  " SS[        R                  U SSR	                  U5      [
        S9$ )Nr    
--instancer"   z4Router appliance instance of the BGP peer being {0}.r#   r$   r%   r(   r&   
short_helpr'   ry   rz   r{   r|   r_   r}   )r(   operation_types     r<   InstanceArgumentForRouterr     s>    		'	'"55*GNN
0
2 2rL   c           
      R    [         R                  " SS[        R                  U SSSS9$ )Nr    r   r"   zFThe name of the virtual machine instance that will handle the traffic.z5If not specified, it will be set to the same as zone.r   )ry   rz   r{   r|   rN   s    r<   !InstanceArgumentForTargetInstancer     s7    		'	'"55*! B	
D 	DrL   c                     [         R                  " SS[        R                  USSR	                  U 5      S[         R
                  S9$ )Nr    z--instancesr"   z5Specifies a list of instances to {0} the target pool.T)r#   r$   r%   r(   r&   r   r*   r'   r   )actionr(   s     r<   InstanceArgumentForTargetPoolr      sD    		'	'"55*I6&>$>>	
@ 	@rL   c                      [         R                  " SS[        R                  S[         R                  R
                  SSSS9$ )zKMakeSourceInstanceTemplateArg.

Returns:
   compute_flags.ResourceArgument
--source-instance-templatezinstance templateFzcompute.instanceTemplateszcompute.regionInstanceTemplateszThe name of the instance template that the instance will be created from. An instance template can be a global/regional resource.

Users can override instance properties using other flags.)r$   r#   r%   r(   scope_flags_usageglobal_collectionregional_collectionr   )ry   rz   r{   InstanceTemplatesCompleterScopeFlagsUsageDONT_USE_SCOPE_FLAGS rL   r<   MakeSourceInstanceTemplateArgr   -  sC     
	'	'''"==%55JJ3;
 rL   c            	      P    [         R                  " SS[        R                  SSSS9$ )Nz--source-machine-imagezmachine imageFzcompute.machineImageszEThe name of the machine image that the instance will be created from.)r$   r#   r%   r(   r   r   )ry   rz   r{   MachineImagesCompleterr   rL   r<   AddMachineImageArgr   E  s/    		'	'##"99/%
' 'rL   c                 \    U R                  SSSR                  [        R                  S9S9  g )Nz$--source-machine-image-csek-key-fileFILEz      Path to a Customer-Supplied Encryption Key (CSEK) key file, mapping resources to user managed keys which were used to encrypt the source machine-image.
      See {csek_help} for more details.
      )	csek_helpmetavarhelp)add_argumentr_   r   CSEK_HELP_URLparsers    r<   "AddSourceMachineImageEncryptionKeyr   P  s4    ,
 &:33&
4  6rL   c                    S nU R                  5       nUR                  5       nUR                  SUSS9  [        R                  " U5        UR                  SSR                  [        R                  S9S9  U(       a  UR                  S	S
S9  U(       a  UR                  SSS9  U(       a  [        R                  " U5        U(       a  UR                  SSSS9  gg)zFAdds arguments related to images for instances and instance-templates.c                      g)z1Returns the detailed help for the `--image` flag.aR  
          Specifies the boot image for the instances. For each
          instance, a new boot disk will be created from the given
          image. Each boot disk will have the same name as the
          instance. To view a list of public images and projects, run
          `$ gcloud compute images list`. It is best practice to use `--image`
          when a specific version of an image is needed.

          When using this option, ``--boot-disk-device-name'' and
          ``--boot-disk-size'' can be used to override the boot disk's
          device name and size, respectively.
          r   r   rL   r<   AddImageHelp"AddImageArgs.<locals>.AddImageHelpc  s    rL   z--imageIMAGE)r   r   z--image-familya        The image family for the operating system that the boot disk will
      be initialized with. Compute Engine offers multiple Linux
      distributions, some of which are available as both regular and
      Shielded VM images.  When a family is specified instead of an image,
      the latest non-deprecated image associated with that family is
      used. It is best practice to use `--image-family` when the latest
      version of an image is needed.

      By default, ``{default_image_family}'' is assumed for this flag.
      )default_image_familyr   z--source-snapshotas          The name of the source disk snapshot that the instance boot disk
        will be created from. You can provide this as a full URL
        to the snapshot or just the snapshot name. For example, the following
        are valid values:

          * https://compute.googleapis.com/compute/v1/projects/myproject/global/snapshots/snapshot
          * snapshot
        z--source-instant-snapshotab          The name of the source disk instant snapshot that the instance boot disk
        will be created from. You can provide this as a full URL
        to the instant snapshot. For example, the following is a valid value:

          * https://compute.googleapis.com/compute/v1/projects/myproject/zones/my-zone/instantSnapshots/instant-snapshot
        z--source-snapshot-regionSOURCE_SNAPSHOT_REGIONz        Sets the region for the `--source-snapshot` flag. By default, when
        specifying a snapshot, the global snapshot scope is used. Use this flag to override this behavior to use regionally scoped snapshots.r   N)		add_groupadd_mutually_exclusive_groupr   r
   AddImageProjectFlagr_   r   DEFAULT_IMAGE_FAMILYAddImageFamilyScopeFlag)r   enable_snapshotssupport_image_family_scopeenable_instant_snapshotssupport_source_snapshot_regionr   image_parent_groupimage_groups           r<   AddImageArgsr   Z  s     '')"??A+9<I!!"45

 &i&D&D&
E  G   
 #  	  ''(:;###"(Q $  $rL   c                 &    U R                  SSSS9  g )Nz--can-ip-forward
store_truezsIf provided, allows the instances to send and receive packets with non-matching destination or source IP addresses.r   r   r   r   s    r<   AddCanIpForwardArgsr     s"    D  FrL   c                 z    [         R                  " SU5      n[        U5      R                  R	                  U 5        g Ncompute)r   GetMessagesModule(GetPrivateIpv6GoogleAccessTypeFlagMapper
choice_argAddToParserr   api_versionrX   s      r<   AddPrivateIpv6GoogleAccessArgr     s0    ##I{;(*84??KKrL   c                  8    [         R                  " SS SSS.SS9$ )N--maintenance-intervalc                 "    U R                  5       $ rF   upperxs    r<   <lambda>(AddMaintenanceInterval.<locals>.<lambda>  s
    QWWYrL   zVMs receive infrastructure and hypervisor updates on a periodic basis, minimizing the number of maintenance operations (live migrations or terminations) on an individual VM. Security updates will still be applied as soon as they are available.a  VMs receive infrastructure and hypervisor updates on a periodic basis, minimizing the number of maintenance operations (live migrations or terminations) on an individual VM.  This may mean a VM will take longer to receive an update than if it was configured for AS_NEEDED.  Security updates will still be applied as soonas they are available. RECURRENT is used for GEN3 and Sliceof Hardware VMs.)PERIODIC	RECURRENTzP
      Specifies how infrastructure upgrades should be applied to the VM.
      )typechoicesr   )r   Argumentr   rL   r<   AddMaintenanceIntervalr     s-    	(
/
 rL   c                  T    [         R                  " S[        R                  " 5       SS9$ )Nz--maintenance-freeze-durationz
        Specifies the amount of hours after instance creation where the instance
        won't be scheduled for maintenance, e.g. `4h`, `2d6h`.
        See $ gcloud topic datetimes for information on duration formats.r   r   )r   r   r   Durationr   rL   r<   AddMaintenanceFreezeDurationr     s*    	%!M
N NrL   c                 h    [        5       R                  U 5        [        5       R                  U 5        g)z"Add flags related to Stable Fleet.N)r   r   r   r   s    r<   AddStableFleetArgsr     s$    &&v. ,,V4rL   c                 `    [         R                  " SU R                  R                  SSSS.SS9$ Nz!--private-ipv6-google-access-typezinherit-subnetworkzenable-bidirectional-accesszenable-outbound-vm-access)INHERIT_FROM_SUBNETWORK%ENABLE_BIDIRECTIONAL_ACCESS_TO_GOOGLE#ENABLE_OUTBOUND_VM_ACCESS_TO_GOOGLEz/The private IPv6 Google access type for the VM.)custom_mappingshelp_str)r   ChoiceEnumMapperInstance&PrivateIpv6GoogleAccessValueValuesEnumrX   s    r<   r   r     s?    		#	#)>> #+) A
B BrL   c                 z    [         R                  " SU5      n[        U5      R                  R	                  U 5        g r   )r   r   3GetPrivateIpv6GoogleAccessTypeFlagMapperForTemplater   r   r   s      r<   (AddPrivateIpv6GoogleAccessArgForTemplater     s-    ##I{;(5
;;v.rL   c                 `    [         R                  " SU R                  R                  SSSS.SS9$ r   )r   r   InstancePropertiesr   r   s    r<   r   r     s?    		#	#)!!HH #+) A
B BrL   c                 \    U R                  S[        R                  " [        S S.S9SSS9  g)	=Adds local SSD argument for instances and instance-templates.--local-ssdc                 "    U R                  5       $ rF   r   r   s    r<   r   !AddLocalSsdArgs.<locals>.<lambda>  s
    !'')rL   )device-name	interfacespecrk   a)        Attaches a local SSD to the instances.

      *device-name*::: Optional. A name that indicates the disk name
      the guest operating system will see. Can only be specified if
      `interface` is `SCSI`. If omitted, a device name
      of the form ``local-ssd-N'' will be used.

      *interface*::: Optional. The kind of disk interface exposed to the VM
      for this SSD.  Valid values are ``SCSI'' and ``NVME''.  SCSI is
      the default and is supported by more guest operating systems.  NVME
      might provide higher performance.
      r   r   r   Nr   r   ArgDictstrr   s    r<   AddLocalSsdArgsr     s=     	+% 	 
  rL   c                 v    U R                  S[        R                  " S[        R                  " 5       0S9SSS9  g)z@Adds local NVDIMM argument for instances and instance-templates.z--local-nvdimmsizer   rk   a        Attaches a local NVDIMM to the instances.

      *size*::: Optional. Size of the NVDIMM disk. The value must be a whole
      number followed by a size unit of ``KB'' for kilobyte, ``MB'' for
      megabyte, ``GB'' for gigabyte, or ``TB'' for terabyte. For example,
      ``3TB'' will produce a 3 terabyte disk. Allowed values are: 3TB and 6TB
      and the default is 3 TB.
      r   N)r   r   r   
BinarySizer   s    r<   AddLocalNvdimmArgsr   !  sE     	
+((*% 	 
  rL   c                     U R                  S[        R                  " [        S [        R                  " SSS9S.S9SS	S
9  g)r   r   c                 "    U R                  5       $ rF   r   r   s    r<   r   )AddLocalSsdArgsWithSize.<locals>.<lambda>A  s
    QWWYrL   375GB6000GBlower_boundupper_bound)r   r   r   r   rk   a;        Attaches a local SSD to the instances.

      *device-name*::: Optional. A name that indicates the disk name
      the guest operating system will see. Can only be specified if `interface`
      is `SCSI`. If omitted, a device name
      of the form ``local-ssd-N'' will be used.

      *interface*::: Optional. The kind of disk interface exposed to the VM
      for this SSD.  Valid values are ``SCSI'' and ``NVME''.  SCSI is
      the default and is supported by more guest operating systems.  NVME
      might provide higher performance.

      *size*::: Optional. The only valid value is ``375GB''. Specify the
      ``--local-ssd'' flag multiple times if you need multiple ``375GB'' local
      SSD partitions. You can specify a maximum of 24 local SSDs for a maximum
      of ``9TB'' attached to an instance.
      r   N)r   r   r   r   r   r   s    r<   AddLocalSsdArgsWithSizer  5  sP     	 .!,,%8 
  rL   c                     U (       a   gg)zAHelper to get documentation for "device-name" param of disk spec.aw  An optional name to display the disk name in the guest operating system. Must be the same as `name` if used with `--container-mount-disk`. If omitted, a device name of the form `persistent-disk-N` is used. If omitted and used with `--container-mount-disk` (where the `name` of the container mount disk is the same as in this flag), a device name equal to disk `name` is used.zAn optional name to display the disk name in the guest operating system. If omitted, a device name of the form `persistent-disk-N` is used.r   container_mount_enableds    r<   GetDiskDeviceNameHelpr	  ]  s    	+rL   c                 |   [        US9n[        X5        [        [        [        R                  " 5       [        [        R                  " 5       [        S.nU(       a!  [        US'   [        R                  " 5       US'   SR                  U5      nU(       a  US-  nU R                  S[        R                  " US9S	US
9  g)zEAdds arguments related to disks for instances and instance-templates.r  )r$   modebootr   auto-deleter   r   zforce-attachaD  
      Attaches an existing disk to the instances.

      *name*::: The disk to attach to the instances. If you create more than
      one instance, you can only attach a disk in read-only mode. By default,
      you attach a zonal disk located in the same zone of the
      instance. If you want to attach a regional disk, you must
      specify the disk using its URI; for example,
      ``projects/myproject/regions/us-central1/disks/my-regional-disk''.

      *mode*::: The mode of the disk. Supported options are ``ro'' for read-only
      mode and ``rw'' for read-write mode. If omitted, ``rw'' is used as
      a default value. If you use ``rw'' when creating more than one instance,
      you encounter errors.

      *boot*::: If set to ``yes'', you attach a boot disk. The
      virtual machine then uses the first partition of the disk for
      the root file systems. The default value for this is ``no''.

      *device-name*::: {}

      *auto-delete*::: If set to ``yes'', the persistent disk is
      automatically deleted when the instance is deleted. However,
      if you detach the disk from the instance, deleting the instance
      doesn't delete the disk. The default value is ``yes''.

      *interface*::: The interface to use for the disk.
      The value must be one of the following:
        * SCSI
        * NVME
      a  
      *scope*::: Can be `zonal` or `regional`. If ``zonal'', the disk is
      interpreted as a zonal disk in the same zone as the instance (default).
      If ``regional'', the disk is interpreted as a regional disk in the same
      region as the instance. The default value for this is ``zonal''.
      *force-attach*::: If ``yes'',  this persistent disk will force-attached to
      the instance even it is already attached to another instance. The default
      value is 'no'.
      --diskr   rk   r   N)r	  AddBootDiskArgsr   r   
ArgBooleanr_   r   r   )r   enable_regional_disks
enable_kmsr  disk_device_name_helpdisk_arg_spec	disk_helps          r<   AddDiskArgsr  n  s     057 &% $$& ++--  M'$/$:$:$<M.!
< &&
'= >  
 
I 	M2	  rL   c                    U R                  SSS9  U R                  S[        R                  " SS9SS9  U R                  S	S
S9  U R                  SSSSS9  U R                  S[        R                  " 5       SS9  U R                  S[        R                  " 5       SS9  U R                  SSS9  U(       a=  / SQn[	        U Vs/ s H	  o3SU-   4PM     sn5      nSn[
        R                  " U SXES9  ggs  snf )zAdds boot disk args.--boot-disk-device-namez      The name the guest operating system will see for the boot disk.  This
      option can only be specified if a new boot disk is being created (as
      opposed to mounting an existing persistent disk).
      r   --boot-disk-size1GBr  a        The size of the boot disk. This option can only be specified if a new
      boot disk is being created (as opposed to mounting an existing
      persistent disk). The value must be a whole number followed by a size
      unit of ``KB'' for kilobyte, ``MB'' for megabyte, ``GB'' for gigabyte,
      or ``TB'' for terabyte. For example, ``10GB'' will produce a 10 gigabyte
      disk. Disk size must be a multiple of 1 GB.  Default size unit is ``GB''.
      r   --boot-disk-typea        The type of the boot disk. This option can only be specified if a new boot
      disk is being created (as opposed to mounting an existing persistent
      disk). To get a list of available disk types, run
      `$ gcloud compute disk-types list`.
      z--boot-disk-auto-deleter   TzAAutomatically delete boot disks when their instances are deleted.r   defaultr   --boot-disk-provisioned-iopsz      Indicates how many IOPS to provision for the disk. This sets the number
      of I/O operations per second that the disk can handle.
      "--boot-disk-provisioned-throughputz      Indicates how much throughput to provision for the disk. This sets the
      number of throughput mb per second that the disk can handle.
      --boot-disk-interfacez      Indicates the interface to use for the boot disk.
      The value must be one of the following:
      * SCSI
      * NVME
      kms-keykms-keyringkms-locationkms-projectz--boot-disk---boot-disk-kms-keydiskflag_overridesr$   N)r   r   r   
BoundedIntdictkms_resource_argsAddKmsKeyResourceArg)r   r  	kms_flagsflagr*  r$   s         r<   r  r    sI   
   	!!e4
  
 	
   	N	  P 	$!!#
   	*!!#
   	
   II3<=94%	&9=?N D**~B  	>s   C3c                     / SQn[        U Vs/ s H	  o"SU-   4PM     sn5      nSn[        R                  " U SX4S9  g s  snf )Nr"  z--instance-z--instance-kms-keyr    r)  )r,  r-  r.  )r   r/  r0  r*  r$   s        r<   AddInstanceKmsArgsr2    sR    G)/8/8t]T!"y . 
$((jDs   >c                 f   [        US9nU(       d  SOSnU(       d  SOSnSR                  UUUS9nU(       a  US-  nU(       a!  USR                  S	[        R                  S
9-  n0 S[        _S[        _S[        _S[        _S[        _S[
        R                  " SS9_S[        _S[        _S[
        R                  " 5       _S[        _S[        _S[
        R                  " SS9_S[        _S[        _S[
        R                  " SSS9_S [        _nU(       a	  [        US!'   U(       a$  [        US"'   [        US#'   [        US$'   [        US%'   U(       a  [
        R                  " 5       US&'   U(       a  US'-  n[        US('   U(       a  US)-  n[        US*'   U
(       a  US+-  n[        US,'   U(       a  US--  n[        US.'   U(       a  [
        R                  " 5       US/'   US0-  nU(       a  [
        R                  " 5       US1'   US2-  nU	(       a  US3-  n[
        R                  " S4S9US5'   U(       aG  US6R                  [        R                  [        R                  S79-  n[
        R                  " SSS9US'   U(       a  US8-  n[        US9'   U R                  S:[
        R                  " US;9S<S=US>9  g?)@z?Adds create-disk argument for instances and instance-templates.r  r,   z] Must specify this option if attaching the disk to a container with `--container-mount-disk`.zk It is an error to create a disk in `ro` mode if attaching it to a container with `--container-mount-disk`.a        Creates and attaches persistent disks to the instances.

      *name*::: Specifies the name of the disk. This option cannot be
      specified if more than one instance is being created.{disk_name}

      *description*::: Optional textual description for the disk being created.

      *mode*::: Specifies the mode of the disk. Supported options
      are ``ro'' for read-only and ``rw'' for read-write. If
      omitted, ``rw'' is used as a default.{disk_mode}

      *image*::: Specifies the name of the image that the disk will be
      initialized with. A new disk will be created based on the given
      image. To view a list of public images and projects, run
      `$ gcloud compute images list`. It is best practice to use image when
      a specific version of an image is needed. If both image and image-family
      flags are omitted a blank disk will be created.

      *image-family*::: The image family for the operating system that the boot
      disk will be initialized with. Compute Engine offers multiple Linux
      distributions, some of which are available as both regular and
      Shielded VM images.  When a family is specified instead of an image,
      the latest non-deprecated image associated with that family is
      used. It is best practice to use --image-family when the latest
      version of an image is needed.

      *image-project*::: The Google Cloud project against which all image and
      image family references will be resolved. It is best practice to define
      image-project. A full list of available image projects can be generated by
      running `gcloud compute images list`.

        * If specifying one of our public images, image-project must be
          provided.
        * If there are several of the same image-family value in multiple
          projects, image-project must be specified to clarify the image to be
          used.
        * If not specified and either image or image-family is provided, the
          current default project is used.

      *size*::: The size of the disk. The value must be a whole number
      followed by a size unit of ``KB'' for kilobyte, ``MB'' for
      megabyte, ``GB'' for gigabyte, or ``TB'' for terabyte. For
      example, ``10GB'' will produce a 10 gigabyte disk. Disk size must
      be a multiple of 1 GB. If not specified, the default image size
      will be used for the new disk.

      *type*::: The type of the disk. To get a list of available disk
      types, run $ gcloud compute disk-types list. The default disk type
      is ``pd-standard''.

      *device-name*::: {disk_device}

      *provisioned-iops*::: Indicates how many IOPS to provision for the disk.
      This sets the number of I/O operations per second that the disk can
      handle. Value must be between 10,000 and 120,000.

      *provisioned-throughput*::: Indicates how much throughput to provision for
      the disk. This sets the number of throughput mb per second that the disk
      can handle.

      *disk-resource-policy*::: Resource policy to apply to the disk. Specify a full or partial URL. For example:
        * ``https://www.googleapis.com/compute/v1/projects/my-project/regions/us-central1/resourcePolicies/my-resource-policy''
        * ``projects/my-project/regions/us-central1/resourcePolicies/my-resource-policy''

      For more information, see the following docs:
        * https://cloud.google.com/sdk/gcloud/reference/beta/compute/resource-policies/
        * https://cloud.google.com/compute/docs/disks/scheduled-snapshots

      *auto-delete*::: If ``yes'', this persistent disk will be
      automatically deleted when the instance is deleted. However,
      if the disk is later detached from the instance, this option
      won't apply. The default value for this is ``yes''.

      *architecture*::: Specifies the architecture or processor type that this
      disk can support. For available processor types on Compute Engine, see
      https://cloud.google.com/compute/docs/cpu-platforms.

      *storage-pool*::: The name of the storage pool in which the new disk is
      created. The new disk and the storage pool must be in the same location.

      *interface*::: The interface to use with the disk. The value must be one
      of the following:
        * SCSI
        * NVME
      )	disk_name	disk_modedisk_devicez
      *boot*::: If ``yes'', indicates that this is a boot disk. The
      instance will use the first partition of the disk for
      its root file system. The default value for this is ``no''.
    a  
      *kms-key*::: Fully qualified Cloud KMS cryptokey name that will
      protect the {resource}.

      This can either be the fully qualified path or the name.

      The fully qualified Cloud KMS cryptokey name format is:
      ``projects/<kms-project>/locations/<kms-location>/keyRings/<kms-keyring>/
      cryptoKeys/<key-name>''.

      If the value is not fully qualified then kms-location, kms-keyring, and
      optionally kms-project are required.

      See {kms_help} for more details.

      *kms-project*::: Project that contains the Cloud KMS cryptokey that will
      protect the {resource}.

      If the project is not specified then the project where the {resource} is
      being created will be used.

      If this flag is set then key-location, kms-keyring, and kms-key
      are required.

      See {kms_help} for more details.

      *kms-location*::: Location of the Cloud KMS cryptokey to be used for
      protecting the {resource}.

      All Cloud KMS cryptokeys are reside in a 'location'.
      To get a list of possible locations run 'gcloud kms locations list'.
      If this flag is set then kms-keyring and kms-key are required.
      See {kms_help} for more details.

      *kms-keyring*::: The keyring which contains the Cloud KMS cryptokey that
      will protect the {resource}.

      If this flag is set then kms-location and kms-key are required.

      See {kms_help} for more details.
      r(  )r8   kms_helpdescriptionr  imageimage-familyzimage-projectr   r  r  r   r   r  zprovisioned-iopszprovisioned-throughputzdisk-resource-policy   )
max_lengtharchitecturezstorage-poollabels:)
min_lengthcustom_delim_charr   r$   r#  r&  r%  r$  r  ac  
      *source-snapshot*::: The source disk snapshot that will be used to
      create the disk. You can provide this as a full URL
      to the snapshot or just the snapshot name. For example, the following
      are valid values:

        * https://compute.googleapis.com/compute/v1/projects/myproject/global/snapshots/snapshot
        * snapshot
      source-snapshotah  
      *source-snapshot-csek-required*::: The CSK protected source disk snapshot
      that will be used to create the disk. This can be provided as a full URL
      to the snapshot or just the snapshot name. Must be specified with
      `source-snapshot-csek-key-file`. The following are valid values:

        * https://www.googleapis.com/compute/v1/projects/myproject/global/snapshots/snapshot
        * snapshot

      *source-snapshot-csek-key-file*::: Path to a Customer-Supplied Encryption
      Key (CSEK) key file for the source snapshot. Must be specified with
      `source-snapshot-csek-required`.
      zsource-snapshot-csek-key-filea\  
      *source-instant-snapshot*::: The source disk instant snapshot that will be used to
      create the disk. You can provide this as a full URL
      to the instant snapshot. For example, the following is a valid value:

        * https://compute.googleapis.com/compute/v1/projects/myproject/zones/myzone/instantSnapshots/instantSnapshot
      source-instant-snapshota  
      *image-csek-required*::: Specifies the name of the CSK protected image
      that the disk will be initialized with. A new disk will be created based
      on the given image. To view a list of public images and projects, run
      `$ gcloud compute images list`. It is best practice to use image when
      a specific version of an image is needed. If both image and image-family
      flags are omitted a blank disk will be created. Must be specified with
      `image-csek-key-file`.

      *image-csek-key-file*::: Path to a Customer-Supplied Encryption Key (CSEK)
      key file for the image. Must be specified with `image-csek-required`.
    zimage-csek-key-filezmulti-writera  
      *multi-writer*::: If ``yes'', the disk is created in multi-writer mode so
      that it can be attached with read-write access to two VMs. The
      default value is ``no''.
      The multi-writer feature requires specialized filesystems, among other
      restrictions. For more information, see
      https://cloud.google.com/compute/docs/disks/sharing-disks-between-vms.
    zconfidential-computez
      *confidential-compute*::: If ``yes'', the disk is created in confidential
      mode. The default value is ``no''. Encryption with a Cloud KMS key is required to enable this option.
    a  
      *replica-zones*::: Required for each regional disk associated with the
      instance. Specify the URLs of the zones where the disk should be
      replicated to. You must provide exactly two replica zones, and one zone
      must be the same as the instance zone.
       zreplica-zonesz
      *labels*::: List of label KEY=VALUE pairs separated by `:` character to
      add to the disk.

      Example: `Key1=Value1:Key2=Value2:Key3=Value3`.


      {KEY_FORMAT_HELP} {VALUE_FORMAT_HELP}
    )KEY_FORMAT_HELPVALUE_FORMAT_HELPz
      *source-snapshot-region*::: The region of the source snapshot that
      will be used to create the disk. You can provide region name to use
      scoped snapshot as the source snapshot.
      zsource-snapshot-region--create-diskr   rk   PROPERTY=VALUEr   r   r   r   N)r	  r_   r   KMS_HELP_URLr   r   r   r  intArgListr   rE  rF  r   r   )r   r  r   r  source_snapshot_csek
image_csekinclude_namesupport_bootsupport_multi_writersupport_replica_zonesenable_source_instant_snapshotsenable_confidential_computesupport_disk_labelsr   r  disk_name_extra_helpdisk_mode_extra_helpr  r   s                      r<   AddCreateDiskArgsrX  
  sk   $ 057#:6  $;F U
j &$$'  k t   I
  (
P &I$:$:  <Q)<IT
S
c
 s
 c	

 s
 k$$7
 c
 S
 [++-
 #
 
 k11Q?
 c
 c
 ##qCH
  3!
$& DLDODDD))+DL 
 
I "D	 
 
I -0D	()$ 
 
I '*D	"#  I #&D	&113D  I !#.#9#9#;D	   I
   I (//1=D  	#33%77 	 	
I !((AMDN# 
 
I
 &)D	!"D)  rL   c                     U R                  SS9nUR                  S[        S5      SSS9  UR                  S[        R                  " 5       SSS9  UR                  S	S
SS9  UR                  SSS9  g)z=Adds arguments related to custom machine types for instances.zCustom machine type extensions.r   --custom-cpuTa        A whole number value specifying the number of cores that are needed in
      the custom machine type.

      For some machine types, shared-core values can also be used. For
      example, for E2 machine types, you can specify `micro`, `small`, or
      `medium`.
      )r   r(   r   --custom-memoryz      A whole number value indicating how much memory is desired in the custom
      machine type. A size unit should be provided (eg. 3072MB or 9GB) - if no
      units are specified, GB is assumed.
      z--custom-extensionsr   z%Use the extended custom machine type.r   z--custom-vm-typez
      Specifies a custom machine type. The default is `n1`. For more information about custom machine types, see:
      https://cloud.google.com/compute/docs/general-purpose-machines#custom_machine_types
      N)r   r   NonEmptyStringr   r   )r   custom_groups     r<   AddCustomMachineTypeArgsr^  >  s    !!'H!I,.)
	   !!#
	   2  4 
  rL   c           
         / nU R                   nU R                  nU R                  UR                  SUR	                  UR                  5       UR                  UR                  S94/US9nU(       a  [        R                  " USS9  US   $ )zReturns the address resource corresponding to the given reference.

Args:
  compute_client: GCE API client,
  address_ref: resource reference to reserved IP address

Returns:
  GCE reserved IP address resource
r[   )addressrQ   region)requestsrS   z!Could not fetch address resource.)error_messager   )
rX   r\   ra   	addressesComputeAddressesGetRequestrm   rQ   ra  r   RaiseToolException)rJ   address_refrt   rX   r   ress         r<   _GetAddressri  b  s     &$$(**'##""E44(--/(00'.. 5 01 2
  	$ 	 # 	AC	Q-rL   c                     U(       d  g [         R                  " [        R                  " U5      5        U$ ! [         a     Of = f[        XU5      n[        X5      nUR                  $ )aZ  Resolves the --address flag value.

If the value of --address is a name, the regional address is queried.

Args:
  resources: resources object,
  compute_client: GCE API client,
  address: The command-line flags. The flag accessed is --address,
  region: The region.

Returns:
  If an --address is given, the resolved IP address; otherwise None.
N)	ipaddress
ip_addresssix	text_type
ValueErrorGetAddressRefri  r`  )r   rJ   r`  ra  rg  rh  s         r<   ExpandAddressFlagrq  |  s_     
	w/0N	 		
 i&9+N0#	s   +6 
AAc                     U R                  US[        R                  R                  R                  R
                  US.S9$ )zEGenerates an address reference from the specified address and region.zcompute.addresses)rQ   ra  rU   )ri   r   rY   rZ   rQ   	GetOrFail)r   r`  ra  s      r<   rp  rp    sA    	$&&++33== 
 
	 	rL   c                 \    [        U 5        [        U 5        [        XS9  [        U UUUUS9  g)z/Validates the values of all disk-related flags.)r  )r   enable_source_snapshot_csekenable_image_csekenable_source_instant_snapshotN)ValidateDiskCommonFlagsValidateDiskAccessModeFlagsValidateDiskBootFlagsValidateCreateDiskFlags)argsr  r   ru  rv  rw  s         r<   ValidateDiskFlagsr}    s3     $d#4
'"=)%CrL   c                    U R                   =(       d    /  H  nUR                  S5      nU(       d*  [        R                  " SSR	                  [
        5      5      eUR                  S5      nU(       a,  US;  a&  [        R                  " SSR	                  U5      5      eUR                  S5      nU(       d  M  U[        ;  d  M  [        R                  " SSR	                  [        U5      5      e   g	)
z2Validates the values of common disk-related flags.r$   r  zH[name] is missing in [--disk]. [--disk] value must be of the form [{0}].r  rwro=Value for [mode] in [--disk] must be [rw] or [ro], not [{0}].r   KValue for [interface] in [--disk] must be one of following: {0}, not [{1}].N)r(  r6   r   InvalidArgumentExceptionr_   DISK_METAVARPD_INTERFACES)r|  r(  r4  
mode_valuer   s        r<   rx  rx    s     iio2od I//
6,'  &!Jj4//

I6*  %IyYm3//
F=)4 ' rL   c                    U R                   =(       d    /  Hl  nUR                  S5      nUR                  S5      n[        U R                  5      S:  d  M@  US:X  d  MH  [        R
                  " SSR                  U5      5      e   g)z%Checks disks R/O and R/W access mode.r$   r  r;  r  r  zFCannot attach disk [{0}] in read-write mode to more than one instance.N)r(  r6   lenr)   r   BadArgumentExceptionr_   )r|  r(  r4  r  s       r<   ry  ry    ss    iio2od I&!J 4!#
d(:++
fY') ) rL   c                 j    SnU =(       d    /  H!  nUR                  SS5      (       d  M  US-  nM#     U$ )z*get number of boot disks in list of disks.r   r  Fr;  r6   )disksnum_of_boot_diskr(  s      r<   GetNumOfBootDiskr    s<    krkdxx!  
rL   c                    Sn[        U R                  5      nUS:  a  [        R                  " SS5      e[        U R                  5      nUS:  a  [        R                  " SS5      eXC-   S:  a  [        R                  " SS5      eXC-   S:X  a  SnU R                  S	5      (       aR  U R                  S
5      (       a%  [        R                  " U R                  5      (       d  [        R                  " SS5      eU R                  S5      (       aR  U R                  S
5      (       a%  [        R                  " U R                  5      (       d  [        R                  " SS5      eU R                  S5      (       aI  U R                  [        ;  a5  [        R                  " SSR                  [        U R                  5      5      eU R                  S5      (       a  [        R                  " U R                   5      nU R                  S
5      (       aJ  U R                  ["        R$                  ;   a,  US:  a&  [        R                  " SSR                  U5      5      eU R&                  (       a  U(       a  [        R                  " SS5      eU(       GaI  U R(                  (       a  [        R                  " SS5      eU R                  (       a  [        R                  " SS5      eU R                   (       a  [        R                  " SS5      eU R*                  (       d  [        R                  " SS5      eU(       a  U R,                  (       a  [        R                  " SS5      eU R.                  (       a  [        R                  " SS5      eU R0                  (       a  [        R                  " SS5      eU R2                  (       a  [        R                  " SS5      eg g g )!z0Validates the values of boot disk-related flags.Fr;  r  zfEach instance can have exactly one boot disk. At least two boot disks were specified through [--disk].rG  zmEach instance can have exactly one boot disk. At least two boot disks were specified through [--create-disk].zxEach instance can have exactly one boot disk. At least two boot disks were specified through [--disk and --create-disk].Tboot_disk_provisioned_iopsboot_disk_typer  zE--boot-disk-provisioned-iops cannot be used with the given disk type. boot_disk_provisioned_throughputr   zK--boot-disk-provisioned-throughput cannot be used with the given disk type.boot_disk_interfacer!  zKValue for [--boot-disk-interface] must be one of following: {0}, not [{1}].boot_disk_size
   r  z=Value must be greater than or equal to 10 GB; received {0} GBzEach instance can have exactly one boot disk. One boot disk was specified through [--disk or --create-disk] and another through [--image].r  zkEach instance can have exactly one boot disk. One boot disk was specified through [--disk or --create-disk]r  z--no-boot-disk-auto-deleter'  z--boot-disk-kms-keyringz--boot-disk-kms-locationz--boot-disk-kms-projectN)r  r(  r   r  create_diskIsSpecifiedr	   IsProvisioningTypeIopsr  r  IsProvisioningTypeThroughputr  r  r_   r   	BytesToGbr  r   LEGACY_DISK_TYPE_LISTr9  boot_disk_device_nameboot_disk_auto_deleteboot_disk_kms_keyboot_disk_kms_keyringboot_disk_kms_locationboot_disk_kms_project)r|  r  boot_disk_specifiednum_of_boot_disk_in_disks num_of_boot_disk_in_create_diskssize_gbs         r<   rz  rz    s   .tyy9"

)
) 67 7 &6d6F6F%G"%)

)
)	=> >
 'BaG

)
)	HI I
 'BqH	233 ..t/B/BCC//
(  
899 44T5H5HII//
. 
 
+,,}4//
!((.T55)  
&''ood112G)**9#B#BBbL//

I6'?  
ZZ'

)
) *+ +
 !!++
#JK K
 ++
 JK K ++
 JK K %%++
&JK K
 			--!LM 	M
 
	#	#--%LM 	M
 
	$	$--&LM 	M
 
	#	#--%LM 	M 
$' / rL   c                 4   [        U SS5      n[        U SS5      n[        U S/ 5      n[        U S/ 5      =(       d    /  GH  n	U	R                  S5      n
U(       a<  [        U5      S:  a-  U
(       a&  [        R                  " SS	R                  U
5      5      eU
(       a%  U(       a  U(       a  [        R                  " SS
5      eU	R                  S5      nU(       a,  US;  a&  [        R                  " SSR                  U5      5      eU	R                  S5      nU(       a5  U[        ;  a+  [        R                  " SSR                  [        U5      5      eU	R                  S5      nU	R                  S5      nU	R                  S5      nU	R                  S5      nU	R                  S5      nU	R                  S5      n[        5       nU(       a  UR                  U5        U(       a  UR                  U5        U(       a  UR                  U5        U(       a  UR                  U5        U(       a  UR                  U5        U(       a  UR                  U5        SS/nU(       a  UR                  S5        U(       a  UR                  S5        U(       a  UR                  S5        U(       a  UR                  S5        SR                  SR                  USS 5      US   5      nSR                  U5      n[        U5      S:  d  GM  [        R                  " U5      e   g) z2Validates the values of create-disk related flags.require_csek_key_createNcsek_key_filenamesr  r$   r;  r  z?Cannot create a disk with [name]={} for more than one instance.zPCannot create a disk with customer supplied key when disk name is not specified.r  r  r  r   r  r9  r:  rB  rN  source_snapshot_csek_filerC  z[image]z[image-family]z[image-csek-required]z[source-snapshot]z[source-snapshot-csek-required]z[source-instant-snapshot]z	{}, or {}rT   zZMust specify exactly one of {} for a [--create-disk]. These fields are mutually exclusive.)getattrr6   r  r   r  r_   r  r  setaddrk   r7   compute_exceptionsArgumentError)r|  r   ru  rv  rO  rw  r  r  resource_namesr(  r4  r  r   image_valueimage_family_valuesource_snapshotimage_csek_filer  source_instant_snapshotdisk_sourcemutex_attributesformatted_attributessource_error_messages                          r<   r{  r{  k  s    $D*CTJ$6-4"-.dM2.4"4d IN+a/I++

K6)  ,++
 
 &!Jj4//

I6*  %IYm3//
F=)4  ((7#K.1hh01Ohh|,O $)D E"hh'@A%Kook"oo()ooo&ooo& oo/0oo-.!#345612"?@%9:&--dii8H"8M.N.>r.BD	@@F A"  ;!,,-ABBA 5rL   c                     U R                   (       a:  U R                  (       d(  U R                  (       d  [        R                  " S5      eggg)zValidates the image flags.zYMust specify either [--image] or [--image-family] when specifying [--image-project] flag.N)image_projectr9  image_familyr  r  r|  s    r<   ValidateImageFlagsr    s<    	t/@/@

*
*	"# # 0ArL   c                     U R                  5       nU[        R                  ;   a  U$ [        R                  " SSU-  5      ez8Validates stack type field, throws exception if invalid.--network-interfacez"Invalid value for stack-type [%s].)r   r   $NETWORK_INTERFACE_STACK_TYPE_CHOICESr   r  stack_type_input
stack_types     r<   !ValidateNetworkInterfaceStackTyper    sB    %%'*9AAA

-
-,z9; ;rL   c                     U R                  5       nU[        R                  ;   a  U[        R                  :w  a  U$ [        R
                  " SSU-  5      er  )r   r   r  &NETWORK_INTERFACE_IPV6_ONLY_STACK_TYPEr   r  r  s     r<   5ValidateNetworkInterfaceStackTypeIpv6OnlyNotSupportedr    sP    %%'*IBBBIDDD

-
-,z9; ;rL   c                     U R                  5       nU[        R                  ;   a  U$ [        R                  " SSU S35      e)z8Validates igmp query field, throws exception if invalid.r  zInvalid value for igmp-query [z].)r   r   $NETWORK_INTERFACE_IGMP_QUERY_CHOICESr   r  )igmp_query_input
igmp_querys     r<   !ValidateNetworkInterfaceIgmpQueryr    sF    %%'*9AAA

-
-
(B79 9rL   c                 |    U R                  5       nU[        R                  ;   a  U$ [        R                  " SS5      e)z:Validates network tier field, throws exception if invalid.r  zInvalid value for network-tier)r   r   !NETWORK_TIER_CHOICES_FOR_INSTANCEr   r  )network_tier_inputnetwork_tiers     r<   _ValidateNetworkTierr    s?    #))+,Y@@@

-
-.C.NP PrL   c                     U R                  5       nU[        R                  ;   a  U$ [        R                  " SSU-  5      e)z?Validates IPv6 network tier field, throws exception if invalid.r  z)Invalid value for ipv6-network-tier [%s].)r   r   +NETWORK_INTERFACE_IPV6_NETWORK_TIER_CHOICESr   r  )ipv6_network_tier_inputipv6_network_tiers     r<   (_ValidateNetworkInterfaceIpv6NetworkTierr    sI    -335		>	>?

-
-36GGI IrL   c                     U R                  5       nU[        R                  ;   a  U$ [        R                  " SSU-  5      e)zDValidates network interface type field, throws exception if invalid.r  zInvalid value for nic-type [%s])r   r   "NETWORK_INTERFACE_NIC_TYPE_CHOICESr   r  )nic_type_inputnic_types     r<   ValidateNetworkInterfaceNicTyper    sC    !!#(===O

-
-@8KM MrL   c
                    U R                  5       n
[        U
5        U(       a  SnOSnU
R                  SUS9  [        [        S[        [        [        [        [        [        [        [        [        [        SS.n[
        US'   [        US'   U(       a	  [        US	'   U(       a
  [        US
'   O	[        US
'   [        US'   / nU(       d  [        US'   UR                  S5        OUR                  S5        UR                  S5        U(       a  [        US'   UR                  S5        U(       a  UR                  S5        OUR                  S5        UR                  S5        U(       d  UR                  S5        UR                  S5        U(       a  UR                  S5        OUR                  S5        UR                  S5        U	(       a  UR                  S5        U(       a  UR                  S5        [        US'   U(       a  UR                  S5        U(       a  U R                  SS9nUR                  S [        R                  " USS!9S"S#S$R                  U5      S%9  U(       a;  S&nUR                  S'[        R                   " 5       S(US)9  S*nUR                  S+S,US-9  ggU R                  S [        R                  " USS!9S"S#S$R                  U5      S%9  g).a  Adds address arguments for instances and instance-templates.

Args:
  parser: gcloud command arguments parser.
  instances: adds address arguments for instances if set to true, for instance
    templates elsewise.
  support_subinterface: indicates subinterface is supported or not.
  instance_create: adds address arguments for instance creation if set to
    true.
  containers: adds address arguments for create-with-containers command if set
    to true, for create command otherwise.
  support_network_queue_count: indicates flexible networking queue count is
    supported or not.
  support_vlan_nic: indicates whether VLAN network interfaces are supported.
  support_ipv6_only: indicates whether IPV6_ONLY stack type is supported.
  support_igmp_query: indicates whether setting igmp query on network
    interfaces is supported.
  support_enable_vpc_scoped_dns: indicates whether setting enable vpc scoped
    dns on network interfaces is supported.
z        Assigns the given external address to the instance that is created.
        The address might be an IP address or the name or URI of an address
        resource. This option can only be used when creating a single instance.
        z        Assigns the given external IP address to the instance that is created.
        This option can only be used when creating a single instance.
        z	--addressr   N)r`  network
no-addresssubnetzprivate-network-ipaliasesznetwork-attachmentzipv6-addresszipv6-prefix-lengthzexternal-ipv6-addresszexternal-ipv6-prefix-lengthzinternal-ipv6-addresszinternal-ipv6-prefix-lengthzenable-vpc-scoped-dnsznetwork-tierznic-typez
igmp-queryz
stack-typezipv6-network-tierzipv6-public-ptr-domaina        Adds a network interface to the instance. Mutually exclusive with any
      of these flags: *--address*, *--network*, *--network-tier*, *--subnet*,
      *--private-network-ip*, *--stack-type*, *--ipv6-network-tier*,
      *--internal-ipv6-address*,
      *--internal-ipv6-prefix-length*, *--ipv6-address*, *--ipv6-prefix-length*,
      *--external-ipv6-address*, *--external-ipv6-prefix-length*,
      *--ipv6-public-ptr-domain*. This flag can be repeated to specify
      multiple network interfaces.
    a        Adds a network interface to the instance. Mutually exclusive with any
      of these flags: *--address*, *--network*, *--network-tier*, *--subnet*,
      *--private-network-ip*, *--stack-type*, *--ipv6-network-tier*,
      *--internal-ipv6-address*,
      *--internal-ipv6-prefix-length*, *--ipv6-address*, *--ipv6-prefix-length*,
      *--external-ipv6-address*, *--external-ipv6-prefix-length*.
      This flag can be repeated to specify multiple network interfaces.
    a  
      The following keys are allowed:
      *address*::: Assigns the given external address to the instance that is
      created. Specifying an empty string will assign an ephemeral IP.
      Mutually exclusive with no-address. If neither key is present the
      instance will get an ephemeral IP.

      *network*::: Specifies the network that the interface will be part of.
      If subnet is also specified it must be subnetwork of this network. If
      neither is specified, this defaults to the "default" network.

      *no-address*::: If specified the interface will have no external IP.
      Mutually exclusive with address. If neither key is present the
      instance will get an ephemeral IP.

      *network-tier*::: Specifies the network tier of the interface.
      ``NETWORK_TIER'' must be one of: `PREMIUM`, `STANDARD`. The default
      value is `PREMIUM`.

      *private-network-ip*::: Assigns the given RFC1918 IP address to the
      interface.

      *subnet*::: Specifies the subnet that the interface will be part of.
      If network key is also specified this must be a subnetwork of the
      specified network.

      *nic-type*::: Specifies the  Network Interface Controller (NIC) type for
      the interface. ``NIC_TYPE'' must be one of: `GVNIC`, `VIRTIO_NET`.
      zqueue-counta4  
      *queue-count*::: Specifies the networking queue count for this interface.
      Both Rx and Tx queues will be set to this number. If it's not specified,
      a default queue count will be assigned. See
      https://cloud.google.com/compute/docs/network-bandwidth#rx-tx for
      more details.
      z
      *stack-type*::: Specifies whether IPv6 is enabled on the interface.
      ``STACK_TYPE'' must be one of: `IPV4_ONLY`, `IPV4_IPV6`, `IPV6_ONLY`.
      The default value is `IPV4_ONLY`.
      z
      *stack-type*::: Specifies whether IPv6 is enabled on the interface.
      ``STACK_TYPE'' must be one of: `IPV4_ONLY`, `IPV4_IPV6`.
      The default value is `IPV4_ONLY`.
      a  
      *ipv6-network-tier*::: Specifies the IPv6 network tier that will be used
        to configure the instance network interface IPv6 access config.
        ``IPV6_NETWORK_TIER'' must be `PREMIUM` (currently only one value is
        supported).

      *internal-ipv6-address*::: Assigns the given internal IPv6 address or range
        to the instance that is created. The address must be the first IP address
        in the range or from a /96 IP address range. This option can be used only
        when creating a single instance.

      *internal-ipv6-prefix-length*::: Optional field that indicates the prefix
        length of the internal IPv6 address range. It should be used together with
        internal-ipv6-address. Only /96 IP address range is supported and the
        default value is 96. If not set, either the prefix length from
        --internal-ipv6-address will be used or the default value of 96 will be
        assigned.

      *external-ipv6-address*::: Assigns the given external IPv6 address to the
        instance that is created. The address must be the first IP address in the
        range. This option can be used only when creating a single instance.

      *external-ipv6-prefix-length*::: The prefix length of the external IPv6
        address range. This field should be used together with
        external-ipv6-address. Only the /96 IP address range is supported, and the
        default value is 96.
      a*  
      *ipv6-public-ptr-domain*::: Assigns a custom PTR domain for the external
      IPv6 in the IPv6 access configuration of instance. If its value is not
      specified, the default PTR record will be used. This option can only be
      specified for the default network interface, `nic0`.
    z
      *aliases*::: Specifies the IP alias ranges to allocate for this
      interface.  If there are multiple IP alias ranges, they are separated
      by semicolons.

      For example:

          --aliases="10.128.1.0/24;range1:/32"

      a/  
      Each IP alias range consists of a range name and an IP range
      separated by a colon, or just the IP range.
      The range name is the name of the range within the network
      interface's subnet from which to allocate an IP alias range. If
      unspecified, it defaults to the primary IP range of the subnet.
      The IP range can be a CIDR range (e.g. `192.168.100.0/24`), a single
      IP address (e.g. `192.168.100.1`), or a netmask in CIDR format (e.g.
      `/24`). If the IP range is specified by CIDR range or single IP
      address, it must belong to the CIDR range specified by the range
      name on the subnet. If the IP range is specified by netmask, the
      IP allocator will pick an available range with the specified netmask
      and allocate it to this network interface.
      a  
      Each IP alias range consists of a range name and a CIDR netmask
      (e.g. `/24`) separated by a colon or just the netmask.
      The range name is the name of the range within the network
      interface's subnet from which to allocate an IP alias range. If
      unspecified, it defaults to the primary IP range of the subnet.
      The IP allocator will pick an available range with the specified
      netmask and allocate it to this network interface.
      z
      *network-attachment*::: Specifies the network attachment that this
        interface should connect to. Mutually exclusive with *--network* and
        *--subnet* flags.
      z
      *enable-vpc-scoped-dns*::: If specified with network_attachment, DNS
      resolution will be enabled over this interface.
      z
      *vlan*::: VLAN ID of a Dynamic Network Interface, must be  an integer in
      the range from 2 to 255 inclusively.
      vlana  
      *igmp-query*::: Determines if the Compute Engine Instance can receive and respond to IGMP query packets on the specified network interface.
      ``IGMP_QUERY'' must be one of: `IGMP_QUERY_V2`, `IGMP_QUERY_DISABLED`.
      It is disabled by default.
    Tmutexr  )r   allow_key_onlyrk   rH  r,   rI  a          Same as --network-interface except that the value for the entry will
        be read from a local file. This is used in case subinterfaces need to
        be specified. All field names in the json follow lowerCamelCase.

        The following additional key is allowed:
         subinterfaces
            Specifies the list of subinterfaces assigned to this network
            interface of the instance.

                The following keys are allowed:
                subnetwork: Specifies the subnet that the subinterface will be
                part of. The subnet should have l2-enable set and VLAN tagged.

                vlan: Specifies the VLAN of the subinterface. Can have a value
                between 2-4094. This should be the same VLAN as the subnet. VLAN tag
                within a network interface is unique.

                ipAddress: Optional. Specifies the ip address of the
                subinterface. If not specified, an ip address will be allocated from
                subnet ip range.

        An example json looks like:
        [
         {
          "network":"global/networks/network-example",
          "subnetwork":"projects/example-project/regions/us-central1/subnetworks/untagged-subnet",
          "subinterfaces":[
             {
              "subnetwork":"projects/example-project/regions/us-central1/subnetworks/tagged-subnet",
              "vlan":2,
              "ipAddress":"111.11.11.1"
           }
          ]
         }
        ]
          --network-interface-from-filezKEY=LOCAL_FILE_PATHr   r   r   z        Same as --network-interface-from-file except that the value for the
        entry will be a json string. This can also be used in case
        subinterfaces need to be specified. All field names in the json follow
        lowerCamelCase.$--network-interface-from-json-stringNETWORK_INTERFACE_JSON_STRINGr   )r   AddNoAddressArgr   r   rK  r  r  r  r  r  r  rk   r   r   r   r7   FileContents)r   r]   support_subinterfaceinstance_create
containerssupport_network_queue_countsupport_vlan_nicsupport_ipv6_onlysupport_igmp_querysupport_enable_vpc_scoped_dnsrd  address_help%multiple_network_interface_cards_specnetwork_interface_help_textsnetwork_interfaces network_interface_file_help_text network_interface_json_help_texts                    r<   AddAddressArgsr    s]   @ 113))LL <8"%("%(#+'" ;O'7 4 ( ) *,7 9 * N * F ( "$	 GJ)*BC '' 	) 		 !'' ) 	 %% '
 < !;>)-8 '' )
   '' )
  !'' )
  %% '
 8 
 '' ) 	 %% 	'
 	  '' )
  !'' )
  %% '
  # '' )
 
  '' )
  58)&1 '' ) 	 )))5##  6
  WW12 $ 4 $*&J %%
)'')'/	 & 1*& %%
01/ & 1e n   6
  WW12  4rL   c                 &    U R                  SSSS9  g )Nz--no-addressr   a             If provided, the instances are not assigned external IP
           addresses. To pull container images, you must configure private
           Google access if using Container Registry or configure Cloud NAT
           for instances to access container images directly. For more
           information, see:
             * https://cloud.google.com/vpc/docs/configure-private-google-access
             * https://cloud.google.com/nat/docs/using-nat
           r   r   r   s    r<   r  r  Y  s       rL   c                 l    Uc  SnU R                  S[        R                  USR                  U5      S9  g )Nz3 If unspecified, the default type is n1-standard-1.--machine-typez      Specifies the machine type used for the instances. To get a
      list of available machine types, run 'gcloud compute
      machine-types list'.{})r%   r(   r   )r   r{   MachineTypesCompleterr_   )r   r(   unspecified_helps      r<   AddMachineTypeArgsr  h  sB    L"88  !''7 8  :rL   c           	          U R                  SSUSR                  UR                  (       a  UR                  S-   OS5      S9  g )Nz--min-cpu-platformPLATFORMa        When specified, the VM will be scheduled on host with specified CPU
      architecture or a newer one. To list available CPU platforms in given
      zone, run:

          $ gcloud {}compute zones describe ZONE --format="value(availableCpuPlatforms)"

      Default setting is "AUTOMATIC".

      CPU platform selection is available only in selected zones.

      You can find more information on-line:
      [](https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform)
       r,   )r   r(   r   )r   r_   prefix)r   trackr(   s      r<   AddMinCpuPlatformArgsr	  u  s@    
 &u||#
<#  >rL   c                 V    U R                  SSS9  U(       a  U R                  SSSS9  g g )Nz--min-node-cpuzp      Minimum number of virtual CPUs this instance will consume when running on
      a sole-tenant node.
      r   z--clear-min-node-cpur   z        Removes the min-node-cpu field from the instance. If specified, the
        instance min-node-cpu will be cleared. The instance will not be
        overcommitted and utilize the full CPU count assigned.
        r   r   )r   	is_updates     r<   AddMinNodeCpuArgr    sE    
   
   rL   c                 &    U R                  SSSS9  g )Nz--location-hintTzQ      Used by internal tools to control sub-zone location of the instance.
      )hiddenr   r   r   s    r<   AddLocationHintArgr    s     
  rL   c                 z    SnU(       a   U R                  S[        R                  US9  gU R                  SSSUS9  g)aN  Set preemptible scheduling property for instances.

For set_scheduling operation, in addition we are providing no-preemptible flag
in use case when user wants to disable this property.

Args:
   parser: ArgumentParser, parser to which flags will be added.
   is_update: Bool. If True, flags are intended for set-scheduling operation.
a$        If provided, instances will be preemptible and time-limited. Instances
      might be preempted to free up resources for standard VM instances,
      and will only be able to run for a limited amount of time. Preemptible
      instances can not be restarted and will not migrate.
      z--preemptibler   r   Fr  Nr   r   StoreTrueFalseAction)r   r  	help_texts      r<   AddPreemptibleVmArgsr    sO    
) 
//  
 e)  MrL   c                 h    SSSS.nU(       a  SUS'   U R                  SU[        R                  SS	9  g
)z=Set arguments for specifing provisioning model for instances.zCompute Engine may stop a Spot VM instance whenever it needs capacity. Because Spot VM instances don't have a guaranteed runtime, they come at a discounted price.zkThe default option. The STANDARD provisioning model gives you full control over your VM instances' runtime.zThe VM instances run for the entire duration of their associated reservation. You can only specify this provisioning model if you want your VM instances to consume a specific reservation with either a calendar reservation mode or a dense deployment type.)SPOTSTANDARDRESERVATION_BOUNDzaThe VM instance is provisioned using the Flex Start provisioning model and has a limited runtime.
FLEX_START--provisioning-modelz      Specifies the provisioning model for your VM instances. This choice
      affects the price, availability, and how long your VM instances can run.
      r   r   r   Nr   r   ChoiceToEnumName)r   support_flex_startr   s      r<   AddProvisioningModelVmArgsr    sV    6
5L'" 	& L 	%%
	  rL   c                    SnSnU(       a  U R                  SSS9nUR                  SSSS	9  UR                  S
[        R                  " 5       US9  U R                  SSS9nUR                  SSSS	9  UR                  S[        R                  R
                  US9  gU R                  S
[        R                  " 5       US9  U R                  S[        R                  R
                  US9  g)zHSet arguments for specifing max-run-duration and termination-time flags.a        Limits how long this VM instance can run, specified as a duration relative
      to the last time when the VM began running. Format the duration,
      MAX_RUN_DURATION, as the number of days, hours, minutes, and seconds
      followed by d, h, m, and s respectively. For example, specify `30m` for a
      duration of 30 minutes or specify `1d2h3m4s` for a duration of 1 day,
      2 hours, 3 minutes, and 4 seconds. Alternatively, to specify a timestamp,
      use --termination-time instead.

      If neither --max-run-duration nor --termination-time is specified
      (default), the VM instance runs until prompted by a user action or system
      event. If either is specified, the VM instance is scheduled to be
      automatically terminated at the VM's termination timestamp
      (`terminationTimestamp`) using the action specified by
      --instance-termination-action.

      Note: The `terminationTimestamp` is removed whenever the VM is stopped or
      suspended and redefined whenever the VM is rerun. For --max-run-duration
      specifically, the `terminationTimestamp` is the sum of MAX_RUN_DURATION
      and the time when the VM last entered the `RUNNING` state, which changes
      whenever the VM is rerun.
      a  
      Limits how long this VM instance can run, specified as a time. Format the
      time, TERMINATION_TIME, as a RFC 3339 timestamp. For more information,
      see https://tools.ietf.org/html/rfc3339. Alternatively, to specify a
      duration, use --max-run-duration instead.

      If neither --termination-time nor --max-run-duration is specified
      (default), the VM instance runs until prompted by a user action or
      system event. If either is specified, the VM instance is scheduled to
      be automatically terminated at the VM's termination timestamp
      (`terminationTimestamp`) using the action specified by
      --instance-termination-action.

      Note: The `terminationTimestamp` is removed whenever the VM is stopped
      or suspended and redefined whenever the VM is rerun. For
      --termination-time specifically, the `terminationTimestamp` remains the
      same whenever the VM is rerun, but any requests to rerun the VM fail if
      the specified timestamp is in the past.
    zMax Run DurationTr  z--clear-max-run-durationr   zP        Removes the max-run-duration field from the scheduling options.
        r   --max-run-durationr   zTermination Timez--clear-termination-timezP        Removes the termination-time field from the scheduling options.
        --termination-timeN)r   r   r   r   Datetimeri   )r   r  max_run_duration_help_texttermination_time_help_textmax_run_duration_grouptermination_time_groups         r<   AddMaxRunDurationVmArgsr(    s%    
. & #--.@-M''" (  ''!!#' (  $--.@-M''" (  ''!!''' (  !!#'  
 !!'''  rL   c                     SnU(       aF  U R                  SSS9nUR                  SSSS9  UR                  S	[        R                  " 5       US
9  gU R                  S	[        R                  " 5       US
9  g)zMSet arguments for specifing discard-local-ssds-at-termination-timestamp flag.a          Required to be set to `true` and only allowed for VMs that have one or
        more local SSDs, use --instance-termination-action=STOP, and use either
        --max-run-duration or --termination-time.

        This flag indicates the value that you want Compute Engine to use for
        the `--discard-local-ssd` flag in the automatic
        `gcloud compute instances stop` command. This flag only supports the
        `true` value, which discards local SSD data when automatically stopping
        this VM during its `terminationTimestamp`.

        For more information about the `--discard-local-ssd` flag, see
        https://cloud.google.com/compute/docs/disks/local-ssd#stop_instance.
      z+Discard Local SSDs At Termination TimestampTr  z3--clear-discard-local-ssds-at-termination-timestampr   zk        Removes the discard-local-ssds-at-termination-timestamp field from the scheduling options.
        r   z---discard-local-ssds-at-termination-timestampr   N)r   r   r   r  )r   r  5discard_local_ssds_at_termination_timestamp_help_text1discard_local_ssds_at_termination_timestamp_groups       r<   AddDiscardLocalSsdVmArgsr,  7  s    ;
7 8>8H8H5T 9I 95 6BB= C  6BB7##%B C  7##%B  rL   c                 L    U R                  S[        R                  " SSS9SS9  g )Nz--host-error-timeout-seconds90s300sr  z
      The timeout in seconds for host error detection. The value must be
      set with 30 second increments, with a range of 90 to 330 seconds.
      If unset, the default behavior of the host error recovery is used.
    r   r   r   r   r   s    r<   AddHostErrorTimeoutSecondsArgsr1  _  s-    $EvF  	rL   c                     U(       a  U R                  SSSSS9  OU R                  S[        R                  SS9  U R                  S[        R                  " S	S
S9SS9  g)z$Set arguments for graceful shutdown.z--graceful-shutdownstore_constTz<        Enables graceful shutdown for the instance.
        )r   constr   zH        Enables or disables graceful shutdown for the instance.
        r   z --graceful-shutdown-max-duration1s3600sr  ax  
      Specifies the maximum time for the graceful shutdown. After this time, the instance is set to STOPPING even if tasks are still running. Specify the time as the number of hours, minutes, or seconds followed by h, m, and s respectively. For example, specify 30m for 30 minutes or 20m10s for 20 minutes and 10 seconds. The value must be between 1 second and 1 hour.
      r   N)r   r   r  r   )r   	is_creates     r<   AddGracefulShutdownArgsr8  j  sy    
	   //   	(DgF
  rL   c                 L    U R                  S[        R                  " 5       SS9  g )Nz--preemption-notice-durationz      Specifies the metadata preemption notice duration before the ACPI G2
      soft off signal is triggered for Spot VMs. e.g. 120s.
      r   r0  r   s    r<   AddPreemptionNoticeDurationArgsr:    s)    $!
  rL   c           	      N    U R                  S[        R                  " SSSS9SS9  g )Nz--local-ssd-recovery-timeouth0h168h)default_unitr  r  z
      Specifies the maximum amount of time a Local Ssd Vm should wait while
      recovery of the Local Ssd state is attempted. Its value should be in
      between 0 and 168 hours with hour granularity and the default value being 1
      hour.
    r   r0  r   s    r<   AddLocalSsdRecoveryTimeoutArgsr@    s3    $&B	  		rL   c                     U(       aE  U R                  SSS9nUR                  SSSS.[        R                  SS	9  UR                  S
SSS9  gU R                  SSSS.[        R                  SS	9  g)a  Set arguments for specifing the termination action for the instance.

For set_scheduling operation we are implementing this as argument group with
additional argument clear-* providing the functionality to clear the
instance-termination-action field.

Args:
   parser: ArgumentParser, parser to which flags will be added.
   is_update: Bool. If True, flags are intended for set-scheduling operation.
zInstance Termination ActionTr  z--instance-termination-actionz`Default only for Spot VMs. Stop the VM without preserving memory. The VM can be restarted later.zPermanently delete the VM.)STOPDELETEz      Specifies the termination action that will be taken upon VM preemption
        (--provisioning-model=SPOT) or automatic instance
        termination (--max-run-duration or --termination-time).
      r  z#--clear-instance-termination-actionr   a          Disables the termination action for this VM if allowed OR
        sets termination action to the default value.
        Depending on a VM's availability settings, a termination action is
        either required or not allowed. This flag is required when you are
        updating a VM such that it's previously specified termination action is
        no longer allowed.
        If you use this flag when a VM requires a termination action,
        it's termination action is just set to the default value (stop).
        r   N)r   r   r   r  )r   r  termination_action_groups      r<   "AddInstanceTerminationActionVmArgsrE    s     %//%T  0  3))': 3
 ''
 *   ))-	 *  ': 3
 ''
  rL   c                    U R                  S5      (       a  U(       a\  U R                  S5      (       dE  U R                  S5      (       d/  U R                  S5      (       d  [        R                  " / SQS5      eO-U R                  S5      (       d  [        R                  " SS5      eU(       aD  U R                  S5      (       a-  U R                  S5      (       a  [        R
                  " S5      eg	g	g	)
z,Validates instance scheduling related flags.instance_termination_actionprovisioning_modelmax_run_durationtermination_time)r  r!  r"  z7required with argument `--instance-termination-action`.r  zlMust specify exactly one of --max-run-duration or --termination-time as these fields are mutually exclusive.N)r  r   MinimumArgumentExceptionRequiredArgumentExceptionr  r  )r|  support_max_run_durations     r<   ValidateInstanceSchedulingrN    s     
34434412212211 3
DF 	F 23300
 
CE E $"2"2# #"../ABB

*
*	23 3 C#rL   c                 D    U R                  SSS9  U R                  SSS9  g)z2Set arguments for choosing the network/subnetwork.z	--networkz      Specifies the network that the VM instances are a part of. If `--subnet`
      is also specified, subnet must be a subnetwork of the network specified by
      this `--network` flag. If neither is specified, the default network is
      used.
      r   z--subnetz      Specifies the subnet that the VM instances are a part of. If `--network`
      is also specified, subnet must be a subnetwork of the network specified by
      the `--network` flag.
      Nr   r   s    r<   AddNetworkArgsrP    s:    
   	
  rL   c                 $    U R                  SSS9  g)z2Set arguments for choosing the network IP address.z--private-network-ipz      Specifies the RFC1918 IP to assign to the instance. The IP should be in
      the subnet or legacy network IP range.
      r   Nr   r   s    r<   AddPrivateNetworkIpArgsrR  	  s    
  rL   c           	      `   U R                  5       nSR                  X4S9nUR                  SSU(       a  SR                  U5      OUS9  SR                  U5      nSR                  U5      nS	R                  U(       a  UOUUS
9n	UR                  SU	S9  U R                  5       n
U
R                  SSU(       a  SR                  US9OSR                  X4S9S9  SnSnSR                  U(       a  UOUU[        R                  " 5       US9nU
R                  S[
        R                  " 5       SUS9  g)a  Add args for configuring service account and scopes.

This should replace AddScopeArgs (b/30802231).

Args:
  parser: ArgumentParser, parser to which flags will be added.
  instance_exists: bool, If instance already exists and we are modifying it.
  extra_scopes_help: str, Extra help text for the scopes flag.
  operation: operation being performed, capitalized. E.g. 'Create' or 'Import'
  resource: resource type on which scopes and service account are being added.
    E.g. 'instance' or 'machine image'.
z.{operation} {resource} without service account)	operationr8   z--no-service-accountr   z#Remove service account from the {0}r   zYou can explicitly specify the Compute Engine default service
  account using the 'default' alias.

  If not provided, the {0} will use the service account it currently has.
  zO

  If not provided, the {0} will use the project's default service account.
  a3    A service account is an identity attached to the {resource}. Its access tokens
  can be accessed through the instance metadata server and are used to
  authenticate applications on the instance. The account can be set using an
  email address corresponding to the required service account. {extra_help}
  )
extra_helpr8   z--service-accountr   --no-scopesz%Remove all scopes from the {resource})r8   z%{operation} {resource} without scopesz keep the scopes it currently hasz/be assigned the default scopes, described belowzFIf not provided, the {resource} will {exists}. {extra}

{scopes_help}
)existsextrascopes_helpr8   --scopesSCOPEr  N)r   r_   r   r   
ScopesHelpr   rL  )r   instance_existsextra_scopes_helprT  r8   service_account_groupno_sa_instance_not_exist	sa_existssa_not_existsservice_account_helpscopes_groupscopes_existsscopes_not_existsrY  s                 r<   AddServiceAccountAndScopeArgsrg  	  s   " !==?6== > 2  $$	 177A6	 % 8 fX	  fX 

 f-=    $$ 4 % 6 446,	 39989LELL M 2	  3 5-G F+=1B
$$&	  	  {**,gK  QrL   c                 `    U R                  S[        R                  [        R                  SS9  g)z,Adds network interface flag to the argparse.r  z      Specifies the name of the network interface which contains the access
      configuration. If this is not provided, then "nic0" is used
      as the default.
      )r  r   r   N)r   r   DEFAULT_NETWORK_INTERFACEr   StoreOnceActionr   s    r<   AddNetworkInterfaceArgsrk  Y	  s1     	11((
	  rL   c                 t    U(       a  U R                  SS SS9  gU(       a  SnOSnU R                  SS US9  g)	z'Adds network tier flag to the argparse.--network-tierc                 "    U R                  5       $ rF   r   r   s    r<   r   $AddNetworkTierArgs.<locals>.<lambda>m	  s
    qwwyrL   z        Update the network tier of the access configuration. It does not allow
        to change from `PREMIUM` to `STANDARD` and visa versa.
        r   Nz        Specifies the network tier that will be used to configure the instance.
        ``NETWORK_TIER'' must be one of: `PREMIUM`, `STANDARD`. The default
        value is `PREMIUM`.
        z        Specifies the network tier of the access configuration. ``NETWORK_TIER''
        must be one of: `PREMIUM`, `STANDARD`. The default value is `PREMIUM`.
        c                 "    U R                  5       $ rF   r   r   s    r<   r   ro  	  s
    qwwyrL   r   )r   r    
for_updatenetwork_tier_helps       r<   AddNetworkTierArgsrs  g	  s\     
     	07H  JrL   c                 p    SnU(       d  US-  nU R                  SU(       a  [        R                  OSUS9  g)zCAdds display device arguments for instance or access configuration.z(Enable a display device on VM instances. Disabled by default.z--enable-display-devicer   r   Nr  r   r  display_helps      r<   AddDisplayDeviceArgrx  	  s;    ;,	++L1:[--  rL   c                 r    SnU(       d  US-  nU R                  SU(       a  [        R                  OSSUS9  g)zCAdds watchdog timer arguments for instance or access configuration.z/Enable a watchdog timer device on VM instances.ru  z--enable-watchdog-timerr   Nr  r  rv  s      r<   AddWatchdogTimerArgrz  	  s>    B,	++L1:[--	  rL   c                     U R                  5       nU(       a  SnOSnUR                  SSUS9  U(       a  SnOSnUR                  SSUS9  g	)
z?Adds public DNS arguments for instance or access configuration.zR        If provided, the instance will not be assigned a public DNS name.
        zy        If provided, the external IP in the access configuration will not be
        assigned a public DNS name.
        z--no-public-dnsr   r   z;        Assigns a public DNS name to the instance.
        z        Assigns a public DNS name to the external IP in the access
        configuration. This option can only be specified for the default
        network-interface, "nic0".
        z--public-dnsNr   r   )r   r    public_dns_argsno_public_dns_helppublic_dns_helps        r<   AddPublicDnsArgsr  	  ss     779/ 3E  G OO
 \  ArL   c                 *   U R                  5       nU(       a  SnOSnUR                  SSUS9  U(       a  SnOSnUR                  SSUS9  U R                  5       nU(       a  S	nOS
nUR                  SSUS9  U(       a  SnOSnUR                  SUS9  g)z?Adds public PTR arguments for instance or access configuration.z        If provided, no DNS PTR record is created for the external IP of the
        instance. Mutually exclusive with public-ptr-domain.
        z        If provided, no DNS PTR record is created for the external IP in the
        access configuration. Mutually exclusive with public-ptr-domain.
        --no-public-ptrr   r   zN        Creates a DNS PTR record for the external IP of the instance.
        z        Creates a DNS PTR record for the external IP in the access
        configuration. This option can only be specified for the default
        network-interface, "nic0".z--public-ptrz        If both this flag and --public-ptr are specified, creates a DNS PTR
        record for the external IP of the instance with the PTR domain name
        being the DNS name of the instance.
        z        If both this flag and --public-ptr are specified, creates a DNS PTR
        record for the external IP in the access configuration with the PTR
        domain name being the DNS name of the instance.
        z--no-public-ptr-domainz        Assigns a custom PTR domain for the external IP of the instance.
        Mutually exclusive with no-public-ptr.
        z        Assigns a custom PTR domain for the external IP in the access
        configuration. Mutually exclusive with no-public-ptr. This option can
        only be specified for the default network-interface, "nic0".
        --public-ptr-domainr   Nr|  )r   r    public_ptr_argsno_public_ptr_helppublic_ptr_helppublic_ptr_domain_argsno_public_ptr_domain_helppublic_ptr_domain_helps           r<   AddPublicPtrArgsr  	  s     779/
 3E  G O&O \  A ">>@!!
 %%$ & &
 

 %%"8 & :rL   c                 &    U R                  SSSS9  g)zFAdds IPv6 public PTR domain for IPv6 access configuration of instance.--ipv6-public-ptr-domainNa        Assigns a custom PTR domain for the external IPv6 in the IPv6 access
      configuration of instance. If unspecified or specified to be an empty
      string, the default PTR record will be used. This option can only be
      specified for the default network interface, ``nic0''.)r  r   r   r   s    r<   AddIpv6PublicPtrDomainArgr  	  s!     @  rL   c                 n    U R                  5       nSnUR                  SSUS9  SnUR                  SUS9  g)	z=Adds IPv6 public PTR arguments for ipv6 access configuration.z        If provided, the default DNS PTR record will replace the existing one
        for external IPv6 in the IPv6 access configuration. Mutually exclusive
        with ipv6-public-ptr-domain.
        --no-ipv6-public-ptrr   r   z        Assigns a custom PTR domain for the external IPv6 in the access
        configuration. Mutually exclusive with no-ipv6-public-ptr. This option
        can only be specified for the default network interface, ``nic0''.
        r  r   Nr|  )r   ipv6_public_ptr_argsno_ipv6_public_ptr_helpipv6_public_ptr_domain_helps       r<   AddIpv6PublicPtrArgsr  
  s]      <<>
 ##\8O $ Q!
 ## 'B $ DrL   c                     [        U SS5      n[        U SS5      nU(       aM  UbI  U[        R                  :w  a4  [        R                  " SR                  [        R                  U5      5      eggg)z1Validates the values of public DNS related flags.network_interfaceN
public_dnszUPublic DNS can only be enabled for default network interface '{0}' rather than '{1}'.)r  r   ri  r  r  r_   )r|  r  r  s      r<   ValidatePublicDnsFlagsr  
  sz     d$7>t\40*%Y@@@,,))/113D*FG G 	A 	& rL   c                 @   [        U SS5      n[        U SS5      nUSL aK  UbH  U[        R                  :w  a4  [        R                  " SR                  [        R                  U5      5      eU R                  b'  U R                  SL a  [        R                  " SS5      egg)z1Validates the values of public PTR related flags.r  N
public_ptrTzUPublic PTR can only be enabled for default network interface '{0}' rather than '{1}'.r  r  )
r  r   ri  r  r  r_   public_ptr_domainno_public_ptrr   ConflictingArgumentsException)r|  r  r  s      r<   ValidatePublicPtrFlagsr  '
  s     d$7>t\40*4%Y@@@,,))/113D*FG G
 
'D,>,>$,F

2
23H3DF F -G'rL   c                 \   [        U SS5      nU R                  c  U R                  (       aK  UbH  U[        R                  :w  a4  [
        R                  " SR                  [        R                  U5      5      eU R                  b)  U R                  (       a  [        R                  " SS5      egg)z6Validates the values of IPv6 public PTR related flags.r  NzZIPv6 Public PTR can only be enabled for default network interface '{0}' rather than '{1}'.r  r  )
r  ipv6_public_ptr_domainno_ipv6_public_ptrr   ri  r  r  r_   r   r  )r|  r  s     r<   ValidateIpv6PublicPtrFlagsr  9
  s     d$7>	  ,0G0G%Y@@@,,))/113D*FG G
 
  ,1H1H

2
23M3IK K 2I,rL   c                     U R                   (       a(  U R                  (       d  [        R                  " SS5      eU R                  =(       d    /  H!  nU(       a  M  [        R
                  " SS5      e   g )NrV  z+required with argument --no-service-accountrZ  z Scope cannot be an empty string.)no_service_account	no_scopesr   rL  scopesr  )r|  r   s     r<   "ValidateServiceAccountAndScopeArgsr  K
  sb    	T^^

.
.     !r!e5//
8: : "rL   c                 L    U R                  S[        R                  " SS9SSS9  g )Nz--tagsr;  r@  TAGa        Specifies a list of tags to apply to the instance. These tags allow
      network firewall rules and routes to be applied to specified VM instances.
      See gcloud_compute_firewall-rules_create(1) for more details.

      To read more about configuring network tags, read this guide:
      https://cloud.google.com/vpc/docs/add-remove-network-tags

      To list instances with their respective status and tags, run:

        $ gcloud compute instances list --format='table(name,status,tags.list())'

      To list instances tagged with a specific tag, `tag1`, run:

        $ gcloud compute instances list --filter='tags:tag1'
      r  r   r   rL  r   s    r<   AddTagsArgsr  W
  s.    !,
	  rL   c                 L    U R                  S[        R                  " SS9SSS9  g)zAdds secure tag related args.z--secure-tagsr;  r  
SECURE_TAGa        Specifies a list of secure tags to apply to the instance. These tags allow
      network firewall rules and routes to be applied to specified VM instances.
      See gcloud_compute_network_firewall-policies_rules_create(1) for more
      details.
      r  Nr  r   s    r<   AddSecureTagsArgsr  n
  s.    !,
	  	rL   c                 l    U R                  S[        R                  " 5       S[        R                  SS9  g)z'Adds resource manager tag related args.z--resource-manager-tagsz	KEY=VALUEzP      Specifies a list of resource manager tags to apply to the instance.
      )r   r   r   r   N)r   r   r   UpdateActionr   s    r<   AddResourceManagerTagsArgsr  |
  s5     %%
  rL   c                 (    U R                  SSSSS9  g )Nz--restart-on-failurer   Tz      The instances will be restarted if they are terminated by Compute Engine.
      This does not affect terminations performed by the user.
      r  r   r   s    r<   AddNoRestartOnFailureArgsr  
  s#    
	  rL   c                     SnS nSnU(       a=  U R                  S5      n U R                  SS[        UUS9  [        R                  " SS	S
9nU R                  SU[        UUS9  g)z'Adds maintenance behavior related args.z  Specifies the behavior of the VMs when their host machines undergo
  maintenance. The default is MIGRATE.
  For more information, see
  https://cloud.google.com/compute/docs/instances/host-maintenance-options.
  c                 "    U R                  5       $ rF   r   r   s    r<   r   *AddMaintenancePolicyArgs.<locals>.<lambda>
  s
    	rL   NzMaintenance Behavior.z--on-host-maintenancemaintenance_policy)destr   r   r   z--maintenance-policyzRThe {flag_name} flag is now deprecated. Please use `--on-host-maintenance` instead)warn)r   r   r   r   )r   r   MIGRATION_OPTIONSr   DeprecationAction)r   	deprecater  	flag_typer   s        r<   AddMaintenancePolicyArgsr  
  s    ) ")&001HIF
!!   &&*+F 	  rL   c                 `    U R                  S[        R                  " [        [        S.S9SS9  g)zAdds Accelerator-related args.--accelerator)r   countr   a~        Attaches accelerators (e.g. GPUs) to the instances.

      *type*::: The specific type (e.g. nvidia-tesla-t4 for NVIDIA T4)
      of accelerator to attach to the instances. Use 'gcloud compute
      accelerator-types list' to learn about all available accelerator types.

      *count*::: Number of accelerators to attach to each
      instance. The default value is 1.
      r   N)r   r   r   r   rK  r   s    r<   AddAcceleratorArgsr  
  s8     	% 		
  rL   c                     [        U SS5      nU(       a1  UR                  SS5      nU(       d  [        R                  " SS5      egg)zValiadates flags specifying accelerators (e.g.

GPUs).

Args:
  args: parsed comandline arguments.

Raises:
  InvalidArgumentException: when type is not specified in the accelerator
  config dictionary.
acceleratorNr   r,   r  zSaccelerator type must be specified. e.g. --accelerator type=nvidia-tesla-t4,count=2)r  r6   r   r  )r|  accelerator_argsaccelerator_type_names      r<   ValidateAcceleratorArgsr  
  sQ     T=$7,00< //
 <= = ! rL   c           	         U R                  SSS9  U R                  SSS9  U R                  SSSS	9  U R                  S
SSS	9  [        U 5        [        U 5        U R                  S[        R                  " 5       SSSS9  U R                  SSS9  U R                  SSSS	9  U R                  SSSS	9  U R                  S/ SQSSS SS9  g)zAdds Konlet-related args.--container-imagezn      Full container image name, which should be pulled onto VM instance,
      eg. `docker.io/tomcat`.
      r   --container-commandz      Specifies what executable to run when the container starts (overrides
      default entrypoint), eg. `nc`.

      Default: None (default container entrypoint is used)
      --container-argrk   a        Argument to append to container entrypoint or to override container CMD.
      Each argument must have a separate flag. Arguments are appended in the
      order of flags. Example:

      Assuming the default entry point of the container (or an entry point
      overridden with --container-command flag) is a Bourne shell-compatible
      executable, in order to execute 'ls -l' command in the container,
      the user could use:

      `--container-arg="-c" --container-arg="ls -l"`

      Caveat: due to the nature of the argument parsing, it's impossible to
      provide the flag value that starts with a dash (`-`) without the `=` sign
      (that is, `--container-arg "-c"` will not work correctly).

      Default: None. (no arguments appended)
      r   --container-privilegedr   zn      Specify whether to run container in privileged mode.

      Default: `--no-container-privileged`.
      --container-envKEY=VALUE, ...a)        Declare environment variables KEY with value VALUE passed to container.
      Only the last value of KEY is taken when KEY is repeated more than once.

      Values, declared with --container-env flag override those with the same
      KEY from file, provided in --container-env-file.
      rI  --container-env-filea@        Declare environment variables in a file. Values, declared with
      --container-env flag override those with the same KEY from file.

      File with environment variables in format used by docker (almost).
      This means:
      - Lines are in format KEY=VALUE.
      - Values must contain equality signs.
      - Variables without values are not supported (this is different from
        docker format).
      - If `#` is first non-whitespace character in a line the line is ignored
        as a comment.
      - Lines with nothing but whitespace are ignored.
      --container-stdinzd      Keep container STDIN open even if not attached.

      Default: `--no-container-stdin`.
      --container-ttyz[      Allocate a pseudo-TTY for the container.

      Default: `--no-container-tty`.
      --container-restart-policyneverz
on-failurealwaysr  POLICYc                 "    U R                  5       $ rF   lowervals    r<   r   AddKonletArgs.<locals>.<lambda>F  
    syy{rL   z<      Specify whether to restart a container on exit.
      )r   r  r   r   r   N)r   _AddContainerMountHostPathFlag_AddContainerMountTmpfsFlagr   r   r   s    r<   AddKonletArgsr  
  s?   
   	
   	
  , 	
   !(f% 
   	
  " 	
   	
   	"/"
  rL   c                     U R                  S5      (       d  [        R                  " SS5      eU R                  S5      (       a8  U R                  R	                  S5      (       a  [        R
                  " SS5      egg)	zValidates Konlet-related args.container_imager  z You must provide container imagemachine_typet2az--machine_typez?T2A machine types are not compatible with Konlet or containers.N)r  r   rL  r  
startswithr  r  s    r<   ValidateKonletArgsr  L  sz    			+	,	,

.
.?A A	n%%$*;*;*F*Fu*M*M

-
-IK K +N%rL   c                    U R                   =(       d    /  GH7  nUR                  S5      nU(       aB  U[        ;  a8  [        R                  " SSR                  USR                  [        5      S95      eUR                  S5      nUc  Mt  U[        R                  [        R                  -  :w  d  M  U[        R                  [        R                  -  :w  d  M  U[        R                  [        R                  -  :w  d  M  [        R                  " SS	R                  U[        R                  [        R                  [        R                  S
95      e   g)zValidate local ssd flags.r   z--local-ssd:interfacezCUnexpected local SSD interface: [{given}]. Legal values are [{ok}].rT   )givenokr   Nz--local-ssd:sizeziUnexpected local SSD size: [{given}] bytes. Legal values are {small}GB, {large}GB, and {z3_metal}GB only.)r  smalllargez3_metal)	local_ssdr6   LOCAL_SSD_INTERFACESr   r  r_   r7   r   SSD_SMALL_PARTITION_GBBYTES_IN_ONE_GBSSD_LARGE_PARTITION_GBSSD_Z3_METAL_PARTITION_GB)r|  r  r   r   s       r<   ValidateLocalSsdFlagsr  W  s#   >>'R'ik*IY&:://
! $%%+V$)),@"A &, &CD D == D 
933i6O6OO
P..1J1JJL11I4M4MMO 11LV6666"<<	  	

 
	
+ (rL   c           	      "   [        U SS5      n[        U SS5      n[        U SS5      nUc  Uc  Uc  gUb.  U H(  nSU;   d  M  SU;   d  M  [        R                  " SS5      e   / S	QnU Vs/ s H  n[        XS5      (       d  M  UPM     nnU Vs/ s H$  nS
R                  UR	                  SS5      5      PM&     nn/ SQnU Vs/ s H  n[        XS5      (       d  M  UPM     n	nU	 Vs/ s H$  nS
R                  UR	                  SS5      5      PM&     nnU(       d  U	(       d  gU(       a  Ub)  [        R
                  " SSSR                  U5      -   5      eUb)  [        R
                  " SSSR                  U5      -   5      e[        R
                  " SSSR                  U5      -   5      eU	(       aG  Ub  Sn
OUb  Sn
OSn
[        R                  R                  SU
 S3SR                  U5      -   S-   5        ggs  snf s  snf s  snf s  snf )a  Validates flags specifying network interface cards.

Throws exceptions or print warning if incompatible nic args are specified.

Args:
  args: parsed command line arguments.

Raises:
  InvalidArgumentException: when it finds --network-interface that has both
                            address, and no-address keys.
  ConflictingArgumentsException: when it finds --network-interface and at
                                 least one of --address, --network,
                                 --private_network_ip, or --subnet.
r  Nnetwork_interface_from_file"network_interface_from_json_stringr`  r  r  z7specifies both address and no-address for one interface)r`  r  private_network_ipr  z--{0}rq   -)
r  r  r  r  internal_ipv6_addressinternal_ipv6_prefix_lengthipv6_addressipv6_prefix_lengthexternal_ipv6_addressexternal_ipv6_prefix_lengthzall of the following: rT   r  r  zWhen z4 is specified, the following arguments are ignored: z.
)
r  r   r  r_   replacer  r7   r   rc   write)r|  r  r  network_interface_from_jsonniconflicting_argsargconflicting_args_presentwarning_argswarning_args_presentnic_arg_names              r<   ValidateNicFlagsr	  {  s^    d$7> '.K(,!. '(L(,!. $?$G!)
$	b\R/11!EG 	G   &%cD)Ac%   8P7OgnnS[[c*+7O  , "!cWT%=c\   8L7KgnnS[[c*+7K   
"*>
$44

"TYY/?%@
@  
%	044
)
"TYY/?%@
@ 
 44
0
"TYY/?%@
@ 
 $*l	$	04l;lJJ
~  	
))L
!	" 	 c&s$   +G=G=+HHH*+Hc                 .    U R                  SSSS.SSS9  g)	zAdds --disk-scope flag.z--disk-scopezThe disk specified in --disk is interpreted as a zonal disk in the same zone as the instance. Ignored if a full URI is provided to the `--disk` flag.zThe disk specified in --disk is interpreted as a regional disk in the same region as the instance. Ignored if a full URI is provided to the `--disk` flag.)zonalregionalzThe scope of the disk.r  )r   r   r  Nr   r   s    r<   AddDiskScopeFlagr    s1    MP	 $  rL   c                     / SQnU R                  S5      (       aY  U R                  5       nU H  nX2;   d  M
  UR                  U5        M     U(       a   [        R                  R                  S5        ggg)zfWarn if --source-instance-template is mixed with unsupported flags.

Args:
  args: Argument namespace
)	z	--projectz--zonez--regionr   zINSTANCE_NAMES:1r   rZ  r[  z--labelssource_instance_templatezWhen a source instance template is used, additional parameters other than --machine-type and --labels will be ignored but provided by the source instance template
N)r  GetSpecifiedArgNamesremover   rc   r   )r|  allowed_flagsspecified_argsr0  s       r<   (WarnForSourceInstanceTemplateLimitationsr    so    - 
011..0N		d#  	jj $ %  2rL   c                     U R                   (       aM  U R                   [        R                  ;  a.  [        R                  " SSR                  U R                   S95      eg g )Nrm  zInvalid network tier [{tier}])tier)r  r   r  r   r  r_   r  s    r<   ValidateNetworkTierArgsr  
  sY    

yJJJ

-
-'..D4E4E.FH H K rL   c                 Z    SnU(       a  SO[         R                  nU R                  SX#S9  g)a@  Adds --deletion-protection Boolean flag.

Args:
  parser: ArgumentParser, parser to which flags will be added.
  use_default_value: Bool, if True, deletion protection flag will be given the
    default value False, else None. Update uses None as an indicator that no
    update needs to be done for deletion protection.
z-Enables deletion protection for the instance.r   z--deletion-protection)r   r   N)r   r  r   )r   use_default_valuer  r   s       r<   AddDeletionProtectionFlagr    s3     ?)  &1&F&F 	-IMrL   c                 \   U(       a  SnSS0nO[         R                  n0 nSnU(       a  US-  nU R                  "  SUSUS.UD6  SnU(       a  US-  nU R                  "  SS	UUS
.UD6  SnU(       a  Sn	OSn	UR                  U	5      n
U(       a  U
S-  n
U R                  "  SU
SUS.UD6  g)a  Adds flags for Shielded VM configuration.

Args:
  parser: ArgumentParser, parser to which flags will be added.
  use_default_value: Bool, if True, flag will be given the default value
    False, else None. Update uses None as an indicator that no update needs to
    be done for deletion protection.
  for_update: Bool, if True, flags are intended for an update operation.
  for_container: Bool, if True, flags intended for an instances with container
    operation.
r   r  Na        The instance boots with secure boot enabled. On Shielded VM instances,
      Secure Boot is not enabled by default. For information about how to modify
      Shielded VM options, see
      https://cloud.google.com/compute/docs/instances/modifying-shielded-vm.
      z}      Changes to this setting with the update command only take effect
      after stopping and starting the instance.
      shielded_vm_secure_boot)r   r  r   a        The instance boots with the TPM (Trusted Platform Module) enabled.
      A TPM is a hardware module that can be used for different security
      operations such as remote attestation, encryption, and sealing of keys.
      On Shielded VM instances, vTPM is enabled by default. For information
      about how to modify Shielded VM options, see
      https://cloud.google.com/compute/docs/instances/modifying-shielded-vm.
      shielded_vm_vtpm)r  r   r   a        Enables monitoring and attestation of the boot integrity of the
      instance. The attestation is performed against the integrity policy
      baseline. This baseline is initially derived from the implicitly
      trusted boot image when the instance is created. This baseline can be
      updated by using
      `gcloud compute instances {} --shielded-learn-integrity-policy`. On
      Shielded VM instances, integrity monitoring is enabled by default. For
      information about how to modify Shielded VM options, see
      https://cloud.google.com/compute/docs/instances/modifying-shielded-vm.
      For information about monitoring integrity on Shielded VM instances, see
      https://cloud.google.com/compute/docs/instances/integrity-monitoring."
      zupdate-containerupdate shielded_vm_integrity_monitoring)z--shielded-secure-boot)z--shielded-vtpm)z--shielded-integrity-monitoring)r   r  r   r_   )r   r  rq  for_containerdefault_actionaction_kwargssecure_boot_help	vtpm_help integrity_monitoring_help_formatupdate_commandintegrity_monitoring_helps              r<   AddShieldedInstanceConfigArgsr(  !  s    !N%M 55NM
  
 

 	$	
 	
)  
 
I
 		
 	&
" 'NN>EE "
 

 	'$-	
 	rL   c                 2    SnSnU R                  SSUSUS9  g)z;Adds flags for shielded instance integrity policy settings.z  Causes the instance to re-learn the integrity policy baseline using
  the current instance configuration. Use this flag after any planned
  boot-specific changes in the instance configuration, like kernel
  updates or kernel driver installation.
  r   z!--shielded-learn-integrity-policy"shielded_vm_learn_integrity_policyNr  r   r  r   r   )r   r  r!  s      r<   &AddShieldedInstanceIntegrityPolicyArgsr,    s2    )  .)/  rL   c                    U(       a  SSS.nSnU(       a  SUS'   SR                  US45      nU(       aH  [        R                  " S	5      n[        [        S
.nU R	                  SS[
        R                  " US9SUS9  U R                  5       n U R	                  SSUUS9  [        R                  " SSSS9nOSnU R	                  SSUSSS9  g)z1Adds flags for confidential compute for instance.zSecure Encrypted Virtualizationz6Secure Encrypted Virtualization - Secure Nested Paging)SEVSEV_SNPaD          The instance boots with Confidential Computing enabled. Confidential
        Computing can be based on Secure Encrypted Virtualization (SEV) or Secure
        Encrypted Virtualization - Secure Nested Paging (SEV-SNP), both of which
        are AMD virtualization features for running confidential instances.
        zTrust Domain eXtensionTDXr,   z        Trust Domain eXtension based on Intel virtualization features for
        running confidential instances is also supported.
        a          Secure VM Service Module (SVSM) is supported on AMD Secure Nested Paging
        (SEV-SNP) VMs for additional security. To specify the svsm-config also
        provide the argument `confidential-compute-type=SEV_SNP` on the command
        line.

        *tpm*::: The virtual Trusted Platform Module (TPM) used by SVSM.
        Currently the only vTPM supported is: EPHEMERAL.
        *snp-irq*::: The interrupt request mode to use for the AMD SEV-SNP VM.
        Currently the only IRQ mode supported is: UNRESTRICTED.
        )tpmzsnp-irqz--svsm-configTr   rH  )r  r   r   r   z--confidential-compute-typeconfidential_compute_type)r  r   r   z--confidential-computezmThe --confidential-compute flag will soon be deprecated. Please use `--confidential-compute-type=SEV` insteadr   )r  r   confidential_computeNz      The instance boots with Confidential Computing enabled. Confidential
      Computing is based on Secure Encrypted Virtualization (SEV), an AMD
      virtualization feature for running confidential instances.
      r+  )
r7   textwrapdedentr   r   r   r   r   r   r  )	r   !support_confidential_compute_type%support_confidential_compute_type_tdxsupport_snp_svsmr   r  svsm_help_textsvsm_congfig_specbool_flag_actions	            r<   AddConfidentialComputeArgsr<    s    '0KGI -/gen''9 (  i  
( 
n  
""(9:"   002F
%(	   00 =  $!
  	rL   c                 $    U R                  SSS9  g)z/Adds flag for overriding hostname for instance.z
--hostnameaL        Specify the hostname of the instance to be created. The specified
      hostname must be RFC1035 compliant. If hostname is not specified, the
      default hostname is [INSTANCE_NAME].c.[PROJECT_ID].internal when using
      the global DNS, and [INSTANCE_NAME].[ZONE].c.[PROJECT_ID].internal
      when using zonal DNS.
      r   Nr   r   s    r<   AddHostnameArgr>    s    
  rL   c                     U R                  US9nSSSS.nU(       a  UR                  SSS.5        UR                  S	US
US9  U(       a  SnOSnUR                  SUS9  g)zFAdds the argument group to handle reservation affinity configurations.r   z,Consume any available, matching reservation.z*Do not consume from any reserved capacity.z)Must consume from a specific reservation.)anynonespecificzPrefer to consume from a specific reservation, but still consume any available matching reservation if the specified reservation is not available or exhausted.zPrefer to consume from a specific reservation, but still consume from the on-demand pool if the specified reservation is not available or exhausted.)specific-then-any-reservationspecific-then-no-reservationz--reservation-affinityr@  )r   r  r   z
The name of the reservation, required when `--reservation-affinity` is one of: `specific`, `specific-then-any-reservation` or `specific-then-no-reservation`.
zO
The name of the reservation, required when `--reservation-affinity=specific`.
--reservationN)r   r  r   )r   
group_textaffinity_text support_specific_then_x_affinitygroupr   reservation_help_texts          r<   AddReservationAffinityGrouprK    s     




+%;:='
 &NN:
.  	   &    rL   c                     [        U SS5      nUS;   a.  U R                  S5      (       d  [        R                  " SS5      egg)z0Validates flags specifying reservation affinity.reservation_affinityN)rB  rC  rD  reservationrE  z7The name of the specific reservation must be specified.)r  r  r   r  )r|  affinitys     r<    ValidateReservationAffinityGrouprP  "  sT    T148(  
 M**//

C  +rL   c                 ,    U (       a  SnSnX4$ SnSnX4$ )z5Get description text for --container-mount-disk flag.a  Mounts a disk to the container by using mount-path or updates how the volume is
mounted if the same mount path has already been declared. The disk must already
be attached to the instance with a device-name that matches the disk name.
Multiple flags are allowed.
zName of the disk. Can be omitted if exactly one additional disk is attached to
the instance. The name of the single additional disk will be used by default.
zMounts a disk to the specified mount path in the container. Multiple '
flags are allowed. Must be used with `--disk` or `--create-disk`.
zName of the disk. If exactly one additional disk is attached
to the instance using `--disk` or `--create-disk`, specifying disk
name here is optional. The name of the single additional disk will be
used by default.
r   )rq  r8  name_descriptions      r<   /_GetContainerMountDescriptionAndNameDescriptionrS  1  s9    K ((K ((rL   c                     U(       a  US:X  a  [         R                  R                  $ US:X  a  [         R                  R                  $ [        R
                  " U S5      e)z(Parser for mode option in ArgDict specs.r  r  zMode can only be [ro] or [rw].)r   MountVolumeMode
READ_WRITE	READ_ONLYr   r  )argument_namer  s     r<   ParseMountVolumeModerY  M  sP    	++666t|++555

-
-m.NP PrL   c                     [        US9u  p#SR                  X#U(       a  SOS5      n[        [        [        [        R
                  " [        S5      S.nU R                  S[        R                  " US/S9US	S
9  g)z Add --container-mount-disk flag.rq  a  {}

*name*::: {}

*mount-path*::: Path on container to mount to. Mount paths with spaces
      and commas (and other special characters) are not supported by this
      command.

*partition*::: Optional. The partition of the disk to mount. Multiple
partitions of a disk can be mounted.{}

*mode*::: Volume mount mode: `rw` (read/write) or `ro` (read-only).
Defaults to `rw`. Fails if the disk mode is `ro` and volume mount mode
is `rw`.
r,   z" Can't be used with --create-disk.--container-mount-disk)r$   
mount-path	partitionr  r]  )r   required_keysrk   )r   r   r   N)
rS  r_   r   rK  rG   rH   rY  r   r   r   )r   rq  r8  rR  r  r   s         r<   AddContainerMountDiskFlagr`  X  s     6L  + F;2!FH &  46NO	
$ 	DG	  rL   c                 r   Uc  [         R                  " SS5      nUc  [        U5      S:X  a  U R                  R	                  US   R
                  5      R                  5       US   R                  US   R                  UR                  R                  R                  R                  :H  S.S4$ U H  nU R                  R	                  UR
                  5      R                  5       nXQ:X  d  M=  UUR                  UR                  UR                  R                  R                  R                  :H  S.S4s  $    g)z6Helper to match a mount disk's name to a disk message.r   alphar;  r   r$   device_namer  FNN)r   GetClientClassr  r   ri   sourcerm   
deviceNamer  MESSAGES_MODULEAttachedDiskModeValueValuesEnumrV  )holdermount_disk_namer(  client	disk_specr4  s         r<   _GetMatchingDiskFromMessagesrp  {  s   ^  G4FTa ""47>>2779G!W\\##00DDOOP   i  &&y'7'78==?I# ""6#9#9#F#F%%jj1 
   
rL   c                    S nU c+  [        X-   5      S:X  a  X-   S   nU" U5      [        U5      4$ U H$  nUR                  S5      U :X  d  M  U" U5      S4s  $    U H$  nUR                  S5      U :X  d  M  U" U5      S4s  $    g)z?Helper to match a mount disk's name to a disk spec from a flag.c                 n    U R                  S5      U R                  S5      U R                  S5      S:H  S.$ )Nr$   r   r  r  rc  r  r   s    r<   _GetMatchingDiskFromSpec;_GetMatchingDiskFromFlags.<locals>._GetMatchingDiskFromSpec  s5     xx.hhv$& rL   r;  r   r$   FTre  )r  boolr6   )rm  r(  r  rs  ro  s        r<   _GetMatchingDiskFromFlagsrv    s     T%7!8A!=#Q'I#I.[0AAAi}}V/%i0%77  i}}V/%i0$66  
rL   c                 b   UR                  S5      nU[        R                  R                  :X  a<  UR                  S5      (       a&  [        R
                  " SSR                  X5      5      eUR                  S5      (       a.  U(       a&  [        R
                  " SSR                  U 5      5      egg)zAMake sure the correct mode is specified for container mount disk.r^  r  r\  zValue for [mode] in [--container-mount-disk] cannot be [rw] if the disk is attached in [ro] mode: disk name [{}], partition [{}]zeCannot mount disk named [{}] to container: disk is created in [ro] mode and thus cannot be formatted.N)r6   r   rU  rV  r   r  r_   )r$   r  
mount_diskmatching_diskcreater^  s         r<   
_CheckModer{    s    nn[))$44???

-
- 	HHNI 
 t

-
- 	--3VD\; ; "(rL   c           
      P   U=(       d    / nU=(       d    / nU(       d  gU(       d%  U(       d  U(       d  [         R                  " SS5      eU(       a  SOSn/ nU GHG  nU(       a  [        XR                  S5      X%S9u  pO[	        UR                  S5      X#5      u  pUR                  S5      (       dg  [        X#-   5      S:w  a&  [         R                  " SS	R                  U5      5      eU	R                  S5      nU(       d  [         R                  " SS
5      eO>UR                  S5      nU	(       d&  [         R                  " SSR                  X5      5      eU	(       a  U	R                  S5      (       ai  U	R                  S5      U	R                  S5      :w  aE  [         R                  " SSR                  U	R                  S5      U	R                  S5      5      5      eUR                  S5      nU	(       a  [        XXU
5        U	(       aR  U
(       aK  UR                  S5      (       a5  [         R                  " SSR                  XR                  S5      5      5      e[        R                  " U5      nUR                  S5      =(       d    UUS'   UR                  U5        GMJ     U$ )z&Validate --container-mount-disk value.Nr\  z-Must be used with `--disk` or `--create-disk`r,   z# using `--disk` or `--create-disk`.r$   )rn  r;  zfMust specify the name of the disk to be mounted unless exactly one disk is attached to the instance{}.zhWhen attaching or creating a disk that is also being mounted to a container, must specify the disk name.z`Attempting to mount a disk that is not attached to the instance: must attach a disk named [{}]{}rd  zContainer mount disk cannot be used with a device whose device-name is different from its name. The disk with name [{}] has the device-name [{}].r  r^  z{Container mount disk cannot specify a partition when the disk is created with --create-disk: disk name [{}], partition [{}])r   r  rp  r6   rv  r  r_   r{  copydeepcopyrk   )rl  container_mount_diskr(  r  rq  rn  messagevalidated_disksrx  ry  rz  r$   r  s                r<   GetValidatedContainerMountDiskr    s`    
$!r+	

+

-
- 79 9 B"G'/(j:
..($?mV 8
..
 $5m>>&!!	T	 A	%11$66<fWoG 	G v&d11$78 	8  ^^F#d11$..4fT.CE 	E 	-++M::-(M,=,=f,EE//
"$f'):):=)IK	L L 'J:fEJNN;$?$?//
"J6${34	6 6
 z*J#/74Jv:&] )^ 
rL   c                    ^  U 4S jnU$ )Nc                 D   > U (       d  [         R                  " TS5      eU $ )NzEmpty string is not allowed.)r   r  )stringparameter_names    r<   FactoryNonEmptyString.<locals>.Factory  s%    //0NP PMrL   r   )r  r  s   ` r<   r\  r\    s     
.rL   c                     U R                  5       nUR                  S[        R                  " 5       SSSS9  UR                  SSS9  UR                  S	[        R                  " 5       SS
SS9  g)z.Add flags to update the container environment.r  rk   r  a        Update environment variables `KEY` with value `VALUE` passed to
      container.
      - Sets `KEY` to the specified value.
      - Adds `KEY` = `VALUE`, if `KEY` is not yet declared.
      - Only the last value of `KEY` is taken when `KEY` is repeated more
      than once.

      Values, declared with `--container-env` flag override those with the
      same `KEY` from file, provided in `--container-env-file`.
      rI  r  aR        Update environment variables from a file.
      Same update rules as for `--container-env` apply.
      Values, declared with `--container-env` flag override those with the
      same `KEY` from file.

      File with environment variables declarations in format used by docker
      (almost). This means:
      - Lines are in format KEY=VALUE
      - Values must contain equality signs.
      - Variables without values are not supported (this is different from
      docker format).
      - If # is first non-whitespace character in a line the line is ignored
      as a comment.
      r   z--remove-container-envKEYz}      Removes environment variables `KEY` from container declaration Does
      nothing, if a variable is not present.
      N)add_argument_groupr   r   r   rL  )r   	env_groups     r<   _AddContainerEnvGroupr    s     '')) 

  " 
  $  
  rL   c                 j    U R                  5       nUR                  SSSS9  UR                  SSSSS	9  g)
z&Add flags to update the container arg.r  rk   a        Completely replaces the list of arguments with the new list.
      Each argument must have a separate --container-arg flag.
      Arguments are appended the new list in the order of flags.

      Cannot be used in the same command with `--clear-container-arg`.
      r   z--clear-container-argsr   Nz      Removes the list of arguments from container declaration.

      Cannot be used in the same command with `--container-arg`.
      r  r|  )r   	arg_groups     r<   _AddContainerArgGroupr  @  sS     113)
  	 
	  rL   c                 |    U R                  5       nUR                  S[        S5      SS9  UR                  SSSSS9  g)	z=Add flags to update the command in the container declaration.r  z      Sets command in the declaration to the specified value.
      Empty string is not allowed.

      Cannot be used in the same command with `--clear-container-command`.
      r   z--clear-container-commandr   Nz~      Removes command from container declaration.

      Cannot be used in the same command with `--container-command`.
      r  )r   r   r\  )r   command_groups     r<   _AddContainerCommandGroupr  [  sW    557-/0
   !
	  rL   c                     U(       a  SnOSnU R                  SS[        R                  " [        [        [        R
                  " [        S5      S.S9SSR                  U5      S	9  g
)z/Helper to add --container-mount-host-path flag.z
      - Adds a volume, if `mount-path` is not yet declared.
      - Replaces a volume, if `mount-path` is declared.
      All parameters (`host-path`, `mount-path`, `mode`) are completely
      replaced.r,   z--container-mount-host-pathz3host-path=HOSTPATH,mount-path=MOUNTPATH[,mode=MODE])z	host-pathr]  r  r   rk   af        Mounts a volume by using host-path.{}

      *host-path*::: Path on host to mount from.

      *mount-path*::: Path on container to mount to. Mount paths with spaces
      and commas (and other special characters) are not supported by this
      command.

      *mode*::: Volume mount mode: rw (read/write) or ro (read-only).

      Default: rw.
      r   r   r   r   N)r   r   r   r   rG   rH   rY  r_   )r   rq  
additionals      r<   r  r  t  sr    J J#C ##$8$AC	 
 &
5  rL   c                 Z    U R                  SS[        R                  " S[        0S9SSS9  g)	z+Helper to add --container-mount-tmpfs flag.z--container-mount-tmpfszmount-path=MOUNTPATHr]  r   rk   z      Mounts empty tmpfs into container at MOUNTPATH.

      *mount-path*::: Path on container to mount to. Mount paths with spaces
      and commas (and other special characters) are not supported by this
      command.
      r  Nr   r   s    r<   r  r    s6    $\3$78
  rL   c           
      .   U R                  5       n[        USS9  [        U5        U(       a
  [        U SS9  SS/nU(       a  UR	                  S5        UR                  S[        R                  " 5       SSR                  S	R                  U5      5      S
9  g)z5Add flags to update what is mounted to the container.Tr[  z`host-path`z`tmpfs`z`disk`z--remove-container-mountszMOUNTPATH[,MOUNTPATH,...]z      Removes volume mounts ({}) with
      `mountPath: MOUNTPATH` from container declaration.

      Does nothing, if a volume mount is not declared.
      rT   r  N)
r  r  r  r`  rk   r   r   rL  r_   r7   )r   container_mount_disk_enabledmount_groupmount_typess       r<   _AddContainerMountGroupr    s     ))++ >k*!f6	*+!x ! )

 &;'
(  	*rL   c                     U R                  S[        S5      SS9  U R                  SSSSS9  U R                  S	SSS
S9  U R                  SSSSS9  U R                  S/ SQSS SS9  g)z$Add basic args for update-container.r  zp      Sets container image in the declaration to the specified value.

      Empty string is not allowed.
      r   r  r   NzE      Sets permission to run container to the specified value.
      r  r  zk      Sets configuration whether to keep container `STDIN` always open to the
      specified value.
      r  zp      Sets configuration whether to allocate a pseudo-TTY for the container
      to the specified value.
      r  r  r  c                 "    U R                  5       $ rF   r  r  s    r<   r   #_AddContainerArgs.<locals>.<lambda>  r  rL   zB      Sets container restart policy to the specified value.
      )r   r   r   r   r   r\  r   s    r<   _AddContainerArgsr    s     	-.
   	
	   	
	   	
	   	"/"
  rL   c                     [         R                  U SS9  [        U 5        [        U 5        [	        U 5        [        XS9  [        U 5        [        U SSSS9  [        U 5        g)z1Add all args to update the container environment.r  )r   )r  FT)r  rq  r   N)	INSTANCE_ARGAddArgumentr  r  r  r  r  r(  r,  )r   r  s     r<   AddUpdateContainerArgsr    s[    6(;F#IF$dL(0rL   c                 8    SnSSS.nU R                  SUSSUS9  g	)
z5Helper to add --post-key-revocation-action-type flag.zuSpecifies the behavior of the instance when the KMS key of one of its attached disks is revoked. The default is noop.No operation is performed.zSThe instance is shut down when the KMS key of one of its attached disks is revoked.)noopshutdownz!--post-key-revocation-action-typer  Fr   r   r(   r   Nr   r   r  choices_texts      r<   "AddPostKeyRevocationActionTypeArgsr    s?    H) '4, 	)  rL   c                 B    U R                  S[        R                  SS9  g )Nz--enable-nested-virtualizationzL      If set to true, enables nested virtualization for the instance.
      r   r  r   s    r<   AddNestedVirtualizationArgsr    s&    &--
  rL   c                 .    U R                  S[        SS9  g )Nz--threads-per-corea/  
      The number of visible threads per physical core. To disable simultaneous
      multithreading (SMT) set this to 1. Valid values are: 1 or 2.

      For more information about configuring SMT, see:
      https://cloud.google.com/compute/docs/instances/configuring-simultaneous-multithreading.
    r   r   rK  r   s    r<   AddThreadsPerCoreArgsr    s       		rL   c                 B    U R                  S[        R                  SS9  g )Nz--enable-uefi-networkingzO      If set to true, enables UEFI networking for the instance creation.
      r   r  r   s    r<   AddEnableUefiNetworkingArgsr  ,  s&     --
  rL   c                 8    U R                  SSSSS.[        SS9  g )Nz--performance-monitoring-unitzGThis enables architecturally defined non-last level cache (LLC) events.z,This enables most documented core/L2 events.z4This enables most documented core/L2 and LLC events.)architecturalstandardenhancedzMThe type of performance monitoring counters (PMCs) to enable in the instance.r  r   r   r   s    r<    AddPerformanceMonitoringUnitArgsr  5  s5    % EL   rL   c                 .    U R                  S[        SS9  g )Nz--numa-node-countz      The number of virtual NUMA nodes for the instance.
      Valid values are: 0, 1, 2, 4 or 8. Setting NUMA node count to 0 means
      using the default setting.
      r   r  r   s    r<   AddNumaNodeCountArgsr  H  s     
  rL   c                 .    U R                  S[        SS9  g )Nz--visible-core-counta  
      The number of physical cores to expose to the instance's guest operating
      system. The number of virtual CPUs visible to the instance's guest
      operating system is this number of cores multiplied by the instance's
      count of visible threads per physical core.
    r   r  r   s    r<   AddVisibleCoreCountArgsr  S  s       	rL   c                 f    SSS.nU(       a  SUS'   U R                  SU[        R                  SS9  g	)
z'Adds stack type arguments for instance.z5The network interface will be assigned IPv4 addressesz;The network interface can have both IPv4 and IPv6 addresses)	IPV4_ONLY	IPV4_IPV6z5The network interface will be assigned IPv6 addresses	IPV6_ONLYz--stack-typezmSpecifies whether IPv6 is enabled on the default network interface. If not specified, IPV4_ONLY will be used.r  Nr  )r   r  r   s      r<   AddStackTypeArgsr  _  sN     K
G' ? K 	%%A  rL   c                 H    U R                  SSS0[        R                  SS9  g)z@Adds IPv6 network tier for network interface IPv6 access config.z--ipv6-network-tierPREMIUMz(High quality, Google-grade network tier.zqSpecifies the IPv6 network tier that will be used to configure the instance network interface IPv6 access config.r  Nr  r   s    r<   AddIpv6NetworkTierArgsr  v  s5    
@ %%A  CrL   c                 8    U R                  S[        S5      SS9  g )Nz--external-ipv6-address
      Assigns the given external IPv6 address to the instance that is created.
      The address must be the first IP address in the range. This option can be
      used only when creating a single instance.
    r   r  r   s    r<   AddIPv6AddressArgsr    s&    34  	rL   c                 8    U R                  S[        S5      SS9  g )Nz--ipv6-addressr  r   r  r   s    r<   AddIPv6AddressAlphaArgsr    s&    *+  	rL   c                 .    U R                  S[        SS9  g )Nz--external-ipv6-prefix-lengthz
      The prefix length of the external IPv6 address range. This field should be
      used together with `--external-ipv6-address`. Only the /96 IP address range
      is supported, and the default value is 96.
    r   r  r   s    r<   AddIPv6PrefixLengthArgsr    s     %  	rL   c                 .    U R                  S[        SS9  g )Nz--ipv6-prefix-lengthz
      The prefix length of the external IPv6 address range. This field should be
      used together with `--ipv6-address`. Only the /96 IP address range is
      supported, and the default value is 96.
    r   r  r   s    r<   AddIPv6PrefixLengthAlphaArgsr    s       	rL   c                 8    U R                  S[        S5      SS9  g )Nz--internal-ipv6-addressa  
      Assigns the given internal IPv6 address or range to the instance that is
      created. The address must be the first IP address in the range or from a
      /96 IP address range. This option can be used only when creating a single
      instance.
    r   r  r   s    r<   AddInternalIPv6AddressArgsr    s&    34  	rL   c                 .    U R                  S[        SS9  g )Nz--internal-ipv6-prefix-lengthap  
      Optional field that indicates the prefix length of the internal IPv6
      address range. It should be used together with --internal-ipv6-address.
      Only /96 IP address range is supported and the default value is 96. If
      not set, either the prefix length from --internal-ipv6-address will be
      used or the default value of 96 will be assigned.
    r   r  r   s    r<   AddInternalIPv6PrefixLengthArgsr    s     %  
rL   c           
      
   SR                  SR                  [        R                   Vs/ s H  n[        R
                  " U5      PM     sn5      S9nS[        0nU R                  S[        R                  " US9SSUS	9  g
s  snf )z:Adds config flags for advanced networking bandwidth tiers.a        Configures network performance settings for the instance.
      If this flag is not specified, the instance will be created
      with its default network performance configuration.

      *total-egress-bandwidth-tier*::: Total egress bandwidth is the available
      outbound bandwidth from a VM, regardless of whether the traffic
      is going to internal IP or external IP destinations.
      The following tier values are allowed: [{tier_values}]

      ,)tier_valuestotal-egress-bandwidth-tier--network-performance-configsr   rk   rH  rI  N)
r_   r7   r   ADV_NETWORK_TIER_CHOICESrm  rn  r   r   r   r   )r   tier_valnetwork_perf_config_helpr   s       r<    AddNetworkPerformanceConfigsArgsr    s    

 &SXX#<<'<h --
!<' 	& 
  (	-$%D)#  %'s    B c                    [        U S/ 5      =(       d    /  H  nUR                  SS5      R                  5       nU(       d  M,  U[        R                  ;  d  MB  [
        R                  " SSR                  USR                  [        R                   Vs/ s H  n[        R                  " U5      PM     sn5      S95      e   gs  snf )	z4Validates advanced networking bandwidth tier values.network_performance_configsr  r,   r  z|Invalid total-egress-bandwidth-tier tier value, "{tier}".
             Tier value must be one of the following {tier_values}r  )r  r  N)r  r6   r   r   r  r   r  r_   r7   rm  rn  )r|  config
total_tierr  s       r<   %ValidateNetworkPerformanceConfigsArgsr    s     ;R@FBFf92>DDFJ
z)K)KK//
)FFLf  XX%.%G%G'%G ]]8,%G'  GM G  G's    Cc                 $    U R                  SSS9  g)zAdds node project argument.z--node-projectza      The name of the project with shared sole tenant node groups to create
      an instance in.r   Nr   r   s    r<   AddNodeProjectArgsr    s      rL   c                 8    SnSSS.nU R                  SUSSUS9  g	)
z0Helper to add --key-revocation-action-type flag.zuSpecifies the behavior of the instance when the KMS key of one of its attached disks is revoked. The default is none.r  zQThe instance is stopped when the KMS key of one of its attached disks is revoked.)rA  stopz--key-revocation-action-typer  Fr  Nr   r  s      r<   AddKeyRevocationActionTypeArgsr    s?    H) +",
 	$  rL   c                 P    SnSS0nU R                  SU[        R                  US9  g)z1Adds maintenance interval arguments for instance.z6Specifies the frequency of planned maintenance events.r   z+PERIODIC means the VM is a Stable Fleet VM.r   r  Nr  r  s      r<   AddMaintenanceIntervalArgsr    s7    F)KL,%%	  rL   c                 L    U R                  S[        R                  " SSS9SS9  g )Nz--availability-domainr;     r  ap  
          Specifies the availability domain that this VM instance should be
          scheduled on. The number of availability domains that a VM can be
          scheduled on is specified when you create the spread placement
          policy.

          Specify a value from 1 to the number of domains that are available in
          your placement policy.
          r   )r   r   r+  r   s    r<   AddAvailabilityDomainAgrsr    s-    !!aQ?  rL   c                 .    U R                  S[        SS9  g )Nz--turbo-modea4  
      Turbo mode to use for the instance. Supported modes include:
      * ALL_CORE_MAX

      To achieve all-core-turbo frequency for more consistent CPU
      performance, set the field to ALL_CORE_MAX. The field is unset by
      default, which results in maximum performance single-core boosting.
      r   r  r   s    r<   AddTurboModeArgsr  ,  s     
  rL   c                 B    U R                  S[        R                  SS9  g )Nz--skip-guest-os-shutdownz      If enabled, then, when the instance is stopped or deleted, the instance
      is immediately stopped without giving time to the guest OS to cleanly
      shut down.
      r   r  r   s    r<   AddSkipGuestOsShutdownArgsr  ;  s&     --
  rL   c                 L    U R                  S[        R                  " 5       SS9  g )Nz--request-valid-for-durationa{  
      When you create an instance by using the FLEX_START provisioning model,
      you can specify the duration to wait for available resources. If the
      instance creation request is still pending after this duration, then the
      request fails. You specify a duration by using numbers followed
      by `h`, `m`, and `s` for hours, minutes, and seconds, respectively. For
      example, specify `30m` for a duration of 30 minutes, or `1h2m3s` for
      1 hour, 2 minutes, and 3 seconds. Longer durations give you higher chances
      that your instance creation request succeeds when resources are in high
      demand.
      r   r0  r   s    r<   AddRequestValidForDurationArgsr  F  s)    $!

  rL   c                 l    U R                  S[        SS9  U R                  S[        R                  SS9  g )Nz
--identityz;      The workload identity to use for the instance.
      r   z--identity-certificatezE      Enables or disables managed workload identities on a VM.
      r   )r   r   r   r  r   s    r<   AddWorkloadIdentityConfigArgsr  X  sF    
   	--
  rL   )T)Fadded)FFFF)F)FFF)FFFFFTFFTFFFF)FFFFF)FFFTF)	TFFFFTFFF)FN)r,   Creater    )TF)TFF)returnNrF   )__doc__
__future__r   r   r   r}  rG   rk  r4  googlecloudsdk.api_lib.computer   r   r   r	   r
   r   r   $googlecloudsdk.api_lib.compute.zonesr   re   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   r   r   r   "googlecloudsdk.command_lib.computer   r{   r  r   ry   r   rn   googlecloudsdk.command_lib.kmsr   r-  $googlecloudsdk.command_lib.util.apisr   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   r   r   rg   rm  r}   r  r  r  r  DISK_METAVAR_ZONAL_OR_REGIONALDEFAULT_LIST_FORMATIPV6_INFO_LIST_FORMATDEFAULT_LIST_FORMAT_WITH_IPV6rz   r|   r  INSTANCE_ARG_NOT_REQUIREDINSTANCES_ARGINSTANCES_ARG_FOR_CREATEINSTANCES_ARG_FOR_IMPORTResourceResolverFromMapro   rp   SSH_INSTANCE_RESOLVERr=   rD   rK   rI   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r	  r  r  r2  rX  r^  ri  rq  rp  r}  rx  ry  r  rz  r{  r  r  r  r  r  r  r  r  r  r  r	  r  r  r  r  r(  r,  r1  r8  r:  r@  rE  rN  rP  rR  rg  rk  rs  rx  rz  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r  r  r  r(  r,  r<  r>  rK  rP  rS  rY  r`  rp  rv  r{  r  r\  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   rL   r<   <module>r     sz   ? &  '     4 ; 5 5 6 4 0 I , + / ( . O O E E M : < # * ; 
 4	H6	  '  E 
	 U $	!	  --	 33(.0 *::	 33(.0  ..	 33(. )99	 33("<<  )99	 33("<<  &66>>((--/BCE :*:"D!/H2	2
D
@0'6 $"#(K\F<N5B/B2(%P,$ ', (-FREBPD !$) %#(qh	!H4@	  %#(*:)xMz  %#(MC`#;	;9P	IM  %"'Q4h

:>*$M4 FRj%P	8
	<~3.( 57,4+5	DQNJ:	A<;:|
D*GF$K$	:.	>,=*l^K!
HcL %2HN  59-205_D& ',*/	P  $	Pf
+\)8P F8,;* /4*.AH0f62%P *4-`1$
	&		.	C				
%8""	 $rL   