
                            d Z ddlmZ ddlmZ ddlm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lmZ ddlmZ ddlmZ d Zd Zdej*                  fdZd Zd Z	 	 	 dedej*                  fdZd Zd Z	 	 	 dedej*                  fdZdej*                  fdZdej*                  fdZdej*                  fdZdej*                  fdZ dej*                  fdZ!dej*                  fdZ"dfdej*                  fdZ#	 dfdZ$d  Z%dfd!Z&	 dfdej*                  fd"Z'dfd#Z(dfd$Z)d% Z*d& Z+d' Z,dfd(Z-dfd)Z.dfd*Z/dfd+Z0dfd,Z1	 dfd-Z2	 dfdej*                  fd.Z3d/ Z4d0 Z5d1 Z6dej*                  fd2Z7dfd3Z8d4 Z9d5 Z:	 dfd6Z;	 dfd7Z<d8 Z=	 dfdej*                  fd9Z>dej*                  fd:Z?dej*                  fd;Z@d< ZAd= ZBdej*                  fd>ZCdej*                  fd?ZD	 dfdej*                  fd@ZEdA ZFdB ZGdej*                  fdCZHdfdDZI	 dfdej*                  fdEZJdej*                  fdFZKdG ZLdej*                  fdHZMdI ZNdJ ZOdK ZPdL ZQ	 dgdej*                  fdMZR	 dfdej*                  fdNZSdO ZTdP ZUdQ ZVdej*                  fdRZWdej*                  fdSZXdfdTZYdfdUZZdfdVZ[dfdWZ\dfdXZ]dY Z^dZ Z_	 dfd[Z`	 dfd\Za	 dfd]Zbdfd^Zc	 dfd_Zddfd`Zedej*                  fdaZfdej*                  fdbZgdej*                  dcdfddZhy)hz@Helpers for flags in commands for Anthos clusters on bare metal.    )absolute_import)division)unicode_literalsN)arg_parsers)parser_arguments)concepts)deps)flags)concept_parsers)presentation_specs)
propertiesc                      t        j                  ddt        j                  t        j
                  j                  j                        g      S )z.Gets Google Cloud location resource attribute.location)Google Cloud location for the {resource}.)name	help_textfallthroughs)r    ResourceParameterAttributeConfigr	   PropertyFallthroughr   VALUEScontainer_bare_metalr        Dlib/googlecloudsdk/command_lib/container/bare_metal/cluster_flags.pyLocationAttributeConfigr   !   sC    		2	2;

