ó –­PSc@sdZddlZddlZddljjZddljjZddl Z ddl m Z ddl ZdZdZdZdZdZd Zd Zd Zd Zd ZeeeeeegZdejfd„ƒYZdejfd„ƒYZd„Zd„Zd„Z d„Z!dS(s Zone linked image module classes. Zone linked images only support child attach. Zone linked image child configuration information is all derived from zonecfg(1m) options and this plugin, no child configuration information is stored within a parent image. iÿÿÿÿN(t DebugValuestglobalt configuredt incompletet unavailablet installedtreadytmountedtrunningt shutting_downtdowntLinkedImageZonePlugincBsºeZdZieej6ZeedgƒeddgƒgƒZd„Z ed„Z d„Z eed„Z d„Z ed „Zeed „Zd „Zd „Zd „Zd„ZRS(sSee parent class for docstring.s system/zonest SUNWzonert SUNWzoneucCsVtjj|||ƒ||_||_|j|_d|_t ƒ|_ d|_ dS(sSee parent class for docstring.N( tlitLinkedImagePlugint__init__t_LinkedImageZonePlugin__pnamet_LinkedImageZonePlugin__linkedtimaget_LinkedImageZonePlugin__imgtNonet$_LinkedImageZonePlugin__in_gz_cachedtdictt _LinkedImageZonePlugin__childrent*_LinkedImageZonePlugin__zoneadm_list_cache(tselftpnametlinked((sA/usr/lib/python2.7/vendor-packages/pkg/client/linkedimage/zone.pyR‚s     cCs‡|jdkr|jSytƒtk|_WnQtk rZ}|rHtStj|ƒ‚n&tjk r}|rvtS|‚nX|jS(sÅCheck if we're executing in the global zone. Note that this doesn't tell us anything about the image we're manipulating, just the environment that we're running in.N( RRt _zonenamet ZONE_GLOBALtOSErrortTruetapxt_convert_errortLinkedImageException(Rt ignore_errorste((sA/usr/lib/python2.7/vendor-packages/pkg/client/linkedimage/zone.pyt__in_gz’s c CstjdƒrtSd}|jjj|}|dkr<tS|jj}tj j tj j |dƒƒsmtStj j tj j |dƒƒs’tS|jj |jj ƒ}tg|jƒD]\}}|^qºƒ}x%|jD]}||@|krßtSqßWtS(sxCheck to see if zones are supported in the current image. i.e. can the current image have zone children.tzones_supportedsvariant.opensolaris.zoneRtetcs etc/zones(Rt get_valueR RtcfgtvariantstFalsetroottostpathtisdirtjoint get_catalogtIMG_CATALOG_INSTALLEDt frozensett pkg_namest!_LinkedImageZonePlugin__zone_pkgs( RtvarianttvalueR/tcatitpubtstemt pkgs_insttpkgs((sA/usr/lib/python2.7/vendor-packages/pkg/client/linkedimage/zone.pyt__zones_supported¬s&  !!%c Csh|rd|_n|jdkrCt|jƒtks<t‚|jS|jƒsbg|_|jƒS|jd|ƒs‡g|_|jƒSy"t|j j |j j ƒƒ}WnQt k r×}|rÅgStj|ƒ‚n&tjk rü}|rógS|‚nXg}xO|jƒD]A\}\}}tjd|j|fƒ} |j| |gƒqW||_|jƒS(sœList the zones associated with the current image. Since this involves forking and running zone commands, cache the results.R$s%s:%sN(RRttypetlisttAssertionErrort'_LinkedImageZonePlugin__zones_supportedt)_LinkedImageZonePlugin__list_zones_cachedt_LinkedImageZonePlugin__in_gzt _list_zonesRR-Rtget_path_transformRR!R"R#t iteritemsRtLinkedImageNameRtappend( RtnocacheR$tzdictR%tzlisttzoneR/tstatetlin((sA/usr/lib/python2.7/vendor-packages/pkg/client/linkedimage/zone.pyt__list_zones_cachedÛs8         cCs d|_dS(sSee parent class for docstring.N(RR(RR-((sA/usr/lib/python2.7/vendor-packages/pkg/client/linkedimage/zone.pyt init_rootscCsQ|jdtd|ƒ}|s%tjS|jjjtjƒtj}tj|fS(sSee parent class for docstring.RJR$( RCR RtPATH_TRANSFORM_NONERR-trstripR.tsep(RR$RLR-((sA/usr/lib/python2.7/vendor-packages/pkg/client/linkedimage/zone.pytguess_path_transforms  c Csüg}x8|jD]-}|j|tj}|j||gƒqWg}x_|j|d|ƒD]H\}}|g|D]}|d^qskr’q]n|j||gƒq]Wg}|j|ƒ|j|ƒx,|D]$\}}|j|jksÐt‚qÐW|S(sSee parent class for docstring.R$i( RRt PROP_PATHRIRCtextendtlin_typeRRA( RRJR$tinmemoryROR/tondisktitrv((sA/usr/lib/python2.7/vendor-packages/pkg/client/linkedimage/zone.pytget_child_list#s #  cCsÌ||jkr|j|Stƒ}||tj s:     /ø   L