
    Z                     0   d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	 ddlmZ ddZ
ddZdd	Z	 	 	 	 dd
ZddZddZddZddZddZddZddZddZddZ	 	 	 	 ddZ	 	 	 	 d dZ	 	 	 	 d!dZ	 	 	 	 d"dZ	 	 	 	 	 d#dZ	 	 	 	 	 d$dZddZddZy)%z&Flag utils for clusters command group.    N)utils)arg_parsers)
exceptions)
flag_typesc           	          |dvrt        j                  d|       | j                  ddt        j                  t        j                  |      d      ||       y	)
z-Adds a config flag for the given API version.v1alphaUnsupported API version: z--configz@Configuration of the cluster specs in the form of a JSON object.)api_versionT)specenable_shorthandhelptyperequiredhiddenN)r   ToolExceptionadd_argumentr   	ArgObjectr   GetClusterFlagTypeparserr   r   r   s       Alib/googlecloudsdk/command_lib/cluster_director/clusters/flags.py	AddConfigr      sc    #

"
"%>{m#L
MMM  ''K@   	    c                     |dvrt        j                  d|       | j                  dt        j                  d      t        j                  t        d      ||       y)	z3Adds an update mask flag for the given API version.r   r
   z--update-maskzq
        Update mask to specify the fields to update.

        For e.g. --update-mask "description,labels"
      T)
value_typer   r   Nr   r   r   textwrapdedentr   r   strr   s       r   AddUpdateMaskr"   +   sb    #

"
"%>{m#L
MM?? 
 
   C$G  
r   c                     |dvrt        j                  d|       | j                  dt        j                  d      t
        |       y)z2Adds a description flag for the given API version.r   r
   z--descriptionzY
        Description of the cluster.

        For e.g. --description {description}
      r   r   r   Nr   r   r   r   r    r!   r   r   r   s      r   AddDescriptionr'   <   sR    #

"
"%>{m#L
MM?? 
 
   	r   c                    |dvrt        j                  d|       d| }|rd| }| j                  d| t        j                  d| d      t
        j                  |       |r[| j                  d| t        j                  d	| d
      t        j                  t              t        j                         |       yy)z-Adds a labels flag for the given API version.r   r
   remove-add---z@
        Cluster labels as key value pairs.

        For e.g. --z key1=value1,key2=value2
      r$   zL
          Parameters to remove cluster label by key.

          For e.g. --z {key1},{key2},...
        element_typer   r   actionr   N)r   r   r   r   r    r   LABELr   ArgListr!   FlattenActionr   namer   r   include_update_flagsremove_flag_names         r   	AddLabelsr7   L   s     #

"
"%>{m#L
MMtf%$=D
4&k??   6 
 
   	 

__ " '' (	 
   c2((*  
 r   c           	          |dvrt        j                  d|       | j                  dt        j                  d      t        j                  t        t        ddgd      |	       y
)z5Adds a create network flag for the given API version.r   r
   z--create-networkz{
        Parameters to create a network.

        For e.g. --create-network name={network},description={description}
      )r4   descriptionr4   Tr   required_keysr   r$   Nr   r&   s      r   AddCreateNetworkr<   q   st    #

"
"%>{m#L
MM?? 
 
         r   c                     |dvrt        j                  d|       | j                  dt        j                  d      t
        ||       y)z.Adds a network flag for the given API version.r   r
   z	--networkzY
        Reference of existing network name.

        For e.g. --network {network}
      r   Nr%   r   s       r   AddNetworkSourcer>      sU    #

"
"%>{m#L
MM?? 
 
   
r   c                     |dvrt        j                  d|       | j                  dt        j                  d      t
        ||       y)z-Adds a subnet flag for the given API version.r   r
   z--subnetz{
        Reference of existing subnetwork name.

        For e.g. --subnet regions/{region}/subnetworks/{subnetwork}
      r   Nr%   r   s       r   AddSubnetSourcer@      sU    #

"
"%>{m#L
MM?? 
 
   
r   c                    |dvrt        j                  d|       t        j                  t        j                  |            }| j                  dt        j                  d      t        j                  t        |j                  j                  t        t        |j                  j                  t        dg ddd      t        j                         |	       y
)z8Adds a create filestores flag for the given API version.r   r
   z--create-filestoresa	  
        Parameters to create a filestore instance.

        For e.g. --create-filestores name=locations/{location}/instances/{filestore},tier=BASIC_HDD,capacityGb={filestoreSize},fileshare={fileshare}

        Supported tier values:
        - BASIC_HDD
        - BASIC_SSD
        - HIGH_SCALE_SSD
        - ZONAL
        - ENTERPRISE
        - REGIONAL

        Supported protocol values:
        - NFSV3
        - NFSV41
        - If not specified, defaults to NFSV3

        Defaults:
        - protocol: NFSV3
      )r4   tier
