*CeVdZddlZddlZddlZddlZddlmZddlmZdddd d dd ZGd d ejZ GddejZ y)znetplan ip command lineN)CalledProcessError)utilsz#run/systemd/netif/leases/{lease_id}ifindex)patternmethodzs K%8"  $rc|jjdd|jjdd|j|_|j |j y)N interfacez1Interface for which to display IP lease settings.)r --root-dirzBSearch for configuration files in this root directory instead of /)parser add_argumentcommand_ip_leasesr!r)r*)rs rr(zNetplanIpLeases.runCsa   &Y ! [   &j ! l**   rcZjdk(rjfd}tjg}jr|djgz }|djgz }t j d| tj|d}i}jd }|D])}|jjd \}}|||<+||y#t$r@tdjztj tjd YwxYw) Nrc  fd} fd}t|dd}t|dd} td|z}tjj d j r)tjj j nd|j j| }tjj|s|jd d }t|5}|jD]}t|j dddy#1swYyxYw#t$rS} td jd t!| t"j$t#j&dYd} ~ yd} ~ wwxYw)NcDtjjdjd} t |5}|j dj cdddS#1swYyxYw#t$r&}tjd|t|d}~wwxYw)Nz/sys/class/netrrzCannot read file %s: %s) ospathjoinr4open readlinesstrip Exceptionloggingdebugstr) ifindex_ffers rlease_method_ifindexzXNetplanIpLeases.command_ip_leases..find_lease_file..lease_method_ifindexTsGGLL)94>>9U i8A {{}Q/557888 MM";YAOs4 A0!A$ A0$A-)A0-A00 B9!BBc tjddjg}|jD]}d|vs|j ddj j }tjddd|g}|jD]:}d|vs|j ddj j ccS td #t$r}td t|zd}~wwxYw) NdevshowzGENERAL.CONNECTION:conidzconnection.uuidz@Could not find a NetworkManager connection for the interface: %sz.find_lease_file..lease_method_nm_connection]s q$)OOUFDNN4S$TM - 8 8 :O/47&*jjoa&8&?&?&A&G&G&IG,1OOUFDRYroot_dirabspathformatr4isfilereplacer?r@printrTrBrEsysstderrexit) mappingrIrY lease_pattern lease_methodr^r=rGrVrHrs rfind_lease_filez:NetplanIpLeases.command_ip_leases..find_lease_fileSsF  `'wy'9:9EM%gi&89(CL ?4, >?Aww||CFJmmBGGOODMM$BY[$1$8$84>>BJ%9%LM ww~~d+<<(BD^_D$Z-1 ! -dkkm,---- QTUVQWX::'  s7CD0+/D$D0$D-)D0-D00 F 9A FF r5z --mappingzcommand ip leases: running %sT)textz:No lease found for interface '%s' (not managed by Netplan)r_rN,=)r4 print_usagerget_generator_pathrcrCrD subprocess check_outputrrhrirjrkrSrA) rroargvoutrl mapping_skeyvaluekeyvalues ` rr8z!NetplanIpLeases.command_ip_leasesNs >>V #    2 h((*+ == \4==1 1D dnn--  5t< ))$T:CIIcN ! !H!)//4JC GCL !  "  NQUQ_Q__fifpfp q HHQK sC!!AD*)D*)r,r-r.rr(r8r/r0s@rr#r#<s$ K!rr#) __doc__rCr<rirurr]rraNetplanCommandr r#rrrsd$ )9 R!  $$(]!e**]!r