
    (                        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K
Jr  SS	KJr  S
 rS r SS\R                   4S jjrS\R                   4S jrS\R                   4S jrS\R                   4S jrS\R                   4S jr SS\R                   4S jjrSS jrS rS r SS jr SS jrS\R                   4S jrS\R                   4S jrS\R                   4S jrg)z@Helpers for flags in commands for Anthos clusters on bare metal.    )absolute_import)division)unicode_literals)arg_parsers)parser_arguments)concepts)cluster_flags)concept_parsersc                  ,    [         R                  " SSS9$ )N	node_poolznode pool of the {resource}.)name	help_text)r    ResourceParameterAttributeConfig     Flib/googlecloudsdk/command_lib/container/bare_metal/node_pool_flags.pyNodePoolAttributeConfigr      s    		2	2"@
 r   c            	          [         R                  " SS[        5       [        R                  " 5       [        R
                  " 5       [         R                  S9$ )NzAgkeonprem.projects.locations.bareMetalClusters.bareMetalNodePoolsr   )resource_namebareMetalNodePoolsIdbareMetalClustersIdlocationsId
projectsId)r   ResourceSpecr   r	   ClusterAttributeConfigLocationAttributeConfig DEFAULT_PROJECT_ATTRIBUTE_CONFIGr   r   r   GetNodePoolResourceSpecr   "   sB    			I24'>>@779::
 r   parserc                     U(       a  SOSn[         R                  R                  U[        5       SR	                  U5      SS9R                  U 5        g)zAdds a resource argument for a Bare Metal node pool.

Args:
  parser: The argparse parser to add the resource arg to.
  verb: str, the verb to describe the resource, such as 'to update'.
  positional: bool, whether the argument is positional or not.
r   z--node-poolznode pool {}T)requiredN)r
   ConceptParserForResourcer   formatAddToParser)r   verb
positionalr   s       r   AddNodePoolResourceArgr(   -   sL     #$++
D!	 , 
 Kr   c                 &    U R                  SSSS9  g)zAdds a flag for the node pool operation to return success and perform no action when there is no matching node pool.

Args:
  parser: The argparse parser to add the flag to.
--allow-missing
store_truezhIf set, and the Bare Metal Node Pool is not found, the request will succeed but no action will be taken.actionhelpNadd_argumentr   s    r   AddAllowMissingNodePoolr2   @   s"     	2	  r   c                 &    U R                  SSSS9  g)aq  Adds a flag to enable allow missing in an update node pool request.

If set to true, and the Bare Metal Node Pool is not found, the request will
create a new Bare Metal Node Pool with the provided configuration. The user
must have both create and update permission to call Update with allow_missing
set to true.

Args:
  parser: The argparse parser to add the flag to.
r*   r+   zIf set, and the Anthos cluster on bare metal is not found, the update request will try to create a new cluster with the provided configuration.r,   Nr/   r1   s    r   AddAllowMissingUpdateNodePoolr4   Q   s"     		  r   c                 .    U R                  S[        SS9  g)zsAdds a flag to specify the display name of the node pool.

Args:
  parser: The argparse parser to add the flag to.
z--display-namezDisplay name for the resource.typer.   N)r0   strr1   s    r   AddNodePoolDisplayNamer9   g   s     	S'G  r   c                 N    U R                  SS[        R                  " 5       SS9  g)z-Adds a flag to specify node pool annotations.z--annotations	KEY=VALUEzAnnotations on the node pool.metavarr7   r.   Nr0   r   ArgDictr1   s    r   AddNodePoolAnnotationsr@   r   s*     *	  r   c                     U(       + nU R                  USS9n[        X15        [        U5        [        U5        [	        X15        g)zAdds a command group to set the node pool config.

Args:
  parser: The argparse parser to add the flag to.
  is_update: bool, whether the flag is for update command or not.