"
"44==
 r   c                  `    t        j                  ddt         j                  t                     S )z?Constructs and returns the Resource specification for Location.zgkeonprem.projects.locationsr   )resource_name
projectsIdlocationsId)r   ResourceSpec DEFAULT_PROJECT_ATTRIBUTE_CONFIGr   r   r   r   GetLocationResourceSpecr"   .   s*    			$::)+	
 r   parserc                     t         j                  j                  dt               dj	                  |      d      j                  |        y)zAdds a resource argument for Google Cloud location.

  Args:
    parser: The argparse.parser to add the resource arg to.
    verb: str, the verb to describe the resource, such as 'to update'.
  
--locationzGoogle Cloud location {}.TrequiredN)r   ConceptParserForResourcer"   formatAddToParserr#   verbs     r   AddLocationResourceArgr.   8   sC     ++!((.	 , 
 Kr   c                  0    t        j                  dd      S )Nclustercluster of the {resource}.r   r   r   r   r   r   r   ClusterAttributeConfigr4   G   s    		2	2,
 r   c                  r    t        j                  ddt               t               t         j                        S )Nz.gkeonprem.projects.locations.bareMetalClustersr0   )r   bareMetalClustersIdr   r   )r   r    r4   r   r!   r   r   r   GetClusterResourceSpecr7   N   s0    			602)+::
 r   c                     |rdnd}t         j                  j                  |t               dj	                  |      ||      j                  |        y)a  Adds a resource argument for an Anthos cluster on Bare Metal.

  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.
    required: bool, whether the argument is required or not.
    flag_name_overrides: {str: str}, dict of attribute names to the desired flag
      name.
  r0   	--clusterz
cluster {}r'   flag_name_overridesN)r   r(   r)   r7   r*   r+   r#   r-   
positionalr'   r;   r   s         r   AddClusterResourceArgr>   X   sO    " !k$++
$- ,  Kr   c                  0    t        j                  dd      S )Nadmin_clusterr1   r2   r3   r   r   r   AdminClusterAttributeConfigrA   s   s    		2	2,
 r   c                  r    t        j                  ddt               t               t         j                        S )Nz3gkeonprem.projects.locations.bareMetalAdminClustersr@   )r   bareMetalAdminClustersIdr   r   )r   r    rA   r   r!   r   r   r   GetAdminClusterResourceSpecrD   z   s0    			;#:<)+::
 r   c                     |rdnd}t         j                  j                  |t               dj	                  |      ||      j                  |        y)a  Adds a resource argument for an Anthos on bare metal admin cluster.

  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.
    required: bool, whether the argument is required or not.
    flag_name_overrides: {str: str}, dict of attribute names to the desired flag
      name.
  r@   --admin-clusterzadmin cluster {}r:   N)r   r(   r)   rD   r*   r+   r<   s         r   AddAdminClusterResourceArgrG      sP    " ',=$++
!#%- ,  Kr   c                 ,    | j                  ddd       y)zAdds a flag for force cluster operation when there are existing node pools.

  Args:
    parser: The argparse parser to add the flag to.
  z--force
store_truezIf set, the operation will also apply to the child node pools. This flag is required if the cluster has any associated node pools.actionhelpNadd_argumentr#   s    r   AddForceClusterrP      s#     	L	  r   c                 ,    | j                  ddd       y)zAdds a flag for the cluster operation to return success and perform no action when there is no matching cluster.

  Args:
    parser: The argparse parser to add the flag to.
  --allow-missingrI   zfIf set, and the Bare Metal cluster is not found, the request will succeed but no action will be taken.rJ   NrM   rO   s    r   AddAllowMissingClusterrS      s"     	2	  r   c                 ,    | j                  ddd       y)ac  Adds a flag to enable allow missing in an update cluster request.

  If set to true, and the cluster is not found, the request will
  create a new cluster 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.
  rR   rI   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.rJ   NrM   rO   s    r   AddAllowMissingUpdateClusterrU      s"     		  r   c                 ,    | j                  ddd       y)zAdds a flag to only validate the request without performing the operation.

  Args:
    parser: The argparse parser to add the flag to.
  z--validate-onlyrI   zMIf set, only validate the request, but do not actually perform the operation.rJ   NrM   rO   s    r   AddValidationOnlyrW      s"     		  r   c                    | j                  dd      }|j                  d      }|j                  d      }d}t        j                  t        j                  dt        j                         |dd	d
d|      t        j                  dt               ddddi|      gddgi      }|j                  |        | j                  d       y)zjAdds flags to specify version config type.

  Args:
    parser: The argparse parser to add the flag to.
   Use cases for querying versions.Tmutexz5Create an Anthos on bare metal user cluster use case.6Upgrade an Anthos on bare metal user cluster use case.a  membership of the admin cluster to query versions for create. Membership name is the same as the admin cluster name.

Examples:

  $ {command}
        --admin-cluster-membership=projects/example-project-12345/locations/us-west1/memberships/example-admin-cluster-name

or

  $ {command}
        --admin-cluster-membership-project=example-project-12345
        --admin-cluster-membership-location=us-west1
        --admin-cluster-membership=example-admin-cluster-name

  --admin-cluster-membership"--admin-cluster-membership-project#--admin-cluster-membership-locationprojectr   Fr;   r'   groupr9   z&Cluster to query versions for upgrade.r    )r'   r;   rc   z--cluster.locationr%   command_level_fallthroughsglobal)!admin_cluster_membership_locationN)
	add_groupr   r(   r   ResourcePresentationSpecr
   %GetAdminClusterMembershipResourceSpecr7   r+   set_defaults)r#   config_type_groupcreate_configupgrade_config"admin_cluster_membership_help_text
arg_parsers         r   AddConfigTyperr      s     &&( '  $--=- %..>.($  ,,

5
5*99;0AC# !
 
5
5$&6#-r"2", "-*4  Ar   c           
          | j                  dd      }|j                  d      }t        j                  t        j                  dt               dddid	|
      gddgi      }|j                  |        y)zxAdds flags to specify admin cluster version config type.

  Args:
    parser: The argparse parser to add the flag to.
  rY   TrZ   r\   rF   z,Admin cluster to query versions for upgrade.r   rd   Frb   z--admin-cluster.locationr%   re   N)ri   r   r(   r   rj   rD   r+   )r#   rm   ro   rq   s       r   AddAdminConfigTypert   "  s     &&( '  %..>. ,,

5
5)+<#-r"2"	 %|n"*  r   c                 2    | }| j                  d|d       y)zAdds a flag to specify the Anthos cluster on bare metal version.

  Args:
    parser: The argparse parser to add the flag to.
    is_update: bool, whether the flag is for update command or not.
  z	--versionzCAnthos cluster on bare metal version for the user cluster resource.r'   rL   NrM   )r#   	is_updater'   s      r   
AddVersionrx   @  s'     ](
O	  r   c                 ^    | }| j                  dd|t        j                  d      d       y)zAdds a flag to specify the IPv4 address ranges used in the services in the cluster.

  Args:
    bare_metal_island_mode_cidr_config_group: The parent group to add the flag
      to.
    is_update: bool, whether the flag is for update command or not.
  z)--island-mode-service-address-cidr-blocksSERVICE_ADDRESS   
min_lengthz3IPv4 address range for all services in the cluster.metavarr'   typerL   NrN   r   ArgList)(bare_metal_island_mode_cidr_config_grouprw   r'   s      r   _AddServiceAddressCIDRBlocksr   Q  s>     ](*771 A 8 r   c                 X    | j                  dddt        j                  d      d       y)	zAdds a flag to specify the IPv4 address ranges used in the pods in the cluster.

  Args:
    bare_metal_island_mode_cidr_config_group: The parent group to add the flag
      to.
  z%--island-mode-pod-address-cidr-blocksPOD_ADDRESSTr{   r|   z/IPv4 address range for all pods in the cluster.r~   Nr   )r   s    r   _AddPodAddressCIDRBlocksr   g  s6     +77- = 8 r   c                 z    | }| j                  d      }|rt        ||       t        |       yt        ||       y)zAdds island mode CIDR config related flags.

  Args:
    bare_metal_network_config_group: The parent group to add the flag to.
    is_update: bool, whether the flag is for update command or not.
  z'Island mode CIDR network configuration.rL   N)ri   r   r   )bare_metal_network_config_grouprw   r'   r   s       r   _AddIslandModeCIDRConfigr   y  sP     ](%//8 0  +  0) EF 0)r   c                     | }| j                  d      }|s|j                  ddd       t        ||       t        ||       |j                  d|d	      }t	        ||       y
)zAdds network config related flags.

  Args:
    parser: The argparse parser to add the flag to.
    is_update: bool, whether the flag is for update command or not.
  z4Anthos on bare metal cluster network configurations.r   z--enable-advanced-networkingrI   zzEnables the use of advanced Anthos networking features, such as Bundled Load Balancing with BGP or the egress NAT gateway.rJ   Tz$Populate one of the network configs.r[   r'   rL   N)ri   rN   _AddEnableMultiNICConfig_AddEnableSrIovConfigr   )r#   rw   r'   r   cluster_cidr_config_mutex_groups        r   AddNetworkConfigr     s     ]($*$4$4A %5 %! 
#00&J	 1  :IF7C$C$M$M1 %N %!
 :IFr   c                 V    |ry | j                  d      }|j                  ddd       y )Nz6Multiple networking interfaces cluster configurations.r   z--enable-multi-nic-configrI   z9If set, enable multiple network interfaces for your pods.rJ   ri   rN   )r   rw   multi_nic_config_groups      r   r   r     s@    :DDC E  %%!F & r   c                     | j                  d      }|r|j                  d      }|}n|}|j                  ddd       |r|j                  d	dd
       yy)zAdds a flag to specify the enablement of SR-IOV Config.

  Args:
    bare_metal_network_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.
  z*SR-IOV networking operator configurations.r   TrZ   z--enable-sr-iov-configrI   z$If set, install the SR-IOV operator.rJ   z--disable-sr-iov-configz/If set, the SR-IOV operator won't be installed.Nr   )r   rw   sr_iov_config_groupsr_iov_config_mutex_groupsurfaces        r   r   r     s     8AA7 B   3 = =D = I'G!G	1  
 !>   r   c           
          | j                  dd      }d}|j                  d|t        j                         d       |j                  ddd	t        j                  t
        t
        d
dg             y)zAdds flags to set the Metal LB node config.

  Args:
    bare_metal_metal_lb_node_config: The parent group to add the flag to.
  z+Populate MetalLB load balancer node config.T)rL   r[   a  
Path of the YAML/JSON file that contains the Metal LB 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/--metal-lb-load-balancer-node-configs-from-filerL   r   hiddenz%--metal-lb-load-balancer-node-configsz)MetalLB load balancer node configuration.appendnode-iplabelsr   specrequired_keysrL   rK   r   Nri   rN   r   YAMLFileContentsArgDictstr)bare_metal_metal_lb_node_confignode_config_mutex_group)metal_lb_node_configs_from_file_help_texts      r   _AddMetalLBNodeConfigsr     s     <EE8 F /+. &&74'')	 '  &&-6 #	 ' r   c                 R    | j                  ddt        j                         d       y)zAdds a flag to assign labels to nodes in a MetalLB node pool.

  Args:
    bare_metal_metal_lb_node_config: The parent group to add the flags to.
  z$--metal-lb-load-balancer-node-labels	KEY=VALUEz0Labels assigned to nodes of a MetalLB node pool.r   r   rL   NrN   r   r   r   s    r   _AddMetalLBNodeLabelsr     s,     ".., =	 / r   c                 R    | j                  dddt        j                                y)zAdds a flag to specify the node taint in the MetalLBnode pool.

  Args:
   bare_metal_metal_lb_node_config: The parent group to add the flags to.
  z$--metal-lb-load-balancer-node-taintsKEY=VALUE:EFFECTz8Node taint applied to every node in a MetalLB node pool.r   rL   r   Nr   r   s    r   _AddMetalLBNodeTaintsr   #  s,     ".., E 	 / r   c                     | j                  d      }|j                  d      }t        |       t        |       t        |       t	        ||       y)zAdds a command group to set the node pool config for MetalLB load balancer.

  Args:
   metal_lb_config_group: The argparse parser to add the flag to.
    is_update: bool, whether the flag is for update command or not.
  zMAnthos on bare metal node pool configuration for MetalLB load balancer nodes.r   z MetalLB Node Pool configuration.rw   N)ri   r   r   r   _AddMetalLBKubeletConfig)metal_lb_config_grouprw   *bare_metal_metal_lb_node_pool_config_groupr   s       r   _AddMetalLBNodePoolConfigr   1  sf     0E/N/N 0O 0, 1::1 ;  " 897878:iPr   c                 b   | }| j                  dd|      }d}d}|j                  d|t        j                         d       |j                  d|d	t        j                  t
        t        j                         t        j                         t        j                  d
      dddg             y)zAdds flags for address pools used by Metal LB load balancer.

  Args:
    metal_lb_config_group: The parent group to add the flags to.
    is_update: bool, whether the flag is for update command or not.
  z$MetalLB address pools configuration.T)rL   r[   r'   a  
Path of the YAML/JSON file that contains the MetalLB address pools.

Examples:

  addressPools:
  - pool: pool-1
    addresses:
    - 10.200.0.14/32
    - 10.200.0.15/32
    avoidBuggyIPs: True
    manualAssign: True
  - pool: pool-2
    addresses:
    - 10.200.0.16/32
    avoidBuggyIPs: False
    manualAssign: False

List of supported fields in `addressPools`

KEY           | VALUE                 | NOTE
--------------|-----------------------|---------------------------
pool          | string                | required, mutable
addresses     | one or more IP ranges | required, mutable
avoidBuggyIPs | bool                  | optional, mutable, defaults to False
manualAssign  | bool                  | optional, mutable, defaults to False

a  
MetalLB load balancer configurations.

Examples:

To specify MetalLB load balancer configurations for two address pools `pool1` and `pool2`,

```
$ {command} example_cluster
      --metal-lb-address-pools 'pool=pool1,avoid-buggy-ips=True,manual-assign=True,addresses=192.168.1.1/32;192.168.1.2-192.168.1.3'
      --metal-lb-address-pools 'pool=pool2,avoid-buggy-ips=False,manual-assign=False,addresses=192.168.2.1/32;192.168.2.2-192.168.2.3'