capacityGb	fileshareprotocolr9   )r4   rB   rC   rD   Tr   r;   r   repeatedr.   N)r   r   	api_utilsGetMessagesModuleGetReleaseTrackr   r   r    r   r   r!   NewFilestoreConfigTierValueValuesEnumintProtocolValueValuesEnumr2   r   r   r   messagess       r   AddCreateFilestoresrQ      s    #

"
"%>{m#L
MM(()B)B;)OP(?? 
 *   11EE"55MM  D &&(K  &r   c                     |dvrt        j                  d|       | j                  dt        j                  d      t        j                  t              t        j                         |       y)z1Adds a filestores flag for the given API version.r   r
   z--filestoresz
        Reference of existing filestore instance.

        For e.g. --filestores locations/{location}/instances/{filestore}
      r,   r.   N	r   r   r   r   r    r   r1   r!   r2   r&   s      r   AddFilestoresrT      si    #

"
"%>{m#L
MM?? 
 
 C0&&(  
r   c                 |   |dvrt        j                  d|       t        j                  t        j                  |            }| j                  dt        j                  d      t        j                  t        |j                  j                  t        t        ddgdd      t        j                         |	       y
)zJAdds a create Google Cloud Storage buckets flag for the given API version.r   r
   z--create-bucketsa  
        Parameters to create a Google Cloud Storage bucket.

        For e.g. --create-buckets name={bucket-path}

        Supported storageClass values:
        - STANDARD
        - NEARLINE
        - COLDLINE
        - ARCHIVE

        Defaults:
        - storageClass: STANDARD

        Note:
        - Either storageClass or enableAutoclass can be set.
        - if enableAutoclass is set, enableHNS should not be set.
        - HNS: Hierarchical namespace
      )r4   storageClassenableAutoclass	enableHNSr4   TrF   r.   N)r   r   rH   rI   rJ   r   r   r    r   r   r!   NewBucketConfigStorageClassValueValuesEnumboolr2   rO   s       r   AddCreateGcsBucketsr\      s    #

"
"%>{m#L
MM(()B)B;)OP(?? 
 &   **FF!%   &&(G  $r   c                     |dvrt        j                  d|       | j                  dt        j                  d      t        j                  t              t        j                         |       y)zCAdds a Google Cloud Storage buckets flag for the given API version.r   r
   z	--bucketszl
        Reference of existing Google Cloud Storage bucket.

        For e.g. --buckets {bucket-path}
      r,   r.   NrS   r&   s      r   AddGcsBucketsr^     i    #

"
"%>{m#L
MM?? 
 
 C0&&(  
r   c                    |dvrt        j                  d|       | j                  dt        j                  d      t        j                  t        t        t        t        dg ddd      t        j                         |	       y
)z5Adds a create lustres flag for the given API version.r   r
   z--create-lustresz
        Parameters to create a Lustre instance.

        For e.g. --create-lustres name=locations/{location}/instances/{lustre},capacityGb={lustreSize},filesystem={filesystem}
      )r4   
filesystemrC   r9   )r4   rC   ra   TrF   r.   N)
r   r   r   r   r    r   r   r!   rM   r2   r&   s      r   AddCreateLustresrb   &  s    #

