+
    i                       a  RQ t-0 t ^ RIt^ RIt^ RIt^ RIHtHtHtHt ^ RI	H
t
HtHt ^ RIHtHtHtHtHtHtHtHtHtHt ]'       d   ^ RIHt ]P4                  ! ]4      t^t^. RRO/t. RSOtR/ RRbR	R
bRRbRRbRRbRRbRRbRRbRRbRRbRRbRRbRR bR!R"bR#R$bR%R&bR'R(bR)R*R+R,/CR-R.R/R0R1R2R3R4RR5R6R7R8R9RR:R;R<R=R>R?R@R//t ] ^ k RA RB lt!RC t" ! RD RE]#4      t$RF t% ! RG RH4      t& ! RI RJ4      t'RK t(RTRL lt)RM t*RN t+RURO RP llt,R# )V    N)TYPE_CHECKINGAnyDictOptional)	lifecyclesafeyamlutil)
find_interface_name_from_macget_interfaces_by_macipv4_mask_to_net_prefixipv6_mask_to_net_prefixis_ip_networkis_ipv4_addressis_ipv4_networkis_ipv6_addressis_ipv6_networknet_prefix_to_ipv4_maskRendererbondzbond-ad-selectz	ad-selectzbond-all-slaves-activezall-slaves-activezbond-arp-all-targetszarp-all-targetszbond-arp-intervalzarp-intervalzbond-arp-ip-targetzarp-ip-targetzbond-arp-validatezarp-validatezbond-downdelayz
down-delayzbond-fail-over-maczfail-over-mac-policyzbond-lacp-ratez	lacp-ratezbond-learn-packet-intervalzlearn-packet-intervalzbond-miimonzmii-monitor-intervalzbond-min-linksz	min-linksz	bond-modemodezbond-num-grat-arpgratuitous-arpzbond-packets-per-slavezpackets-per-slavezbond-primaryprimaryzbond-primary-reselectzprimary-reselect-policyzbond-updelayzup-delayzbond-xmit-hash-policyztransmit-hash-policybridgebridge_ageingzageing-timebridge_bridgepriopriority	bridge_fdzforward-delaybridge_gcintbridge_helloz
hello-timebridge_maxagezmax-agebridge_maxwaitbridge_pathcostz	path-costbridge_portpriozport-priority
bridge_stpstpbridge_waitportc                (    V ^8  d   QhR\         RR/# )   diktreturnNdict)formats   "=/usr/lib/python3/dist-packages/cloudinit/net/network_state.py__annotate__r0   \   s     
 
d 
t 
    c                X    RV 9   g   RV 9   d   \         P                  ! RRRR7       R# R# )z8Warn about deprecations of v2 properties for all devicesgateway4gateway6z$The use of `gateway4` and `gateway6`z22.4zbFor more info check out: https://docs.cloud-init.io/en/latest/topics/network-config-format-v2.html)
deprecateddeprecated_versionextra_messageN)r   	deprecate)r*   s   &r/   warn_deprecated_all_devicesr9   \   s0    TZ4/=%X	
 0r1   c                 P    \        V 4      pV F  pVP                  V4       K  	  V# N)setdiscard)expectedactualmissingkeys   &&  r/   	diff_keysrB   g   s&    (mG Nr1   c                       ] tR t^ntRtR# )InvalidCommand N)__name__
__module____qualname____firstlineno____static_attributes__rE   r1   r/   rD   rD   n   s    r1   rD   c                    a  V 3R  lpV# )c                 J   <a  \         P                  ! S 4      V V3R  l4       pV# )c                 z   < S'       d(   \        SV4      pV'       d   \        R V: RS: 24      hS! W.VO5/ VB # )zCommand missing z of required keys )rB   rD   )selfcommandargskwargsmissing_keysfuncrequired_keyss   &&*, r/   	decorator7ensure_command_keys.<locals>.wrapper.<locals>.decoratort   sC    (@('8  7777r1   )	functoolswraps)rS   rU   rT   s   f r/   wrapper$ensure_command_keys.<locals>.wrappers   s&    			8 
	8 r1   rE   )rT   rY   s   f r/   ensure_command_keysr[   r   s     Nr1   c                      a  ] tR t^t o ]3V 3R lR llt]V 3R lR l4       t]R 4       t]R 4       t	]R 4       t
]R 4       tRR
 ltRR ltR tR t]V 3R lR l4       tRtV tR	# )NetworkStatec                &   < V ^8  d   QhRS[ RS[/# )r)   network_stateversion)r-   int)r.   __classdict__s   "r/   r0   NetworkState.__annotate__   s     ' '!',/'r1   c                    \         P                  ! V4      V n        W n        VP	                  R R4      V n        RV n        R# )use_ipv6FN)copydeepcopy_network_state_versiongetre   _has_default_route)rN   r_   r`   s   &&&r/   __init__NetworkState.__init__   s6     #mmM:%))*e<"&r1   c                    < V ^8  d   QhRS[ /# r)   r+   r,   )r.   rb   s   "r/   r0   rc      s     - - -r1   c                (    V P                   R ,          # )config)rh   rN   s   &r/   rq   NetworkState.config   s    ""8,,r1   c                    V P                   # r;   )ri   rr   s   &r/   r`   NetworkState.version   s    }}r1   c                ^     V P                   R ,          R,          #   \         d    . u # i ; i)dnsnameserversrh   KeyErrorrr   s   &r/   dns_nameserversNetworkState.dns_nameservers   s1    	&&u-m<< 	I	    ,,c                ^     V P                   R ,          R,          #   \         d    . u # i ; i)rw   searchry   rr   s   &r/   dns_searchdomainsNetworkState.dns_searchdomains   s1    	&&u-h77 	I	r}   c                `    V P                   f   V P                  4       V n         V P                   # r;   )rk   _maybe_has_default_routerr   s   &r/   has_default_routeNetworkState.has_default_route   s+    ""*&*&C&C&ED#&&&r1   Nc              #     "   V P                   P                  R / 4      pVP                  4        F!  pVf   Vx  K  V! V4      '       g   K  Vx  K#  	  R# 5i)