```

Use quote around the flag value to escape semicolon in the terminal.
z"--metal-lb-address-pools-from-filer   z--metal-lb-address-poolsr   ;custom_delim_charpoolzavoid-buggy-ipszmanual-assign	addressesr   r   r   r   N)ri   rN   r   r   r   r   
ArgBooleanr   )r   rw   r'   "metal_lb_address_pools_mutex_group*metal_lb_address_pools_from_file_help_text metal_lb_address_pools_help_texts         r   _AddMetalLBAddressPoolsr   J  s     ]('<'F'F1 (G ($
0,:&" %11*5'')	 2  %11 +!,!7!7!9*557&..E	  -	 2 r   c                 X    | j                  d      }t        ||       t        ||       y)zAdds flags for metalLB load balancer.

  Args:
    lb_config_mutex_group: The parent mutex group to add the flags to.
    is_update: bool, whether the flag is for update command or not.
  z$MetalLB load balancer configuration.r   N)ri   r   r   )lb_config_mutex_grouprw   r   s      r   _AddMetalLBConfigr     s0     099, /;1YGr   c                 X    |ry| j                  d      }|j                  dddd       y)	zAdds flags for manual load balancer.

  Args:
    lb_config_mutex_group: The parent mutex group to add the flags to.
    is_update: bool, whether the flag is for update command or not.
  N#Manual load balancer configuration.r   --enable-manual-lbTrI   ,ManualLB typed load balancers configuration.r'   rK   rL   r   )r   rw   manual_lb_config_groups      r   _AddManualLBConfigr     sD     0::0 ;  %%9	 & r   c                     |ry| j                  dd      }|j                  ddd       |j                  ddd	       y)
zAdds flags to set VIPs used by the load balancer.

  Args:
    bare_metal_load_balancer_config_group: The parent group to add the flags to.
    is_update: bool, whether the flag is for update command or not.
  Nz  VIPs used by the load balancer.TrL   r'   --control-plane-vip+VIP for the Kubernetes API of this cluster.rv   z--ingress-vipz*VIP for ingress traffic into this cluster.r   )%bare_metal_load_balancer_config_grouprw   bare_metal_vip_config_groups      r   _AddVIPConfigr     sc      E O O- !P ! **8 + 
 **7 + r   c                 b    |ry| j                  dd      }|j                  dddt               y)zAdds flags to set port for load balancer.

  Args:
    bare_metal_load_balancer_config_group: The parent group to add the flags to.
    is_update: bool, whether the flag is for update command or not.
  N/Control plane load balancer port configuration.Tr   "--control-plane-load-balancer-portr'   rL   r   ri   rN   int)r   rw   -control_plane_load_balancer_port_config_groups      r   _AddLoadBalancerPortConfigr     sK      ,55@ 6  0 0<<*<	 = r   c                     | }| j                  d|      }|j                  d|d      }t        ||       t        ||       t        ||       t	        ||       t        ||       y)Adds a command group to set the load balancer config.

  Args:
    parser: The argparse parser to add the flag to.
    is_update: bool, whether the flag is for update command or not.
  z9Anthos on bare metal cluster load balancer configuration.r   Tz#Populate one of the load balancers.r   N)ri   r   _AddBGPLBConfigr   r   r   )r#   rw   r'   r   r   s        r   AddLoadBalancerConfigr     s     ](*0*:*:F +; +'
 @II0 J  )95'35yABIN*I6r   c                 z    | j                  dd      }|j                  ddd       |j                  ddd       y	)
zAdds flags to set LVP Share class and path used by the storage.

  Args:
    bare_metal_lvp_share_config_group: The parent group to add the flags to.
  z. LVP share class and path used by the storage.Tr   z--lvp-share-pathzPath for the LVP share class.rv   z--lvp-share-storage-classzStorage class for LVP share.Nr   )!bare_metal_lvp_share_config_group)bare_metal_storage_lvp_share_config_groups     r   _AddStorageLVPShareConfigr     s^     (11? 2  , ,88* 9 
 ,88!) 9 r   c                 f    | j                  dd      }|j                  dd       t        |       y)zAdds flags to set LVP Share class and path used by the storage.

  Args:
    bare_metal_storage_config_group: The parent group to add the flags to.
  z LVP share configuration.Tr   z--shared-path-pv-countz.Number of subdirectories to create under path.r   N)ri   rN   r   )bare_metal_storage_config_groupr   s     r   _AddLVPShareConfigr   %  sH     'F&O&O& 'P '#
 $00; 1 
 =>r   c                 z    | j                  dd      }|j                  ddd       |j                  ddd       y	)
zAdds flags to set LVP Node Mounts class and path used by the storage.

  Args:
    bare_metal_storage_config_group: The parent group to add the flags to.
  z4 LVP node mounts class and path used by the storage.Tr   z--lvp-node-mounts-config-pathz#Path for the LVP node mounts class.rv   z&--lvp-node-mounts-config-storage-classz"Storage class for LVP node mounts.Nr   )r    bare_metal_lvp_node_config_groups     r   _AddLVPNodeMountsConfigr   8  s^     &E%N%NA &O &" #//%0 0 
 #//./ 0 r   c                 V    | j                  dd      }t        |       t        |       y)zoAdds a command group to set the storage config.

  Args:
    parser: The argparse parser to add the flag to.
  z3Anthos on bare metal cluster storage configuration.Tr   N)ri   r   r   )r#   r   s     r   AddStorageConfigr   N  s4     %+$4$4@ %5 %! 459:r   c           
          | }| j                  d|d      }d}|j                  d|t        j                         d       |j                  ddd	t        j                  t
        t
        d
dg             y)zAdds flags to set the control plane node config.

  Args:
    bare_metal_node_config_group: The parent mutex group to add the flags to.
    is_update: bool, whether the flag is for update command or not.
  z#Populate control plane node config.T)rL   r'   r[   a  
Path of the YAML/JSON file that contains the control plane 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&--control-plane-node-configs-from-filer   z--control-plane-node-configsz!Control plane node configuration.r   r   r   r   r   Nr   )bare_metal_node_config_grouprw   r'   r   .control_plane_node_configs_from_file_help_texts        r   _AddControlPlaneNodeConfigsr   \  s     ](8BB084 C 40. &&.9'')	 '  &&$. #	 ' r   c                 R    | j                  ddt        j                         d       y)zAdds a flag to assign labels to nodes in a node pool.

  Args:
    bare_metal_node_config_group: The parent group to add the flags to.
  z--control-plane-node-labelsr   z(Labels assigned to nodes of a node pool.r   Nr   r   s    r   _AddControlPlaneNodeLabelsr     s,     ++# 5	 , r   c                 R    | j                  dddt        j                                y)zAdds a flag to specify the node taint in the node pool.

  Args:
    bare_metal_node_config_group: The parent group to add the flags to.
  z--control-plane-node-taintsr   ;Node taint applied to every Kubernetes node in a node pool.r   Nr   r   s    r   _AddControlPlaneNodeTaintsr     s,     ++# H 	 , r   c                     | }| j                  d|      }|j                  d|      }t        ||       t        |       t        |       t	        ||       y)zAdds a command group to set the node pool config.

  Args:
    bare_metal_control_plane_node_pool_config_group: The argparse parser to add
      the flag to.
    is_update: bool, whether the flag is for update command or not.
  zEAnthos on bare metal node pool configuration for control plane nodes.r   z@Anthos on bare metal node configuration for control plane nodes.N)ri   r   r   r   _AddControlPlaneKubeletConfig)/bare_metal_control_plane_node_pool_config_grouprw   r'   !bare_metal_node_pool_config_groupr   s        r   _AddNodePoolConfigr     sv     ](&U&_&_  '` '# "C!L!LM "M "
 :IF9:9: <iHr   c                 H    | }| j                  d|      }t        ||       y)zAdds a command group to set the control plane node pool config.

  Args:
    bare_metal_control_plane_config_group: The argparse parser to add the flag
      to.
    is_update: bool, whether the flag is for update command or not.
  zCAnthos on bare metal cluster control plane node pool configuration.r   N)ri   r   )%bare_metal_control_plane_config_grouprw   r'   r   s       r   _AddControlPlaneNodePoolConfigr    s:     ](+55   6  2 DiPr   c                 R    | j                  dddt        j                                y)zAdds a flag to specify the API server args.

  Args:
    bare_metal_control_plane_config_group: The parent group to add the flags to.
  z--api-server-argsr   z"API Server argument configuration.r   Nr   )r  s    r   _AddControlPlaneAPIServerArgsr    s,     (44/ 	 5 r   c                 ^    | }| j                  d|      }t        ||       t        |       y)zAdds a command group to set the control plane config.

  Args:
    parser: The argparse parser to add the flag to.
    is_update: bool, whether the flag is for update command or not.
  z9Anthos on bare metal cluster control plane configuration.r   N)ri   r  r  )r#   rw   r'   r  s       r   AddControlPlaneConfigr    sA     ](*0*:*:F +; +' !+Y   EFr   c                 4    | j                  dt        d       y)zwAdds a flag to specify the description of the resource.

  Args:
    parser: The argparse parser to add the flag to.
  z--descriptionzDescription for the resource.r   rL   NrN   r   rO   s    r   AddDescriptionr
    s     	C&E  r   c                 R    | j                  ddt        j                         d       y)zkAdds a flag to specify cluster annotations.

  Args:
    parser: The argparse parser to add the flag to.
  z--annotationsr   z1Annotations on the Anthos on bare metal resource.r   Nr   rO   s    r   AddAnnotationsr    s,     	 >	  r   c                 6    | j                  ddt        d       y)Adds a flag to specify the address of the proxy server.

  Args:
    bare_metal_proxy_config_group: The parent group to add the flag to.
  z--uriTzAddress of the proxy server.)r'   r   rL   Nr	  bare_metal_proxy_config_groups    r   _AddURIConfigr    s#      ,,)	 - r   c                 R    | j                  ddt        j                         d       y)r  z
