
    ^                     D   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S.rSS0rSSSS.r " S S\R*                  5      rS,S jrS-S jrS.S jrS rS rS rS rS rS rS/S  jr S0S! jr!S" r"S# r#S$ r$S% r%S& r&S' r'S( r(S) r)S* r*g+)1z3Flags and helpers for the compute routers commands.    )absolute_import)division)unicode_literals)utils)arg_parsers)
completers)flags)	arg_utilsz    table(
      name,
      region.basename(),
      network.basename().if(network),
      ncc_gateway.basename().if(ncc_gateway)
    )z^    table(
      name,
      region.basename(),
      network.basename().yesno(no="N/A")
    )z,Default (Google-managed) BGP advertisements.z,Custom (user-configured) BGP advertisements.)DEFAULTCUSTOMALL_SUBNETSzyAutomatically advertise all available subnets. This excludes any routes learned for subnets that use VPC Network Peering.zAThe Cloud Router will initiate the BFD session for this BGP peer.z]The Cloud Router will wait for the peer router to initiate the BFD session for this BGP peer.z"BFD is disabled for this BGP peer.)ACTIVEPASSIVEDISABLEDc                   (   ^  \ rS rSrU 4S jrSrU =r$ )RoutersCompleterB   c                 4   > [         [        U ]
  " SSSS.UD6  g )Ncompute.routerszcompute routers list --uri)
collectionlist_command )superr   __init__)selfkwargs	__class__s     7lib/googlecloudsdk/command_lib/compute/routers/flags.pyr   RoutersCompleter.__init__D   s(    	
D* $1     r   )__name__
__module____qualname____firstlineno__r   __static_attributes____classcell__)r   s   @r   r   r   B   s     r    r   c           	      X    [         R                  " S[        UU S[         R                  S9$ )Nrouterr   )resource_name	completerpluralrequiredregional_collectionregion_explanationcompute_flagsResourceArgumentr   REGION_PROPERTY_EXPLANATION)r,   r+   s     r   RouterArgumentr3   L   s-    		'	' +&BB
 r    c                 \    [         R                  " SS[        SU SS[         R                  S9$ )Nr(   --routerFr   z"Router to use for dynamic routing.)r)   namer*   r+   r,   r-   