interfacesN)rh   rj   values)rN   filter_funcifacesifaces   &&  r/   iter_interfacesNetworkState.iter_interfaces   sH     $$((r:]]_E"u%%K %s   AA
Ac              #     "   V P                   P                  R . 4       F!  pVe   V! V4      '       d   Vx  K  K  Vx  K#  	  R# 5iroutesNrh   rj   )rN   r   routes   && r/   iter_routesNetworkState.iter_routes   sD     ((,,Xr:E&u%%K &  ;s
   1AAc                2   V P                  4        F  pV P                  V4      '       g   K   R # 	  V P                  4        FQ  pVP                  R. 4       F8  pVP                  R. 4       F  pV P                  V4      '       g   K     R # 	  K:  	  KS  	  R# )Tsubnetsr   F)r   _is_default_router   rj   )rN   r   r   subnets   &   r/   r   %NetworkState._maybe_has_default_route   s    %%'E%%e,, ( ))+E))Ir2#ZZ"5E--e44# 6 3 ,
 r1   c                f    RpVP                  R4      ^ 8H  ;'       d    VP                  R4      V9   # )::prefixnetwork)r   z0.0.0.0)rj   )rN   r   default_netss   && r/   r   NetworkState._is_default_route   s3    (IIh1$MM9)=)M	
r1   c                $   < V ^8  d   QhRS[ RR/# )r)   r_   r+   r]   r,   )r.   rb   s   "r/   r0   rc      s     8 84 8N 8r1   c                B    / pRV9   d   VR,          VR&   V ! RV/3/ VB # )zInstantiates a `NetworkState` without interpreting its data.

That means only `config` and `version` are copied.

:param network_state: Network state data.
:return: Instance of `NetworkState`.
r`   rq   rE   )clsr_   rQ   s   && r/   to_passthroughNetworkState.to_passthrough   s5     % -i 8F9Hm,777r1   )rk   rh   ri   re   r;   )rF   rG   rH   rI   NETWORK_STATE_VERSIONrl   propertyrq   r`   r{   r   r   r   r   r   r   classmethodr   rJ   __classdictcell__rb   s   @r/   r]   r]      s     2G' ' - -       ' '
 	
 8 8r1   r]   c            
       <  a  ] tR t^t o R/ R. RR. R. /RRRR	/t]R	R	3V 3R
 lR llt]V 3R lR l4       t]R 4       t	]	P                  R 4       t	R tR tR tR tR/R ltR/R ltR/R lt]! R.4      R 4       t]! R.4      R 4       t]! . R0O4      R 4       t]! . R1O4      R 4       t]! RR.4      R 4       t]! R.4      R 4       tR t]! R .4      R! 4       t]! R .4      R" 4       t]! R#.4      R$ 4       tR% tR& tR' tR( t R) t!V 3R* lR+ lt"R2R, lt#R- t$R.t%V t&R	# )3NetworkStateInterpreterr   r   rw   rx   r   re   Frq   Nc                   < V ^8  d   QhRR/# )r)   rendererzOptional[Renderer]rE   )r.   rb   s   "r/   r0   $NetworkStateInterpreter.__annotate__   s     
 
 '	
r1   c                   Wn         W n        \        P                  ! V P                  4      V n        W P
                  R &   RV n        / V n        W0n        RV P                  RV P                  RV P                  RV P                  RV P                  RV P                  RV P                  R	V P                   R