--no-proxyNO_PROXYz?List of IPs, hostnames, and domains that should skip the proxy.r   Nr   r  s    r   _AddNoProxyConfigr  +  s,      ,, L	 - r   c                 T    | j                  d      }t        |       t        |       y)zmAdds a command group to set the proxy config.

  Args:
    parser: The argparse parser to add the flag to.
  z1Anthos on bare metal cluster proxy configuration.r   N)ri   r  r  )r#   r  s     r   AddProxyConfigr  9  s1     #)"2"2> #3 # -.12r   c                 P    | j                  d      }|j                  ddd       y)zzAdds a command group to set the cluster operations config.

  Args:
    parser: The argparse parser to add the flag to.
  z6Anthos on bare metal cluster operations configuration.r   z--enable-application-logsrI   zfWhether collection of application logs/metrics should be enabled (in addition to system logs/metrics).rJ   Nr   )r#   *bare_metal_cluster_operations_config_groups     r   AddClusterOperationsConfigr  F  s>     06/?/?C 0@ 0, -99!/	 : r   c                 ~    | }| j                  d      }|j                  dt        j                         dd|       y)zAdds a command group to set the maintenance config.

  Args:
    parser: The argparse parser to add the flag to.
    is_update: bool, whether the flag is for update command or not.
  z7Anthos on bare metal cluster maintenance configuration.r   z!--maintenance-address-cidr-blocksMAINTENANCE_ADDRESS_CIDR_BLOCKSz2IPv4 addresses to be placed into maintenance mode.)r   r   rL   r'   N)ri   rN   r   r   )r#   rw   r'   #bare_metal_maintenance_config_groups       r   AddMaintenanceConfigr  Z  sQ     ]((.(8(8D )9 )% &22) /? 3 r   c                 4    | j                  ddt               y)zAdds flags to set maximum pods per node.

  Args:
    bare_metal_workload_node_config_group: The parent group to add the flags to.
  z--max-pods-per-nodez&Maximum number of pods a node can run.)rL   r   NrN   r   %bare_metal_workload_node_config_groups    r   _AddMaxPodsPerNoder"  q  s      (443 5 r   c                 *    | j                  dd       y)zAdds flags to set runtime for containers.

  Args:
    bare_metal_workload_node_config_group: The parent group to add the flags to.
  z--container-runtimezDContainer runtime which will be used in the bare metal user cluster.r   NrM   r   s    r   _AddContainerRuntimer$  ~  s     (44
P 5 r   c                 T    | j                  d      }t        |       t        |       y)uAdds a command group to set the workload node config.

  Args:
    parser: The argparse parser to add the flag to.
  z9Anthos on bare metal cluster workload node configuration.r   N)ri   r"  r$  r#   r!  s     r   AddWorkloadNodeConfigr(    s1     +1*:*:F +; +' :;<=r   c                 X    | }| j                  d      }|j                  ddd|       y)zAdds flags to specify applied and managed RBAC policy.

  Args:
    bare_metal_security_config_group: The parent group to add the flags to.
    is_update: bool, whether the flag is for update command or not.
  zMUser cluster authorization configurations to bootstrap onto the admin clusterr   z--admin-userszgUsers that will be granted the cluster-admin role on the cluster, providing full access to the cluster.r   )rL   rK   r'   Nr   ) bare_metal_security_config_grouprw   r'   authorization_groups       r   _AddAuthorizationr,    sL     ](8BB C  ""3  # r   c                 @    | j                  d      }t        ||       y)zAdds a command group to set the security config.

  Args:
    parser: The argparse parser to add the flag to.
    is_update: bool, whether the flag is for update command or not.
  z4Anthos on bare metal cluster security configuration.r   N)ri   r,  )r#   rw   r*  s      r   AddSecurityConfigr.    s*     &,%5%5A &6 &" 4i@r   c                 X    | j                  d      }|j                  dt        d       y)zsAdds a command group to set the node access config.

  Args:
    parser: The argparse parser to add the flag to.
  zGAnthos on bare metal node access related settings for the user cluster.r   z--login-userz'User name used to access node machines.r  N)ri   rN   r   )r#   #bare_metal_node_access_config_groups     r   AddNodeAccessConfigr1    s=     )/(8(8 )9 )% &224 3 r   c                  `    t        j                  ddt               t         j                        S )Nz'gkeonprem.projects.locations.operations	operation)r   r   r   )r   r    r   r!   r   r   r   GetOperationResourceSpecr4    s*    			/)+::	
 r   c                     t         j                  j                  dt               dj	                  |      d      j                  |        y)zAdds a resource argument for operation in bare metal.

  Args:
    parser: The argparse parser to add the resource arg to.
    verb: str, the verb to describe the resource, such as 'to update'.
  operation_idzoperation {}.Tr&   N)r   r(   r)   r4  r*   r+   r,   s     r   AddOperationResourceArgr7    sC     ++ T"	 , 
 Kr   c                  0    t        j                  dd      S )Nadmin_cluster_membershipzwadmin cluster membership of the {resource}, in the form of projects/PROJECT/locations/LOCATION/memberships/MEMBERSHIP. r2   r3   r   r   r   'AdminClusterMembershipIdAttributeConfigr:    s    		2	2%J
 r   c                  0    t        j                  dd      S )z:Gets admin cluster membership location resource attribute.r   r   r2   r3   r   r   r   -AdminClusterMembershipLocationAttributeConfigr<    s    		2	2;
 r   c                  0    t        j                  dd      S )z-Gets Google Cloud project resource attribute.ra   z(Google Cloud project for the {resource}.r2   r3   r   r   r   ,AdminClusterMembershipProjectAttributeConfigr>    s    		2	2:
 r   c                  f    t        j                  ddt               t               t	                     S )Nz%gkehub.projects.locations.membershipsr9  )r   membershipsIdr   r   )r   r    r:  r<  r>  r   r   r   rk   rk   	  s-    			-.;=?A=?
 r   c           	          |rdnd}d}t         j                  j                  |t               ||ddd      j	                  |        y)	a	  Adds a resource argument for a bare metal admin cluster membership.

  Args:
    parser: The argparse parser to add the resource arg to.
    positional: bool, whether the argument is positional or not.
    required: bool, whether the argument is required or not.
  r9  r]   a  membership of the admin cluster. Membership name is the same as the admin cluster name.

