
    Wf                     $   S 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 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\R(                  S\S\S\S\4
S jjr    S(S\R(                  S\S\S\S\4
S jjr    S)S\R(                  S\S\S\S\4
S j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     S0S jr S#S  jr!     S1S! jr"g)2z&Flag utils for clusters command group.    N)utils)arg_parsers)
exceptions)parser_arguments)
flag_typesc           
          US;  a  [         R                  " SU 35      eU R                  SS[        R                  " [
        R                  " US9SS9UUS9  g	)
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           	          US;  a  [         R                  " SU 35      eU R                  S[        R                  " S5      [
        R                  " [        SS9UUS9  g)	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                     US;  a  [         R                  " SU 35      eU R                  S[        R                  " S5      [
        US9  g)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                    US;  a  [         R                  " SU 35      eSU 3nU(       a  SU 3nU R                  SU 3[        R                  " SU S35      [
        R                  US9  U(       aX  U R                  SU 3[        R                  " S	U S
35      [        R                  " [        S9[        R                  " 5       US9  gg)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   	AddLabelsr8   M   s     #

"
"%>{m#L
MMtf%$=D
4&k??   6 
 
   	 

__ " '' (	 
   c2((*  
 r   c           
          US;  a  [         R                  " SU 35      eU R                  S[        R                  " S5      [
        R                  " [        [        S.S/SS9US	9  g
)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}
      )r5   descriptionr5   Tr   required_keysr   r%   Nr   r'   s      r   AddCreateNetworkr=   r   st    #

"
"%>{m#L
MM?? 
 
         r   c                     US;  a  [         R                  " SU 35      eU R                  S[        R                  " S5      [
        UUS9  g)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                     US;  a  [         R                  " SU 35      eU R                  S[        R                  " S5      [
        UUS9  g)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   AddSubnetSourcerA      sU    #

"
"%>{m#L
MM?? 
 
   
r   c                    US;  a  [         R                  " SU 35      e[        R                  " [        R                  " U5      5      nU(       a  SnU R                  SU 3[        R                  " S5      [        R                  " [        UR                  R                  [        [        UR                  R                  [        S./ SQSSS	9[        R                  " 5       US
9  g)z8Adds a create filestores flag for the given API version.r	   r   zadd-new-filestore-instancesr,   a  
        Parameters to create a filestore instance.

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

        Supported tier values:
        - ZONAL
        - REGIONAL

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

        Defaults:
        - protocol: NFSV3
      )r5   tier
capacityGb	fileshareprotocolr:   )r5   rC   rD   rE   Tr   r<   r   repeatedr/   N)r   r   	api_utilsGetMessagesModuleGetReleaseTrackr   r    r!   r   r   r"   NewFilestoreConfigTierValueValuesEnumintProtocolValueValuesEnumr3   r   r5   r   r   r6   messagess         r   AddCreateFilestoresrR      s     #

"
"%>{m#L
MM(()B)B;)OP((D
4&k?? 
 "   11EE"55MM  D &&(C  "r   c                    US;  a  [         R                  " SU 35      eSnU(       a  SnU R                  SU 3[        R                  " SU S35      [
        R                  " [        S9[
        R                  " 5       US	9  U(       aX  U R                  SU 3[        R                  " S
U S35      [
        R                  " [        S9[
        R                  " 5       US	9  gg)z1Adds a filestores flag for the given API version.r	   r   zremove-filestore-instanceszadd-filestore-instancesr,   zG
        Reference of existing filestore instance.

        For e.g. --z2 locations/{location}/instances/{filestore}
      r-   r/   zc
          Parameters to remove filestore instance config by filestore name.

          For e.g. --ze locations/{location}/instances/{filestore1},locations/{location}/instances/{filestore2},...
        N	r   r   r   r    r!   r   r2   r"   r3   r4   s         r   AddFilestoresrU      s     #

"
"%>{m#L
MM1$D
4&k??   6 
 
 C0&&(  
 

__ " '' (	 
   c2((*  
 r   r   r5   r   r   r6   c                    US;  a  [         R                  " SU 35      e[        R                  " [        R                  " U5      5      nU(       a  SnU R                  SU 3[        R                  " SU S35      [        R                  " [        UR                  R                  [        [        S.S/S	S	S
9[        R                  " 5       US9  g)zJAdds a create Google Cloud Storage buckets flag for the given API version.r	   r   zadd-new-storage-bucketsr,   zQ
        Parameters to create a Google Cloud Storage bucket.

        For e.g. --au   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
      )r5   storageClassenableAutoclass	enableHNSr5   TrG   r/   N)r   r   rI   rJ   rK   r   r    r!   r   r   r"   NewBucketConfigStorageClassValueValuesEnumboolr3   rP   s         r   AddCreateGcsBucketsr]     s     #

"
"%>{m#L
MM(()B)B;)OP($D
4&k??   6 
 &   **FF!%   &&(G  $r   c                    US;  a  [         R                  " SU 35      eSU 3nU(       a  SU 3nU R                  SU 3[        R                  " SU S35      [
        R                  " [        S9[
        R                  " 5       US	9  U(       aX  U R                  SU 3[        R                  " S
U S35      [
        R                  " [        S9[
        R                  " 5       US	9  gg)zCAdds a Google Cloud Storage buckets flag for the given API version.r	   r   zremove-storage-zadd-storage-r,   zP
        Reference of existing Google Cloud Storage bucket.

        For e.g. --z {bucket-path}
      r-   r/   zb
          Parameters to remove Google Cloud Storage bucket by bucket name.

          For e.g. --z! {bucket1},{bucket2},...
        NrT   r4   s         r   AddGcsBucketsr_   7  s	    #

"
"%>{m#L
MM&tf-$ D
4&k??   6 
 
 C0&&(  
 

__ " '' (	 
   c2((*  
 r   c                 .   US;  a  [         R                  " SU 35      eU(       a  SnU R                  SU 3[        R                  " SU S35      [
        R                  " [        [        [        [        S./ SQS	S	S
9[
        R                  " 5       US9  g)z5Adds a create lustres flag for the given API version.r	   r   zadd-new-lustre-instancesr,   zE
        Parameters to create a Lustre instance.

        For e.g. --zd name=locations/{location}/instances/{lustre},capacityGb={lustreSize},filesystem={filesystem}
      )r5   
filesystemrD   r:   )r5   rD   ra   TrG   r/   N)
r   r   r   r    r!   r   r   r"   rN   r3   )r   r5   r   r   r6   s        r   AddCreateLustresrb   ]  s     #

"
"%>{m#L
MM%D
4&k??   6 
 
    	 =
 &&('  r   c                    US;  a  [         R                  " SU 35      eSnU(       a  SnU R                  SU 3[        R                  " SU S35      [
        R                  " [        S9[
        R                  " 5       US	9  U(       aX  U R                  SU 3[        R                  " S
U S35      [
        R                  " [        S9[
        R                  " 5       US	9  gg)z.Adds a lustres flag for the given API version.r	   r   zremove-lustre-instanceszadd-lustre-instancesr,   zD
        Reference of existing Lustre instance.

        For e.g. --z/ locations/{location}/instances/{lustre}
      r-   r/   z]
          Parameters to remove lustre instance config by lustre name.

          For e.g. --z_ locations/{location}/instances/{lustre1},locations/{location}/instances/{lustre2},...
        NrT   r4   s         r   
AddLustresrd     s     #

"
"%>{m#L
MM.!D
4&k??   6 
 
 C0&&(  
 

__ " '' (	 
   c2((*  
 r   c                    US;  a  [         R                  " SU 35      eSU 3nU(       a  SU 3nU R                  SU 3[        R                  " SU S35      [
        R                  " [        [        [        S./ SQS	S	S
9[
        R                  " 5       US9  U(       aX  U R                  SU 3[        R                  " SU S35      [
        R                  " [        S9[
        R                  " 5       US9  gg)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machineTypeTrG   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"   r3   r2   r4   s         r   AddOnDemandInstancesrm     #    #

"
"%>{m#L
MMtf%$=D
4&k??   6 
 
    
 6	 &&(%  ( 

__ " '' (	 
   c2((*  
 r   c                    US;  a  [         R                  " SU 35      eSU 3nU(       a  SU 3nU R                  SU 3[        R                  " SU S35      [
        R                  " [        [        [        S./ SQS	S	S
9[
        R                  " 5       US9  U(       aX  U R                  SU 3[        R                  " SU S35      [
        R                  " [        S9[
        R                  " 5       US9  gg)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   TrG   r/   zZ
          Parameters to remove spot instance config by compute id.

          For e.g. --rk   r-   Nrl   r4   s         r   AddSpotInstancesrp     rn   r   c                    US;  a  [         R                  " SU 35      eSU 3nU(       a  SU 3nU R                  SU 3[        R                  " SU S35      [
        R                  " [        [        [        S./ SQS	S	S
9[
        R                  " 5       US9  U(       aX  U R                  SU 3[        R                  " SU S35      [
        R                  " [        S9[
        R                  " 5       US9  gg)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   TrG   r/   z^
          Parameters to remove reserved instance config by compute id.

          For e.g. --rk   r-   Nrl   r4   s         r   AddReservedInstancesrs     s#    #

"
"%>{m#L
MMtf%$=D
4&k??   6 
 
     
 =	 &&(%  ( 

__ " '' (	 
   c2((*  
 r   c                    US;  a  [         R                  " SU 35      eSU 3nU(       a  SU 3nU R                  SU 3[        R                  " SU S35      [
        R                  " [        [        [        [        S./ SQS	S	S
9[
        R                  " 5       US9  U(       aX  U R                  SU 3[        R                  " SU S35      [
        R                  " [        S9[
        R                  " 5       US9  gg)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   maxDurationTrG   r/   z^
          Parameters to remove DWS Flex instance config by compute id.

          For e.g. --rk   r-   Nrl   r4   s         r   AddDwsFlexInstancesrv   3  s'    #

"
"%>{m#L
MMtf%$=D
4&k??   6 
 
     	 E
 &&('  * 

__ " '' (	 
   c2((*  
 r   c                     US;  a  [         R                  " SU 35      eSU 3nSU 3nU(       a  SU 3nU R                  SU 3[        R                  " SU S35      [
        R                  " [        [        [        [        [
        R                  " 5       [        R                  S	.S
S/SSS9[
        R                  " 5       UUS9  U(       a  U R                  SU 3[        R                  " SU S35      [
        R                  " [        [        [        S.S
/SSS9[
        R                  " 5       UUS9  U R                  SU 3[        R                  " SU S35      [
        R                  " [        S9[
        R                  " 5       UUS9  gg)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   TrG   r   r   r0   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"   rN   r   r1   r3   r2   r   r5   r   r   r   r6   update_flag_namer7   s           r   AddSlurmNodeSetsr   c  s    #

"
"%>{m#L
MMtf%tf%$=D
4&k??   6 

    !$%(*446"(( {+ &&(?   B 

__ " '' (	 
 ""#&'*
  &!	
 ((*'  * 
__ " '' (	 
   c2((*  - r   c                    US;  a  [         R                  " SU 35      eSU 3nSU 3nU(       a  SU 3nU R                  SU 3[        R                  " SU S35      [
        R                  " [        [
        R                  " [        S	S
9[        S.SS/S	S	S9[
        R                  " 5       UUS9  U(       a  U R                  SU 3[        R                  " SU S35      [
        R                  " [        [
        R                  " [        S	S
9[        S.S/S	S	S9[
        R                  " 5       UUS9  U R                  SU 3[        R                  " SU S35      [
        R                  " [        S9[
        R                  " 5       UUS9  gg)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   rH   )rh   
nodesetIds	exclusiverh   r   rG   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\   r3   r2   r   s           r   AddSlurmPartitionsr     s    #

"
"%>{m#L
MMtf%tf%$=D
4&k??   6 
 
   '11 4   |, &&(+  . 

__ " '' (	 
 "")33"T "  &!
 ((*+  . 
__ " '' (	 
   c2((*  1 r   c                     US;  a  [         R                  " SU 35      eU R                  S[        R                  " S5      [
        US9  g)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           
         US;  a  [         R                  " SU 35      eUnU(       a*  SU 3nSU S3n[        [        R                  " 5       S.n/ n	OESn[
        [
        [        [        [        [        R                  " 5       [        R                  S.nS	S
/n	U R                  SU 3[        R                  " U5      [        R                  " UU	SS9UUS9  g)z7Adds a slurm login node flag for the given API version.r	   r   rx   z
        Parameters to update slurm cluster login node.
        Only count and startupScript can be updated.

        For e.g. --z( count=2,startupScript="echo hello"
    )countr|   a7  
        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   r   enableOSLoginenablePublicIPsr|   r}   rj   ri   r,   Tr;   r   N)r   r   rN   r   r   r"   r\   r   r1   r   r    r!   )
r   r5   r   r   r   r6   	flag_name	help_textr   req_keyss
             r   AddSlurmLoginNoder     s     #

"
"%>{m#L
MM)$ I ; 	I $..0D H
I" $..0""D v&H
9+??9%   
   
r   )NFF)NF)r}   NFF)zcreate-filestoresNFF)
filestoresNFF)zcreate-bucketsNFF)bucketsNFF)zcreate-lustresNFF)lustresNFF)zon-demand-instancesNFF)zspot-instancesNFF)zreserved-instancesNFF)zdws-flex-instancesNFF)zslurm-node-setsNFFF)zslurm-partitionsNFFF)zslurm-login-nodeNFFF)#__doc__r    *googlecloudsdk.api_lib.hypercomputeclusterr   rI   googlecloudsdk.callioper   r   r   4googlecloudsdk.command_lib.cluster_director.clustersr   r   r#   r(   r8   r=   r?   rA   rR   rU   ArgumentInterceptorr"   r\   r]   r_   rb   rd   rm   rp   rs   rv   r   r   r   r    r   r   <module>r      s     -  I / . 4 K F "$ 
"J."& 
/h 
#P !!&1001
1 1 	1
 1l !&#00#
# # 	#
 #P !!& 00 
    	 
  J 
#P 
,b 
,b 
,b 
-d 
Ql 
IX$ 
>r   