
    H                        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J	r	  SSKJ
r
  SSKJr  SS	KJr  SS
KJr  SSKJr  Sr/ SQrSS jrS rS rS\
R,                  R.                  4S jrS rS rSS jrS rS rS rS rg)z;Flags and helpers for the compute instance groups commands.    )absolute_import)division)unicode_literalsN)arg_parsers)base)
exceptions)
completers)flags)service_proxy_aux_dataz    table(
      name,
      properties.machineType.machine_type(),
      properties.scheduling.preemptible.yesno(yes=true, no=''),
      creationTimestamp
    ))zattach-read-onlyblankcustom-imagezdo-not-includezsource-imagezsource-image-familyFc                 d    [         R                  " S[        R                  U SU(       a  SS9$ S S9$ )Nzinstance templatezcompute.instanceTemplateszcompute.regionInstanceTemplates)resource_name	completerpluralglobal_collectionregional_collection)r
   ResourceArgumentr	   InstanceTemplatesCompleter)r   include_regionals     Blib/googlecloudsdk/command_lib/compute/instance_templates/flags.pyMakeInstanceTemplateArgr   2   s>    			'553. =
; ; 59
; ;    c            	      P    [         R                  " SS[        R                  SSSS9$ )N--source-instanceinstanceFzcompute.instanceszPThe name of the source instance that the instance template will be created from.)namer   r   requiredzonal_collection
short_help)r
   r   r	   InstancesCompleter r   r   MakeSourceInstanceArgr#   <   s/    			--**
, ,r   c                     U R                  S[        R                  " [        R                  " 5       [        [        [        S.S9SSSR                  SR                  [        5      5      S9  g )	N--configure-disk)zauto-deletedevice-nameinstantiate-fromr   )speczPROPERTY=VALUEappenda/      This option has effect only when used with `--source-instance`. It
    allows you to override how the source-instance's disks are defined in
    the template.

    *device-name*::: Name of the device for which the configuration is being
    overridden.

    *auto-delete*::: If `true`, this persistent disk will be automatically
    deleted when the instance is deleted. However, if the disk is
    detached from the instance, this option won't apply. If not provided,
    the setting is copied from the source instance. Allowed values of the
    flag are: `false`, `no`, `true`, and `yes`.

    *instantiate-from*::: Specifies whether to include the disk and which
    image to use. Valid values are: {}

    *custom-image*::: The custom image to use if custom-image is specified
    for instantiate-from.
    z, )typemetavaractionhelp)add_argumentr   ArgDict