Examples:

  $ {command}
        --admin-cluster-membership=projects/example-project-12345/locations/us-west1/memberships/example-admin-cluster-name

or

  $ {command}
        --admin-cluster-membership-project=example-project-12345
        --admin-cluster-membership-location=us-west1
        --admin-cluster-membership=example-admin-cluster-name

  r^   r_   r`   r:   N)r   r(   r)   rk   r+   )r#   r=   r'   r   rp   s        r   $AddAdminClusterMembershipResourceArgrB    s[     %/ 4P ($ ++
+-(9; , 	 Kr   c                 r    | }| j                  d|      }t        |       t        |       t        |       y)r   z?Anthos on bare metal admin cluster load balancer configuration.r   N)ri   _AddAdminVIPConfig_AddAdminLoadBalancerPortConfig_AddAdminManualLBConfig)r#   rw   r'   +bare_metal_admin_load_balancer_config_groups       r   AddAdminLoadBalancerConfigrH  ;  sE     ](060@0@L 1A 1- @A!"MNEFr   c                 R    | j                  dd      }|j                  ddd       y)zAdds flags to set VIPs used by the load balancer.

  Args:
    bare_metal_admin_load_balancer_config_group: The parent group to add the
      flags to.
  zVIPs used by the load balancer.Tr   r   r   rv   Nr   )rG  r   s     r   rD  rD  N  s@     2;;0 <   **8 + r   c                 \    | j                  dd      }|j                  dddt               y)zAdds flags to set port for load balancer.

  Args:
    bare_metal_admin_load_balancer_config_group: The parent group to add the
      flags to.
  r   Tr   r   r   Nr   )rG  r   s     r   rE  rE  b  sC     2;;@ <  0 0<<*<	 = r   c                 R    | j                  d      }|j                  dddd       y)	zAdds flags for manual load balancer.

  Args:
    bare_metal_admin_load_balancer_config_group: The parent group to add the
      flags to.
  r   r   r   TrI   r   r   Nr   )rG  r   s     r   rF  rF  y  s@     2;;4 <  
 %%9	 & r   c                 >    | j                  d      }t        |       y)r&  z?Anthos on bare metal admin cluster workload node configuration.r   N)ri   r"  r'  s     r   AddAdminWorkloadNodeConfigrM    s(     +1*:*:L +; +' :;r   c                 ,    | j                  ddd       y)zdAdds a flag for ignore_errors field.

  Args:
    parser: The argparse parser to add the flag to.
  z--ignore-errorszmIf set, the deletion of a bare metal user cluster resource will succeed even if errors occur during deletion.rI   )rL   rK   NrM   rO   s    r   AddIgnoreErrorsrO    s$     	;   r   c                     | }| j                  d      }|j                  dt        |d       t        ||       t	        ||       t        ||       y)zAdds a flag for BGP Load Balancer Config field.

  Args:
    lb_config_mutex_group: The parent mutex group to add the flags to.
    is_update: bool, whether the flag is for update command or not.
  z BGP load balancer configuration.r   z	--bgp-asnz2BGP autonomous system number (ASN) of the cluster.)r   r'   rL   r   N)ri   rN   r   _AddBGPPeerConfigs_AddBGPAddressPools!_AddBGPLoadBalancerNodePoolConfig)r   rw   r'   bgp_lb_config_groups       r   r   r     sh     ](-77- 8  ""?	 #  (I>)Y?#$79Mr   c                     | j                         }|j                         }t        ||       t        |       t        |       t	        ||       y )Nr   )ri   _AddBGPNodeConfigs_AddBGPNodeTaints_AddBGPNodeLabels_AddBGPKubeletConfig)rT  rw   bgp_lb_node_pool_config_groupbgp_node_pool_config_groups       r   rS  rS    sH    "5"?"?"A<FFH/9E././1YGr   c                     d}| }| j                  d|d|t        j                  t        t        t        j
                  d      dddg	      d
       y)zAdds a flag for BGP peer config field.

  Args:
    bgp_node_pool_config_group: The parent group to add the flags to.
    is_update: bool, whether the flag is for update command or not.
  a  
List of BGP peers that the cluster will connect to. At least one peer must be configured for each control plane node.

Examples:

To specify configurations for two peers of BGP autonomous system number (ASN) 10000 and 20000,

```
$ {command} example_cluster
      --bgp-peer-configs 'asn=10000,ip=192.168.1.1,control-plane-nodes=192.168.1.2;192.168.1.3'
      --bgp-peer-configs 'asn=20000,ip=192.168.2.1,control-plane-nodes=192.168.2.2;192.168.2.3'
