
    c$                         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r
S	rS
SS.rSSS.rSSSS.rS rS rS rS rS rS rS rS rS rS rS rg) z9Code that's shared between multiple networks subcommands.    )absolute_import)division)unicode_literals)arg_parsers)parser_errors)	arg_utilsa      Specifies the IPv4 address range of legacy mode networks. The range
    must be specified in CIDR format:
    [](http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing)

    This flag only works if mode is
    [legacy](https://cloud.google.com/compute/docs/vpc/legacy).

    Using legacy networks is **DEPRECATED**, given that many newer Google
    Cloud Platform features are not supported on legacy networks. Please be
    advised that legacy networks may not be supported in the future.
    z3--range can only be used with --subnet-mode=legacy.zCloud Routers in this network advertise subnetworks from all regions to their BGP peers, and program instances in all regions with the router's best learned BGP routes.zCloud Routers in this network advertise subnetworks from their local region only to their BGP peers, and program instances in their local region only with the router's best learned BGP routes.)globalregionalz;Network Firewall Policy is enforced after classic firewall.z<Network Firewall Policy is enforced before classic firewall.)AFTER_CLASSIC_FIREWALLBEFORE_CLASSIC_FIREWALLzFSubnets are created automatically.  This is the recommended selection.zCreate subnets manually.z}[Deprecated] Create an old style network that has a range and cannot have subnets.  This is not recommended for new networks.)autocustomlegacyc                 L    U R                  SSS9  U R                  S[        S9  g)z-Adds common arguments for creating a network.z--descriptionz1An optional, textual description for the network.helpz--rangeN)add_argumentRANGE_HELP_TEXTparsers    @lib/googlecloudsdk/command_lib/compute/networks/network_utils.pyAddCreateBaseArgsr   M   s2     	O   	io6    c                 4    U R                  S[        S SSS9  g)zAdds the --subnet-mode flag.z--subnet-modec                 "    U R                  5       $ Nlowermodes    r   <lambda>(AddCreateSubnetModeArg.<locals>.<lambda>\   
    

r   MODEzQThe subnet mode of the network. If not specified, defaults to
              AUTO.choicestypemetavarr   N)r   _CREATE_SUBNET_MODE_CHOICESr   s    r   AddCreateSubnetModeArgr*   W   s&    )$  r   c                 .    U R                  S[        SS9  g)zAdds the --mtu flag.z--mtuaN  Maximum transmission unit (MTU) is the size of the largest
              IP packet that can be transmitted on this network. Default value
              is 1460 bytes. The minimum value is 1300 bytes and the maximum
              value is 8896 bytes. The MTU advertised via DHCP to all instances
              attached to this network.r'   r   N)r   intr   s    r   	AddMtuArgr.   c   s     +  r   c                     U R                  SS9nUR                  SSSS.S[        R                  S9  UR                  S	[        R
                  S
S9  UR                  SSSS.S[        R                  S9  g)zpAdds the BGP Best Path Selection flags.

Args:
  parser (parser_arguments.ArgumentInterceptor): Argument parser
zBGP Best Path Selection flagsr   z--bgp-best-path-selection-modezDynamic routes are ranked based on the multiple exit-discriminator (MED) BGP attribute. When global routing is enabled, the MED of the routes received from other regions is the original MED plus the region-to-region cost.aB  Dynamic routes are ranked based on AS Path, Origin, Neighbor ASN and MED BGP attributes. When global routing is enabled, region-to-region cost is used as a tiebreaker. This mode offers customizations to fine-tune BGP best path routing with additional flags like --bgp-bps-always-compare-med and --bgp-bps-inter-region-cost)LEGACYSTANDARDz5The BGP best path selection algorithm to be employed.)r&   r   r'   z--bgp-bps-always-compare-medzEnables/disables the comparison of MED across routes with different Neighbor ASNs. This value can only be set if the --bgp-best-path-selection-mode is STANDARD.actionr   z--bgp-bps-inter-region-costz~MED is compared as originally received from peers. When multiple routes have the same MED, cost is evaluated as the next step.zAdds inter-region cost to the MED before comparing the MED value. When multiple routes have the same value after the Add-cost-to-med comparison, the route selection continues and prefers the route with lowest cost.)DEFAULTADD_COST_TO_MEDzDefines the preferred approach for handling inter-region cost in the selection process. This value can only be set if the --bgp-best-path-selection-mode is STANDARD.N)add_argument_groupr   r   ChoiceToEnumNamer   StoreTrueFalseAction)r   groups     r   AddBgpBestPathSelectionArgGroupr:   p   s     
#
#)L
#
M%&B-  G%%'  * $-- r  
 #O5 w%%  r   c                 N    U R                  S[        R                  " 5       SSS9  g)z&Adds the --resource-manager-tags flag.z--resource-manager-tagsz	KEY=VALUEzY          A comma-separated list of Resource Manager tags to apply to the network.
      )r'   r(   r   N)r   r   ArgDictr   s    r   
