
    H'                     ^   S r SSKJr  SSKJr  SSKJr  SSKrSSK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SKJr  \R.                  " S5      r\R2                  \R4                  " \R6                  R8                  5       " S S\R:                  5      5       5       rg)z#Command to create an HA Controller.    )absolute_import)division)unicode_literalsN)base_classes)utils)poller)arg_parsers)base)	arg_utils)
exceptions)loga      The JSON/YAML file containing the configuration of desired nodes onto
    which instance in this zone could be scheduled. These rules filter the nodes
    according to their node affinity labels. A node's affinity labels come
    from the node template of the group the node is in.

    The file should contain a list of a JSON/YAML objects. For an example,
    see https://cloud.google.com/compute/docs/nodes/provisioning-sole-tenant-vms#configure_node_affinity_labels.
    The following list describes the fields:

    *key*::: Corresponds to the node affinity label keys of
    the Node resource.
    *operator*::: Specifies the node selection type. Must be one of:
      `IN`: Requires Compute Engine to seek for matched nodes.
      `NOT_IN`: Requires Compute Engine to avoid certain nodes.
    *values*::: Optional. A list of values which correspond to the node
    affinity label values of the Node resource.
    c                   .    \ rS rSrSr\S 5       rS rSrg)Create7   zCreate an HA Controller.