ArgBooleanstrformatjoin_INSTANTIATE_FROM_VALUES)parsers    r   AddConfigureDiskArgsr6   G   sc    (335 "%!	 & 	tyy123=  r   c           	      &   U R                  US9nS[        [        [        R                  [        [        S.n[
        R                  " S5      nU[        R                  R                  :X  a1  UR                  S[        S.5        U[
        R                  " S5      -  nU[        R                  R                  :X  d  U[        R                  R                  :X  aE  UR                  S[        [        [        [        [        S.5        U[
        R                  " S5      -  nUR                  S	[        R                  " US
S/S9UUS9  UR                  SS[        R                  " 5       USS9  UR                  SSS
SS9  UR                  S[        S
SS9  g)zBAdds service proxy configuration arguments for instance templates.hiddenN)enabledserving-ports
proxy-porttracingz
access-lognetworka  
  Controls whether the Traffic Director service proxy (Envoy) and agent are
  installed and configured on the VM. "cloud-platform" scope is enabled
  automatically to allow connections to the Traffic Director API. Do not use
  the --no-scopes flag.

  *enabled*::: If specified, the service-proxy software will be installed when
  the instance is created. The instance is configured to work with Traffic
  Director.

  *serving-ports*::: Semi-colon-separated (;) list of the ports, specified
  inside quotation marks ("), on which the customer's application/workload
  is serving.

  For example:

        serving-ports="80;8080"

  The service proxy will intercept inbound traffic, then forward it to the
  specified serving port(s) on localhost. If not provided, no incoming traffic
  is intercepted.

  *proxy-port*::: The port on which the service proxy listens.
  The VM intercepts traffic and redirects it to this port to be handled by the
  service proxy. If omitted, the default value is '15001'.

  *tracing*::: Enables the service proxy to generate distributed tracing
  information. If set to ON, the service proxy's control plane generates a
  configuration that enables request ID-based tracing. For more information,
  refer to the `generate_request_id` documentation for the Envoy proxy. Allowed
  values are `ON` and `OFF`.

  *access-log*::: The filepath for access logs sent to the service proxy by the
  control plane. All incoming and outgoing requests are recorded in this file.
  For more information, refer to the file access log documentation for the Envoy
  proxy.

  *network*::: The name of a valid VPC network. The Google Cloud Platform VPC
  network used by the service proxy's control plane to generate dynamic
  configuration for the service proxy.
  )zintercept-dnssourcea<  
    *intercept-dns*::: Enables interception of UDP traffic by the service proxy.

    *source*::: The Google Cloud Storage bucket location source
    for the Envoy. The service-proxy-agent will download the archive from Envoy
    and install it on the virtual machine, unpacking it into the root (/)
    directory of the virtual machine. Therefore, the archive must contain not
    only the executable and license files but they must be located in the
    correct directories within the archive. For example:
    /usr/local/bin/envoy and /usr/local/doc/envoy-LICENSE
    )intercept-all-outbound-trafficexclude-outbound-ip-rangesexclude-outbound-port-rangesscopemeshzproject-numbera  
    *intercept-all-outbound-traffic*::: Enables interception of all outgoing
    traffic. The traffic is intercepted by the service proxy and then redirected
    to external host.

    *exclude-outbound-ip-ranges*::: Semi-colon-separated (;) list of the IPs or
    CIDRs, specified inside quotation marks ("), that should be excluded from
    redirection. Only applies when `intercept-all-outbound-traffic` flag is set.

    For example:

         exclude-outbound-ip-ranges="8.8.8.8;129.168.10.0/24"

    *exclude-outbound-port-ranges*::: Semi-colon-separated (;) list of the ports
    or port ranges, specified inside quotation marks ("), that should be
    excluded from redirection. Only applies when
    `intercept-all-outbound-traffic` flag is set.

    For example:

         exclude-outbound-port-ranges="81;8080-8090"

    *scope*::: Scope defines a logical configuration boundary for a Gateway
    resource. On VM boot up, the service proxy reaches the Traffic Director to
    retrieve routing information that corresponds to the routes attached to the
    gateway with this scope name. When scope is specified, the network value is
    ignored. You cannot specify `scope` and `mesh` values at the same time.

    *mesh*::: Mesh defines a logical configuration boundary for a Mesh resource.
    On VM boot up, the service proxy reaches the Traffic Director to retrieve
    routing information that corresponds to the routes attached to the mesh with
    this mesh name. When mesh is specified, the network value is ignored. You
    cannot specify `scope` and `mesh` values at the same time.

    *project-number*::: Project number defines the project where Mesh and
    Gateway resources are created. If not specified, the project where the
    instance exists is used.
    --service-proxyTr:   r(   allow_key_onlyrequired_keysr*   r9   r-   z--service-proxy-labelszKEY=VALUE, ...ag        Labels that you can apply to your service proxy. These will be reflected in your Envoy proxy's bootstrap metadata.
      These can be any `key=value` pairs that you want to set as proxy metadata (for example, for use with config filtering).
      You might use these flags for application and version labels: `app=review` and/or `version=canary`.
      )r+   r*   r9   r-   z--service-proxy-agent-locationLOCATIONza      GCS bucket location of service-proxy-agent. Mainly used for testing and development.
      )r+   r9   r-   z--service-proxy-xds-versionz>      xDS version of the service proxy to be installed.
      )	add_groupr1   intr   TracingStatetextwrapdedentr   ReleaseTrackALPHAupdateBETAr.   r   r/   )r5   hide_argumentsrelease_trackservice_proxy_groupservice_proxy_specservice_proxy_helps         r   AddServiceProxyConfigArgsrY   j   s    (((? '44   (( (T d''---  (// 
+ 
	 
	 t((...t((---*.&)(+  (// %+ %	 %	N ""!"%  #  "" 
 # 	 ""&
	 #  ""#
	 # r   c                    [        U SS5      (       Ga*  U R                  (       a  [        R                  " SS5      eSU R                  ;   aQ   [        [        [        U R                  S   R                  S5      5      5      nU H  nUS:  d  US:  d  M  [        e   S
U R                  ;   a#   U R                  S
   nUS:  d  US:  a  [        e SU R                  ;   ae  SU R                  ;  a  [        R                  " SS5      eU R                  S   R                  S5      nU H  n [        R                  " U5        M     SU R                  ;   a  SU R                  ;  a  [        R                  " SS5      eU R                  S   R                  S5      nU He  nUR                  S5      n [        U5      S:X  a  [        US   5        M4  [        U5      S:X  a  [        US   5        [        US   5        Ma  [        e   SU R                  ;   a(  SU R                  ;   a  [        R                  " SS5      eggg! [         a    [        R                  " SS	5      ef = f! [         a    [        R                  " S
S5      ef = f! [         a    [        R                  " SS5      ef = f! [         a    [        R                  " SS5      ef = f)z:Validates the values of all --service-proxy related flags.service_proxyFrE   --no-scopesr;   ;     z;List of ports can only contain numbers between 1 and 65535.r<   i  z.Port value can only be between 1025 and 65535.rA   r@   zWexclude-outbound-ip-ranges parameters requires intercept-all-outbound-traffic to be setz)List of IPs may contain only IPs & CIDRs.rB   zYexclude-outbound-port-ranges parameters requires intercept-all-outbound-traffic to be set-r      zVList of port ranges can only contain numbers between 1 and 65535, i.e. "80;8080-8090".rC   rD   z--service-proxy:scopez--service-proxy:meshN)getattr	no_scopesr   ConflictingArgumentsExceptionr[   listmaprL   split
ValueErrorInvalidArgumentExceptionRequiredArgumentException	ipaddress
ip_networklenValidateSinglePort)	argsserving_portsport
proxy_port	ip_rangesip_rangeport_ranges
port_rangeportss	            r   ValidateServiceProxyFlagsrx     s    T?E**~~ 445F5BD D $,,,KT''8>>sCDF!DAX " t)))L''5

U 2
 !3 $t'9'99	)1C1C	C22,78 	8
 $$%ABHHMi(	;


x
(   &););;	)1C1C	C22,78 	8 

;
<
B
B3
G #*  %	-Z1_uQx(5zQuQx(uQx( $" $$$$43E3E)E445L5KM M *F$U +  K11IK 	KK  L11JL 	LL  	;33*9; ;	;2  	-33,,- -	-sC   AH? H? .!I$ +J	1J.+J.=J.?"I!$"J	"J+."Kc                 >    [        U 5      nUS:  d  US:  a  [        eg )Nr^   r_   )rL   rh   )port_strrq   s     r   rn   rn   X  s#    	X$	AX
 r   c           	          U R                  US9nUR                  S[        R                  " [        [        S.SSS/S9USS	9  g
)zHAdds Anthos Service Mesh configuration arguments for instance templates.r8   --mesh)gke-clusterworkloadFr}   r~   rF   az        Controls whether the Anthos Service Mesh service proxy (Envoy) and agent are installed and configured on the VM.
      "cloud-platform" scope is enabled automatically to allow the service proxy to be started.
      Do not use the `--no-scopes` flag.

      *gke-cluster*::: The location/name of the GKE cluster. The location can be a zone or a
          region, e.g. ``us-central1-a/my-cluster''.

      *workload*::: The workload identifier of the VM. In a GKE cluster, it is
          the identifier namespace/name of the `WorkloadGroup` custom resource representing the VM
          workload, e.g. ``foo/my-workload''.
      rI   N)rK   r.   r   r/   r1   )r5   rT   
mesh_groups      r   AddMeshArgsr   _  s]     ~6*  &
35 
  r   c                    [        U SS5      (       a  U R                  (       a  [        R                  " SS5      eSn [        R
                  " XR                  S   5      (       d  [        e  [        R
                  " XR                  S   5      (       d  [        eg
g
! [         a    [        R                  " SS5      ef = f! [         a    [        R                  " SS	5      ef = f)z(Validates the values of the --mesh flag.rD   Fr|   r\   z
(.*)\/(.*)r}   z7GKE cluster value should have the format location/name.r~   z5Workload value should have the format namespace/name.N)	rb   rc   r   rd   rematchrD   rh   ri   )ro   rgxs     r   ValidateMeshFlagr   {  s     T65!!~~ 44X}MM
CEXXc99]344 5OXXc99Z011 2 "  E//

CE EE  O//
MO OOs   .B ..C "C "C%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-typePOLICYFchoicesr+   r   r-   Nr.   r5   	help_textchoices_texts      r   "AddPostKeyRevocationActionTypeArgsr     s?    H) '4, 	)  r   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.)nonestopz--key-revocation-action-typer   Fr   Nr   r   s      r   AddKeyRevocationActionTypeArgsr     s?    H) +",
 	$  r   c                 $   [        U SS5      (       a  [        U SS5      (       a  [        R                  " SS5      e[        U SS5      (       a  [        R                  " SS5      e[        U SS5      (       a  U R                   H  nS	U;  a  [        R                  " S	S
5      eUR                  S5      nUR                  S5      nU(       a  US:w  a  [        R                  " SS5      eUS:X  d  Mn  Ub  Ms  [        R                  " SS5      e   ggg)z!Validates --source-instance flag.source_instanceFmachine_typer   z--machine-typelabelsz--labelsconfigure_diskr&   z3`--configure-disk` requires `device-name` to be setr'   r   r%   z[Value for `instantiate-from` must be 'custom-image' if the key `custom-image` is specified.NzZValue for 'custom-image' must be specified if `instantiate-from` has value `custom-image`.)rb   r   rd   r   rj   getri   )ro   diskinstantiate_fromcustom_images       r   ValidateSourceInstanceFlagsr     s+    T$e,,t^U++ 445H5EG GtXu%% 445H5?A A t%u--%%$$44CE E  88$67xx/,>33 -. . ~-,2F33 +, , & . -r   )FF)F) __doc__
__future__r   r   r   rk   r   rN   googlecloudsdk.callioper   r   r   "googlecloudsdk.command_lib.computer	   r
   5googlecloudsdk.command_lib.compute.instance_templatesr   DEFAULT_LIST_FORMATr4   r   r#   r6   rP   GArY   rx   rn   r   r   r   r   r   r"   r   r   <module>r      s    B &  '  	  / ( . 9 4 X	  ;, H .3,0,=,=,@,@YxOMd8O2$"!,r   