AddTagsArgr=      s,     
	  r   c                 B    U R                  S[        R                  SS9  g)z)Adds the --enable-ula-internal-ipv6 flag.z--enable-ula-internal-ipv6zEnable/disable ULA internal IPv6 on this network. Enabling this
      feature will assign a /48 from google defined ULA prefix fd20::/20.r2   N)r   r   r8   r   s    r   AddEnableUlaInternalIpv6Argr?      s'    "--M  r   c                 .    U R                  S[        SS9  g)z$Adds the --internal-ipv6-range flag.z--internal-ipv6-rangea  When enabling ULA internal IPv6, caller can optionally specify
      the /48 range they want from the google defined ULA prefix fd20::/20.
      ULA_IPV6_RANGE must be a valid /48 ULA IPv6 address and within the
      fd20::/20. Operation will fail if the speficied /48 is already in used
      by another resource. If the field is not speficied, then a /48 range
      will be randomly allocated from fd20::/20 and returned via this field.r,   N)r   strr   s    r   AddInternalIpv6RangeArgrB      s!    P  	r   c                 0    U R                  S[        SSS9  g)z:Adds the --network-firewall-policy-enforcement-order flag.z+--network-firewall-policy-enforcement-order)NETWORK_FIREWALL_POLICY_ENFORCEMENT_ORDERzThe Network Firewall Policy enforcement order of this network. If
              not specified, defaults to AFTER_CLASSIC_FIREWALL.)r&   r(   r   N)r   2_NETWORK_FIREWALL_POLICY_ENFORCEMENT_ORDER_CHOICESr   s    r   +AddNetworkFirewallPolicyEnforcementOrderArgrF      s$    3@9D	  r   c           	      6    U R                  S[        SS SSS9  g)z!Adds the --bgp-routing-mode flag.--bgp-routing-moder
   c                 "    U R                  5       $ r   r   r   s    r   r!   ,AddCreateBgpRoutingModeArg.<locals>.<lambda>   r#   r   r$   z\The BGP routing mode for this network. If not specified, defaults
              to regional.)r&   defaultr'   r(   r   N)r   _BGP_ROUTING_MODE_CHOICESr   s    r   AddCreateBgpRoutingModeArgrM      s)    '$  r   c                     U R                  SS9nUR                  SSSS9  UR                  S[        S S	S
S9  [        U 5        [	        U 5        [        U 5        [        U 5        [        U 5        g)z&Adds arguments for updating a network.F)requiredz--switch-to-custom-subnet-mode
store_truez;Switch to custom subnet mode. This action cannot be undone.r2   rH   c                 "    U R                  5       $ r   r   r   s    r   r!   AddUpdateArgs.<locals>.<lambda>   r#   r   r$   z-The target BGP routing mode for this network.r%   N)add_mutually_exclusive_groupr   rL   r.   rB   r?   rF   r:   )r   	mode_argss     r   AddUpdateArgsrU      s     1151A)&L   '$>   F&!f%-f5!&)r   c                     U R                  S5      (       aB  U R                  S5      (       a+  U R                  S:w  a  [        R                  " [        5      eggg)zGChecks for range being used with incompatible mode and raises an error.rangesubnet_moder   N)IsSpecifiedrX   r   ArgumentError_RANGE_NON_LEGACY_MODE_ERROR)argss    r   CheckRangeLegacyModeOrRaiser]      sU     w


=
)
)


h
&

%
%&B
CC ' *  r   N)__doc__
__future__r   r   r   googlecloudsdk.callioper   r   $googlecloudsdk.command_lib.util.apisr   r   r[   rL   rE   r)   r   r*   r.   r:   r=   r?   rB   rF   rM   rU   r]    r   r   <module>rc      s    @ &  ' / 1 : : 	=
	   	F 	G6 2 	Q(	C	 7	
1h	
*6Dr   