+
    i>+                         ^ RI t ^ RIt^ RIt^ RIHtHtHtHt ^ RIH	t	 ^ RI
Ht ]P                  ! ]4      t]t]t ! R R] P&                  R7      t ! R R	]4      t ! R
 R]4      t ! R R]4      tR# )    N)netperformancesubputil)ifconfig)Iproute2c                     a  ] tR t^t o RtV 3R lR ltRR/V 3R lR llt]P                  V 3R lR	 l4       t	V 3R
 lR lt
V 3R lR ltV 3R lR ltR tRR/V 3R lR lltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR  ltV 3R! lR" ltR#R/V 3R$ lR% lltV 3R& lR' ltV 3R( lR) lt]P                  V 3R* lR+ l4       tV 3R, lR- ltV 3R. lR/ ltV 3R0 lR1 ltV 3R2 lR3 lt]P                  R4R/V 3R5 lR6 ll4       tR#R7/V 3R8 lR9 llt]P                  V 3R: lR; l4       t R<t!V t"R# )=
NetworkingzThe root of the Networking hierarchy in cloud-init.

This is part of an ongoing refactor in the cloud-init codebase, for more
details see "``cloudinit.net`` -> ``cloudinit.distros.networking``
Hierarchy" in CONTRIBUTING.rst for full details.
c                    < V ^8  d   QhRS[ /#    returndict)format__classdict__s   ">/usr/lib/python3/dist-packages/cloudinit/distros/networking.py__annotate__Networking.__annotate__   s     . .$ .    c                ,    \         P                  ! 4       # N)r   _get_current_rename_infoselfs   &r   r   #Networking._get_current_rename_info   s    ++--r   current_infoNc                $   < V ^8  d   QhRS[ RR/# )r   renamesr   Nlist)r   r   s   "r   r   r      s     J J$ J Jr   c               0    \         P                  ! WR 7      # ))r   )r   _rename_interfaces)r   r   r   s   &&$r   r#   Networking._rename_interfaces   s    %%gIIr   c                $   < V ^8  d   QhRS[ RR/# r   netcfgr   NNetworkConfig)r   r   s   "r   r   r   !   s     F F F4 Fr   c                    R# )z7Read the network config and rename devices accordingly.N r   r'   s   &&r   apply_network_config_names%Networking.apply_network_config_names        r   c                    < V ^8  d   QhRS[ /# r   devname
DeviceName)r   r   s   "r   r   r   $   s     ) )J )r   c                .    \         P                  ! V4      # r   )r   device_devidr   r2   s   &&r   r6   Networking.device_devid$   s    ((r   c                    < V ^8  d   QhRS[ /# r1   r3   )r   r   s   "r   r   r   '   s     * *Z *r   c                .    \         P                  ! V4      # r   )r   device_driverr7   s   &&r   r;   Networking.device_driver'   s      ))r   c                &   < V ^8  d   QhRS[ RS[/# )r   r'   r   )r)   r!   )r   r   s   "r   r   r   *   s     , ,} , ,r   c                .    \         P                  ! V4      # r   )r   extract_physdevsr,   s   &&r   r?   Networking.extract_physdevs*   s    ##F++r   c                ,    \         P                  ! 4       # r   )r   find_fallback_nicr   s   &r   rB   Networking.find_fallback_nic-   s    $$&&r   config_driverFc                    < V ^8  d   QhRS[ /# )r   rD   )bool)r   r   s   "r   r   r   0   s     I I Ir   c               0    \         P                  ! VR 7      # ))rD   )r   generate_fallback_config)r   rD   s   &$r   rH   #Networking.generate_fallback_config0   s    ++-HHr   c                    < V ^8  d   QhRS[ /# r   r    )r   r   s   "r   r   r   3        $ $ $r   c                ,    \         P                  ! 4       # r   )r   get_devicelistr   s   &r   rM   Networking.get_devicelist3       !!##r   c                    < V ^8  d   QhRS[ /# r   r   )r   r   s   "r   r   r   6   s     1 1T 1r   c                ,    \         P                  ! 4       # r   )r   get_ib_hwaddrs_by_interfacer   s   &r   rR   &Networking.get_ib_hwaddrs_by_interface6   s    ..00r   c                &   < V ^8  d   QhRS[ RS[/# )r   r2   ethernet_formatr4   rF   )r   r   s   "r   r   r   9   s!     E E!E48Er   c                .    \         P                  ! W4      # r   )r   get_ib_interface_hwaddr)r   r2   rU   s   &&&r   rX   "Networking.get_ib_interface_hwaddr9   s     **7DDr   c                    < V ^8  d   QhRS[ /# r1   r3   )r   r   s   "r   r   r   >   s     . . .r   c                .    \         P                  ! V4      # r   )r   get_interface_macr7   s   &&r   r\   Networking.get_interface_mac>       $$W--r   c                    < V ^8  d   QhRS[ /# r   r    )r   r   s   "r   r   r   A   rK   r   c                ,    \         P                  ! 4       # r   )r   get_interfacesr   s   &r   ra   Networking.get_interfacesA   rO   r   c                    < V ^8  d   QhRS[ /# r   r   )r   r   s   "r   r   r   D   s     + +t +r   c                ,    \         P                  ! 4       # r   )r   get_interfaces_by_macr   s   &r   re    Networking.get_interfaces_by_macD   s    ((**r   c                    < V ^8  d   QhRS[ /# r1   r3   )r   r   s   "r   r   r   G   s     ' '* 'r   c                .    \         P                  ! V4      # r   )r   
get_masterr7   s   &&r   ri   Networking.get_masterG       ~~g&&r   strictc                ,   < V ^8  d   QhRS[ RS[RS[/# )r   r2   rl   r   rV   )r   r   s   "r   r   r   J   s*     A A!A.2A	Ar   c               0    \         P                  ! WR 7      # ))rl   )r   interface_has_own_mac)r   r2   rl   s   &&$r   ro    Networking.interface_has_own_macJ   s     ((@@r   c                &   < V ^8  d   QhRS[ RS[/# r   r2   r   rV   )r   r   s   "r   r   r   O        $ $z $d $r   c                .    \         P                  ! V4      # r   )r   is_bondr7   s   &&r   ru   Networking.is_bondO       {{7##r   c                &   < V ^8  d   QhRS[ RS[/# rr   rV   )r   r   s   "r   r   r   R   s     & & & &r   c                .    \         P                  ! V4      # r   )r   	is_bridger7   s   &&r   rz   Networking.is_bridgeR   s    }}W%%r   c                &   < V ^8  d   QhRS[ RS[/# rr   rV   )r   r   s   "r   r   r   V   s      : $ r   c                    R# )z
Is ``devname`` a physical network device?

Examples of non-physical network devices: bonds, bridges, tunnels,
loopback devices.
Nr+   r7   s   &&r   is_physicalNetworking.is_physicalU   r/   r   c                &   < V ^8  d   QhRS[ RS[/# rr   rV   )r   r   s   "r   r   r   ^   s     ' '* ' 'r   c                .    \         P                  ! V4      # r   )r   
is_renamedr7   s   &&r   r   Networking.is_renamed^   rk   r   c                &   < V ^8  d   QhRS[ RS[/# rr   rV   )r   r   s   "r   r   r   a   s     " "Z "D "r   c                .    \         P                  ! V4      # r   )r   is_upr7   s   &&r   r   Networking.is_upa   s    yy!!r   c                &   < V ^8  d   QhRS[ RS[/# rr   rV   )r   r   s   "r   r   r   d   rs   r   c                .    \         P                  ! V4      # r   )r   is_vlanr7   s   &&r   r   Networking.is_vland   rw   r   c                &   < V ^8  d   QhRS[ RS[/# rr   rV   )r   r   s   "r   r   r   g   s     5 5
 5t 5r   c                .    \         P                  ! V4      # r   )r   master_is_bridge_or_bondr7   s   &&r   r   #Networking.master_is_bridge_or_bondg   s    ++G44r   existsc                   < V ^8  d   QhRR/# r   r   Nr+   )r   r   s   "r   r   r   k   s     	 	 	r   c                   R# )af  Wait for device population in the system to complete.

:param exists:
    An optional optimisation.  If given, only perform as much of the
    settle process as is required for the given DeviceName to be
    present in the system.  (This may include skipping the settle
    process entirely, if the device already exists.)
:type exists: Optional[DeviceName]
Nr+   r   r   s   &$r   settleNetworking.settlej   r/   r   Tc                *   < V ^8  d   QhRS[ RS[RR/# )r   r'   rl   r   N)r)   rF   )r   r   s   "r   r   r   v   s%     0$ 0$#0$040$	0$r   c          	     D   V P                  V4      p\        V Uu. uF  qD^ ,          V^,          3NK  	  up4      p\        VP                  4       4      pV P	                  4       P                  4       p\        ^4       F  pVP                  V4      '       d   \        P                  R4        R# VP                  V4      p	\        P                  RV	4       V	 FW  p
WZ,          pRP                  V4      p\        P                  ! VRR7      ;_uu_ 4        V P                  VR7       RRR4       KY  	  V P	                  4       P                  4       pK  	  RX	,          p\        P                  V4       V'       d   \        V4      hR# u upi   + '       g   i     K  ; i)	a  Wait for all the physical devices in `netcfg` to exist on the system

Specifically, this will call `self.settle` 5 times, and check after
each one if the physical devices are now present in the system.

:param netcfg:
    The NetworkConfig from which to extract physical devices to wait
    for.
:param strict:
    Raise a `RuntimeError` if any physical devices are not present
    after waiting.
z*net: all expected physical devices presentNz)net: waiting for expected net devices: %szWaiting for settle or {} existsalways)log_moder   z-Not all expected physical devices present: %s)r?   r   setkeysre   rangeissubsetLOGdebug
differencer   r   Timedr   warningRuntimeError)r   r'   rl   physdevsifaceexpected_ifacesexpected_macspresent_macs_missingmacr2   msgs   &&$          r   wait_for_physdevsNetworking.wait_for_physdevsv   sW    ((0 (K(q58 4(KLO0023 11388: qA%%l33		FG#..|<GIIA7K).7>>wG &&sX>>KKwK/ ?>	   557<<>L " >GCs## ;  L* ?>>s   F	F	Fc                &   < V ^8  d   QhRS[ RS[/# rr   rV   )r   r   s   "r   r   r      s     L Lz Ld Lr   c                    R# )z=Try setting the link to up explicitly and return if it is up.Nr+   r7   s   &&r   try_set_link_upNetworking.try_set_link_up   r/   r   r+   )#__name__
__module____qualname____firstlineno____doc__r   r#   abcabstractmethodr-   r6   r;   r?   rB   rH   rM   rR   rX   r\   ra   re   ri   ro   ru   rz   r~   r   r   r   r   r   r   r   __static_attributes____classdictcell__r   s   @r   r
   r
      s    . .J J J 	F F) )* *, ,'I I I$ $1 1E E
. .$ $+ +' 'A5:A A
$ $& & 	 ' '" "$ $5 5 		t 	 	 	0$7;0$ 0$d 	L Lr   r
   )	metaclassc                      a a ] tR t^t oRtV 3R lt]V3R lR l4       tR tV3R lR lt	V3R lR	 lt
V3R
 lR ltV3R lR ltV3R lR ltV3R lR ltRR/V3R lR lltV3R lR ltRtVtV ;t# )BSDNetworkingz>Implementation of networking functionality shared across BSDs.c                f   < \         P                  ! 4       V n        / V n        \        SV `  4        R # r   )r   Ifconfigifc_ifssuper__init__)r   	__class__s   &r   r   BSDNetworking.__init__   s%    $$&	r   c                    < V ^8  d   QhRS[ /# r   r   )r   r   s   "r   r   BSDNetworking.__annotate__   s      T r   c                ^    V P                   '       g   V P                  4        V P                   # r   )r   _update_ifsr   s   &r   ifsBSDNetworking.ifs   s!    yyyyyr   c                    \         P                   ! R R.4      pV^ ,          '       d*   V P                  P                  V^ ,          4      V n        R# R# )r   z-aN)r   r   parser   )r   ifconfs   & r   r   BSDNetworking._update_ifs   s=    J-. !99vay1DI r   c                $   < V ^8  d   QhRS[ RR/# r&   r(   )r   r   s   "r   r   r      s     6 6 64 6r   c                0    \         P                  R 4       R# )z Cannot rename network interface.N)r   r   r,   s   &&r   r-   (BSDNetworking.apply_network_config_names   s    		45r   c                &   < V ^8  d   QhRS[ RS[/# rr   rV   )r   r   s   "r   r   r      s     - -: -$ -r   c                <    V P                   V,          P                  # r   )r   r~   r7   s   &&r   r~   BSDNetworking.is_physical   s    xx ,,,r   c                &   < V ^8  d   QhRS[ RS[/# rr   rV   )r   r   s   "r   r   r           ) )z )d )r   c                <    V P                   V,          P                  # r   )r   ru   r7   s   &&r   ru   BSDNetworking.is_bond       xx (((r   c                &   < V ^8  d   QhRS[ RS[/# rr   rV   )r   r   s   "r   r   r      s     + + + +r   c                <    V P                   V,          P                  # r   )r   rz   r7   s   &&r   rz   BSDNetworking.is_bridge   s    xx ***r   c                &   < V ^8  d   QhRS[ RS[/# rr   rV   )r   r   s   "r   r   r      r   r   c                <    V P                   V,          P                  # r   )r   r   r7   s   &&r   r   BSDNetworking.is_vlan   r   r   c                &   < V ^8  d   QhRS[ RS[/# rr   rV   )r   r   s   "r   r   r      s     $ $Z $D $r   c                <    V P                   V,          P                  # r   )r   upr7   s   &&r   r   BSDNetworking.is_up   s    xx ###r   r   Nc                   < V ^8  d   QhRR/# r   r+   )r   r   s   "r   r   r      s     ? ? ?r   c                   R# )z0BSD has no equivalent to `udevadm settle`; noop.Nr+   r   s   &$r   r   BSDNetworking.settle   r/   r   c                &   < V ^8  d   QhRS[ RS[/# rr   rV   )r   r   s   "r   r   r           # #z #d #r   c                V    \         P                   ! RVR.4       V P                  V4      # )Try setting the link to up explicitly and return if it is up.
Not guaranteed to bring the interface up. The caller is expected to
add wait times before retrying.r   r   )r   r   r7   s   &&r   r   BSDNetworking.try_set_link_up   s&     			:w-.zz'""r   )r   r   )r   r   r   r   r   r   propertyr   r   r-   r~   ru   rz   r   r   r   r   r   r   __classcell__)r   r   s   @@r   r   r      s     H
  