V P"                  RV P$                  RV P&                  RV P(                  RV P*                  /V n        R# )rq   Fr   bondsr   bridges	ethernets
infinibandloopback
nameserverphysicalr   vlanvlanswifisN)ri   _configrf   rg   initial_network_staterh   _parsed_interface_dns_map	_rendererhandle_bondhandle_bondshandle_bridgehandle_bridgeshandle_ethernetshandle_infinibandhandle_loopbackhandle_nameserverhandle_physicalhandle_routehandle_vlanhandle_vlanshandle_wifiscommand_handlers)rN   r`   rq   r   s   &&&&r/   rl    NetworkStateInterpreter.__init__   s      "mmD,F,FG(.H%(*!D$$T&&d((t**..$00,,$00,,T&&D$$T&&T&&!
r1   c                    < V ^8  d   QhRS[ /# ro   )r]   )r.   rb   s   "r/   r0   r     s     H H| Hr1   c                   ^ RI Hp V P                  ^8X  dQ   \        V P                  V4      '       d5   \
        P                  R4       \        P                  V P                  4      # \        V P                  V P                  R7      # )r   r   zPassthrough netplan v2 configr`   )cloudinit.net.netplanr   ri   
isinstancer   LOGdebugr]   r   r   rh   )rN   NetplanRenderers   & r/   r_   %NetworkStateInterpreter.network_state  sZ    E==A*T^^_"M"MII56..t||<<D//GGr1   c                8    V P                   P                  R 4      # )re   r   rr   s   &r/   re    NetworkStateInterpreter.use_ipv6  s    ""&&z22r1   c                @    V P                   P                  R V/4       R# )re   N)rh   update)rN   vals   &&r/   re   r     s    ""J#45r1   c                z    R V P                   RV P                  RV P                  /p\        P                  ! V4      # r`   rq   r_   )ri   r   rh   r   dumps)rN   states   & r/   dumpNetworkStateInterpreter.dump  s7    t}}dllT00

 ~~e$$r1   c                d   R V9  d!   \         P                  R4       \        R4      h\        VR ,          ,          p\	        W!4      pV'       d*   RV,          p\         P                  V4       \        V4      hV Uu. uF  qUR9  g   K  VNK  	  up F  p\        WW,          4       K  	  R# u upi )r`   z$Invalid state, missing version fieldzInvalid state, missing keys: %sNr   )r   error
ValueErrorNETWORK_STATE_REQUIRED_KEYSrB   setattr)rN   r   rT   rR   msgkrA   s   &&     r/   loadNetworkStateInterpreter.load  s    E!II<=CDD3E)4DE 63|DCIIcNS/!  -E}!0DAA}ECDuz* FEs   <B-	B-c                B    \         P                  ! V P                  4      # r;   )r   r   rh   rr   s   &r/   dump_network_state*NetworkStateInterpreter.dump_network_state,  s    ~~d1122r1   c                6    R V P                   RV P                  /# )r`   rq   )ri   r   rr   s   &r/   as_dictNetworkStateInterpreter.as_dict/  s    4==(DLLAAr1   c                    V P                   ^8X  d   V P                  VR7       RV n        R# V P                   ^8X  d   V P                  VR7       RV n        R# R# )   skip_brokenTN)ri   parse_config_v1r   parse_config_v2)rN   r   s   &&r/   parse_config$NetworkStateInterpreter.parse_config2  sO    ==A  [ 9DL]]a  [ 9DL  r1   c                z   V P                    F)  pVR ,          p V P                  V,          p T! T4       K+  	  V P                  P                  4        F9  w  rgRp V P                  R,          V,          pT'       g   K,  Tw  rRT	R	T
/TR
&   K;  	  R#   \         d   p\        RT,          4      ThRp?ii ; i  \         dI    T'       g   h \
        P                  RTRR7       \
        P                  T P                  4       4        K  i ; i  \         d!   p\        RP                  T4      4      ThRp?ii ; i)typez"No handler found for  command '%s'NSkipping invalid command: %sTexc_infor   zINameserver specified for interface {0}, but interface {0} does not exist!rx   r   rw   )r   r   rz   RuntimeErrorrD   r   warningr   r   r   itemsrh   r   r.   )rN   r   rO   command_typehandlere	interfacerw   r   rx   r   s   &&         r/   r   'NetworkStateInterpreter.parse_config_v1:  s<   ||G"6?L//=
	9  $$ #55;;=NIE++L9)D u&)#!;f e >  "8<G " 9"KK6$    IId55789   88>y8I sF   BB9DB6B11B69D<DDD:D55D:c                   ^ RI Hp \        V P                  V4      '       d   R# V P                  P                  4        F<  w  r4VR9   d   K   V P                  V,          p T! T4       T P                  T4       K>  	  R#   \         d   p\        RT,          4      ThRp?ii ; i  \         dI    T'       g   h \        P                  RTRR7       \        P                  T P                  4       4        K  i ; i)r   r   Nz!No handler found for command '%s'r   Tr   )r`   r   )r   r   r   r   r   r   r   rz   r   
_v2_commonrD   r   r   r   r   )rN   r   r   r  rO   r  r  s   &&     r/   r   'NetworkStateInterpreter.parse_config_v2]  s    Ednno66%)\\%7%7%9!L66//=

