
    c                        S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  S.S jrS.S	 jrS.S
 jrS.S jrS.S jrS.S jrS.S jrS.S jrS.S jrS.S jrS.S jrS.S jrS.S jrS.S jrS.S jrS.S jrS.S jrS.S jrS.S jrS.S jrS.S jrS/S jr S/S jr!S/S jr"S/S  jr#S/S! jr$S/S" jr%S/S# jr&S/S$ jr'S/S% jr(S/S& jr)S/S' jr*S/S( jr+S/S) jr,S/S* jr-S/S+ jr.S/S, jr/g-)0z-Flags for backup-dr restore compute commands.    )absolute_import)division)unicode_literals)arg_parsers)util)	arg_utilsc                 0    U R                  S[        USS9  g )Nz--namez&Name of the restored Compute Instance.typerequiredhelpadd_argumentstrparserr   s     @lib/googlecloudsdk/command_lib/backupdr/restore/compute_flags.py
AddNameArgr      s!    3	      c                 0    U R                  S[        USS9  g )Nz--target-zonez+Zone where the target instance is restored.r
   r   r   s     r   AddTargetZoneArgr   #   s!    8	  r   c                 0    U R                  S[        USS9  g )Nz--target-projectz(Project where the restore should happen.r
   r   r   s     r   AddTargetProjectArgr   ,   s!    5	  r   c                 `   SnSnSn[         R                  " SU5      n[         R                  " SU5      n[         R                  " SU5      n[        [        [        [        [        [        [        [        U[        U[        U[        S.nU R	                  SU[
        R                  " US	9S
SSS9  g)z+Network interface of the restored resource.)NETWORK_TIER_UNSPECIFIEDSTANDARDPREMIUM)STACK_TYPE_UNSPECIFIED	IPV4_ONLY	IPV4_IPV6)NIC_TYPE_UNSPECIFIED
VIRTIO_NETGVNICnetwork-tier
stack-typenic-type)networksubnetzprivate-network-ipzinternal-ipv6-addresszinternal-ipv6-prefix-lengthaddresszexternal-ipv6-addresszexternal-ipv6-prefix-lengthr$   aliasesr%   zqueue-countr&   znetwork-attachmentz--network-interfacespecappendPROPERTY=VALUEan  Adds a network interface to the instance. This flag can be repeated to specify multiple network interfaces. The following keys are allowed: network, subnet, private-network-ip, internal-ipv6-address, internal-ipv6-prefix-length, address, external-ipv6-address, external-ipv6-prefix-length, network-tier, aliases, stack-type, queue-count, nic-type, network-attachmentr   r   actionmetavarr   N)r   GetOneOfValidatorr   intr   r   ArgDict)	r   r   network_tier_optionsstack_type_optionsnic_type_optionsnetwork_tier_validatorstack_type_validatornic_type_validatornetwork_interface_specs	            r   AddNetworkInterfaceArgr<   5   s    LKD11* //& --j:JK"%("%(,($  	$:;C  r   c                 0    U R                  S[        USS9  g)z Service account used to restore.z--service-accountag  A service account is an identity attached to the instance. 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. If not provided, the instance will use the project's default service account.r
   Nr   r   s     r   AddServiceAccountArgr>   d   s#    4  r   c                     U R                  5       nUR                  S[        R                  " [        5      USSS9  UR                  SSSS9  g	)
z/Scopes for the service account used to restore.z--scopesSCOPEa  If not provided, the instance will be assigned the default scopes, described below. However, if neither --scopes nor --no-scopes are specified and the project has no default service account, then the instance will be created with no scopes. Note that the level of access that a service account has is determined by a combination of access scopes and IAM roles so you must configure both access scopes and IAM roles for the service account to work properly. SCOPE can be either the full URI of the scope or an alias. Default scopes are assigned to all instances. Available aliases are: https://cloud.google.com/sdk/gcloud/reference/compute/instances/create#--scopesr   r   r1   r   z--no-scopes
store_truez#Create the instance with no scopes.)r0   r   N)add_mutually_exclusive_groupr   r   ArgListr   )r   r   scopes_groups      r   AddScopesArgrF   u   s^    446,s#	]  & 0  r   c           	          [         [        R                  " [         SS9[         S.nU R                  SU[        R                  " US9SSSS	9  g
)z+Attaches persistent disks to the instances. )custom_delim_char)namezreplica-zoneszdevice-namez--create-diskr+   r-   r.   a  
          Creates and attaches persistent disks to the instances.

          *name*: Specifies the name of the disk.

          *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.

          *device-name*: Device name of the disk from the source instance.
          r/   N)r   r   rD   r   r4   )r   r   	disk_specs      r   AddCreateDiskArgrL      sU     "**3#F)
 	I.  r   c                 0    U R                  S[        USS9  g)z%Description of the restored instance.z--descriptionz9Specifies a textual description of the restored instance.r
   Nr   r   s     r   AddDescriptionArgrN      s!    F	  r   c           
      r    SnU R                  SU[        R                  " SS90 SU[        R                  S9  g)z<Metadata to be made available to the guest operating system.a        Metadata to be made available to the guest operating system
      running on the instances. Each metadata entry is a key/value
      pair separated by an equals sign. Each metadata key must be unique
      and have a max of 128 bytes in length. Each value must have a max of
      256 KB in length. Multiple arguments can be
      passed to this flag, e.g.,
      ``--metadata key-1=value-1,key-2=value-2,key-3=value-3''.
      The combined total size for all metadata entries is 512 KB.

      In images that have Compute Engine tools installed on them,
      such as the
      link:https://cloud.google.com/compute/docs/images[official images],
      the following metadata keys have special meanings:

      *startup-script*::: Specifies a script that will be executed
      by the instances once they start running.

      *startup-script-url*::: Same as ``startup-script'' except that
      the script contents are pulled from a publicly-accessible
      location on the web.


      For startup scripts on Windows instances, the following metadata keys
      have special meanings:
      ``windows-startup-script-url'',
      ``windows-startup-script-cmd'', ``windows-startup-script-bat'',
      ``windows-startup-script-ps1'', ``sysprep-specialize-script-url'',
      ``sysprep-specialize-script-cmd'', ``sysprep-specialize-script-bat'',
      and ``sysprep-specialize-script-ps1''. For more information, see
      [Running startup scripts](https://cloud.google.com/compute/docs/startupscript).
      z
--metadata   
min_length	KEY=VALUE)r   r   defaultr1   r   r0   N)r   r   r4   StoreOnceActionr   r   helptexts      r   AddMetadataArgrX      sE    
(@ 	!,((  r   c           	      V    SnU R                  SU[        R                  " 5       0 SUS9  g)z#Labels to be added to the instance.a        List of label KEY=VALUE pairs to add.

      Keys must start with a lowercase character and contain only hyphens (-),
      underscores (_), lowercase characters, and numbers. Values must contain
      only hyphens (-), underscores (_), lowercase characters, and numbers.
      z--labelsrS   )r   r   rT   r1   r   Nr   r   r4   rV   s      r   AddLabelsArgr[      s9    
( 	   r   c                 R    SnU R                  SU[        R                  " SS9SUS9  g)z!Tags to be added to the instance.z      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.
      z--tagsrP   rQ   TAG)r   r   r1   r   Nr   r   rD   rV   s      r   
AddTagsArgr_      s8    
(
 	!,  r   c                 4    SnU R                  S[        UUS9  g)z,Machine type used for the restored instance.a        Specifies the machine type used for the restored instance. To get a list
      of available machine types, run 'gcloud compute machine-types list'. If
      unspecified, the default type will be based on the source instance.

      This can either be the fully qualified path or the name.
      For example:
      * ``--machine-type=projects/my-project/zones/us-central1-a/machineTypes/n1-standard-1''
      * ``--machine-type=n1-standard-1''
      z--machine-typer
   Nr   rV   s      r   AddMachineTypeArgra   
  s*    	
( 		  r   c                 4    SnU R                  S[        UUS9  g)z!Hostname of the restore instance.ab        Specify the hostname of the restore instance to be created. The specified
      hostname must be RFC1035 compliant. If hostname is not specified, the
      default hostname is [INSTANCE_NAME].c.[TARGET_PROJECT_ID].internal when using the
      global DNS, and [INSTANCE_NAME].[ZONE].c.[TARGET_PROJECT_ID].internal when using
      zonal DNS.
      z
--hostnamer
   Nr   rV   s      r   AddHostnameArgrc     s*    
( 		  r   c                 H    SnU R                  S[        R                  UUS9  g)z1Enable UEFI networking for the instance creation.zO      If set to true, enables UEFI networking for the instance creation.
      z--enable-uefi-networkingr0   r   r   Nr   r   StoreTrueFalseActionrV   s      r   AddEnableUefiNetworkingArgrh   /  s0    
( 	 --	  r   c                 4    SnU R                  S[        UUS9  g)z0The number of visible threads per physical core.a/  
      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.
    z--threads-per-corer
   Nr   r3   rV   s      r   AddThreadsPerCoreArgrk   <  s*    ( 		  r   c                 4    SnU R                  S[        UUS9  g)zPThe number of physical cores to expose to the instance's guest operating system.a  
      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.
    z--visible-core-countr
   Nrj   rV   s      r   AddVisibleCoreCountArgrm   M  s*    ( 		  r   c                 j    SnU R                  S[        R                  " [        [        S.S/S9UUS9  g)z3Attaches accelerators (e.g. GPUs) to the instances.a        Attaches accelerators (e.g. GPUs) to the instances.

      *type*::: The specific type (e.g. nvidia-tesla-k80 for nVidia Tesla K80)
      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.
      z--accelerator)r   countr   )r,   required_keysr
   N)r   r   r4   r   r3   rV   s      r   AddAcceleratorArgrq   ]  sC    	
( 	c*6(   r   c                 6    SnU R                  S[        USUS9  g)z1Minimum CPU platform to be used for the instance.a        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)
      z--min-cpu-platformPLATFORMrA   Nr   rV   s      r   AddMinCpuPlatformrt   s  s-    
( 	  r   c                 P    SnU R                  SSSS.[        R                  UUS9  g)z/Maintenance policy to be used for the instance.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.
      z--maintenance-policyzThe 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choicesr   r   r   Nr   r   ChoiceToEnumNamerV   s      r   AddMaintenancePolicyArgr|     sA    
( 	" = %%  r   c                 H    SnU R                  S[        R                  UUS9  g)z.Preemptible state to be used for the instance.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--preemptiblere   Nrf   rV   s      r   AddPreemptibleArgr~     s0    
( 	--	  r   c                 H    SnU R                  S[        R                  UUS9  g)z5Restart on failure state to be used for the instance.z      The instances will be restarted if they are terminated by Compute Engine.
      This does not affect terminations performed by the user.
      z--restart-on-failurere   Nrf   rV   s      r   AddRestartOnFailureArgr     s0    
( 	--	  r   c                 4    SnU R                  S[        UUS9  g)z.Minimum Node CPUs to be used for the instance.zp      Minimum number of virtual CPUs this instance will consume when running on
      a sole-tenant node.
      z--min-node-cpur
   Nrj   rV   s      r   AddMinNodeCpuArgr     s*    
( 		  r   c                 P    SnU R                  SSSS.[        R                  UUS9  g)z/Provisioning model to be used for the instance.z      Specifies provisioning model, which determines price, obtainability,
      and runtime for the restored VM instance.
      z--provisioning-modelzSpot VMs are spare capacity; Spot VMs are discounted to have much lower prices than standard VMs but have no guaranteed runtime. Spot VMs are the new version of preemptible VM instances, except Spot VMs do not have a 24-hour maximum runtime.zoDefault. Standard provisioning model for VM instances, which has user-controlled runtime but no Spot discounts.)SPOTr   rx   Nrz   rV   s      r   AddProvisioningModelArgr     sA    
( 	+' %%%  r   c                 P    SnU R                  SSSS.[        R                  UUS9  g)z/Termination action to be used for the instance.z      Specifies the termination action that will be taken upon VM preemption
        (--provisioning-model=SPOT) or automatic instance
        termination (--max-run-duration or --termination-time).
      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DELETErx   Nrz   rV   s      r   AddInstanceTerminationActionArgr     sA    
(
 	%8 1 %%  r   c           	      T    SnU R                  S[        R                  " SSSS9UUS9  g)	z7Local SSD recovery timeout to be used for the instance.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.
      z--local-ssd-recovery-timeouth0h168h)default_unitlower_boundupper_boundr
   N)r   r   DurationrV   s      r   AddLocalSsdRecoveryTimeoutArgr     s>    
( 	$&   r   c                 T    SnU R                  S[        R                  " 5       UUSS9  g)z/Node affinity file to be used for the instance.a        The JSON/YAML file containing the configuration of desired nodes onto
      which this instance could be scheduled. These rules filter the nodes
      according to their node affinity labels. A node's affinity labels come
      from the node template of the group the node is in.

      The file should contain a list of a JSON/YAML objects. For an example,
      see https://cloud.google.com/compute/docs/nodes/provisioning-sole-tenant-vms#configure_node_affinity_labels.
      The following list describes the fields:

      *key*::: Corresponds to the node affinity label keys of
      the Node resource.
      *operator*::: Specifies the node selection type. Must be one of:
        `IN`: Requires Compute Engine to seek for matched nodes.
        `NOT_IN`: Requires Compute Engine to avoid certain nodes.
      *values*::: Optional. A list of values which correspond to the node
      affinity label values of the Node resource.
      z--node-affinity-fileT)r   r   r   hiddenN)r   r   YAMLFileContentsrV   s      r   AddNodeAffinityFileArgr     s6    
($ 	'')  r   c                 |    SnSnSnU R                  US9nUR                  SSSSS	.UUS
9  UR                  SUUS9  g)z1Reservation affinity to be used for the instance.z+Specifies the reservation for the instance.z@      Specifies the reservation affinity of the instance.
      zMThe name of the reservation, required when `--reservation-affinity=specific`.)r   z--reservation-affinityz,Consume any available, matching reservation.z*Do not consume from any reserved capacity.z)Must consume from a specific reservation.)anynonespecific)ry   r   r   z--reservation)r   r   N)	add_groupr   )r   r   reservation_group_helptextreservation_affinity_helptextreservation_help_textgroups         r   AddReservationArgsr   1  sw    P#
 n


 :

;%?>A
 (  	    r   c                 H    SnU R                  S[        R                  UUS9  g)z'Enable display device for the instance.zW      Enable a display device on the restored VM instances. Disabled by default.
      z--enable-display-devicere   Nrf   rV   s      r   AddEnableDisplayDeviceArgr   M  s0    
( 	--	  r   c                 H    SnU R                  S[        R                  UUS9  g)z0Enable can ip forward for the restored instance.z      If provided, allows the restored instances to send and receive packets
      with non-matching destination or source IP addresses.
      z--can-ip-forwardre   Nrf   rV   s      r   AddCanIpForwardArgr   Z  s0    
( 	--	  r   c           	          SnSSSS.nUSR                  SR                  [        UR                  5       5      5      5      -  nU R	                  S[
        R                  " U5      R                  UUS	9  g
)z=Enable private ipv6 google access for the  restored instance.zE      The private IPv6 Google access type for the restored VM.
      INHERIT_FROM_SUBNETWORK%ENABLE_BIDIRECTIONAL_ACCESS_TO_GOOGLE#ENABLE_OUTBOUND_VM_ACCESS_TO_GOOGLE)zinherit-subnetworkzenable-bidirectional-accesszenable-outbound-vm-accessz2PRIVATE_IPV6_GOOGLE_ACCESS_TYPE must be one of: {}z, z!--private-ipv6-google-access-typer
   N)formatjoinlistkeysr   r   
EnumMapperParser   r   rW   enum_mappingss       r   AddPrivateIpv6GoogleAccessArgr   h  s    
( 6%L#H-
 BII
ii]'')*+ ( 	)??=)//	  r   c                 ^    SnU R                  S[        R                  " S[        0S9SUUS9  g)z<Enable network performance config for the restored instance.a        Configures network performance settings for the restored instance.
      If this flag is not specified, the restored instance will be created
      with its source instance's 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: [DEFAULT, TIER_1]
      z--network-performance-configsztotal-egress-bandwidth-tierr+   r.   r   r1   r   r   N)r   r   r4   r   rV   s      r   AddNetworkPerformanceConfigsArgr   }  sD    	
( 	%+S
   
r   c                 ,    SnU R                  SSUUS9  g)z6Enable confidential compute for the restored instance.z      The restored instance boots with Confidential Computing enabled.
      Confidential Computing is based on Secure Encrypted Virtualization (SEV),
      an AMD virtualization feature for running confidential instances.
      z--confidential-computerB   re   N)r   rV   s      r   AddConfidentialComputeArgr     s*    
(
 		  r   c                 H    SnU R                  S[        R                  UUS9  g)z5Enable deletion protection for the restored instance.zC      Enables deletion protection for the restored instance.
      z--deletion-protectionre   Nrf   rV   s      r   AddDeletionProtectionArgr     s0    
( 	--	  r   c                 T    SnU R                  S[        R                  " 5       SUUS9  g)z0ResourceManagerTags to be added to the instance.zP      Specifies a list of resource manager tags to apply to the instance.
      z--resource-manager-tagsrS   r   NrZ   rV   s      r   AddResourceManagerTagsArgr     s6    
( 	   r   c                 R    SnU R                  S[        R                  " SS9SUUS9  g)z-ResourcePolicies to be added to the instance.z      A list of resource policy names to be added to the instance.
      The policies must exist in the same region as the instance.
      z--resource-policiesrP   rQ   RESOURCE_POLICYr   Nr^   rV   s      r   AddResourcePoliciesArgr     s8    
( 	!,  r   c                 t    SnSSS.nU R                  SS[        R                  " U5      R                  UUS9  g)	z4KeyRevocationActionType to be added to the instance.a8        Specifies the behavior of the instance when the KMS key of one of its
      attached disks is revoked. The default is none. POLICY must be one of:
      * none
      No operation is performed.
      * stop
      The instance is stopped when the KMS key of one of its attached disks is
      revoked.
      NONEr   )r   stopz--key-revocation-action-typePOLICY)r1   r   r   r   N)r   r   r   r   r   s       r   AddKeyRevocationActionTypeArgr     sK    
( - 	$??=)//  r   c                 4    SnU R                  S[        UUS9  g)z+InstanceKmsKey to be added to the instance.a        The Cloud KMS (Key Management Service) cryptokey that will be used to
      protect the restored instance.

      Provide the full resource name of the cryptokey in the format:
      `projects/<project>/locations/<location>/keyRings/<key-ring>/cryptoKeys/<key>`
      z--instance-kms-keyr
   Nr   rV   s      r   AddInstanceKmsKeyArgr     s*    
( 		  r   N)T)F)0__doc__
__future__r   r   r   googlecloudsdk.callioper   #googlecloudsdk.command_lib.backupdrr   $googlecloudsdk.command_lib.util.apisr   r   r   r   r<   r>   rF   rL   rN   rX   r[   r_   ra   rc   rh   rk   rm   rq   rt   r|   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r   r   <module>r      s    4 &  ' / 4 :,^"<:*Z& ("
" ,20 8,$:8
*2
0r   