```

Use quote around the flag value to escape semicolon in the terminal.

  z--bgp-peer-configsr   r   r   )asnipzcontrol-plane-nodesr]  r^  r   z5asn=ASN,ip=IP,control-plane-nodes=NODE_IP_1;NODE_IP_2)rL   rK   r'   r   r   N)rN   r   r   r   r   r   )r[  rw   bgp_peer_config_help_textr'   s       r   rQ  rQ    sh      ]())$%0%8%83%O
  F * r   c                     d}| }| j                  d|d|t        j                  t        t        j                         t        j                         t        j
                  d      dddg	      
       y)zAdds a flag for BGP address pool field.

  Args:
    bgp_lb_config_group: The parent group to add the flags to.
    is_update: bool, whether the flag is for update command or not.
  a  
BGP load balancer address pools configurations.

Examples:

To specify configurations for two address pools `pool1` and `pool2`,

```
$ {command} example_cluster
      --bgp-address-pools 'pool=pool1,avoid-buggy-ips=True,manual-assign=True,addresses=192.168.1.1/32;192.168.1.2-192.168.1.3'
      --bgp-address-pools 'pool=pool2,avoid-buggy-ips=False,manual-assign=False,addresses=192.168.2.1/32;192.168.2.2-192.168.2.3'
```

Use quote around the flag value to escape semicolon in the terminal.
z--bgp-address-poolsr   r   r   r   r   r   r   )rL   rK   r'   r   N)rN   r   r   r   r   r   )rT  rw   bgp_address_pools_help_textr'   s       r   rR  rR    sx    ! ](""&!,!7!7!9*557&..E	  - # r   c                 ~    d}| }| j                  d||ddt        j                  t        t        ddg             y	)
zAdds a flag for BGP node config fields.

  Args:
    bgp_lb_config_group: The parent group to add the flags to.
    is_update: bool, whether the flag is for update command or not.
  a  
BGP load balancer data plane node configurations.

Examples:

To specify configurations for two nodes of IP `192.168.0.1` and `192.168.1.1`,

```
$ {command} example_cluster
      --bgp-load-balancer-node-configs 'node-ip=192.168.0.1,labels=KEY1=VALUE1;KEY2=VALUE2'
      --bgp-load-balancer-node-configs 'node-ip=192.168.1.1,labels=KEY3=VALUE3'