9 ( &:
  "7,F " 9"KK6$    IId55789s0   B"B'B$BB$'C::<C:9C:namec                $    V P                  V4      # r;   r   rN   rO   s   &&r/   r   'NetworkStateInterpreter.handle_loopbacky  s    ##G,,r1   c                    V P                   P                  R/ 4      pVP                  VR,          / 4      pVP                  R/ 4      P                  4        F  w  rEVP                  WE/4       K  	  \	        VP                  R4      4      pV P
                  '       gY   V FR  pVP                  R4      P                  R4      '       g#   \        VP                  R4      4      '       g   KK  RV n         M	  VP                  R	R
4      pVe   \        P                  ! V4      pVP                  RR
4      p	V	e   \        P                  ! V	4      p	VP                  RR
4      p
V
e   \        P                  ! V
4      p
VP                  RVP                  R4      RVP                  R4      RVP                  R4      RVP                  R4      RRRRRVP                  R4      RR
RR
RVR	VRV	RV
RVP                  R4      /4       VR,          '       d   VR,          P                  4       VR&   VP                  RVP                  R4      4      pV P                   R,          P                  W/4       V P                  4        R
# )z
command = {
    'type': 'physical',
    'mac_address': 'c0:d6:9f:2c:e8:80',
    'name': 'eth0',
    'subnets': [
        {'type': 'dhcp4'}
     ],
    'accept-ra': 'true'
}
r   r	  paramsr   r   6addressT	accept-raN	wakeonlanoptional	config_idmac_addressinetr   manualmtugatewaykeep_configuration)rh   rj   r   r   _normalize_subnetsre   endswithr   r	   is_truelowerr   )rN   rO   r   r   paramr   r   r   	accept_rar  r  	iface_keys   &&          r/   r   'NetworkStateInterpreter.handle_physical}  s(    ((,,\2>
wv3!++h399;JELL%& < %W[[%;< }}}!::f%..s33JJy)8 8 %)DM " KKT2	 Y/IKKT2	 Y/I;;z40||H-HW[[5F+F+w{{=9w{{5)447YYH$gkk2F&G	
& #(#7#=#=#?E- KKW[[-@A	L)00)1CD!r1   c                &   V P                   P                  R/ 4      pV P                  V4       VP                  VP                  R4      / 4      pVP                  R4      VR&   VP                  R4      VR&   VP                  VR,          V/4       R# )z
auto eth0.222
iface eth0.222 inet static
        address 10.10.10.1
        netmask 255.255.255.0
        hwaddress ether BC:76:4E:06:96:B3
        vlan-raw-device eth0
