R4Sc$@sdZddkZddkZddkZddkZddkZddkZddkZddk Z ddk i Z ddkZ ddkiiZddkiiZddkZ ddkiiZddkiiZddkZ ddkiiZddkZ ddkZ ddki Z ddk!Z ddk"Z ddk#l$Z$e$i%Z%dZ&dZ'dZ(dZ)dZ*d Z+d Z,d Z-d Z.d Z/dZ0e1e)e*e+e,e-e.e/e0gZ2e1e)e*e/gZ3dZ4dZ5dZ6e1e5e6gZ7dZ8ei9i:e8dZ;ei9i:e8dZ<ei9i:e8dZ=ei9i:e8dZ>ddfZ?ei@ddZAdZBdZCdZDdZEdeFfdYZGd eFfd!YZHd"eFfd#YZId$eFfd%YZJd&eFfd'YZKd(ZLeMd)ZNeMd*ZOdePd+ZQeRdePeRd,ZSd-eiTfd.YZUd/ZVd0ZWeMeMeMeMeMeMeMeMeMeMeMeMd1 ZXdd2ZYd3ZZd4Z[eRd5Z\d6Z]d7Z^d8Z_d9Z`d:ZadS(;s5 Linked image module classes. The following classes for manipulating linked images are defined here: LinkedImage LinkedImageChild The following template classes which linked image plugins should inherit from are also defined here: LinkedImagePlugin LinkedImageChildPlugin iN(tglobal_settingstparenttselftchildsli-current-parentsli-current-pathsli-modelsli-names li-parentsli-pathsli-path-transforms li-recurset-tpushtpulltlinkedtlinked_pfacetst linked_ppkgst linked_propt linked_ppubst/t LI_RVTuplesrvt_rv rvt_e rvt_p_dictcCst|tjpt|\}}}t|tjpt|djpt|tijpt|djpt|tjpt|ti ti gjp|djpt|ti jp|djpt|S(sSanity check a linked image operation return value tuple. The format of said tuple is: process return code LinkedImageException exception (optional) json dictionary containing planned image changes N( ttypeR tAssertionErrortinttNonetapxtLinkedImageExceptiontdicttpkgdefstEXIT_OKtEXIT_NOP(trvtupletrvtetp_dict((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt_li_rvtuple_checks *'-$cCsht|tjptxG|iD]9\}}t|tjptd|ft|q'W|S(sSGiven a linked image return value dictionary, sanity check all the entries.sUnexpected rvdict key: (RRRt iteritemstLinkedImageNameR(trvdicttktv((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt_li_rvdict_checks  cCsFt|g}|iD]$}|idj o||iqq~S(sGiven a linked image return value dictionary, return a list of any exceptions that were encountered while processing children.N(R"tvaluestrvt_eR(Rt_[1]R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt_li_rvdict_exceptionss cCsNt|}t|djo|dn|otid|ndS(sIf an exception was encountered while operating on a linked child then raise that exception. If multiple exceptions were encountered while operating on multiple children, then bundle those exceptions together and raise them.iitbundleN(R&tlenRR(Rt exceptions((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt_li_rvdict_raise_exceptionss  tLinkedImagePlugincBskeZdZeZeZdZdZedZeedZ dZ dZ dZ dZ RS( sThis class is a template that all linked image plugins should inherit from. Linked image plugins derived from this class are designed to manage linked aspects of the current image (vs managing linked aspects of a specific child of the current image). All the interfaces exported by this class and its descendants are private to the linked image subsystem and should not be called directly by any other subsystem.cCsdS(sInitialize a linked image plugin. 'pname' is the name of the plugin class derived from this base class. 'linked' is the LinkedImage object initializing this plugin. N((RtpnameR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__init__s cCs tdS(sCalled when the path to the image that we're operating on is changing. This normally occurs when we clone an image after we've planned and prepared to do an operation.N(tNotImplementedError(Rtroot((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt init_rootscCs tdS(sIf the linked image plugin is able to detect that we're operating on an image in an alternate root then return an transform that can be used to translate between the original image path and the current one.N(R.(Rt ignore_errors((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pytguess_path_transformscCs tdS(sReturn a list of the child images and paths associated with the current image. The paths that are returned should be absolute paths to the original child image locations.N(R.(RtnocacheR1((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pytget_child_listscCs tdS(sZGet the linked image properties associated with the specified child image.N(R.(Rtlin((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pytget_child_propsscCs tdS(sgAttach the specified child image. This operation should only affect in-memory state of the current image. It should not update any persistent on-disk linked image state or access the child image in any way. This routine should assume that the linked image properties have already been validated.N(R.(Rtpropst allow_relink((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pytattach_child_inmemoryscCs tdS(sDetach the specified child image. This operation should only affect in-memory state of the current image. It should not update any persistent on-disk linked image state or access the child image in any way.N(R.(RR5((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pytdetach_child_inmemoryscCs tdS(sPSync out the in-memory linked image state of this image to disk.N(R.(R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pytsync_children_todisks(t__name__t __module__t__doc__tFalsetsupport_attachtsupport_detachR-R0R2R4R6R9R:R;(((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyR+s    tLinkedImageChildPlugincBs eZdZdZdZRS(sThis class is a template that all linked image child plugins should inherit from. Linked image child plugins derived from this class are designed to manage linked aspects of children of the current image. (vs managing linked aspects of the current image itself). All the interfaces exported by this class and its descendants are private to the linked image subsystem and should not be called directly by any other subsystem.cCsdS(sInitialize a linked image child plugin. 'lic' is the LinkedImageChild object initializing this plugin. N((Rtlic((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyR-*scCs tdS(sCalled before a parent image saves linked image properties into a child image. Gives the linked image child plugin a chance to update the properties that will be saved within the child image.N(R.(RR7((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt munge_props2s(R<R=R>R-RD(((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyRB s RcBsqeZdZdZed dZed dZdZdZ dZ dZ dZ d Z RS( s`A class for naming child linked images. Linked image names are used for all child images (and only child images), and they encode two pieces of information. The name of the plugin used to manage the image and a linked image name. Linked image names have the following format ":cCst|tjptd|_|_y|id\|_|_Wn%tj oti d|nXt |idjpt |idjoti d|n|it i i ijoti d|ndS(Nt:t lin_malformedi(RtstrRRtlin_typetlin_nametsplitt ValueErrorRRR(tpkgtclientt linkedimagetp_types(Rtname((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyR-Cs,cCs t|S(sReturns the serialized state of this object in a format that that can be easily stored using JSON, pickle, etc.(RG(tobjtje_state((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pytgetstateSscCs t|S(s`Allocate a new object using previously serialized state obtained via getstate().(R(tstatetjd_state((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt fromstateZscCsd|i|ifS(Ns%s:%s(RHRI(R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__str__ascCst|iS(N(R(RW(R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__len__dscCst|tjpt|pdS|tjodSt|tjptt|i|i}|djo|St|i|i}|S(Nii(RRRt PV_NAME_NONEtcmpRHRI(Rtothertc((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__cmp__gs  cCstt|S(N(thashRG(R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__hash__tscCs+t|tptSt|t|jS(N(t isinstanceRR?RG(RR[((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__eq__wscCs|i| S(N(Ra(RR[((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__ne__}sN(R<R=R>R-t staticmethodRRSRVRWRXR]R_RaRb(((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyR<s     t LinkedImagec BseZdZeegZeeeeegZ eeeee gZ e ee Be B@ pt dZedZdZdHdZdZedHdHedZedZedZed Zed Zed Zed Zed ZedZ edZ!dZ"dZ#dZ$dZ%dZ&edZ'dZ(edZ)dZ*edZ+dHdZ,dZ-dZ.dZ/dZ0dZ1d Z2dHd!Z3d"Z4ed#Z5d$Z6d%Z7d&Z8ed'Z9dHed(Z:dHd)Z;eed*Z<ed+Z=d,Z>ed-Z?ed.Z@edHd/ZAd0ZBd1ZCd2ZDed3ZEd4ZFeeeeeedHeeGiHeed5 ZId6ZJeeedHeeeGiHeed7 ZKeeeed8ZLeeedHd9ZMeedHeNiOd:ZPdHdHed;ZQd<ZRdHdHd=ZSd>ZTd?ZUed@ZVedAZWdBZXdCZYdDZZdEZ[dFZ\dGZ]RS(IsHA LinkedImage object is used to manage the linked image aspects of an image. This image could be a child image, a parent image, or both a parent and child. This object allows for access to linked image properties and also provides routines that allow operations to be performed on child images.cCs||_t|_t|_d|_tii |_ d|_ d|_ h|_ d|_d|_d|_d|_d|_t|_|it|_x:tiiiD])}tiii||||i||idt|io|i|_n|in|ipdS|p|i|idtnx*|iiD]\}}|i|qWx!|ii D]}|i!qWdS(stCalled during object initialization and by image.py`__set_root() to let us know when we're changing the root location of the image. (The only time we change the root path is when changes BEs during operations which clone BEs. So when this happens most our metadata shouldn't actually change.s root = %ss imgdir = %sttmpNtupdate("ReR/RRGRzRpRtrstriptostseptpathtjoint PATH_PPKGSRqt PATH_PROPRrt PATH_PUBSRst PATH_PFACETSRtt_LinkedImage__loadR?tischildt_LinkedImage__insyncRvRft_LinkedImage__set_current_pathRuRxRR0Rot itervaluestchild_init_root(Rt first_passR/RztplugintlipRC((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyR{s6    cCs|djo t}nr|oj|i|xZtD]N}|tjot|joq5n||jptd|t|fq5Wn||_t |_ d|_ t i i|_d|_dS(sInternal helper routine used when we want to update any linked image properties. This routine sanity check the new properties, updates them, and resets any cached state that is affected by property values.s'%s' not in %sN(RRt_LinkedImage__verify_propsttemporal_propstPROP_CURRENT_PARENT_PATHtPROP_PARENT_PATHRtsetRfRgRhRiRLRjRkRlRm(RR7R}((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__update_props s         c Cst|}|t|ijo|St|jotd|idtgnytt|t}Wn6ti j o'td|idt|tfnX|i |i jo#td|id|d|i nt |jo#td|id|dt gn|t }|t jo&td|id|dt |fn|tjo8|i|}|o td|id|d|qn|tjo8|i|}|o td|id|d|qndS(srPerform internal consistency checks for a set of linked image properties. Don't update any state.Rt missing_propstbad_propR5t bad_lin_typeN(RRt_LinkedImage__parent_propst PROP_NAMEt_rterrRpRRGRRRHRxt PROP_MODELt model_valuest PV_MODEL_PUSHt_LinkedImage__push_child_propst PV_MODEL_PULLt_LinkedImage__pull_child_props(RR7t props_setR5tmodeltmissing((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__verify_props's>         cCs|o#t|t@ptd|n!t|t@ ptd||djp|djpt|dj p|dj pt|dj ot||}n!|dj ot||}n||t<||t<||t" appended to them.s%s.%dRRN(RrRt client_runidt path_existst load_dataRRRRRRRRRRpR(RRRtpath_tmpR7RPR5((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__load_ondisk_propss(        cCsti}d|itif}|ot|ot|}n|i}t|dt}|djodSt i i }x*|i D]\}}|i ||qW|S(s8Load linked image inherited facets from disk. Don't update any internal state. 'tmp' determines if we should read/write to the official linked image metadata files, or if we should access temporary versions (which have "." appended to them.s%s.%dt missing_okN(tmisct EmptyDictRtRRRRRuRRLRjRkRt_set_inherited(RRtpfacetsRRR R!((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__load_ondisk_pfacetss      cCsd}d|itif}|ot|ot|}n|i}t|dt}|djodStg}|D]}|ti i t |q{~S(s7Load linked image parent packages from disk. Don't update any internal state. 'tmp' determines if we should read/write to the official linked image metadata files, or if we should access temporary versions (which have "." appended to them.s%s.%dRN( RRqRRRRRuRgRLtfmritPkgFmriRG(RRt fmri_strsRR%ts((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__load_ondisk_ppkgss    cCs_d}d|itif}|ot|ot|}n|i}t|dt}|S(s9Load linked image parent publishers from disk. Don't update any internal state. 'tmp' determines if we should read/write to the official linked image metadata files, or if we should access temporary versions (which have "." appended to them.s%s.%dRN(RRsRRRRRu(RRtppubsR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__load_ondisk_ppubss   cCs|id|}| o|idt odS|p|idt}n|i||i||ipdS|id|}|dj o ||_ n|i d|}|dj o ||_ n|i d||_ dS(sLoad linked image properties and constraints from disk. Update the linked image internal state with the loaded data.RR1N(t_LinkedImage__load_ondisk_propst_LinkedImage__isparentRut$_LinkedImage__fabricate_parent_propsRRwRt_LinkedImage__load_ondisk_ppkgsRRht!_LinkedImage__load_ondisk_pfacetsRlt_LinkedImage__load_ondisk_ppubsRi(RRR7tppkgsR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__load%s"         cCsG|ttgjotSt|tjo|idjotStS(s'Verify property value for PROP_RECURSE.ttruetfalse(struesfalse(RuR?RRGtlower(R!((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__validate_prop_recursebs &cCs=h|it6}|tjo |i}n|tjpt|i}g}x|iD]\}}||jo |it i d|qZn|||p&|it i d||fqZn||jo |it i d|qZqZqZWt |djo|dn|ot i d|ndS(sgValidate user supplied linked image attach properties. Don't update any internal state.tattach_bad_proptattach_bad_prop_valueiiR'N( t#_LinkedImage__validate_prop_recurset PROP_RECURSERRRRRRRRRR((RRR7tvalidate_propst allowed_propsterrsR R!((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__validate_attach_propsks2          c Csyti|Wn%tj otid|nXy+|iid|dtd|ii}Wn(ti j otid|nX|S(sVInitialize an Image object which can be used to access a parent image.tparent_bad_pathR/tuser_provided_dirtcmdpathtparent_bad_img( RtstattOSErrorRRRetallocRuRtImageNotFoundException(RRtpimg((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt __init_pimgs c Cs|i oT|i oF|i|i|i|ig}x |D]}t|otSqAWtS|i dt}|djo t }nt |i t}||jotS|i|i|ig}|ip(x |D]}t|otSqWtSx |D]}t|ptSqW|idt}|i|jotS|idt}|i|jotS|idt}|i|jotStS(sIf our in-memory linked image state matches the on-disk linked image state then there's nothing to do. If the state differs then there is stuff to do since the new state needs to be saved to disk.RN(tisparentRRtRqRsRrRR?RuRRRt rm_dict_entRfRRRlRRhRRi(RtpathsRtli_ondisk_propstli_inmemory_propstli_ondisk_pfacetstli_ondisk_ppkgstli_ondisk_ppubs((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt nothingtodosP              cCs|ipdS|iiidodSt|i}|i}|djodSt|t|joti d||fnxIt ||D]8\}}||joqnti d||fqWdS(sUIf we're a child image's, verify that the parent image publisher configuration is a subset of the child images publisher configuration. This means that all publishers configured within the parent image must also be configured within the child image with the same: - publisher rank - sticky and disabled settings The child image may have additional publishers configured but they must all be lower ranked than the parent's publishers. Nsuse-system-repotlinked_pub_error( RRetcfgt get_policytget_pubsRiRR(RtPlanCreationExceptiontzip(RtpubsRR}tpp((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pytpubchecks"       cCs|ipdS|ittjodS|ip"|i}|i||_nt|i|_t |i|_ t |i|_ dS(s`Update linked image constraint, publisher data, and state from our parent image.N( RRfRRRmt parent_patht_LinkedImage__init_pimgRRit get_packagesRhtget_inheritable_facetsRl(RR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__syncmd_from_parents   cCsNy|iWn9tij o*}|p |nt|i|dSXdS(sUpdate linked image constraint, publisher data, and state from our parent image. If catch_exception is true catch any linked image exceptions and pack them up in a linked image return value tuple.N(t _LinkedImage__syncmd_from_parentRRR t lix_exitrvR(Rtcatch_exceptionR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pytsyncmd_from_parent/s cCs>|i|i|i|ig}x1|D])}d|tif}t|dtq%W|i o4|i o&x|D]}t|dtquWdSt |i t }t |i||ip>t|idtt|idtt|idtdSt |i|it |i|it |i|idS(s+Write in-memory linked image state to disk.s%s.%dtnoent_okN(RtRqRsRrRRt path_unlinkRuRRRRfRt save_dataRlRhRi(RRRR7((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pytsyncmd=s0   cCs(|ip|in|itS(sIf the current image is a child image, this function returns a linked image name object which represents the name of the current image.(Rt_LinkedImage__apx_not_childRfR(R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt child_nameds cCs t|ijS(s5Indicates whether the current image is a child image.(RRf(R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyRnscCst|id|djS(sIndicates whether the current image is a parent image. 'ignore_plugin_errors' ignore plugin runtime errors when trying to determine if we're a parent image. R1i(R(t_LinkedImage__list_children(RR1((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt __isparentss cCst|id|djS(s6Indicates whether the current image is a parent image.t li_ignorei(R(R(RR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyR}scCs|ip |iS(s5Indicates wether the current image is already linked.(RR(R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pytislinkedscCs|iittS(s+Return the current path transform property.(RftgetRR(R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pytget_path_transforms cCs|itjS(sVCheck if we're accessing a linked image at an alternate location/path.(RR(R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt inaltrootscCs|ipt|itS(sReport our current image path.(RRRfR(R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyRscCs|ipt|itS(sReport our current image path.(RRRfR(R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyRscCs>t|ijodS|it}|ddjpt|S(sUIf we know where our parent should be, report it's expected location.iR N(RRfRRR(RR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyRs  cCsw|djo|iiS|i|dt|i|i}|i|i}|i||i d|t |S(sReturn a dictionary which represents the linked image properties associated with a linked image. 'lin' is the name of the child image. If lin is None then the current image is assumed to be a linked image and it's properties are returned. Always returns a copy of the properties in case the caller tries to update them.t raise_exceptRN( RRftcopyt_LinkedImage__verify_child_nameRuRxRHR6RRR(RR5RR7((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt child_propss  cCstid|iS(sRRaise an exception because the current image is not a child image.tself_not_child(RRRp(R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__apx_not_childscCsut|tjptdt|x*|iD]}|d|jotSq4W|otid|ntS(s'Check if a specific child image exists.s%s == LinkedImageNameit child_unknown(RRRRRuRRR?(RR5Rti((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__verify_child_names  cCsXt|tp tdt|t|fx!|D]}|i|dtq7WdS(s\Given a list of linked image name objects, make sure all the children exist.s)type(lin_list) == %s, str(lin_list) == %sRN(R`RRRRGRRu(Rtlin_listR5((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt verify_namess cCs|iS(s'Facets inherited from our parent image.(Rl(R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pytinherited_facetsscCs|ipdS|iS(s1A set of the fmris installed in our parent image.N(RRRh(R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt parent_fmriss cCsHt|tjptt|}|p|i|dtn|S(sGiven a string representing a linked image child name, returns linked image name object representing the same name. 'allow_unknown' indicates whether the name must represent actual children or simply be syntactically correct.R(RRGRRRRu(RRPt allow_unknownR5((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt parse_names  c Cs|gjogSg}xtiiiD]o}xf|i|id|D]K\}}|i|jptt||i }|i ||gqHWq(Wt |dt i d}|djo|Stg}|D]\}}||q~}g} t||D]}| tid|q ~ } t| djo| dn| otid| ng} |D]*\}}||jo| ||fququ~ S(sReturns a list of linked child images associated with the current image. 'li_ignore' see list_related() for a description. The returned value is a list of tuples where each tuple contains (
  • ,
  • ).R1tkeyiRiR'N(RLRMRNRORxR4RHRRRRtsortedtoperatort itemgetterRRRRR(( RRR1t li_childrenR}R5RR%tli_allt_[2]Rt_[3]((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__list_childrens2   -0c Cs|id|}g}|D]\}}||t|fq~}| o|i ogSt}|io |i}n|i}|t|f}|i||i}|dj o tt |f}|i|nt |dt i d}|S(s,Returns a list of linked images associated with the current image. This includes both child and parent images. 'li_ignore' is either None or a list. If it's None (the default), all children will be listed. If it's an empty list no children will be listed. Otherwise, any children listed in li_ignore will be ommited from the results. The returned value is a list of tuples where each tuple contains (
  • , ,
  • ).RR%iN(Rt REL_CHILDRRYRRtREL_SELFRRRt REL_PARENTR&R'R(( RRR)R%R5Rtli_listtli_selft li_parent((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt list_related.s" )      c Cst|tjptt|tjpt|d jp't|tjptdt||d jo t}n|i|i}|io!| ot i d|i n|i o!| ot i d|int ii|pt i d|n|i|}|i}|iio+t i d|ii|ifn|it||i||i |i}||t\} } | |i#joq-n| |jo| || RR9RRtLinkedImageChildRt_LinkedImage__children_opt PKG_OP_SYNCR?RuRdRR;RR$R (RR5RR7RR8R?RRRt progtrackRRRRRRtcwdtp_propsRR R!RCRRtrvtuple2((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt attach_childs #                         c Csv|gjo d}n|id|dt\}}t|idtid|id|dti dt|S( skAudit one or more children of the current image to see if they are in sync with this image.RtfailfastRRRRRN( Rt_LinkedImage__children_initR?RRRtPKG_OP_AUDIT_LINKEDR#tprogresstQuietProgressTracker(RRtlic_dictR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pytaudit_childrenos       c  Cs|djoti}n|gjo d}n|id|} t} | o|o t} nh} t|idti d| i d| d|dtdtd| d |d |d |d |d |d|d| d| | S(s/Sync one or more children of the current image.RRRRRRRRRRRRRRRRN( RRtNullProgressTrackerRRuR?RRRRR#(RRRRRRRRRRRRRR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt sync_childrens4        c Cs|gjo d }n|id|dt\}}xy|D]q}|i|i} | ip|oq<ntid|i} t| i | d ||Rtpdc ss|ipt|i||i|\}}}t||||i<|o6t|o)x|D]}|iqkWt|n|i t i t i gjo|i |i||n|o|i t i jo |iVndS(scAn iterator function invoked when a child has finished an operation. 'lic' is the child that has finished execution. 'lic_list' a list of children to remove 'lic' from. See __children_op() for an explanation of the other parameters.N(tchild_op_is_doneRtremovet child_op_rvRRR&tchild_op_abortR*RdRRRtli_recurse_outputRc( RCtlic_listRRRRRtstdouttstderr((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__child_op_finishs      N(0treduceR'taddR(RRRRtclient_concurrencyRRtPKG_OP_PUBCHECKtclient_concurrency_settli_recurse_startRRuRRRRReRRtchild_op_setupRRRR RR&RR*RR?tpoptchild_op_startR&tli_recurse_statusRtfilenotselecttpolltkeystregistertPOLLINtli_recurse_progressR"tli_recurse_end((RRRRRRRRRR%Rtlic_alltlic_numR+t concurrencytpkg_opt lic_setupRRtignore_syncmd_nopt_pmdRRRRCRt_LinkedImage__child_op_finishRt lic_runningtprogtrack_updatetdoneR,t lin_runningt_[4]tfd_hashR}tfdteventst_[5]tevent((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__children_op_vec s" +  >          ) 2         '  )   )     c Cs|djp|djpt|djo2g}|i|D]}||dqB~}n|i|h}h}x_|D]W}yt||} | ||d |jpt|d |d d |jpt|d |d RgRRRRRRRRRRR-tpropertyR~R{RRwRRcR?RRRRRuRRRRRRR;RRRRRR RRRRRRRRRRRR RR R!R"R$RR4R@RERRaRbRoRpRqRrRR<RtEmptyIRRRRRRRRRRRRR)R'R(R-R.R/R4R5R6(((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyRds    & <  0  $ '    = ,  E *   '            - * F  ,  9  @ N  v   "E "   _5? (   #Rc BsaeZdZdZedZedZedZdZe e dZ e e dZ e e dZ e e d Z e e d Zee e eid Ze e ee eeie eied Zd ZdZdZdZe ee dZdZdZdZdZdZdZ dZ!dZ"dZ#RS(sVA LinkedImageChild object is used when a parent image wants to access a child image. These accesses may include things like: saving/pushing linked image metadata into a child image, syncing or auditing a child image, or recursing into a child image to keep it in sync with planned changes in the parent image.cCst|tptdt|t|tptdt|||_|i|_|ii||_ |i t |jptyt i |i }Wn9tj o-}tid|dd|i |fnX|ptid|d|i ntii|t|_tii|t|_tii|t|_tii|t|_tiii|i ||_!tii"i#|_$d|_&d|_'dS(Nsisinstance(%s, LinkedImage)sisinstance(%s, LinkedImageName)R5RvRwRx((R`RdRRRt_LinkedImageChild__linkedR~t_LinkedImageChild__imgRt_LinkedImageChild__propsRR{R|t child_pathRRRRRRRt_LinkedImageChild__path_ppkgsRt_LinkedImageChild__path_propRt_LinkedImageChild__path_ppubsRt_LinkedImageChild__path_pfacetsRLRMRNtp_classes_childRHt_LinkedImageChild__plugint pkgremotet PkgRemotet_LinkedImageChild__pkg_remoteRt#_LinkedImageChild__child_op_rvtuplet_LinkedImageChild__child_op(RRR5RzR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyR- s0    cCs |itS(s+Get the name associated with a child image.(R;R(R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyR scCs'|iio |itS|itS(s+Get the path associated with a child image.(R9RR;RR(R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyR< s cCs|iS(sTGet a pointer to the parent image object associated with this child.(R:(R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt child_pimage sc Cs%yd|tif}t||d|dtt}t|dtd|dtdt}|d j o9t|d|dtdt} || jo t}qn| p|oti|||S|pti |||nWn<t j o0} t i d|i dd|i| fnXtS( sWrite data to a child image.s%s.%sR/RRtdecodeR5Rvsmetadata updateN(RRR R?RuRRR{t ar_unlinkt ar_renameRRRRR<( RR/RtdataRttestRtupdatedtold_datatnew_dataR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt __push_data s2        cCs|i|i|i|||S(sSync linked image parent constraint data to a child image. 'tmp' determines if we should read/write to the official linked image metadata files, or if we should access temporary versions (which have "." appended to them.(t_LinkedImageChild__push_dataR<R=(RRRRM((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt __push_ppkgs scCs|i|i|i|||S(sSync linked image parent facet data to a child image. 'tmp' determines if we should read/write to the official linked image metadata files, or if we should access temporary versions (which have "." appended to them.(RRR<R@(RRRRM((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__push_pfacets scCsa|ii}t|jpt|ii|t|t}|i|i |i |||S(s Sync linked image properties data to a child image. 'tmp' determines if we should read/write to the official linked image metadata files, or if we should access temporary versions (which have "." appended to them.( R;RRRRBRDRRRRR<R>(RRRMR7((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt __push_props s cCs|i|i|i|||S(sSync linked image parent publisher data to a child image. 'tmp' determines if we should read/write to the official linked image metadata files, or if we should access temporary versions (which have "." appended to them.(RRR<R?(RRRRM((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt __push_ppubs sc Csy|\}}}|i|||}|i||}|i|||} |i|||} |p|p | p| S(sSync linked image data to a child image. 'tmp' determines if we should read/write to the official linked image metadata files, or if we should access temporary versions (which have "." appended to them.(t_LinkedImageChild__push_ppkgst_LinkedImageChild__push_propst_LinkedImageChild__push_ppubst_LinkedImageChild__push_pfacets( RtpmdRRMRRRt ppkgs_updatedt props_updatedt pubs_updatedtpfacets_updated((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__syncmd sc Cs|titigjotSy|i|d|d|}Wn1tij o"}t|i|d|_ t SX|otS|otStti dd|_ t S(sPrepare to perform an operation on a child image by syncing the latest linked image data to that image. As part of this operation, if we discover that the meta data hasn't changed we may report back that there is nothing to do (EXIT_NOP). 'pmd' is a tuple that contains parent metadata that we will sync to the child image. Note this is not all the metadata that we will sync, just the set which is common to all children. 'ignore_syncmd_nop' a boolean that indicates if we should always recurse into a child even if the linked image meta data isn't changing. 'tmp' a boolean that indicates if we should save the child image meta data into temporary files (instead of overwriting the persistent meta data files). 'test' a boolean that indicates we shouldn't save any child image meta data, instead we should just test to see if the meta data is changing. 'stage' indicates which stage of execution we should be performing on a child image.RRMN( RRRRut_LinkedImageChild__syncmdRRR RRRFR?R(RR[RRRMRRNR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__child_op_setup_syncmd. sc/Cs|oD|i|dtd|d| pdSttidd|_dS|i|d|d|d| pdS|ii|i ti d|ddddd t d dd dd |d t d|dtdgddd|dgdt i dt id| d| d| d| d| dt idS(s6Prepare to sync a child image. This involves updating the linked image metadata in the child and then possibly recursing into the child to actually update packages. For descriptions of parameters please see the descriptions in api.py`gen_plan_*RRMRNRRt backup_betbackup_be_namet be_activateRRRtli_parent_syncRt li_target_alltli_target_listtnew_beRtoriginstparsable_versiontquietRt reject_patsRRtverbose(t(_LinkedImageChild__child_op_setup_syncmdR?R RRRRFREtsetupR<RRuRtclient_output_parsable_versiontclient_output_quiettclient_output_verbose(RRRRRRRRRRRRRR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__child_setup_syncb sF     c 1Cs|i|dtd|d| pdS|djo g}n|ii|itiddd|ddd dd td dd |d tdddddtddd|dgd|dti dti d|d| d| d| d| dti dS(s Prepare to update a child image.RRRNt act_timeoutiRRcRdReRR?tignore_missingt li_erecurseRRfRiRRjtpargsRkRlRRmRRRn( RoRuRRERpR<RRRRqRrRs( RRRRRR?RR#RRRRR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__child_setup_update s>      c -Cs|i|dtd|d| pdS|ii|itid|ddddd dd td dd dd ddtddd|dgd|dti dti d|d|d| d| d| dti dS(s*Prepare to install a pkg in a child image.RRRNRRuiRcRdReRRwRRfRiRRjRxRkRlRRmRRRn( RoRuRERpR<RRRRRqRrRs( RRRRRRR RRRRR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__child_setup_install s6    c%Cs|i|dtd|d|pdS|ii|itiddddddd td dd dd dd tddd|d|dti dti d|d|dtdti dS(s*Prepare to install a pkg in a child image.RRRNRuiRcRdReRRwRRfRiRRxRkRlRRvRn( RoRuRERpR<RRRRRqRrRs(RRRRRR"RR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__child_setup_uninstall s.    c /Cs>|i|dtd|d| pdS| o| pt| oti} | }nti} |}g}|iD]\}}|d||fqw~}|ii|i | d|ddd dd dd td dd ddddtddd|dgd|dt i dt i d|d|d| d| d| dt idS(s*Prepare to install a pkg in a child image.RRRNs%s=%sRRuiRcRdReRRwRRfRiRRjRxRkRlRRmRRRn(RoRuRRRRtitemsRERpR<RRRqRrRs(RRRRRR!RRRRRRRJRt varcet_dictR%RXtbtvarcets((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__child_setup_change_varcets# sD    7  cCsS|ii|itidtd|d|dtdgd|dtidti d S( s Prepare to detach a child image.R?RRRgRhRRlRnN( RERpR<RRRuR?RRrRs(RRRRR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__child_setup_detachS s  cCs8|i|dtpdS|ii|itidS(s7Prepare to a check if a child's publishers are in sync.RN(RoRuRERpR<RR(RR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__child_setup_pubcheckb sc CsV|i|dtpdS|ii|itidtdtdgdtdtdS(sUPrepare to a child image to see if it's in sync with its constraints.RNRfRgRht omit_headersRl(RoRuRERpR<RRR?(RR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt__child_setup_audito s cCs#|iid|_d|_dS(s8Public interface to abort an operation on a child image.N(REtabortRRFRG(R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyR s  cKs|idjpt|idjpt||_|tijo|i||n>|tijo|i||n|ti jo|i ||n|ti jo|i |||||n|ti jo|i||||n|tijo|i||||nu|tijo|i||||nK|tijp|tijo|i||||ntd|dS(sbPublic interface to setup an operation that we'd like to perform on a child image.s!Unsupported package client op: %sN(RFRRRGRRt$_LinkedImageChild__child_setup_auditRt%_LinkedImageChild__child_setup_detachRt'_LinkedImageChild__child_setup_pubcheckRt#_LinkedImageChild__child_setup_syncRt%_LinkedImageChild__child_setup_updateRt&_LinkedImageChild__child_setup_installRt(_LinkedImageChild__child_setup_uninstallRRt-_LinkedImageChild__child_setup_change_varcetst RuntimeError(RRRRRRR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyR s6      cCs&|idj otS|iidS(s8Public interface to start an operation on a child image.N(RFRRuREtstart(R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyR scCs"|idj otS|iiS(sSPublic interface to query if an operation on a child image is done.N(RFRRuREtis_done(R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyR sc Cs(|i}d|_|idj o |i}d|_|ddfS|iipt|ii\}}}}|dj o ti}n|dj p|ti ti gjoQt i d|i d|d|||||f}t||d}|||fS|ti jo4|djptt|dd}|||fStidjp| o t|dd}|||fSd}yti|}WnYtj oM}t i d|i d||||f}t||d}|||fSXt|i |dR-R7RR<RHRRR?RWRZRXRYRaRuRRRoRR8RRRRRRRRRRRRRRR(((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyR} sJ & ,   5 F , % 0   $ G cCs:g}|idtD]}|t||igq~S(sZReturn publisher information for the specified image. Publisher information is returned in a sorted list of lists of the format: , Where: is a string is a boolean The tuples are sorted by publisher rank. t inc_disabled(tget_sorted_publishersR?RGtsticky(R|R%R}((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyR) scCst|i|ii}|dj ox|iD]\}}||joq5n|o+||jpt|t|g8}n|o+||jpt|t|gO}q5q5Wnt|S(s<Figure out the current (or planned) list of packages in img.N(RRHRIRLRt plan_descRRg(R|RRtsrctdst((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyR< s   c Cst|d|}|ii}|d j o|id j o |i}ntg}|D]}||i|fqV~}t}|i|i}x|D]}x|i ||i gD]} | i djp| i ddjoqn|i | } | pqntg} | D]} | | dq~ ttgjoqn| || tj o2} |oti| nti| nX|S(s4Load JSON encoded linked image metadata from a file.R/trRsutf-8t object_hookN(RRLRMRNt PkgDecoderRR{RRtO_RDONLYRRtloadRRRR( RRR/RIRRRRRLR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyR s  RcBseZdZdZRS(s<Utility class used when json encoding linked image metadata.cCst|tiitiiiifo t|St|t i o |i St|t t fo t|Stii||S(sRequired routine that overrides the default base class version. This routine must serialize 'obj' when attempting to save 'obj' json format.(R`RLRRRMRNtcommonRRGtpkgplantPkgPlanRSRRgRRt JSONEncodertdefault(RRQ((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyRs   (R<R=R>R(((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyR scCsh}x|iD]\}}t|tjo|id}nt|tjo|id}nt|tjo>|idjo t}q|idjo t}qn||| %siis*Found saved temporal linked properties: %ssLinked image error: sLinked image (%s) error: ts Linked image (%s) path: %ss Linked image path: %ss%s: %s%sN( RRRRGRRRR~R/R<R(RRCR5RRmtbad_cptbad_iupRRRRtsaved_temporal_propsRt transformt err_prefixt err_suffix((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyR?sb '      cCs?yti||SWn$tj o}ti|nXdS(s7Simple wrapper for accessing files in the current root.N(R{RRRR(RR/R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyRscCs?ytid|SWn$tj o}ti|nXdS(s7Simple wrapper for accessing files in the current root.R N(R{tar_isdirRRR(RR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt path_isdirscCsBytid||SWn$tj o}ti|nXdS(s7Simple wrapper for accessing files in the current root.R N(R{RRRR(RRR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt path_mkdirscCsEytid|d|SWn$tj o}ti|nXdS(s7Simple wrapper for accessing files in the current root.R R N(R{RJRRR(RR R((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyR scCsitii|ptd||ititi}|tjotS|i|dotSt S(s3Check if 'path_transform' can be applied to 'path'.spath is not absolute: %si( RRR:RRRRRuRR?(RR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pytpath_transform_applicables! cCs[tii|ptd||ititi}|d|df}t||S(s5Check if 'path_transform' has been applied to 'path'.spath is not absolute: %sii(RRR:RRRR(RR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyR=s!cCstii|ptd||ititi}|tjo|S|\}}t||pttii||t |S(s%Apply the 'path_transform' to 'path'.spath is not absolute: %s( RRR:RRRRRRR((RRtoroottnroot((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyRs!  cCs!|d|df}t||S(s)Unapply the 'path_transform' from 'path'.ii(R(RR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyRscCstii|ptd|tii|ptd||ititi}|ititi}d}|ddd}|ddd}xCttt|t|D] }||||joPqqW||dddititi}||dddititi}|d|djo djnpt|d|djo djnpt||jot S||fS(sYGiven an two paths create a transform that can be used to translate between them.sopath is not absolute: %ssnpath is not absolute: %siNiR ( RRR:RRRtrangetminR(R(topathtnpathRt opath_revt npath_revRR((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyRs$!!" **-- (bR>t collectionsRRR'RRt simplejsonRt pkg.actionsRLt pkg.altroottaltrootR{t pkg.catalogtpkg.client.api_errorsRMt api_errorsRtpkg.client.bootenvR}tpkg.client.linkedimagetpkg.client.pkgdefsRtpkg.client.pkgplanRtpkg.client.pkgremotetpkg.client.progressRt pkg.facettpkg.fmritpkg.miscRtpkg.pkgsubprocesst pkg.versiont pkg.clientRtloggerR0R/R.RRRRRRRRRgRCRRYRRRt __DATA_DIRRRRRRRRt namedtupleR RR"R&R*tobjectR+RBRRdRRRRRRuR R?RRRRRRRRRR RR=RRR(((sC/usr/lib/python2.6/vendor-packages/pkg/client/linkedimage/common.pyt)s                       UD        A