+
    i$                        ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t	 ^ RI
HtHt RtRt]P                  ! ]4      t ! R R] P$                  R7      t ! R	 R
]4      t].tRR ltR tRR ltR tR tR tRR ltR# )    N)util)get_devicelistread_sys_net_safez#/run/initramfs/open-iscsi.interfacedisabledc                      a  ] tR t^t o Rt]P                  V 3R lR l4       t]P                  V 3R lR l4       tRt	V t
R# )InitramfsNetworkConfigSourcezBABC for net config sources that read config written by initramfsesc                    < V ^8  d   QhRS[ /#    returnbool)format__classdict__s   "7/usr/lib/python3/dist-packages/cloudinit/net/cmdline.py__annotate__)InitramfsNetworkConfigSource.__annotate__   s     P Pt P    c                    R# )zAIs this initramfs config source applicable to the current system?N selfs   &r   is_applicable*InitramfsNetworkConfigSource.is_applicable       r   c                    < V ^8  d   QhRS[ /# r
   dict)r   r   s   "r   r   r   #   s     J Jt Jr   c                    R# )z;Render a v1 network config from the initramfs configurationNr   r   s   &r   render_config*InitramfsNetworkConfigSource.render_config"   r   r   r   N)__name__
__module____qualname____firstlineno____doc__abcabstractmethodr   r    __static_attributes____classdictcell__r   s   @r   r   r      s>     LP P 	J Jr   r   )	metaclassc                   R   a  ] tR t^'t o RtR	R ltV 3R lR ltV 3R lR ltRtV t	R# )
KlibcNetworkConfigSourcezInitramfsNetworkConfigSource for klibc initramfs (i.e. Debian/Ubuntu)

Has three parameters, but they are intended to make testing simpler, _not_
for use in production code.  (This is indicated by the prepended
underscores.)
Nc                L   Wn         W n        W0n        V P                   f   \        4       V n         V P                  f   \        P
                  ! 4       V n        V P                  f?   / V n        \        4        F'  p\        VR4      pV'       g   K  WPP                  V&   K)  	  R # R # )Naddress)_files
_mac_addrs_cmdline_get_klibc_net_cfg_filesr   get_cmdliner   r   )r   r1   r2   r3   kmac_addrs   &&&&  r   __init__!KlibcNetworkConfigSource.__init__/   s    $  ;;24DK==  ,,.DM??" DO#%,Q	:8)1OOA& & #r   c                    < V ^8  d   QhRS[ /# r
   r   )r   r   s   "r   r   %KlibcNetworkConfigSource.__annotate__A   s      t r   c                   V P                   '       dm   \        P                  ! V P                  4       F  pVP	                  R4      '       g   K   R# 	  \
        P                  P                  \        4      '       d   R# R# )a  
Return whether this system has klibc initramfs network config or not

Will return True if:
    (a) klibc files exist in /run, AND
    (b) either:
        (i) ip= or ip6= are on the kernel cmdline, OR
        (ii) an open-iscsi interface file is present in the system
TF)zip=zip6=)	r1   shlexsplitr3   
startswithospathexists_OPEN_ISCSI_INTERFACE_FILE)r   items   & r   r   &KlibcNetworkConfigSource.is_applicableA   sR     ;;;DMM2???33 3 ww~~899r   c                    < V ^8  d   QhRS[ /# r
   r   )r   r   s   "r   r   r;   T   s     
 
t 
r   c                D    \        V P                  V P                  R 7      # ))files	mac_addrs)config_from_klibc_net_cfgr1   r2   r   s   &r   r    &KlibcNetworkConfigSource.render_configT   s    (++oo
 	
r   )r3   r1   r2   )NNN)
r"   r#   r$   r%   r&   r8   r   r    r)   r*   r+   s   @r   r.   r.   '   s#     2$ &
 
r   r.   c                   Vf   / p\         P                  ! V 4      p RV9   d
   VR,          MVR,          pTP	                  RTP	                  R4      4      pT'       g   TP	                  R4      '       d   RpMR	pTR9   d   R	pTR9  d   \        RT,          4      hRRRTR. /pY19   d   Y,          TR&   R EFd  pTR,           T9  d   K  TP	                  TR,           T4      pTR	8X  d   R
pRTRR/p	TR
8X  d   Y'R,           ,          T	R&   R F1  p
Yz,           T9   g   K  Y'T
,           ,          YP                  4       &   K3  	  . pR Fd  pTP	                  Y|,           4      pT'       g   K$  \        TP                  R4      4      '       g   KF  TP                  Y'T,           ,          4       Kf  	  T'       dM   YR&   TP	                  R4      pT'       d0   RT9   d   TP                  R4      T	R&   MTP                  4       T	R&   TR,          P                  T	4       EKg  	  Y63#   \         d   p\        R4      ThRp?ii ; i)a  Convert a klibc written shell content file to a 'config' entry
When ip= is seen on the kernel command line in debian initramfs
and networking is brought up, ipconfig will populate
/run/net-<name>.cfg.

The files are shell style syntax, and examples are in the tests
provided here.  There is no good documentation on this unfortunately.