r   r	  	vlan_linkzvlan-raw-devicevlan_idN)rh   rj   r   r   )rN   rO   r   r   s   &&  r/   r   #NetworkStateInterpreter.handle_vlan  s     ((,,\2>
W%w{{62B7#*;;{#; ";;y1i5=%01r1   c                6   V P                  V4       V P                  P                  R4      pVP                  VP                  R4      / 4      pVP                  R4      P                  4        F  w  rEVP	                  WE/4       K  	  VP	                  RR/4       V P                  R,          P	                  VR,          V/4       VP                  R4       F  pWb9  d   RVRR/pV P                  V4       V P                  P                  R/ 4      pVP                  V4      pVP                  R4      VR	&   VP                  R4      P                  4        F  w  rEVP	                  WE/4       K  	  V P                  R,          P	                  Wh/4       K  	  R
# )a  
#/etc/network/interfaces
auto eth0
iface eth0 inet manual
    bond-master bond0
    bond-mode 802.3ad

auto eth1
iface eth1 inet manual
    bond-master bond0
    bond-mode 802.3ad

auto bond0
iface bond0 inet static
     address 192.168.0.10
     gateway 192.168.0.1
     netmask 255.255.255.0
     bond-slaves none
     bond-mode 802.3ad
     bond-miimon 100
     bond-downdelay 200
     bond-updelay 200
     bond-lacp-rate 4
r   r	  r  zbond-slavesnonebond_interfacesr   r   zbond-masterN)r   rh   rj   r   r   )	rN   rO   r   r   r   r   ifnamecmdbond_ifs	   &&       r/   r   #NetworkStateInterpreter.handle_bond  s^   6 	W%((,,\:
w{{62B7!++h/557JELL%& 8mV,-L)00%-1GH kk"34F'FF
 $$S),,00rBJ nnV,G%,[[%8GM"%kk(399;
|, <-44f5FG 5r1   bridge_interfacesc                   V P                   P                  R/ 4      pVP                  R4       F   pW29   d   K  RV/pV P                  V4       K"  	  V P                   P                  R/ 4      pV P                  V4       VP                  VP                  R4      / 4      pVR,          VR&   VP                  R/ 4      P                  4        F  w  rgVP	                  Wg/4       K  	  VP                  R4      pVeY   \        V\        4      '       gC   VR9   d   RpM%VR9   d   R	pM\        R
P                  VR7      4      hVP	                  RV/4       VP	                  VR,          V/4       R# )a  
    auto br0
    iface br0 inet static
            address 10.10.10.1
            netmask 255.255.255.0
            bridge_ports eth0 eth1
            bridge_stp off
            bridge_fd 0
            bridge_maxwait 0

bridge_params = [
    "bridge_ports",
    "bridge_ageing",
    "bridge_bridgeprio",
    "bridge_fd",
    "bridge_gcint",
    "bridge_hello",
    "bridge_hw",
    "bridge_maxage",
    "bridge_maxwait",
    "bridge_pathcost",
    "bridge_portprio",
    "bridge_stp",
    "bridge_waitport",
]
r   r/  r	  bridge_portsr  r%   NTFz2Cannot convert bridge_stp value ({stp}) to boolean)r&   )on1r   )off0r   )	rh   rj   r   r   r   r   boolr   r.   )	rN   rO   r   r+  r,  r   r   r   r%   s	   &&       r/   r   %NetworkStateInterpreter.handle_bridge  sZ   > ((,,\2>
kk"56F# C   % 7 ((,,\2>
W%w{{62B7 '(; <n!++h399;JELL%& < YY|,
!*Z*F*F^+!
."
 %v*v5  LL,
345=%01r1   c                (    V P                  V4       R # r;   r  r  s   &&r/   r   )NetworkStateInterpreter.handle_infinibandF  s    W%r1   c                   . p. pR V9   d=   VR ,          p\        V\        4      '       g   V.pV F  pVP                  V4       K  	  RV9   d=   VR,          p\        V\        4      '       g   V.pV F  pVP                  V4       K  	  W#3# )r  r   )r   listappend)rN   rO   rx   r   addrsaddrpathspaths   &&      r/   
_parse_dns"NetworkStateInterpreter._parse_dnsJ  s    I&EeT**""4( wH%EeT**d# ""r1   r  c                   V P                   P                  R 4      pV P                  V4      w  r4RV9   d   VV3V P                  VR,          &   R# VR,          P	                  V4       VR,          P	                  V4       R# )rw   r  rx   r   N)rh   rj   rA  r   extend)rN   rO   rw   rx   r   s   &&   r/   r   )NetworkStateInterpreter.handle_nameserver[  su    !!%%e,"oog6'!=D##GK$89
 %%k2M  (r1   c                    V P                   P                  R 4      pV P                  V4      w  rERVRV/W2,          R&   R# )r   rx   r   rw   N)rh   rj   rA  )rN   rO   r   _ifacerx   r   s   &&&   r/   _handle_individual_nameserver5NetworkStateInterpreter._handle_individual_nameserverh  s>    $$((6"oog6 -{HfMer1   destinationc                \    V P                   R ,          P                  \        V4      4       R# r   )rh   r<  _normalize_router  s   &&r/   r   $NetworkStateInterpreter.handle_routen  s!    H%,,-=g-FGr1   c                ,    V P                  VRR7       R# )a  
v2_command = {
  bond0: {
    'interfaces': ['interface0', 'interface1'],
    'parameters': {
       'mii-monitor-interval': 100,
       'mode': '802.3ad',
       'xmit_hash_policy': 'layer3+4'}},
  bond1: {
    'bond-slaves': ['interface2', 'interface7'],
    'parameters': {
        'mode': 1,
    }
  }
}

v1_command = {
    'type': 'bond'
    'name': 'bond0',
    'bond_interfaces': [interface0, interface1],
    'params': {
        'bond-mode': '802.3ad',
        'bond_miimon: 100,
        'bond_xmit_hash_policy': 'layer3+4',
    }
}

r   cmd_typeN_handle_bond_bridger  s   &&r/   r   $NetworkStateInterpreter.handle_bondss  s    : 	  6 :r1   c                ,    V P                  VRR7       R# )a_  
v2_command = {
  br0: {
    'interfaces': ['interface0', 'interface1'],
    'forward-delay': 0,
    'stp': False,
    'maxwait': 0,
  }
}

v1_command = {
    'type': 'bridge'
    'name': 'br0',
    'bridge_interfaces': [interface0, interface1],
    'params': {
        'bridge_stp': 'off',
        'bridge_fd: 0,
        'bridge_maxwait': 0
    }
}

r   rO  NrQ  r  s   &&r/   r   &NetworkStateInterpreter.handle_bridges  s    . 	  8 <r1   c                   \        4       pVP                  4        EFU  w  r4RVRR/pVP                  R/ 4      pVP                  RR4      pV'       g!   \        P	                  RV\        V4      4       WuR&   TpVP                  R	4      p	V	'       d   T	pM5V'       d.   V'       d&   VP                  4       p
\        V
4      pV'       d   TpWR
&   VP                  RR4      pV'       d   RV/VR&   R F  pW9   g   K  WM,          W]&   K  	  \        V4       V P                  V4      p\        V4      ^ 8  d   VP                  RV/4       \        P	                  RV4       V P                  V4       EKX  	  R# )a  
ethernets:
  eno1:
    match:
      macaddress: 00:11:22:33:44:55
      driver: hv_netvsc
    wakeonlan: true
    dhcp4: true
    dhcp6: false
    addresses:
      - 192.168.14.2/24
      - 2001:1::1/64
    gateway4: 192.168.14.1
    gateway6: 2001:1::2
    nameservers:
      search: [foo.local, bar.local]
      addresses: [8.8.8.8, 8.8.4.4]
  lom:
    match:
      driver: ixgbe
    set-name: lom1
    dhcp6: true
    accept-ra: true
  switchports:
    match:
      name: enp2*
    mtu: 1280

command = {
    'type': 'physical',
    'mac_address': 'c0:d6:9f:2c:e8:80',
    'name': 'eth0',
    'subnets': [
        {'type': 'dhcp4'}
     ]
}
r  r   r   match
macaddressNzHNetworkState Version2: missing "macaddress" info in config entry: %s: %sr  set-namer	  driverr  r   z!v2(ethernets) -> v1(physical):
%s)r  rW  r  r  r  )r   r   rj   r   r   strr  r
   r9   _v2_to_v1_ipcfglenr   r   )rN   rO   ifaces_by_macethcfgphy_cmdrW  r  r	  set_namelcase_mac_addressmacrZ  rA   r   s   &&             r/   r   (NetworkStateInterpreter.handle_ethernets  sU   Z ./HCS
G GGGR(E))L$7K		.H	 &1M" Dwwz*H$/$5$5$7!23DED"FOYYx.F%-v$6!M:#&8GL N (,**3/G7|a	734II:GD  )] (r1   c                   VP                  4        F  w  r#RRRVRVP                  R4      RVP                  R4      RVP                  R	4      /pR
V9   d   VR
,          VR
&   \        V4       V P                  V4      p\	        V4      ^ 8  d   VP                  RV/4       \        P                  RV4       V P                  V4       K  	  R# )z
v2_vlans = {
    'eth0.123': {
        'id': 123,
        'link': 'eth0',
        'dhcp4': True,
    }
}

v1_command = {
    'type': 'vlan',
    'name': 'eth0.123',
    'vlan_link': 'eth0',
    'vlan_id': 123,
    'subnets': [{'type': 'dhcp4'}],
}
r   r   r	  r&  idr%  linkr  rX  r  r   zv2(vlans) -> v1(vlan):
%sN)	r   rj   r9   r\  r]  r   r   r   r   )rN   rO   r   r`  vlan_cmdr   s   &&    r/   r   $NetworkStateInterpreter.handle_vlans
  s    $ !ID3774=SWWV_sww|4H |"%e*',**3/G7|aG 45II2H=X& )r1   c                0    \         P                  R 4       R# )zOWifi configuration is only available to distros with netplan rendering support.N)r   r   r  s   &&r/   r   $NetworkStateInterpreter.handle_wifis-  s    *	
r1   c                   < V ^8  d   QhRR/# )r)   r+   NrE   )r.   rb   s   "r/   r0   r   3  s     D D Dr1   c                P   \         P                  R V4       VP                  4        F{  w  r#RV9   g   K  VP                  R4      P                  R4      pVP                  R4      P                  R4      pRR/pV'       d   WFR&   V'       d   WVR&   V P	                  Wb4       K}  	  R# )zv2_common: handling config:
%srx   r   	addressesr   r   r  N)r   r   r   rj   rH  )rN   r`  r   dev_cfgr   rw   name_cmds   &&     r/   r  "NetworkStateInterpreter._v2_common3  s    		3S9!iikNE' ]377Akk-044[A"L1)/X&*-Y'228C *r1   c                Z  a
 \        R \        P                  V4      P                  4        4       4      o