short_helpr.   r/   r,   s    r   RouterArgumentForVpnTunnelr9   W   s3    		'	' +5&BB	
 	r    c                 F    Sn[         R                  " SS[        SU SSUUS9	$ )NzUShould be the same as --region, if not specified, it will be inherited from --region.r(   r5   Fr   z/Google Cloud Router to use for dynamic routing.)	r)   r6   r*   r+   r,   r-   r7   r.   region_hiddenr0   r1   r   )r,   suppress_regionr.   s      r   RouterArgumentForOtherResourcesr>   d   s<    ,  
	'	' +B+#

 
r    c                  @    [         R                  " SS[        SSSSSS9$ )Nr(   r5   FTr   zRouter to use for NAT.)r)   r6   r*   r+   r,   r-   r7   r;   r<   r   r    r   RouterArgumentForNatr@   v   s-    		'	' +)	
 	r    c                 :    U R                  SSS9  [        U 5        g)z+Adds common arguments for creating routers.z--descriptionz'An optional description of this router.helpN)add_argument	AddAsnArgparsers    r   AddCreateRouterArgsrH      s'     	E   Fr    c           	      N    U R                  S[        R                  " SSSS9SS9  g)	z-Adds keepalive interval argument for routers.z--keepalive-intervals20s60s)default_unitlower_boundupper_boundac  The interval between BGP keepalive messages that are sent to the peer. If set, this value must be between 20 and 60 seconds. The default is 20 seconds. See $ gcloud topic datetimes for information on duration formats.

BGP systems exchange keepalive messages to determine whether a link or host has failed or is no longer available. Hold time is the length of time in seconds that the BGP session is considered operational without any activity. After the hold time expires, the session is dropped.

Hold time is three times the interval at which keepalive messages are sent, and the hold time is the maximum number of seconds allowed to elapse between successive keepalive messages that BGP receives from a peer. BGP will use the smaller of either the local hold time value or the peer's  hold time value as the hold time for the BGP connection between the two peers.typerC   N)rD   r   DurationrF   s    r   AddKeepaliveIntervalArgrS      s2    5/  r    c                 B    U R                  S[        R                  SS9  g)z/Adds BGP identifier range argument for routers.z--bgp-identifier-rangea  The range of valid BGP Identifiers for this Router. Must be a link-local IPv4 range from 169.254.0.0/16, of size at least /30, even if the BGP sessions are over IPv6. It must not overlap with any IPv4 BGP session ranges. This is commonly called "router ID" by other vendors.rP   N)rD   r   IPV4RangeArgumentrF   s    r   AddBgpIdentifierRangeArgrV      s&    ""	  
r    c                 .    U R                  S[        SS9  g)zNccGateway for router.z--ncc-gatewayz The NCC gateway for this router.rP   N)rD   strrF   s    r   AddNccGatewayArgrY      s    -  r    c                 0    U R                  SS[        SS9  g)zAdds Asn argument for routers.z--asnFzThe optional BGP autonomous system number (ASN) for this router. Must be a 16-bit or 32-bit private ASN as defined in https://tools.ietf.org/html/rfc6996, for example `--asn=64512`.r,   rQ   rC   N)rD   intrF   s    r   rE   rE      s$    L  	r    c                 V   SnU(       a  SnU R                  SSSR                  U5      S9  U R                  S[        R                  SS	9  U R                  S
[        R
                  " SSS9SS	9  U R                  S[        R                  SSS.SS9  U(       d  U R                  SSS9  gg)zDAdds common arguments for routers add-interface or update-interface.addedupdatedz--interface-nameTz$The name of the interface being {0}.r,   rC   --ip-addresszMThe link local (IPv4) or ULA (IPv6) address of the router for this interface.rP   z--mask-lengthr   ~   rN   rO   zThe subnet mask for the IP range of the interface. The interface IP address and BGP peer IP address must be selected from the subnet defined by this range.z--ip-versionzInterface with IPv4-based BGP.zInterface with IPv6-based BGP.)IPV4IPV6zQIP version of the interface. Possible values are IPV4 and IPV6. Defaults to IPV4.)rQ   choicesrC   z--redundant-interfacez9The interface that is redundant to the current interface.rB   N)rD   formatr   
IPArgumentr   
BoundedIntr
   ChoiceToEnumName)rG   
for_update	operations      r   AddInterfaceArgsrm      s     )I188C   		   	!!aSA+	   	%%22
   

H   
r    c           
         SnU(       a  SnU R                  SSSR                  U5      S9  U R                  SUSS9  U R                  S	U[        S
S9  U(       d  U R                  S[        R                  SS9  U R                  S[        R                  SS9  U R                  S[
        R                  " SSS9SS9  SR                  U(       a  SOS5      nU R                  US9nUR                  S[        S SSS9  UR                  S[
        R                  " S S!S"S S#9S$S9  UR                  S%[
        R                  " S S!S"S S#9S&S9  UR                  S'[        S(S9  S)nU(       d  US*-  nU R                  S+[
        R                  US,9  S-nU(       d  US.-  nU R                  S/[
        R                  US,9  U R                  S0[        R                  S1S9  U R                  S2[        R                  S3S9  S4nU(       d  US5-  nU R                  S6[
        R                  US,9  U R                  S7[        R                  S8S9  U R                  S9[        R                  S:S9  U R                  S;[        S<S9  U(       a  U R                  S=S>S?S@SA9  U R                  SBSC[
        R                  " 5       SDSE9  U R                  SF[
        R                  " 5       SGSHSI9  g?)Jz-Adds common arguments for managing BGP peers.r_   r^   z--peer-nameTz'The name of the new BGP peer being {0}.r`   z--interfacez,The name of the interface for this BGP peer.z
--peer-asnzThe BGP autonomous system number (ASN) for this BGP peer. Must be a 16-bit or 32-bit private ASN as defined in https://tools.ietf.org/html/rfc6996, for example `--asn=64512`.r[   ra   zThe address of the Cloud Router interface for this BGP peer. Must be a link-local IPv4 address in  the range 169.254.0.0/16 or an ULA IPv6 address in the range fdff:1::/64. It must also be in the same subnet as the interface address of the peer router.rP   z--peer-ip-addresszThe address of the peer router. Must be a link-local IPv4 address in the range 169.254.0.0/16 or an ULA IPv6 address in the range fdff:1::/64.z--advertised-route-priorityr     rc   zThe priority of routes advertised to this BGP peer. In the case where there is more than one matching route of maximum length, the routes with lowest priority value win. 0 <= priority <= 65535. If not specified, will use Google-managed priorities.zCArguments to {0} BFD (Bidirectional Forwarding Detection) settings:update	configurerB   z!--bfd-session-initialization-modec                 "    U R                  5       $ Nuppermodes    r   <lambda> AddBgpPeerArgs.<locals>.<lambda>H  
    

r    BFD_SESSION_INITIALIZATION_MODEa*  The BFD session initialization mode for this BGP peer. Must be one of:

ACTIVE - The Cloud Router will initiate the BFD session for this BGP peer.

PASSIVE - The Cloud Router will wait for the peer router to initiate the BFD session for this BGP peer.

DISABLED - BFD is disabled for this BGP peer.rf   rQ   metavarrC   z--bfd-min-transmit-intervalms1000ms30000ms)rM   rN   rO   parsed_unitzThe minimum transmit interval between BFD control packets. The default is 1000 milliseconds. See $ gcloud topic datetimes for information on duration formats.z--bfd-min-receive-intervalzThe minimum receive interval between BFD control packets. The default is 1000 milliseconds. See $ gcloud topic datetimes for information on duration formats.z--bfd-multiplierzqThe number of consecutive BFD control packets that must be missed before BFD declares that a peer is unavailable.zIf enabled, the peer connection can be established with routing information. If disabled, any active session with the peer is terminated and all associated routing information is removed.z Enabled by default.z	--enabled)actionrC   zIf IPv6 is enabled, the peer connection can be established with IPv6 route exchange. If disabled, no IPv6 route exchange is allowed on any active session.z Disabled by default.z--enable-ipv6z--ipv6-nexthop-addressa^  If IPv6 route exchange is enabled for IPv4-based BGP, the IPv6 next hop address of the Cloud Router interface for this BGP peer. Ignored otherwise. Must be a Google owned global unicast IPv6 address belonging to the range 2600:2d00:0:2:0:0:0:0/64 or 2600:2d00:0:3:0:0:0:0/64 and must belong to same subnet as the interface address of the peer router.z--peer-ipv6-nexthop-addresszIf IPv6 route exchange is enabled for IPv4-based BGP, the IPv6 next hop address of the peer router. Ignored otherwise. Must be a Google owned global unicast IPv6 address belonging to the range 2600:2d00:0:2:0:0:0:0/64 or 2600:2d00:0:3:0:0:0:0/64.zIf IPv4 is enabled, the peer connection can be established with IPv4 route exchange. If disabled, no IPv4 route exchange is allowed on any active session.z0 By default enabled for IPv4-based BGP sessions.z--enable-ipv4z--ipv4-nexthop-addressa.  If IPv4 route exchange is enabled for IPv6-based BGP, the IPv4 next hop address of the Cloud Router interface for this BGP peer. Ignored otherwise. Must be a Google owned link-local IPv4 address in the range 169.254.0.0/16 and must belong to the same subnet as the interface address of the peer router.z--peer-ipv4-nexthop-addresszIf IPv4 route exchange is enabled for IPv6-based BGP, the IPv4 next hop address of the peer router. Ignored otherwise. Must be a Google owned link-local IPv4 address in the range 169.254.0.0/16.z--md5-authentication-keyz{The MD5 authentication key for this BGP peer. Maximum length is 80 characters. Can contain only printable ASCII characters.z--clear-md5-authentication-key
store_trueNz:If specified, remove MD5 authentication from the BGP peer.)r   defaultrC   z--export-policiesEXPORT_POLICYz]Comma-separated list of export policies. Passing an empty string removes all export policies.)r}   rQ   rC   z--import-policiesIMPORT_POLICYz]Comma-separated list of import policies. Passing an empty string removes all import policies.rQ   r}   rC   )rD   rg   r\   r   rh   r   ri   	add_group(_BFD_SESSION_INITIALIZATION_MODE_CHOICESrR   StoreTrueFalseActionIPV6ArgumentIPV4ArgumentrX   ArgList)	rG   for_add_bgp_peer	is_updaterl   bfd_group_help	bfd_groupenabled_display_helpenable_ipv6_display_helpenable_ipv4_display_helps	            r   AddBgpPeerArgsr      s    )I4;;IF   	9   	L  	 

	  
 	 	   	#!!aUCI	  	&YK@  N3))6$/0   #	-   "	-   C	  F  
22--   
 
 77--#   	3	   	#C	  	 
 
: 	--#   	7	  
 	#O	   	 H	   
(I	   	 *   	 *  r    c                 0    [        X5        [        X5        g)zAAdds common arguments for setting/updating custom advertisements.N)!AddReplaceCustomAdvertisementArgs%AddIncrementalCustomAdvertisementArgsrG   resource_strs     r    AddUpdateCustomAdvertisementArgsr     s     $F9'=r    c           	      *   U R                  S[        S SSR                  U5      S9  U R                  S[        R                  " [
        S S9S	S
R                  U5      S9  U R                  S[        R                  " SS9SSR                  U5      S9  g)z:Adds common arguments for replacing custom advertisements.z--advertisement-modec                 "    U R                  5       $ rs   rt   rv   s    r   rx   3AddReplaceCustomAdvertisementArgs.<locals>.<lambda>  rz   r    MODEz(The new advertisement mode for this {0}.r|   z--set-advertisement-groupsc                 "    U R                  5       $ rs   rt   groups    r   rx   r   	  
    U[[]r    rf   element_typeGROUPzThe list of pre-defined groups of IP ranges to dynamically
              advertise on this {0}. This list can only be specified in
              custom advertisement mode.r   z--set-advertisement-rangesTallow_key_onlyCIDR_RANGE=DESCa  The list of individual IP ranges, in CIDR format, to dynamically
              advertise on this {0}. Each IP range can (optionally) be given a
              text description DESC. For example, to advertise a specific range,
              use `--set-advertisement-ranges=192.168.10.0/24`.  To store a
              description with the range, use
              `--set-advertisement-ranges=192.168.10.0/24=my-networks`. This
              list can only be specified in custom advertisement mode.N)rD   _MODE_CHOICESrg   r   r   _GROUP_CHOICESArgDictr   s     r   r   r     s     	$9@@N   	" /J ,,2F<,@  	 	"d3J KQ&
K  r    c                    U R                  SS9nUR                  S[        R                  " [        S S9SSR                  U5      S9  UR                  S	[        R                  " [        S
 S9SSR                  U5      S9  UR                  S[        R                  " SS9SSR                  U5      S9  UR                  S[        R                  " 5       SSR                  U5      S9  g)zGAdds common arguments for incrementally updating custom advertisements.Fr8   z--add-advertisement-groupsc                 "    U R                  5       $ rs   rt   r   s    r   rx   7AddIncrementalCustomAdvertisementArgs.<locals>.<lambda>)  r   r    r   r   zA list of pre-defined groups of IP ranges to dynamically advertise
              on this {0}. This list is appended to any existing advertisements.
              This field can only be specified in custom advertisement mode.r   z--remove-advertisement-groupsc                 "    U R                  5       $ rs   rt   r   s    r   rx   r   6  r   r    a  A list of pre-defined groups of IP ranges to remove from dynamic
              advertisement on this {0}. Each group in the list must exist in
              the current set of custom advertisements. This field can only be
              specified in custom advertisement mode.z--add-advertisement-rangesTr   r   a(  A list of individual IP ranges, in CIDR format, to dynamically
              advertise on this {0}. This list is appended to any existing
              advertisements. Each IP range can (optionally) be given a text
              description DESC. For example, to advertise a specific range, use
              `--advertisement-ranges=192.168.10.0/24`.  To store a description
              with the range, use
              `--advertisement-ranges=192.168.10.0/24=my-networks`. This list
              can only be specified in custom advertisement mode.z--remove-advertisement-ranges
CIDR_RANGEa  A list of individual IP ranges, in CIDR format, to remove from
              dynamic advertisement on this {0}. Each IP range in the list must
              exist in the current set of custom advertisements. This field can
              only be specified in custom advertisement mode.N)add_mutually_exclusive_grouprD   r   r   r   rg   r   )rG   r   incremental_argss      r   r   r   !  s    88%8H" /J PPVPV
Q    % /J 9 :@9M   
 "d3E FLV
F     % A BH
B   
r    c                 0    [        U 5        [        U 5        g)zrAdds common arguments for setting/updating custom learned routes.

Args:
  parser: The parser to parse arguments.
N)!AddReplaceCustomLearnedRoutesArgs%AddIncrementalCustomLearnedRoutesArgsrF   s    r    AddUpdateCustomLearnedRoutesArgsr   \  s     $F+'/r    c                     U R                  S[        R                  " SSS9SSS9  U R                  S[        R                  " 5       S	S
S9  g)zkAdds common arguments for replacing custom learned routes.

Args:
  parser: The parser to parse arguments.
z--custom-learned-route-priorityr   ro   rc   PRIORITYa  An integral value `0` <= priority <= `65535`, to be applied to all
              custom learned route IP address ranges for this peer. If not
              specified, a Google-managed priority value of 100 is used. The
              routes with the lowest priority value win.r   z!--set-custom-learned-route-rangesr   a  The list of user-defined custom learned route IP address ranges
              for this peer. This list is a comma separated IP address ranges
              such as `1.2.3.4`,`6.7.0.0/16`,`2001:db8:abcd:12::/64` where each
              IP address range must be a valid CIDR-formatted prefix. If an IP
              address is provided without a subnet mask, it is interpreted as a
              /32 singular IP address range for IPv4, and /128 for IPv6.N)rD   r   ri   r   rF   s    r   r   r   g  s_     	'!!aUC<	   	) L	  
r    c                     U R                  SS9nUR                  S[        R                  " 5       SSS9  UR                  S[        R                  " 5       SSS9  g	)
zxAdds common arguments for incrementally updating custom learned routes.

Args:
  parser: The parser to parse arguments.
Fr8   z!--add-custom-learned-route-rangesr   a  A list of user-defined custom learned route IP address ranges to
              be added to this peer. This list is a comma separated IP address
              ranges such as `1.2.3.4`,`6.7.0.0/16`,`2001:db8:abcd:12::/64`
              where each IP address range must be a valid CIDR-formatted prefix.
              If an IP address is provided without a subnet mask, it is
              interpreted as a /32 singular IP address range for IPv4, and /128
              for IPv6.r   z$--remove-custom-learned-route-rangesa  A list of user-defined custom learned route IP address ranges to
              be removed from this peer. This list is a comma separated IP
              address ranges such as `1.2.3.4`,`6.7.0.0/16`,`2001:db8:abcd:12::/64`
              where each IP address range must be a valid CIDR-formatted prefix.
              If an IP address is provided without a subnet mask, it is
              interpreted as a /32 singular IP address range for IPv4, and /128
              for IPv6.N)r   rD   r   r   )rG   r   s     r   r   r     sn     88%8H) 	    , 	   r    c                 &    U R                  SSSS9  g)z/Adds common arguments for get-nat-mapping-info.
--nat-nameFz2The NAT name to filter out NAT mapping informationr`   NrD   rF   s    r   AddGetNatMappingInfoArgsr     s      	?  r    c                 &    U R                  SSSS9  g)z.Adds common arguments for get-ip-mapping-info.r   Fz-The NAT name to filter out NAT IP informationr`   Nr   rF   s    r   AddGetNatIpInfoArgsr     s      	:  r    c                 *    U R                  SSSSSS9  g)z(Adds encrypted interconnect router flag.z--encrypted-interconnect-routerFr   NzfIndicates if a router is dedicated for use with encrypted interconnect attachments (VLAN attachments).)r,   r   r   rC   r   rF   s    r   AddEncryptedInterconnectRouterr     s&    '9  	r    N)TF)T)TT)F)FF)+__doc__
__future__r   r   r   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer   compute_completersr	   r0   $googlecloudsdk.command_lib.util.apisr
   DEFAULT_CREATE_FORMATDEFAULT_LIST_FORMATr   r   r   ListCommandCompleterr   r3   r9   r>   r@   rH   rS   rV   rY   rE   rm   r   r   r   r   r   r   r   r   r   r   r   r    r   <module>r      s    : &  ' 0 / O E :	 	  >< 	G 	L	% 5	, ()>> 
$
4/drj>#L8v0<!Hr    