26 6- -) )+ +) )$ $?t ? ?# # #r   r   c                   D   a  ] tR t^t o V 3R lR ltV 3R lR ltRtV tR# )FreeBSDNetworkingc                $   < V ^8  d   QhRS[ RR/# r&   r(   )r   r   s   "r   r   FreeBSDNetworking.__annotate__   s       4 r   c                    R # r   r+   r,   s   &&r   r-   ,FreeBSDNetworking.apply_network_config_names   s    
 	r   c                &   < V ^8  d   QhRS[ RS[/# rr   rV   )r   r   s   "r   r   r      s      *  r   c                    V P                   V,          P                  '       g   R # \        P                  ! RRV.^ ^.R7      w  r#VRP                  V4      8X  d   R# R # )Fdevinfoz-p)rcszdevinfo: {}: Not found
T)r   r~   r   r   )r   r2   r   errs   &&  r   r   FreeBSDNetworking.is_renamed   sU    xx ,,,  ItW5Aq6B,33G<<r   r+   N)r   r   r   r   r-   r   r   r   r   s   @r   r   r      s       r   r   c                      a  ] tR tRt o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R	 lR
 ltV 3R lR lt	V 3R lR lt
V 3R lR ltV 3R lR ltRR/V 3R lR lltV 3R lR ltRtV tR# )LinuxNetworking   zCImplementation of networking functionality common to Linux distros.c                $   < V ^8  d   QhRS[ RR/# r&   r(   )r   r   s   "r   r   LinuxNetworking.__annotate__  s       4 r   c                     V P                  V P                  V4      4       R#   \         d   p\        RT,          4      ThRp?ii ; i)zRead the network config and rename devices accordingly.