"
"%>{m#L
MM?? 
 
    	 =
 &&('  r   c                     |dvrt        j                  d|       | j                  dt        j                  d      t        j                  t              t        j                         |       y)z.Adds a lustres flag for the given API version.r   r
   z	--lustreszz
        Reference of existing Lustre instance.

        For e.g. --lustres locations/{location}/instances/{lustre}
      r,   r.   NrS   r&   s      r   
AddLustresrd   A  r_   r   c           
         |dvrt        j                  d|       d| }|rd| }| j                  d| t        j                  d| d      t        j                  t        t        t        dg dd	d	
      t        j                         |       |r[| j                  d| t        j                  d| d      t        j                  t              t        j                         |       yy)z;Adds an on demand instances flag for the given API version.r   r
   r)   r*   r+   zO
        Parameters to define cluster on demand instances.

        For e.g. --< id={computeId},zone={zone},machineType={machineType}
      idzonemachineTypeTrF   r.   z`
          Parameters to remove on demand instances config by compute id.

          For e.g. --' {computeId1},{computeId2},...
        r,   N
r   r   r   r   r    r   r   r!   r2   r1   r3   s         r   AddOnDemandInstancesrm   R  #    #

"
"%>{m#L
MMtf%$=D
4&k??   6 
 
    
 6	 &&(%  ( 

__ " '' (	 
   c2((*  
 r   c           
         |dvrt        j                  d|       d| }|rd| }| j                  d| t        j                  d| d      t        j                  t        t        t        dg dd	d	
      t        j                         |       |r[| j                  d| t        j                  d| d      t        j                  t              t        j                         |       yy)z6Adds an spot instances flag for the given API version.r   r
   r)   r*   r+   zJ
        Parameters to define cluster spot instances.

        For e.g. --rf   rg   TrF   r.   zZ
          Parameters to remove spot instance config by compute id.

          For e.g. --rk   r,   Nrl   r3   s         r   AddSpotInstancesrp     rn   r   c           
         |dvrt        j                  d|       d| }|rd| }| j                  d| t        j                  d| d      t        j                  t        t        t        dg dd	d	
      t        j                         |       |r[| j                  d| t        j                  d| d      t        j                  t              t        j                         |       yy)z:Adds an reserved instances flag for the given API version.r   r
   r)   r*   r+   zN
        Parameters to define cluster reserved instances.

        For e.g. --zd id={computeId},reservation=zones/{zone}/reservations/{reservation},machineType={machineType}
      )rh   reservationrj   TrF   r.   z^
          Parameters to remove reserved instance config by compute id.

          For e.g. --rk   r,   Nrl   r3   s         r   AddReservedInstancesrs     s#    #

"
"%>{m#L
MMtf%$=D
4&k??   6 
 
     
 =	 &&(%  ( 

__ " '' (	 
   c2((*  
 r   c                    |dvrt        j                  d|       d| }|rd| }| j                  d| t        j                  d| d      t        j                  t        t        t        t        dg dd	d	
      t        j                         |       |r[| j                  d| t        j                  d| d      t        j                  t              t        j                         |       yy)z:Adds an DWS Flex instances flag for the given API version.r   r
   r)   r*   r+   zN
        Parameters to define cluster DWS Flex instances.

        For e.g. --zO id={computeId},zone={zone},machineType={machineType},maxDuration=10000s
      )rh   ri   rj   maxDurationTrF   r.   z^
          Parameters to remove DWS Flex instance config by compute id.

          For e.g. --rk   r,   Nrl   r3   s         r   AddDwsFlexInstancesrv     s'    #

"
"%>{m#L
MMtf%$=D
4&k??   6 
 
     	 E
 &&('  * 

__ " '' (	 
   c2((*  
 r   c                    |dvrt        j                  d|       d| }d| }|rd| }| j                  d| t        j                  d| d      t        j                  t        t        t        t        t        j                         t        j                  d	d
dgdd      t        j                         ||       |r| j                  d| t        j                  d| d      t        j                  t        t        t        dd
gdd      t        j                         ||       | j                  d| t        j                  d| d      t        j                  t              t        j                         ||       yy)z6Adds a slurm node sets flag for the given API version.r   r
   update-r)   r*   r+   zP
        Parameters to define slurm cluster nodeset config.

        For e.g. --a   id={nodesetId},computeId={computeId},staticNodeCount={staticNodeCount},maxDynamicNodeCount={maxDynamicNodeCount},startupScript="echo hello",labels="{key1=value1,key2=value2}"

        Defaults:
        - staticNodeCount: 1

        Note:
        - startupScript:
          - Either str or file_path
          - For file_path, only bash file format (.sh or .bash) is supported.
          - For file_path, only absolute path is supported.
      )rh   	computeIdstaticNodeCountmaxDynamicNodeCountstartupScriptlabelsrh   ry   TrF   r   r   r/   r   r   z_
          Parameters to define and update slurm cluster nodeset config.

          For e.g. --zd id={nodesetId},staticNodeCount={staticNodeCount},maxDynamicNodeCount={maxDynamicNodeCount}
        )rh   rz   r{   zZ
          Parameters to remove slurm nodeset config by nodeset id.

          For e.g. --z' {nodesetId1},{nodesetId2},...
        r,   N)r   r   r   r   r    r   r   r!   rM   r   r0   r2   r1   r   r4   r   r   r   r5   update_flag_namer6   s           r   AddSlurmNodeSetsr     s    #

"
"%>{m#L
MMtf%tf%$=D
4&k??   6 

    !$%(*446"(( {+ &&(?   B 

__ " '' (	 
 ""#&'*
  &!	
 ((*'  * 
__ " '' (	 
   c2((*  - r   c                    |dvrt        j                  d|       d| }d| }|rd| }| j                  d| t        j                  d| d      t        j                  t        t        j                  t        d	
      t        dddgd	d	      t        j                         ||       |r| j                  d| t        j                  d| d      t        j                  t        t        j                  t        d	
      t        ddgd	d	      t        j                         ||       | j                  d| t        j                  d| d      t        j                  t              t        j                         ||       yy)z7Adds a slurm partitions flag for the given API version.r   r
   rx   r)   r*   r+   zL
        Parameters to define slurm cluster partitions.

        For e.g. --zO id={partitionId},nodesetIds=[{nodesetId1},{nodesetId2}],exclusive=false
      T)r   rG   )rh   
nodesetIds	exclusiverh   r   rF   r~   za
          Parameters to define and update slurm cluster partition config.

          For e.g. --zQ id={partitionId},nodesetIds=[{nodesetId1},{nodesetId2}],exclusive=false
        z^
          Parameters to remove slurm partition config by partition id.

          For e.g. --z+ {partitionId1},{partitionId2},...
        r,   N)r   r   r   r   r    r   r   r!   r[   r2   r1   r   s           r   AddSlurmPartitionsr   c  s    #

"
"%>{m#L
MMtf%tf%$=D
4&k??   6 
 
   '11 4   |, &&(+  . 

__ " '' (	 
 "")33"T "  &!
 ((*+  . 
__ " '' (	 
   c2((*  1 r   c                     |dvrt        j                  d|       | j                  dt        j                  d      t
        |       y)z>Adds a slurm default partition flag for the given API version.r   r
   z--slurm-default-partitionz
        Parameters to define slurm cluster default partition.

        For e.g. --slurm-default-partition {partitionId}
      r$   Nr%   r&   s      r   AddSlurmDefaultPartitionr     sR    #

"
"%>{m#L
MM!?? 
 
   	r   c                 6   |dvrt        j                  d|       | j                  dt        j                  d      t        j                  t        t        t        t        t        t        j                         t        j                  dddgd	      ||
       y)z7Adds a slurm login node flag for the given API version.r   r
   z--slurm-login-nodea7  
        Parameters to define slurm cluster login node.

        For e.g. --slurm-login-node machineType={machineType},zone={zone},count={count},enableOSLogin=true,enablePublicIPs=true,startupScript="echo hello",labels="{key1=value1,key2=value2}"

        Defaults:
        - count: 1
        - enableOSLogin: true
        - enablePublicIPs: true

        Note:
        - startupScript:
          - Either str or file_path
          - For file_path, only bash file format (.sh or .bash) is supported.
          - For file_path, only absolute path is supported.
      )rj   ri   countenableOSLoginenablePublicIPsr|   r}   rj   ri   Tr:   r   N)r   r   r   r   r    r   r   r!   rM   r[   r   r0   r   s       r   AddSlurmLoginNoder     s    #

"
"%>{m#L
MM?? 
      #!%*446"(( '/ A  !r   )NFF)NF)r}   NFF)zon-demand-instancesNFF)zspot-instancesNFF)zreserved-instancesNFF)zdws-flex-instancesNFF)zslurm-node-setsNFFF)zslurm-partitionsNFFF)__doc__r   *googlecloudsdk.api_lib.hypercomputeclusterr   rH   googlecloudsdk.callioper   r   4googlecloudsdk.command_lib.cluster_director.clustersr   r   r"   r'   r7   r<   r>   r@   rQ   rT   r\   r^   rb   rd   rm   rp   rs   rv   r   r   r   r    r   r   <module>r      s     -  I / . K F "$ 
"J.""+\")X"6& 
,b 
,b 
,b 
-d 
Ql 
IX %r   