VP                  4        EFa  w  r4\        R VP                  4        4       4      pVP                  R/ 4      pVP	                  RR4      pV'       d   WvR&   RVRVVR	,           VP                  R
4      R\        V
3R lVP                  4        4       4      /pRV9   d   VR,          VR&   RV9   d   VR,          VR&   \        V4       V P                  V4      p	\        V	4      ^ 8  d   VP                  RV	/4       \        P                  RW"V4       VR8X  d   V P                  V4       EK.  VR8X  d   V P                  V4       EKI  \        RP                  VR7      4      h	  R# )z(Common handler for bond and bridge typesc              3   ,   "   T F
  w  rW!3x  K  	  R # 5ir;   rE   .0r   vs   &  r/   	<genexpr>>NetworkStateInterpreter._handle_bond_bridge.<locals>.<genexpr>E  s      
EtqQFEs   c              3   F   "   T F  w  rV\         9  g   K  W3x  K  	  R # 5ir;   )NETWORK_V2_KEY_FILTER)rv  rA   values   &  r/   rx  ry  J  s&      $4LS33 $4s   !!
parameterszgratuitious-arpNr   r   r	  _interfacesr   r  c              3   >   <"   T F  w  rSV,          V3x  K  	  R # 5ir;   rE   )rv  r   rw  v2key_to_v1s   &  r/   rx  ry  Z  s     N~tqA2~s   r  rX  r  r   zv2(%s) -> v1(%s):
%sr   r   z Unknown command type: {cmd_type}rO  )r-   NET_CONFIG_TO_V2rj   r   popr9   r\  r]  r   r   r   r   r   r   r.   )rN   rO   rP  	item_nameitem_cfgitem_paramsr  
grat_valuev1_cmdr   r  s   &&&       @r/   rR  +NetworkStateInterpreter._handle_bond_bridgeA  s     
/33H=CCE
 
 $+==?I $,NN$4 K !__\26F$5t<J+5'( 	=((,,|*D$Nv||~NN	F   (ux'(0(>}%'1**84G7|ay'23II-x6J8#""6*V#  ( 6==!) >  I $3r1   c                   R p. pVP                  R4      '       d/   RR/pV! VP                  R/ 4      V4       VP                  V4       VP                  R4      '       d6   RR/pRV n        V! VP                  R/ 4      V4       VP                  V4       RpRp/ pVP                  R	. 4       F  pRR
RV/pRV9   d1   RV9   d)   Vf%   VP                  R4      pVP                  RV/4       M/RV9   d)   Vf%   VP                  R4      pVP                  RV/4       RV9   dr   V'       gj   VP                  R4      P                  R	4      p	V	'       d   WR&   VP                  R4      P                  R4      p
V
'       d   WR&   VP                  V4       VP                  V4       K  	  . pVP                  R. 4       Fr  pVP                  \	        RVP                  R4      RVP                  R4      RVP                  R4      RVP                  R4      RVP                  R4      /4      4       Kt  	  \        V4      '       d   \        V4      '       d   W^ ,          R&   V# )z7Common ipconfig extraction from v2 to v1 subnets array.c                 0    R V 9   d   V R ,          VR&   R# R# )zroute-metricmetricNrE   )	overridesr   s   &&r/   _add_dhcp_overridesDNetworkStateInterpreter._v2_to_v1_ipcfg.<locals>._add_dhcp_overridesv  s    *#,^#<x  +r1   dhcp4r   dhcp4-overridesdhcp6Tdhcp6-overridesNro  staticr  :r4   r  r3   rx   r{   r   
dns_searchr   rJ  toviar  r  table)rj   r<  re   r   rL  r]  )rN   r`  r  r   r   r3   r4   rx   r  ro  r   r   r   s   &&           r/   r\  'NetworkStateInterpreter._v2_to_v1_ipcfgs  s+   	= 777g&F(92 >GNN6"777g&F DM(92 >GNN6"ww{B/G7F
 g~$)9"wwz2HMM9h"78$)9"wwz2HMM9h"78#KGGM266{C	5> 12/33H=06-k*NN6"1 04 WWXr*EMM %uyy!599U#3 %))H"5uyy/7!3
 + w<<CKK#)AJx r1   )r   r   rh   r   r   ri   r   re   )T)r	  r&  r%  )r	  r*  r  r;   )'rF   rG   rH   rI   r   r   rl   r   r_   re   setterr   r   r   r   r   r   r   r[   r   r   r   r   r   r   rA  r   rH  r   r   r   r   r   r   r  rR  r\  rJ   r   r   s   @r/   r   r      s    b"2b
 	E$	 &)-	
 
: H H 3 3 __6 6%+ 3B !F98 &"- #- &"?" #?"B 9:2 ;2  >?2H @2Hh &"567>2 8>2@ &"& #&#" )%
) &
) )%N &N
 -)H *H;>=2]*~!'F
D D0dB Br1   r   c                 d   \         P                  ! V 4      p \        R  V P                  4        4       4      pV P	                  R4      R9   d   VP                  \        VRR7      4       V P	                  R. 4       Uu. uF  p\        V4      NK  	  upVR&   R pR F  pV! W4       K  	  V# u upi )c              3   @   "   T F  w  rV'       g   K  W3x  K  	  R # 5ir;   rE   ru  s   &  r/   rx  $_normalize_subnet.<locals>.<genexpr>  s     @NDAa!Ns   r   address_keysr   c                     W9   d9   \        W,          \        4      '       g   W,          P                  4       W&   R # R # R # r;   )r   r;  split)snetr	  s   &&r/   listify"_normalize_subnet.<locals>.listify  s.    <
4:t < <))+DJ !=<r1   )r  static6)r  
ip_address)r  r{   )rf   rg   r-   r   rj   r   _normalize_net_keysrL  )r   normal_subnetrr  r   s   &    r/   _normalize_subnetr    s    ]]6"F@FLLN@@Mzz&22	
 &,ZZ"%=%=%=M(, /! / s   =B-c                   V P                  4        UUu/ uF  w  r#V'       g
   V^ 8X  g   K  W#bK  	  pppRpV F  pVP                  V4      '       g   K  Tp M	  V'       g:   RRP                  V4      : RV : 2p\        P	                  V4       \        V4      h\        VP                  V4      4      pVR8X  d   \        VP                  R4      4      p	V	'       g#   Rp\        P	                  V4       \        V4      h\        V	4      '       d   RpM:\        V	4      '       d   R	pM&R
V	 R2p\        P	                  V4       \        V4      h\        V4      '       g&   \        P	                  RV4       \        RV R24      h\        V4      p
\        V4      pVP                  R4      pRV9   df   VP                  R4      w  rpWV&   V
'       d   \        V4      pMV'       d   \        V4      pM\        P	                  RV4       \        RV R24      hRV9   d   \        VR,          4      pMDV'       d   V'       d   \        V4      pM(V'       d   V
'       d   \        V4      pMV
'       d   ^@M^pRV9   d8   \        VR,          4      \        V4      8w  d   \        P!                  RVV4       VVR&   V
'       d   RV9   d   VR V# V'       d   \#        VR,          4      VR&   V# u uppi )a  Normalize dictionary network keys returning prefix and address keys.

@param network: A dict of network-related definition containing prefix,
    netmask and address_keys.
@param address_keys: A tuple of keys to search for representing the address
    or cidr. The first address_key discovered will be used for
    normalization.

@returns: A dict containing normalized prefix and matching addr_key.
Nz No config network address keys [,z] found in defaultr  zGateway IP is emptyz	0.0.0.0/0z::/0zInvalid Gateway IP: ''z$Address %s is not a valid ip networkzAddress z is not a valid ip addressnetmask/r   z;Overwriting existing 'prefix' with '%s' in network info: %s)r   rj   joinr   r   r   r[  r   r   r   r   r   	partitionr   r   ra   r   r   )r   r  r   rw  netaddr_keyrA   messager>  gw_ipipv6ipv4r  	addr_part_maybe_prefixr   s   &&               r/   r  r    s~    $MMO
;ODAqAF414OC
;H773<<H  8HH\"
 			'!!swwx !DyCGGI&'+GIIgW%%5!!DU##D-eWA6GIIgW%%		8$?8D6)CDEE4 D4 Dggi G
d{%)^^C%8"	l!H,\:F,\:F II<dCxv-GHII	SS]#	T(1	T(133s8}-V<I	

 CM I J 
0X?IJ] <s
   K,K,c                Z   \        R V P                  4        4       4      pRV9   d   VR,          VR&   VR VP                  \        VRR7      4       VP	                  R4      pV'       d    \        V4      VR&   V# V#   \         d!   p\        RP                  T4      4      ThRp?ii ; i)	ag  normalize a route.
return a dictionary with only:
   'type': 'route' (only present if it was present in input)
   'network': the network portion of the route as a string.
   'prefix': the network prefix for address as an integer.
   'metric': integer metric (only if present in input).
   'netmask': netmask (string) equivalent to prefix iff network is ipv4.
c              3   >   "   T F  w  rVR9  g   K  W3x  K  	  R# 5i) N)r  NrE   ru  s   &  r/   rx  #_normalize_route.<locals>.<genexpr>;  s       (41AZ,?=s   rJ  r   r  r  z(Route config metric {} is not an integerN)r   rJ  )	r-   r   r   r  rj   ra   r   	TypeErrorr.   )r   normal_router  r  s   &   r/   rL  rL  1  s       ;;= L $".}"=Y''A	
 h'F	%([L"
 <	  	:AA&I	s   -A? ?B*
B%%B*c                 V    V '       g   . p V  Uu. uF  p\        V4      NK  	  up# u upi r;   )r  )r   ss   & r/   r  r  S  s(    *12'Qa '222s   &c                <    V ^8  d   QhR\         R\        R\        /# )r)   
net_configr   r+   )r-   r6  r]   )r.   s   "r/   r0   r0   Y  s&       	r1   c                    RpV P                  R4      pV P                  R4      pV^8X  d   T pV'       d0   Ve,   \        WEVR7      pVP                  VR7       VP                  pV'       g   \	        RV  24      hV# )z^Parses the config, returns NetworkState object

:param net_config: curtin network config dict
Nr`   rq   )r`   rq   r   r   zpNo valid network_state object created from network config. Did you specify the correct version? Network config:
)rj   r   r   r_   r   )r  r   r   r   r`   rq   nsis   &&&    r/   parse_net_config_datar  Y  s     EnnY'G^^H%F!| 6%%X
 	[1!!El
 	
 Lr1   c                    V ^8  d   Qh/ ^ \         9   d,   \        \        \        \        \        3,          3,          ;R&   # )r)   r  )__conditional_annotations__r   r[  r   )r.   s   "r/   r0   r0      s0    ^# #$sDcN*+ #_ r1   r   )ro  r  r  r  r  r3   r4   r   rW  r  rx   r   rY  r  r  r  )rE   )TN).r  rf   rW   loggingtypingr   r   r   r   	cloudinitr   r   r	   cloudinit.netr
   r   r   r   r   r   r   r   r   r   cloudinit.net.rendererr   	getLoggerrF   r   r   r   r{  r  r9   rB   	ExceptionrD   r[   r]   r   r  r  rL  r  r  r0   )r  s   @r/   <module>r     s      5 5 / /   /! -  (  + "5 	 1 	^	
 	o 	^ 	, 	4 	+ 	%&= 	- 	+ 	V 	- 	!"5  		!" 	 !:#$ 	
!7'* Z_$;?e4-#/  #L
	Y 	$S8 S8l[ [|:YxD3 r1   