
                         l    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 r
SS	 jrSS
 jrS rg)zRFlags and helpers for the Distributed Cloud Edge Network routers related commands.    )absolute_import)division)unicode_literalsN)utils)arg_parsersc                 *    SnU R                  SUSS9  g)z.Adds a --description flag to the given parser.zDescription for the subnet.z--descriptionFhelprequiredN)add_argument)parser	help_texts     Elib/googlecloudsdk/command_lib/edge_cloud/networking/routers/flags.pyAddDescriptionFlagr      s    /)oIF    c                 &   SnSnU(       a  SnU R                  SSR                  U5      SS9  U R                  SUSS9nUR                  S	S
9nUR                  SSR                  U5      S
9  UR                  SS
9nUR                  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S
9nUR                  S[
        R                  " 5       SSS9  g)zDAdds common arguments for routers add-interface or update-interface.z@The argument group for configuring the interface for the router.addedupdatedz--interface-namez$The name of the interface being {0}.Tr	   )mutexr
   r   zCThe argument group for adding southbound interfaces to edge router.r
   z--subnetworkz&Subnetwork of the interface being {0}.zCThe argument group for adding northbound interfaces to edge router.z--interconnect-attachmentz3Interconnect attachment of the interface being {0}.z--ip-addressz4Link-local address of the router for this interface.)typer
   z--ip-mask-lengthr      )lower_boundupper_boundzSubnet mask for the link-local IP range of the interface. The interface IP address and BGP peer IP address must be selected from the subnet defined by this link-local range.zAThe argument group for adding loopback interfaces to edge router.z--loopback-ip-addressesLOOPBACK_IP_ADDRESSESz1The list of ip ranges for the loopback interface.)r   metavarr
   N)r   formatadd_argument_groupr   
IPArgumentr   
BoundedIntArgList)r   
for_updater   	operationinterface_groupsouthbound_interface_groupnorthbound_interface_grouploopback_interface_groups           r   AddInterfaceArgsr(   !   s    M  )I188C  
 --y4 . /  /AAP  B   ))3::9E *   /AAP  B   ))!@GG
 *  ))A * 
 ))!!aSA?	 *  -??N @  '' %>	 ( r   c                 4   SnU(       a  SnU R                  SU(       + SS9  U R                  SSSR                  U5      S9  U R                  S	U(       + [        S
S9  U R                  U(       + S9nUR                  SSS9  U(       a  UR                  SSS9  gg)z-Adds common arguments for managing BGP peers.r   r   z--interfacez,The name of the interface for this BGP peer.)r   r
   z--peer-nameTz'The name of the new BGP peer being {0}.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   r   r
   )r   z--peer-ipv4-rangez5The IPv4 link-local address range of the peer router.r   z--peer-ipv6-rangez5The IPv6 link-local address range of the peer router.N)r   r   intadd_mutually_exclusive_group)r   r"   enable_peer_ipv6_ranger#   ip_address_parsers        r   AddBgpPeerArgsr.   _   s     )I~9  ; 	4;;IF  H 	~H	  I 99~ :    B !  ""D #  r   c                     S nS nU R                  SS9nUR                  SU" SS5      U/ S9  UR                  S	U" S
S5      U/ S9  UR                  SU" SS5      U/ S9  g)zAdds arguments for Update.c                 $    SR                  X5      $ )NzH{} the comma-separated list of CIDRs {} the set of range advertisements.)r   )verbpreps     r   helptextAddUpdateArgs.<locals>.helptext   s    %vd12r   c                     U R                  S5      n[        [        R                  U5      n[	        U5      n[        U5      n[        U5      [        U5      :w  a  [        S5      eU$ )N,zCIDR list contained duplicates.)splitmap	ipaddress
ip_networksortedsetlen
ValueError)argstrr7   parsedretlistretsets        r   cidrlistAddUpdateArgs.<locals>.cidrlist   sU    LLE%%u-FVnG\F
7|s6{"899Nr   T)r   z--add-advertisement-rangesaddto)r
   r   defaultz--set-advertisement-rangesreplacewithz--remove-advertisement-rangesremovefromN)r   r   )r   r3   rC   	adv_groups       r   AddUpdateArgsrM      s    2 ''d'3)"E4 	  
 "Iv&	  
 %Hf%	  r   )F)FF)__doc__
__future__r   r   r   r9   ,googlecloudsdk.api_lib.edge_cloud.networkingr   googlecloudsdk.callioper   r   r(   r.   rM    r   r   <module>rS      s4    Y &  '  > /G;|!Hr   