```

Use quote around the flag value to escape semicolon in the terminal.
z --bgp-load-balancer-node-configsz)node-ip=IP,labels=KEY1=VALUE1;KEY2=VALUE2r   r   r   r   )rL   r'   r   rK   r   N)rN   r   r   r   )rT  rw   bgp_node_configs_help_textr'   s       r   rV  rV    sU      ](""(%9 # # r   c                 R    | j                  dddt        j                                y)zAdds a flag to specify the node taint in the node pool.

  Args:
    bgp_node_pool_config_group: The parent group to add the flags to.
  z--bgp-load-balancer-node-taintsr   r   r   Nr   r[  s    r   rW  rW  D  s,     ))' H 	 * r   c                 R    | j                  ddt        j                         d       y)zAdds a flag to assign labels to nodes in a BGP node pool.

  Args:
    bgp_node_pool_config_group: The parent group to add the flags to.
  z--bgp-load-balancer-node-labelsr   z,Labels assigned to nodes of a BGP node pool.r   Nr   re  s    r   rX  rX  R  s,     ))' 9	 * r   c                     |r| j                  d      }|}n| }|j                  ddd       |r|j                  ddd       y	y	)
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.
  TrZ   z---disable-control-plane-serialize-image-pullsrI   CIf set, prevent the Kubelet from pulling multiple images at a time.rJ   z,--enable-control-plane-serialize-image-pulls=If set, enable the Kubelet to pull multiple images at a time.Nr   )bare_metal_kubelet_config_grouprw   !serialize_image_pulls_mutex_groupr   s       r   *_AddDisableControlPlaneSerializeImagePullsrl  `  sk     '111= & 0G-G	5