DEVICE=<name> is expected/required and PROTO should indicate if
this is 'none' (static) or 'dhcp' or 'dhcp6' (LP: #1621507) or 'static'
or 'off' (LP: 2065787). Note that IPV6PROTO is also written to address
the possibility of both ipv4 and ipv6 getting addresses.

Full syntax is documented at:
https://git.kernel.org/pub/scm/libs/klibc/klibc.git/plain/usr/kinit/ipconfig/README.ipconfig
NDEVICEDEVICE6z&no 'DEVICE' or 'DEVICE6' entry in dataPROTO	IPV6PROTOfilenamedhcpnonestaticzUnexpected value for PROTO: %stypephysicalnamesubnetsmac_addressADDRcontrolmanualr0   z:.0dns_nameserversDOMAINSEARCH,
dns_search)rT   off)rS   rR   dhcp6)IPV4IPV6)NETMASK	BROADCASTGATEWAY)DNS0DNS1)
r   load_shell_contentKeyError
ValueErrorgetlowerlenstripappendr>   )contentrI   datarW   eprotoifacepre	cur_protosubnetkeydnsnskeynssearchs   &&             r   _klibc_to_config_entryr   ^   s-   $ 	""7+DJ!)T!1tH~tI HHWdhh{34E88JEE!!--9EABB 	
2E (m  <t# HHS7]E2	 I)Y9   $6\ 2F9 7CyD &*9oyy{# 7 %E#+&Brc"((5/**

4e,-	 &
 (+$%XXn-F&=+1<<+<F<(+1<<>F<(i'O  R ;K  JABIJs   H% %I0H<<Ic                  d    \         P                   ! R 4      \         P                   ! R4      ,           # )z/run/net-*.confz/run/net6-*.conf)globr   r   r   r4   r4      s!    99&'$))4F*GGGr   c                 d   V f   \        4       p . p/ pV  EF  p\        \        P                  ! V4      VR7      w  rVWS9   d   W5,          R,          pVP	                  R4      VP	                  R4      8w  dY   \        RP                  VRP                  W5,          R,          4      VP	                  R4      VP	                  R4      R7      4      hVR,          P                  VR,          4       W5,          R,          P                  V4       K  RV.RV/W5&   VP                  V4       EK  	  R	VR
^/# )N)rI   entryrY   zedevice '{name}' was defined multiple times ({files}) but had differing mac addresses: {old} -> {new}. rH   )rW   rH   oldnewrX   configversion)
r4   r   r   load_text_filerm   rl   r   joinextendrq   )rH   rI   entriesnamescfg_filerW   r   prevs   &&      r   rJ   rJ      s   }(*GE,)Y
 =;w'Dxx&%))M*BB HHN!!hhu{7';< HH]3!IIm4	 IO I  O""5#34K ''1"XJ?EKNN5!) , gy!,,r   c                 ~    \          F2  p V ! 4       pVP                  4       '       g   K"  VP                  4       u # 	  R# )z
Return v1 network config for initramfs-configured networking (or None)

This will consider each _INITRAMFS_CONFIG_SOURCES entry in turn, and return
v1 network configuration for the first one that is applicable.  If none are
applicable, return None.
N)_INITRAMFS_CONFIG_SOURCESr   r    )src_cls
cfg_sources     r   read_initramfs_configr      s;     -Y
''))'')) - r   c                    \         P                  ! V 4      ;_uu_ 4       pR p \        P                  ! RVR7      pVP	                  4       V'       d   VP                  4        uuR R R 4       #   \         d(    T u T'       d   TP                  4        uuR R R 4       # i ; i  T'       d   TP                  4        i i ; i  + '       g   i     R # ; i)Nrb)modefileobj)ioBytesIOgzipGzipFilereadcloseIOError)blobiobufgzfps   &  r   _decomp_gzipr      s    	D		U	==dE:D99; 

 
	
  	K

 
	
	 

  
		s@   C 'A-
C -B:B";C BB""B==C  C	c                     \         P                  ! V 4      p\        T4      #   \        \        3 d    \        P                  RT 4        R# i ; i)zDecode a string base64 encoding, if gzipped, uncompress as well

:return: decompressed unencoded string of the data or empty string on
   unencoded data.
zaExpected base64 encoded kernel command line parameter network-config. Ignoring network-config=%s. )base64	b64decode	TypeErrorrl   LOGerrorr   )rs   r   s   & r   _b64dgzr     sS    %  z" 		;	

 s   # 'AAc                 H   V f   \         P                  ! 4       p RV 9   d   R pV P                  4        F5  pVP                  R4      '       g   K  VP                  R^4      ^,          pK7  	  V'       d/   V\        8X  d   RR/# \         P
                  ! \        V4      4      # R # )Nznetwork-config==r   r   )r   r5   r>   r?   &KERNEL_CMDLINE_NETWORK_CONFIG_DISABLED	load_yamlr   )cmdlinedata64toks   &  r   read_kernel_cmdline_configr     s    ""$G#==?C~~/003*1- # ?? *-->>'&/22r   )N)NN)r'   r   r   r   r   loggingr@   r=   	cloudinitr   cloudinit.netr   r   rC   r   	getLoggerr"   r   ABCMetar   r.   r   r   r4   rJ   r   r   r   r   r   r   r   <module>r      s        	  	   ;B )3 &!	JS[[ 	J1
; 1
h 66 ]@H->$&r   