
                         h    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 Z
dd	Zdd
Zd Zy)zRFlags and helpers for the Distributed Cloud Edge Network routers related commands.    )absolute_import)division)unicode_literalsN)utils)arg_parsersc                 0    d}| j                  d|d       y)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                 Z   d}d}|rd}| j                  ddj                  |      d       | j                  d|d      }|j                  d	
      }|j                  ddj                  |      
       |j                  d
      }|j                  ddj                  |      
       |j                  dt        j                  d       |j                  dt        j                  dd      d       |j                  d
      }|j                  dt        j                         dd       y)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                 ,   d}|rd}| j                  d| d       | j                  dddj                  |             | j                  d	| t        d
       | j                  |       }|j                  dd       |r|j                  dd       yy)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                     d }d }| j                  d      }|j                  d |dd      |g        |j                  d	 |d
d      |g        |j                  d |dd      |g        y)zAdds arguments for Update.c                 &    dj                  | |      S )NzH{} the comma-separated list of CIDRs {} the set of range advertisements.)r   )verbpreps     r   helptextzAddUpdateArgs.<locals>.helptext   s    %vdD12r   c                     | j                  d      }t        t        j                  |      }t	        |      }t        |      }t        |      t        |      k7  rt        d      |S )N,zCIDR list contained duplicates.)splitmap	ipaddress
ip_networksortedsetlen
ValueError)argstrr6   parsedretlistretsets        r   cidrlistz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   rB   	adv_groups       r   AddUpdateArgsrK      s    2 ''d'3)"E4 	  
 "Iv&	  
 %Hf%	  r   )F)FF)__doc__
__future__r   r   r   r8   ,googlecloudsdk.api_lib.edge_cloud.networkingr   googlecloudsdk.callioper   r   r(   r.   rK    r   r   <module>rQ      s4    Y &  '  > /G;|!Hr   