O	   6L   r   c                     | j                  d      }|j                  dt        d       |j                  dt        d       t        ||       y)	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.
  :Modifiable kubelet configurations for bare metal machines.z!--control-plane-registry-pull-qps#Limit of registry pulls per second.r  z--control-plane-registry-burst{Maximum size of bursty pulls, temporarily allow pulls to burst to this number, while still not exceeding registry_pull_qps.r   N)ri   rN   r   rl  )r   rw   rj  s      r   r   r     sg     %F$O$OB%! "..)0 / 
 "..&G	 /  -%r   c                     |r| j                  d      }|}n| }|j                  ddd       |r|j                  ddd       y	y	)
zAdds a flag to specify the enablement of serialize image pulls.

  Args:
    bgp_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.
  TrZ   z1--disable-bgp-load-balancer-serialize-image-pullsrI   rh  rJ   z0--enable-bgp-load-balancer-serialize-image-pullsri  Nr   )bgp_kubelet_config_grouprw   rk  r   s       r   !_AddDisableBGPSerializeImagePullsrs    so     (@(J(J )K )% 0G&G	9
O	   :L   r   c                     | j                  d      }|j                  dt        d       |j                  dt        d       t        ||       y)	zAdds flags to specify the kubelet configurations in the node pool.

  Args:
    bgp_node_pool_config_group: The parent group to add the flags to.
    is_update: bool, whether the flag is for update command or not.
  rn  z%--bgp-load-balancer-registry-pull-qpsro  r  z"--bgp-load-balancer-registry-burstrp  r   N)ri   rN   r   rs  )r[  rw   rr  s      r   rY  rY    sf     8AAB ''-0 ( 
 ''*G	 (  $)r   c                     |r| j                  d      }|}n| }|j                  ddd       |r|j                  ddd       y	y	)
zAdds a flag to specify the enablement of serialize image pulls.

  Args:
    metal_lb_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.
  TrZ   z6--disable-metal-lb-load-balancer-serialize-image-pullsrI   rh  rJ   z5--enable-metal-lb-load-balancer-serialize-image-pullsri  Nr   )metal_lb_kubelet_config_grouprw   rk  r   s       r   %_AddDisableMetalLBSerializeImagePullsrw    so     (E(O(O )P )% 0G+G	>
O	   ?L   r   c                     | j                  d      }|j                  dt        d       |j                  dt        d       t        ||       y)	zAdds flags to specify the kubelet configurations in the node pool.

  Args:
    bare_metal_metal_lb_node_config: The parent group to add the flags to.
    is_update: bool, whether the flag is for update command or not.
  rn  z*--metal-lb-load-balancer-registry-pull-qpsro  r  z'--metal-lb-load-balancer-registry-burstrp  r   N)ri   rN   r   rw  )r   rw   rv  s      r   r   r     sg     #B"K"KB#  ,,20 - 
  ,,/G	 -  (#yr   c                 >   | j                  d      }|j                  dddt        j                                |j                  ddd	t        j                                |j                  d
ddd       |j                  dddt        j                         d       y)zaAdds flags to update annotations.

  Args:
    parser: The argparse parser to add the flag to.
  TrZ   z--add-annotationszKEY1=VALUE1,KEY2=VALUE2zhAdd the given key-value pairs to the current annotations, or update its value if the key already exists.r   z--remove-annotationsz	KEY1,KEY2z%Remove annotations of the given keys.z--clear-annotationsrI   z!Clear all the current annotations)r   rK   rL   z--set-annotationsz#Replace all the current annotations)r   r   r   rL   N)ri   rN   r   r   r   )r#   annotations_mutex_groups     r   AddUpdateAnnotationsr{    s     #,,4,8&&'2   '  &&2 	 '  &&.	 '  &&' 0 ' r   c                 4    | j                  dt        d       y )Nz	--timeoutz8Timeout (seconds) waiting for the operation to complete.r  r  rO   s    r   AddOperationTimeoutr}  >  s    E  r   returnc                     | j                  d      }|j                  dt        j                         t	        j
                  d      j                                y)zlAdds flags to update cluster upgrade policy.

  Args:
    parser: The argparse parser to add the flag to.
  zUpgrade policy for the cluster.r   z--upgrade-control-planea  
      If not specified, worker node pools are upgraded with the control plane.

      Examples:

        To upgrade control plane only and keep node pools version unchanged,

          ```shell
          $ {command} --upgrade-control-plane=True
          ```

        To upgrade both control plane and node pools,

          ```shell
          $ {command} --upgrade-control-plane=False
          ```
r  N)ri   rN   r   r   textwrapdedentstrip)r#   upgrade_policy_groups     r   AddUpgradePolicyr  F  s[      )), *  ##!!#??    UW' $ r   )TTN)F)TT)i__doc__
__future__r   r   r   r  googlecloudsdk.callioper   r    googlecloudsdk.calliope.conceptsr   r	   .googlecloudsdk.command_lib.container.gkeonpremr
   (googlecloudsdk.command_lib.util.conceptsr   r   googlecloudsdk.corer   r   r"   ArgumentInterceptorr.   r4   r7   r>   rA   rD   rG   rP   rS   rU   rW   rr   rt   rx   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r
  r  r  r  r  r  r  r"  r$  r(  r,  r.  r1  r4  r7  r:  r<  r>  rk   rB  rH  rD  rE  rF  rM  rO  r   rS  rQ  rR  rV  rW  rX  rl  r   rs  rY  rw  r   r{  r}  r  r   r   r   <module>r     s   G &  '  / 4 5 1 @ D G *
#3#G#G  006 006,@@  #3#G#G  )9)M)M ,.BB  :B*>> :Bz!/CC !<';; $ 9>,$4 =B G00 GF<1hQ2L^H*6 6;6 =B700780?&,;-AA ;3l @EI< 6;Q. =BG00G(+?? +?? 
3+?? 
3'7'K'K * =B00.
>"2"F"F >4 =BA00A  0 D D ($4$H$H  MQ%00%R =BG00G&(.(
<'7'K'K 
<,@@  N,H'T&R%P 05D 27> ).B: .3B8"!1!E!E "J 0 D D -AA d r   