z-Anthos on bare metal node pool configuration.)r!   r.   N)	add_group_AddNodeConfigs_AddNodeLabels_AddNodeTaints_AddBareMetalKubeletConfig)r   	is_updater!   !bare_metal_node_pool_config_groups       r   AddNodePoolConfigrI   |   sM     ](&,&6&6: '7 '# 3?2323>Jr   c           
          U(       + nU R                  SUSS9nSnUR                  SU[        R                  " 5       SS9  UR                  SSS	[        R                  " [
        [
        S
.S/S9S9  g)zAdds flags to set the node configs.

Args:
  bare_metal_node_pool_config_group: The parent group to add the flags to.
  is_update: bool, whether the flag is for update command or not.
z*Populate Bare Metal Node Pool node config.T)r.   r!   mutexa  
Path of the YAML/JSON file that contains the node configs.

Examples:

  nodeConfigs:
  - nodeIP: 10.200.0.10
    labels:
      node1: label1
      node2: label2
  - nodeIP: 10.200.0.11
    labels:
      node3: label3
      node4: label4

List of supported fields in `nodeConfigs`

KEY           | VALUE                     | NOTE
--------------|---------------------------|---------------------------
nodeIP        | string                    | required, mutable
labels        | one or more key-val pairs | optional, mutable

z--node-configs-from-file)r.   r7   hiddenz--node-configsz(Bare Metal Node Pool node configuration.append)node-iplabelsrN   )specrequired_keys)r.   r-   r7   N)rB   r0   r   YAMLFileContentsr?   r8   )rH   rG   r!   node_config_mutex_group%node_pool_configs_from_file_help_texts        r   rC   rC      s     ](=GG7 H 
+'. && 0'')	 '  &&5 #	 ' r   c                 N    U R                  SS[        R                  " 5       SS9  g)zAdds a flag to assign labels to nodes in a node pool.

Args:
  bare_metal_node_pool_config_group: The parent group to add the flags to.
z--node-labelsr;   z(Labels assigned to nodes of a node pool.r<   Nr>   rH   s    r   rD   rD      s,     $00 5	 1 r   c                 N    U R                  SSS[        R                  " 5       S9  g)zAdds a flag to specify the node taint in the node pool.

Args:
  bare_metal_node_pool_config_group: The parent group to add the flags to.
z--node-taintszKEY=VALUE:EFFECTz;Node taint applied to every Kubernetes node in a node pool.)r=   r.   r7   Nr>   rV   s    r   rE   rE      s,     $00 H 	 1 r   c                     U(       a  U R                  SS9nUnOU nUR                  SSSS9  U(       a  UR                  SSSS9  g	g	)
zAdds a flag to specify the enablement of serialize image pulls.

Args:
  bare_metal_kubelet_config_group: The parent group to add the flags to.
  is_update: bool, True to add flags for update command, False to add flags
    for create command.
T)rK   z--disable-serialize-image-pullsr+   zCIf set, prevent the Kubelet from pulling multiple images at a time.r,   z--enable-serialize-image-pullsz=If set, enable the Kubelet to pull multiple images at a time.N)rB   r0   )bare_metal_kubelet_config_grouprG   !serialize_image_pulls_mutex_groupsurfaces       r   _AddDisableSerializeImagePullsr\      sk     '111= & 0G-G	'
O	   (L   r   c                     U R                  S5      nUR                  S[        SS9  UR                  S[        SS9  [        X!S9  g)	zAdds flags to specify the kubelet configurations in the node pool.

Args:
  bare_metal_node_pool_config_group: The parent group to add the flags to.
  is_update: bool, whether the flag is for update command or not.
z:Modifiable kubelet configurations for bare metal machines.z--registry-pull-qpsz#Limit of registry pulls per second.r6   z--registry-burstz{Maximum size of bursty pulls, temporarily allow pulls to burst to this number, while still not exceeding registry_pull_qps.)rG   N)rB   r0   intr\   )rH   rG   rY   s      r   rF   rF     se     %F$O$OB%! "..0 / 
 "..G	 /  !%r   c                 &    U R                  SSSS9  g)z^Adds a flag for ignore_errors field.

Args:
  parser: The argparse parser to add the flag to.
z--ignore-errorszjIf set, the deletion of a Bare Metal Node Pool resource will succeed even if errors occur during deletion.r+   )r.   r-   Nr/   r1   s    r   AddIgnoreErrorsr`   #  s$     	;   r   c                 &    U R                  SSSS9  g)zAdds a flag to only validate the request without performing the operation.

Args:
  parser: The argparse parser to add the flag to.
z--validate-onlyr+   zMIf set, only validate the request, but do not actually perform the operation.r,   Nr/   r1   s    r   AddValidationOnlyrb   3  s"     		  r   c                 $    U R                  SSS9  g)zbAdds a flag for node pool version field.

Args:
  parser: The argparse parser to add the flag to.
z	--versionzGAnthos version for the node pool. Defaults to the user cluster version.)r.   Nr/   r1   s    r   AddNodePoolVersionrd   C  s     	  r   N)T)F)__doc__
__future__r   r   r   googlecloudsdk.callioper   r    googlecloudsdk.calliope.conceptsr   /googlecloudsdk.command_lib.container.bare_metalr	   (googlecloudsdk.command_lib.util.conceptsr
   r   r   ArgumentInterceptorr(   r2   r4   r9   r@   rI   rC   rD   rE   r\   rF   r`   rb   rd   r   r   r   <module>rl      s   G &  ' / 4 5 I D DH00&$4$H$H "*:*N*N ,#3#G#G #3#G#G  =BK00K(5p 05D 27<,@@  .BB  /CC r   