Renames are only attempted for interfaces of type 'physical'. It is
expected that the network system will create other devices with the
correct name in place.
z(Failed to apply network config names: %sN)r#   r?   r   )r   r'   es   && r   r-   *LinuxNetworking.apply_network_config_names  sH    	##D$9$9&$AB 	:Q>	s    $ AAAc                &   < V ^8  d   QhRS[ RS[/# rr   )r4   str)r   r   s   "r   r   r    s     - -
 -s -r   c                .    \         P                  ! V4      # r   )r   get_dev_featuresr7   s   &&r   r
   LinuxNetworking.get_dev_features  s    ##G,,r   c                &   < V ^8  d   QhRS[ RS[/# rr   rV   )r   r   s   "r   r   r    s     8 8: 8$ 8r   c                .    \         P                  ! V4      # r   )r   has_netfail_standby_featurer7   s   &&r   r  +LinuxNetworking.has_netfail_standby_feature  s    ..w77r   c                &   < V ^8  d   QhRS[ RS[/# rr   rV   )r   r   s   "r   r   r    s     + +j +T +r   c                .    \         P                  ! V4      # r   )r   is_netfailoverr7   s   &&r   r  LinuxNetworking.is_netfailover  s    !!'**r   c                &   < V ^8  d   QhRS[ RS[/# rr   rV   )r   r   s   "r   r   r    s     . . . .r   c                .    \         P                  ! V4      # r   )r   is_netfail_masterr7   s   &&r   r  !LinuxNetworking.is_netfail_master  r^   r   c                &   < V ^8  d   QhRS[ RS[/# rr   rV   )r   r   s   "r   r   r         / /* / /r   c                .    \         P                  ! V4      # r   )r   is_netfail_primaryr7   s   &&r   r  "LinuxNetworking.is_netfail_primary      %%g..r   c                &   < V ^8  d   QhRS[ RS[/# rr   rV   )r   r   s   "r   r   r  !  r  r   c                .    \         P                  ! V4      # r   )r   is_netfail_standbyr7   s   &&r   r   "LinuxNetworking.is_netfail_standby!  r  r   c                &   < V ^8  d   QhRS[ RS[/# rr   rV   )r   r   s   "r   r   r  $  s     C C: C$ Cr   c                j    \         P                  P                  \        P                  ! VR 4      4      # )device)ospathr   r   sys_dev_pathr7   s   &&r   r~   LinuxNetworking.is_physical$  s"    ww~~c..wABBr   r   Nc                   < V ^8  d   QhRR/# r   r+   )r   r   s   "r   r   r  '  s     + + +r   c               h    Ve   \         P                  ! V4      p\        P                  ! VR7       R # )Nr   )r   r'  r   udevadm_settler   s   &$r   r   LinuxNetworking.settle'  s&    %%f-F6*r   c                &   < V ^8  d   QhRS[ RS[/# rr   rV   )r   r   s   "r   r   r  ,  r   r   c                P    \         P                  ! V4       V P                  V4      # )r   )r   link_upr   r7   s   &&r   r   LinuxNetworking.try_set_link_up,  s!     	!zz'""r   r+   )r   r   r   r   r   r-   r
  r  r  r  r  r   r~   r   r   r   r   r   s   @r   r   r      su     M - -8 8+ +. ./ // /C C+t + +
# #r   r   )r   loggingr%  	cloudinitr   r   r   r   cloudinit.distros.parsersr   cloudinit.net.netops.iproute2r   	getLoggerr   r   r  r4   r   r)   ABCMetar
   r   r   r   r+   r   r   <module>r7     sq    
  	 2 2 . 2!
 
XL3;; XLv/#J /#d B1#j 1#r   