Create an High Availability (HA) Controller, which helps
ensure that a virtual machine (VM) instance remains operational by
automatically managing failover across two zones.
c                 2  ^ [         R                  R                  U 5        [        R                  " U [         R
                  R                  R                  R                  5       5        [        R                  " S5      mU R                  SSS9  U R                  SSS9  U R                  SSU4S	 jS
[        R                  " TR                  R                  5       3S9  U R                  SSU4S jS[        R                  " TR                  R                  5       3S9  U R                  SS[        R                   " S[        R                   " ["        SS9[        R                   " U4S jS[        R                  " TR$                  R&                  5       3S9[        R                   " ["        SS9[        R                   " ["        S[        R                  " TR(                  R*                  5       3S9[        R                   " [        R,                  " 5       S[.        S9[        R                   " ["        SS9[        R                   " ["        SS9S.S9[        R0                  " 5       SS9  U R                  SS[        R                   " [        R                   " U4S jS [        R                  " TR2                  R4                  5       3S9[        R                   " ["        S!S9[        R                   " ["        S"S9S#.S$9[        R0                  " 5       S%S9  g )&Nalphaz--descriptionzZAn optional, user-provided description for the HA Controller to help identify its purpose.)helpz--instance-namezThe name of the existing VM that the HA Controller manages. This VM must already exist in one of the zones specified in --zone-configuration.z--failover-initiationTc                 Z   > [         R                  " U TR                  R                  5      $ N)r   ChoiceToEnumHaController!FailoverInitiationValueValuesEnumxmessagess    ,lib/surface/compute/ha_controllers/create.py<lambda>Create.Args.<locals>.<lambda>Z   s"    y--!!CC
    zuSpecifies how a failover is triggered. Set to MANUAL_ONLY if you want to trigger failovers yourself. Must be one of: )requiredtyper   z--secondary-zone-capacityc                 Z   > [         R                  " U TR                  R                  5      $ r   )r   r   r   $SecondaryZoneCapacityValueValuesEnumr   s    r   r   r   g   s"    y--!!FF
r   zDetermines the capacity guarantee in the secondary zone. Use BEST_EFFORT to create a VM based on capacity availability at the time of failover, suitable for workloads that can tolerate longer recovery times. Must be one of: z--zone-configurationFz[Specifies the reservation name. The reservation must exist within the HA Controller region.)
value_type	help_textc                 Z   > [         R                  " U TR                  R                  5      $ r   )r   r   0HaControllerZoneConfigurationReservationAffinity%ConsumeReservationTypeValueValuesEnumr   s    r   r   r      s"    )?)? QQww*r   z:Specifies the reservation-affinity value. Must be one of: zMSpecifies the node name. The node must exist within the HA Controller region.zjSpecifies the node-group name. The node-group must exist within the HA Controller region. Must be one of: )r$   enable_file_uploadr%   z_Specifies the name of the project with shared sole tenant node groups to create an instance in.zESpecifies the zone. The zone must be within the HA Controller region.)reservationzreservation-affinitynodez
node-groupznode-affinity-fileznode-projectzone)r)   speczConfigures the two zones for the HA Controller and specifies how VM capacity is reserved in each zone. You must provide two zone configurations. You can also specify an existing reservation or node-group to guarantee capacity.)r    r!   actionr   z--network-auto-configurationc                 Z   > [         R                  " U TR                  R                  5      $ r   )r   r   /HaControllerNetworkingAutoConfigurationInternalStackTypeValueValuesEnumr   s    r   r   r      s#    )?)? PPii*kr   zsSpecifies the stack type for the network configuration. Must match the stack type of the instance. Must be one of: zrSpecifies an optional IPv4 address to assign to the instance. If not specified, an ephemeral IP will be generated.zrSpecifies an optional IPv6 address to assign to the instance. If not specified, an ephemeral IP will be generated.)z
stack-typeaddresszinternal-ipv6-address)r-   z)Adds a network interface to the instance.)r
   
ASYNC_FLAGAddToParserr   AddHaControllerNameArgToParserReleaseTrackALPHAnamelowerGetMessagesModuleadd_argumentEnumTypeToChoicesr   r   r#   r	   	ArgObjectstrr'   r(   )HaControllerZoneConfigurationNodeAffinityOperatorValueValuesEnumFileContents_NODE_AFFINITY_FILE_HELP_TEXTFlattenActionr0   r1   )parserr   s    @r   ArgsCreate.ArgsA   s-   OO'	((!!'',,224 &&w/H
*   %   

''(=(=(_(_`ac   #

 ''(=(=(b(bcd	f   ""$*44"B  )4(=(= 
!33H4m4m  5T  5T  U  VW
) $--"5 *33" "33H4f4f4~4~  AB '2&;&;*779',;'
 !, 5 5"H! $--"._69
t ((*1  DJ &"")33 k "33H4l4l  5F  5F  G  HI
 '00") *5)>)>")*)
> ((*7I  &r   c                 $   [         R                  " U R                  5       5      nUR                  nUR                  R
                  R                  5       nUR                  R                  UR                  5       UR                  UR                  UR                  UR                  UR                  [        R                   " UR"                  5      [        R$                  " UR&                  5      S9n[(        R*                  " X%XAR,                  5      $ )N)r8   regiondescriptioninstanceNamefailoverInitiationsecondaryZoneCapacityzoneConfigurationsnetworkingAutoConfiguration)r   ComputeApiHolderr6   clientCONCEPTSha_controllerParser   r   NamerH   rI   instance_namefailover_initiationsecondary_zone_capacityr   MakeZoneConfigurationzone_configurationMakeNetworkConfigurationnetwork_auto_configuration	api_utilsInsertasync_)selfargsholderrP   ha_controller_refrR   s         r   Run
Create.Run   s    **4+<+<+>?F]]F3399;OO00##% ''$$''33":: 66t7N7NO$)$B$B++%
 1 M 0++ r    N)	__name__
__module____qualname____firstlineno____doc__staticmethodrE   rc   __static_attributes__re   r   r   r   r   7   s#     \ \|r   r   )rj   
__future__r   r   r   textwrapgooglecloudsdk.api_lib.computer   -googlecloudsdk.api_lib.compute.ha_controllersr   r\   )googlecloudsdk.api_lib.compute.operationsr   googlecloudsdk.callioper	   r
   1googlecloudsdk.command_lib.compute.ha_controllers$googlecloudsdk.command_lib.util.apisr   googlecloudsdk.corer   core_exceptionsr   dedentrB   DefaultUniverseOnlyReleaseTracksr6   r7   CreateCommandr   re   r   r   <module>r{      s     * &  '  7 L < / ( C : = # !) 1 !	 ( D%%++,yT y - yr   