Oc@s\ddkZddkZddkZddkZddkZddkZddkiiZ ddk Z ddk i i Zddki iZddkiZddkiZddkiZddgZddgZddgZddgZdd gZdd gZdd gZdd gZdd gZddgZ ddgZ!ddgZ"ddgZ#ddgZ$dddgZ%heei&6eei'6eei(6eei)6eei*6eei+6eei,6eei-6eei.6eei/6eei06eei16eei26eei36e ei46e#ei56eei66ee76e"e86Z9de:fdYZ;de:fdYZ<dS(iNtCanceledtNonetIgnoreds Nothing to dot SucceededtFaileds Bad Requestt Configurationt ConstrainedtLockedtSearchtStoraget TransporttActuators Out of MemorysConflicting ActionstUnknowntcontentstinfotlistt_HistoryOperationcBseZdZhZdZdZdZdZdZ dZ dZ dZ dZ dZdZdZdZdZdZdZdZdZdZdZdZedZRS(sA _HistoryOperation object is a representation of data about an operation that a pkg(5) client has performed. This class is private and not intended for use by classes other than History. This class provides an abstraction layer between the stack of operations that History manages should these values need to be manipulated as they are set or retrieved. cCsgt}x'dD]}t||t||qWg}|iD]}|ti|qA~|_|S(Ntnamet start_timetend_timet start_statet end_statetusernametuseridtbet be_existstbe_uuidt current_betcurrent_new_betnew_bet new_be_existst new_be_uuidtresultt release_notestsnapshot(snames start_timesend_times start_states end_statesusernamesuseridsbeRsbe_uuids current_bescurrent_new_besnew_beRs new_be_uuidsresults release_notesssnapshot(Rtsetattrtgetattrterrorstcopy(tselfthtattrt_[1]te((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyt__copy__us 0c Cs0|d jot|}nti|||S( NR R%RRRRRRRR"( sresultserrorssbesbe_uuids current_bescurrent_new_besnew_bes new_be_existss new_be_uuidssnapshot(tstrtobjectt __setattr__(R'Rtvalue((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyR/s  cCsnd|i|i|i|i|i|i|i|i|i|i |i |i |i |i |i|i|ifS(NsOperation Name: %s Operation Result: %s Operation Start Time: %s Operation End Time: %s Operation Start State: %s Operation End State: %s Operation User: %s (%s) Operation Boot Env.: %s Operation Boot Env. Currrent: %s Operation Boot Env. UUID: %s Operation New Boot Env.: %s Operation New Boot Env. Current: %s Operation New Boot Env. UUID: %s Operation Snapshot: %s Operation Release Notes: %s Operation Errors: %s (RR RRRRRRRRRRRRR"R!R%(R'((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyt__str__scCs g|_dS(N(R%(R'((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyt__init__scCs5tiphtdd6tdd6tdd6tdd6tdd6tdd6tdd6tdd6td d 6td d 6td d 6td d 6td d 6tdd6tdd6tdd6tdd6t_n|i p |i odSti|idti|idfS(svReturns a tuple containing the translated text for the operation result of the form (outcome, reason).RRRs Nothing to doRs Bad RequestRRRRR R R s Out of MemorysConflicting ActionsR Rtii(R3R3(Rt result_l10nt_RR (R'((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyt result_texts.                 N(t__name__t __module__t__doc__R4R,R/R1RRRRRRR%RRRRRRRRR!R"R R2tpropertyR6(((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyRis0  tHistorycBseZdZdZdZdZdZgZdZ dZ dZ dZ dZ dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZddddZdZe dZ!e dZ"e d Z#d Z$d Z%e&d Z'dd Z(dZ)dZ*dZ+dddZ,dZ-dddZ.ddddZ/dZ0dZ1dZ2dZ3RS(sA History object is a representation of data about a pkg(5) client and about operations that the client is executing or has executed. It uses the _HistoryOperation class to represent the data about an operation. c Cst}x'dD]}t||t||qWti|dg}|iD]}|ti|qM~g}|iD]}|ti|q{~|_|S(Ntroot_dirt client_nametclient_versiont client_args(sroot_dirs client_namesclient_version( R;R#R$R.R/R?R&t_History__operationstdeepcopy(R'R(R)R*tat_[2]to((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyR,s  .0cCs}|djoti||S|idpti||Sti|d}|pdSt|dd|tdS(NR?t operation_R@it operation(R.t__getattribute__t startswithRR$tlen(R'Rtops((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyRG*s c Cs%|djotd|n|idpti|||Sti|d}|djoF|pg}ti|d|n|ihdd6td6n|ptd|n|d d}t||t d||djot i t i d|_yti|_Wntj od |_nXti|_d}t id ot id g}n |ig}|it id ti|d|ti|d tinV|djoHt i d|_|itjo|tjo|in|d =ndS(NR?s-'history' object attribute '%s' is read-only.RER@toperation_nametpathnameRFsF'history' object attribute '%s' cannot be set before 'operation_name'.itunknowniiR>toperation_result(tAttributeErrorRHR.R/RGtappendRRR#RItsyst exc_cleartmiscttime_to_timestampRtportablet get_usernameRtKeyErrort get_useridRtargvR=textendtpkgtVERSIONRRtDISCARDED_OPERATIONStRESULT_NOTHING_TO_DOt_History__save(R'RR0RJtoptca((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyR/7sP         t.cCsPti|dgtiii|_||_|o|i|d|ndS(s*'root_dir' should be the path of the directory where the history directory can be found (or created if it doesn't exist). 'filename' should be the name of an XML file containing serialized history information to load. 'uuid_be_dic', if supplied, should be a dictionary of BE uuid information, as produced by pkg.client.bootenv.BootEnv.get_uuid_be_dic(), otherwise that method is called each time a History object is created. R?t uuid_be_dicN(R.R/R[tclienttglobal_settingsR=R<t_History__load(R'R<tfilenameRc((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyR2s  cCs;|i}dig}|D]}|t|dq~S(Ns RF(R@tjoinR-(R'RJR*R`((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyR1s cCstii|idS(scThe directory where history files will be written to or read from. thistory(tostpathRhR<(R'((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyRkscCsW|ipdS|i}|dd}|p&tii|id|ddiS|S(sReturns the pathname that the history information was read from or will attempted to be written to. Returns None if no operation has started yet or if no operation has been loaded. iRLs %s-01.xmlRFN(toperation_start_timeRR@RjRkRhR(R'RJRL((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyRLs  ccs|ipdSyGtii|id|i}x"t|dD]}|iVq@WWn$tj o}ti |nXdS(s{Generates the lines of release notes for this operation. If no release notes are present, no output occurs.Ntnotestr( toperation_release_notesRjRkRhR<tfiletrstript ExceptiontapxtHistoryLoadException(R'trpathRBR+((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyRms  cCs2d|_d|_ti|dgg|_dS(s`Discards all information related to the current history object. R?N(RR=R>R.R/R@(R'((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pytclears  c Cs|id|_|id|_y|idd}Wntj oneXti|d}xN|idD]=}y|i|idi Wqst tfj oqsXqsWdS(slInternal function to load the client data from the given XML 'node' object. RtversiontargsiR?targN( t getAttributeR=R>tgetElementsByTagNamet IndexErrorR.RGRPt childNodest wholeTextRO(R'tnodeRxRatcnode((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyt__load_client_datascs)t}id|_id|_id|_id|_id|_idid|_t |idjo|ii d n|id d jo t |_ni d oid |_ ni d oid |_ni do?id|_|i o|i|i |i|_qdni do?id|_|io|i|i|i|_qni doid|_ndfd}|d|_|d|_|ii|ddd|S(sInternal function to load the operation data from the given XML 'node' object and return a _HistoryOperation object. RRRRRR s, iRis Nothing to doRRRRs release-notescsyei|d}|o9|i|}g}|D]}||idiq7~S|idiSWnttfj onX|ogSdS(Ni(R{R}R~ROR|(t parent_namet child_nametparenttcnodesR*R(R(s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pytget_node_valuess #RRR%RterrorN(RRzRRRRRtsplitR RIRPR^t hasAttributeRRRtgetRRRR!RRRR%RZ(RRcR`R((Rs8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyt__load_operation_datas@     c Cs0|iy|ptii}nWntij o}h}nXytii|i|}t i |}|i }xp|i D]e}|i djo|i|q|i djo.|iih|d6|i||d6qqWWn9tj o n%tj o}ti|nXdS(sLoads the history from a file located in self.path/history/ {filename}. The file should contain a serialized history object in XML format. RdRFRLN(RvtbootenvtBootEnvtget_uuid_be_dicRst ApiExceptionRjRkRhtxminitparsetdocumentElementR}tnodeNamet_History__load_client_dataR@RPt_History__load_operation_datatKeyboardInterruptRrRt(R'RgRcR+RLtdtrootR((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyt__loads.     cCs|idj pt|idj pt|i}|id}|id|i|id|i|i||iol|id}|i|xM|iD]>}|id}|i||i|i t |qWndS(sInternal function used to serialize current client data using the supplied 'd' (xml.dom.minidom) object. RdRRwRxRyN( R=RtAssertionErrorR>Rt createElementt setAttributet appendChildR?tcreateCDATASectionR-(R'RRRdRxtentryRy((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyt__serialize_client_dataBs       cCs|idjotidn$|idjotidn|i}|id}|id|i|idt |i|idt |i|iddi |i |id |i |id |i |io|id |in|io|id |in|io|id |in|io|id|in|io|id|in|io|id|in|i||io?|id}|i||i|it |in|io?|id}|i||i|it |in|iol|id}|i|xM|iD]>}|id}|i||i|it |qzWndS(sInternal function used to serialize current operation data using the supplied 'd' (xml.dom.minidom) object. sqUnable to determine the id of the user that performed the current operation; unable to store history information.swUnable to determine the username of the user that performed the current operation; unable to store history information.RFRRRR s, RRRRRRR"s release-notesRRR%RN(toperation_useridRRstHistoryStoreExceptiontoperation_usernameRRRRKR-RhRNRltoperation_end_timet operation_betoperation_be_uuidtoperation_new_betoperation_new_be_uuidtoperation_snapshotRoRtoperation_start_stateRtoperation_end_statetoperation_errors(R'RRR`tstateR%RR((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyt__serialize_operation_dataYsZ                   c Cszti}|i|id|i||i|tii|ipyti |it i Wqt j o?}|i t it it ifjoti|ndStj o qtj o}ti|qXn|i}xttddD]c}y`titi|titiBtiBt id}|i|dti|i dSWqt j o}|i t i!jojtii"tii#|\}}|i$ddd}tii%|id ||d|f}qn0|i t it ifjoti|ndStj o qtj o}ti|qXqWdS( sSerializes the current history information and writes it to a file in self.path/{operation_start_time}-{sequence}.xml. RiNiidtwtencodingt-is %s-%02d%s(&RtDocumentRRt_History__serialize_client_datat"_History__serialize_operation_dataRjRktexiststmkdirRSt PKG_DIR_MODEtEnvironmentErrorterrnotEROFStEACCEStENOENTRsRRRrRLtrangetfdopentopentO_CREATtO_EXCLtO_WRONLYt PKG_FILE_MODEtwritexmlRQtgetdefaultencodingtclosetEEXISTtsplitexttbasenameRRh(R'RR+RLtitfRtext((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyt__savesV         cCsd|_||_||_yti|iWntj o n{tj oB}|iti ti fjot |_ dSt i|n.tj o}t i|n Xt |_ dS(sRemoves all history information by deleting the directory indicated by the value self.path and then creates a new history entry to record that this purge occurred. s purge-historyN(RKRRtshutiltrmtreeRkRRRRtESRCHtRESULT_SUCCEEDEDRNRstHistoryPurgeExceptionRr(R'tbe_nameRR+((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pytpurges    cCs:yx|io ||_qWWntj odSXdS(ssIntended to be used by the client during top-level error handling to indicate that an unrecoverable error occurred during the current operation(s). This allows History to end all of the current operations properly and handle any possible errors that might be encountered in History itself. N(RKRNR(R'R ((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pytaborts  cCs||_||_||_dS(sPMarks the start of an operation to be recorded in image history.N(RKRR(R'RRR((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pytlog_operation_start s  cCs|o#|i|d|_d|_n|o| ozyt|i}WnQttfj o?x:tiD]'\}}t ||o |}PqnqnWnX|p t }qn|p t }n|o ||_ n||_ dS(sMarks the end of an operation to be recorded in image history. 'result' should be a pkg.client.history constant value representing the outcome of an operation. If not provided, and 'error' is provided, the final result of the operation will be based on the class of 'error' and 'error' will be recorded for the current operation. If 'result' and 'error' is not provided, success is assumed.N(tlog_operation_errorRRRt error_resultst __class__RORWt iteritemst isinstancetRESULT_FAILED_UNKNOWNRRoRN(R'RR R!Rtval((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pytlog_operation_ends(       c Cs7|io)d}d}t}t|to<ti\}}}||joti}t }qhnt|t o |}n|odi ti }|o5t |}| p |djo|ii}qndi g} ||gD]} | o | | qq~ }n|ii|indS(snAdds an error to the list of errors to be recorded in image history for the current operation.R3RN(RKRtTrueRRrRQtexc_infot tracebackt format_exctFalset basestringRht format_stackR-RR7RRPtstrip( R'Rt out_stacktout_errtuse_current_stackttypeRttbtoutputR*titem((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyR6s*     "c Csh}|_x!dD]}t||||R?t __operationsN(sroot_dirs client_namesclient_version(t_History__snapshotR$R?R&R@RA(R'tattrsR)R*RBRCRD((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pytcreate_snapshotes  1cCs d|_dS(sVDiscards the current history and operation state information snapshot.N(RR(R'((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pytdiscard_snapshotuscCsj|ipdSxD|iiD]3\}}|idpti|||qqW|id|_dS(sRestores the last snapshot taken of history and operation state information completely discarding the existing history and operation state information. If nothing exists to restore, this this function will silently return.Nt__R(RRRHR.R/R@(R'RR((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pytrestore_snapshotzs  N(4R7R8R9RR<R=R>R?R@RRKRRtoperation_current_beRRtoperation_current_new_beRRRlRRRRRRNRoR,RGR/R2R1R:RkRLRmRvRt staticmethodRRfRRR_RRRRRRRR(((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pyR;s^ I  > $  @ F & /  (=R&RRjRRQRtxml.dom.minidomtdomtminidomRR[tpkg.client.api_errorsRdt api_errorsRstpkg.client.bootenvRtpkg.fmritfmritpkg.miscRSt pkg.portableRUtRESULT_CANCELEDR^RtRESULT_FAILED_BAD_REQUESTtRESULT_FAILED_CONFIGURATIONtRESULT_FAILED_CONSTRAINEDtRESULT_FAILED_LOCKEDtRESULT_FAILED_SEARCHtRESULT_FAILED_STORAGEtRESULT_FAILED_TRANSPORTtRESULT_FAILED_ACTUATORtRESULT_FAILED_OUTOFMEMORYtRESULT_CONFLICTING_ACTIONSRR]tImageLockedErrortInvalidCatalogFiletBENamingNotSupportedtInvalidBENameExceptiontCertificateErrortPublisherErrortCanceledExceptiontImageUpdateOnLiveImageExceptiont$ProblematicPermissionsIndexExceptiontPermissionsExceptiontSearchExceptiontPlanCreationExceptiontNonLeafPackageExceptiontIpkgOutOfDateExceptiontInvalidDepotResponseExceptiontConflictingActionErrorst IllegalFmriRt MemoryErrorRR.RR;(((s8/usr/lib/python2.6/vendor-packages/pkg/client/history.pytsb