oB]c@sddlZddlZddlmZddlmZddlmZddlmZej e Z dej fdYZ ddZdd Zdd Zd Zd Zd e fdYZe ejffeejejffgZdZdS(iN(tlog(teni(tsources(tutiltDataSourceNoCloudcBskeZdZdZdZdZdZedZdZ dZ dZ ed Z RS( tNoCloudcCsktjj||||d|_tjj|jdtjj|jdg|_ d|_d|_ dS(Ntnoclouds nocloud-nett/sfile://(Rsfile://( Rt DataSourcet__init__tNonetseedtostpathtjointseed_dirt seed_dirstsupported_seed_starts(tselftsys_cfgtdistrotpaths((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyR s   cCs)tjj|}d||j|jfS(Ns%s [seed=%s][dsmode=%s](RRt__str__R tdsmode(Rtroot((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyR"scCstjrHgd|d|gD]}tjj|r!|^q!}ntjddtjddtjd}|jtjdtjd|j}|jtjd|jt t |t |@}|j d t |S( Ns /dev/msdosfs/s /dev/iso9660/R s/dev/sr0s/dev/sr1s TYPE=vfats TYPE=iso9660sLABEL=%streverse( Rt is_FreeBSDR R texiststfind_devs_withtextendtuppertlowertlisttsettsorttTrue(Rtlabeltptdevlisttfslistt label_list((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyt _get_devices&s ! cCsidd6|jd6}g}iid6dd6dd6dd6}yTi}tjd }|rt||r|jd t|i|d6}nWn"tk rtjt d t SXy<i}t|r|jd t|i|d6}nWn"tk rtjt d t SXiddgd6ddgd6}xh|j D]]}yCtj ||}|j|t j d|t||}PWqCtk rqCXqCW|jjdr|jd|jd|ddR#( tds_idR}R,targlinettokttmptkvpairsts2ltitemtktv((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyRs4          cCst}|jd|}||kr+|Sd}t|tsWtj|d||Stt|jdkrtj|d||S|jddkrtj|d|n5t d|kd |kfstj|d ||Stj|d ||S( sMIf network-config contains top level 'network' key, then remove it. Some providers of network configuration may provide a top level 'network' key (LP: #1798117) even though it is not necessary. Be friendly and remove it if it really seems so. Return the original value if no change or the updated value if changed.tnetworks.Top level network key in network-config %s: %sswas not a dictishad multiple top level keystconfigtdisabledswas config/disabledtversions!but missing 'config' or 'version's#fixed by removing shifting network.( tobjectREt isinstancetdictR@RBRLR tkeystall(tcfgtnullvalt network_valtbmsg((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyt_maybe_remove_top_networkBs$  cCs|j}|jdi}t|dtsGtj|d}ntj|d|g|d<|jdrttj|jd|d s     (