Ñò ÒR4Sc@sddkZddkZddkZddklZeiZddkiiZddk i Z ddk i Z ddk iZyddkZWn9ej o-yddkZWnej onXnXdefd„ƒYZdefd„ƒYZdeƒjo eZndS(iÿÿÿÿN(tglobal_settingstBootEnvcBsLeZdZdd„Zdd„Zd„Zed„Zd„Z e d„ƒZ e d„ƒZ e d„ƒZ e d „ƒZe d „ƒZe d „ƒZe d „ƒZe ed „ƒZe d„ƒZe d„ƒZe d„ƒZe d„ƒZdd„Zdd„Zd„Zed„Zd„Zd„Zd„Zd„ZRS(s¡A BootEnv object is an object containing the logic for managing the recovery of image-modifying operations such as install, uninstall, and update. Recovery is only enabled for ZFS filesystems. Any operation attempted on UFS will not be handled by BootEnv. This class makes use of usr/lib/python*/vendor-packages/libbe.py as the python wrapper for interfacing with libbe. Both libraries are delivered by the install/beadm package. This package is not required for pkg(1) to operate successfully. It is soft required, meaning if it exists the bootenv class will attempt to provide recovery support.c CsÜd|_d|_d|_d|_d|_||_t|_t|_ d|_ ||_ |ii ƒ|_ d}|i djpt‚|idtƒ|_x7t|iƒD]\}}|idƒ}| p|idƒ oq®n|i djo$|idƒpq®q=t|_n!|idƒ|i joq®n||_|idƒ|_ti|iƒ\}}tiƒ|_|djo||_ ||i_ntitd ƒƒtd ‚t|_ Pq®Wtd ‚dS( Nit raise_errort orig_be_nametmountedt/tactivet mountpointtdatasetsApkg: unable to create an auto snapshot. pkg recovery is disabled.trecoveryDisabled(tNonetbe_nameRt be_name_clonetbe_name_clone_uuidt clone_dirtimgtFalset is_live_BEtis_validt snapshot_nametprogress_trackertget_roottroottAssertionErrort get_be_listtTruetbeListt enumeratetgettbetbeCreateSnapshotttempfiletmkdtempthistorytoperation_snapshottloggerterrort_t RuntimeError( tselfRRtrctitbeValsR terrR((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyt__init__BsJ                 c Cs‡|i}|o||7}n|idƒ\}}}|o®|iƒo¡t|ƒ}|}x˜|iD]}}|iddƒ}|pqfn|idƒ\} }} | p| |jp| iƒ oqfntt| ƒ|ƒ}qfWn |}d}t} |} x}| pudi |t | ƒfƒ}xI|iD]8}|iddƒ}|pq2n||joPq2q2Wt } | d7} qW|S(s#Create a new boot environment name.t-RiiN( R t rpartitiontisdigittintRRR tmaxRtjointstrR( R'tsuffixt new_benametbasetseptrevtmaxrevtdtobentnbasetnrevtgoodtnum((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyt__get_new_be_name•sD      cCs|iiiƒdS(s§Internal function used to preserve current image information and history state to be restored later with __reset_image_state if needed.N(RR!tcreate_snapshot(R'((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyt__store_image_stateÆscCs{|ipdS|i|iijoB|o|iiiƒn|iiiƒ|ii|iƒn|iiiƒdS(s§Internal function intended to be used to reset the image state, if needed, after the failure or success of boot environment operations.N(RRR!trestore_snapshottdiscard_snapshott find_root(R'tfailure((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyt__reset_image_stateÐs cCs|iS(s1Return true if this object represents a valid BE.(R(R'((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pytexistsîscCstS(N(R(((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyt libbe_existsôscCs ttdƒS(NtbeVerifyBEName(thasattrR(((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyt check_verifyøscCsF|idƒ}||idƒ|idƒ|idƒ|idƒfS(NRRt active_boott space_usedtdate(R(tbeetname((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pytsplit_be_entryüscCsti||ƒS(N(RtbeRename(t orig_nametnew_name((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyt rename_bescCsti|dtƒS(Ni(Rt beDestroyR(R ((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyt destroy_bescCs ti|ƒS(N(Rt beActivate(R ((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pytset_default_be scCsžyu|djodSti|ƒdjoti|ƒ‚ntiƒ}|d„|Dƒjoti|ƒ‚nWn"tj oti |ƒ‚nXdS(Nicss"x|]}|idƒVqWdS(RN(R(t.0R((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pys s ( R RRJt api_errorstInvalidBENameExceptionRRtDuplicateBENametAttributeErrortBENamingNotSupported(R R((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyt check_be_names  cCsŽdtijo tiƒSd}tiƒ}t|dtƒo|\}}n|}| p |djo|o td‚ng}n|S(NtPKG_NO_LIVE_ROOTitnobootenvironments( tostenviront BootEnvNullRRRt isinstanceR0R&(RR(R*R((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyR s    cCs¬tiƒ}x™|D]‘}|idƒ}|idƒ}| p|idƒ oqn|djo|idƒo ||fSq|idƒ|jo ||fSqWdS( ssLooks for the name of the boot environment corresponding to an image root, returning name and uuid Rtuuid_strRRRRN(NN(RRRR (tpathRRR tbe_uuid((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyt get_be_name:s  cCsCtiƒ}h}x*|D]"}|idƒ||idƒ}|idtƒoqn|idƒo|idƒSqWWn"tj otitƒ‚nXdS(Ntactive_unbootableRMR(RRRRR_R\R`R (RR((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pytget_activated_be_name^s cCshy?tiƒ}x,|D]$}|idƒo|idƒSqWWn"tj otitƒ‚nXdS(NRR(RRRR_R\R`R (RR((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pytget_active_be_namens cCsÃ|i|ƒ|ioˆtiƒ\}}}|djotiƒ‚n|p|iddƒ}nti||ƒ}|djoti||ƒ‚q¿n!|dj oti |ƒ‚ndS(s¯Create a backup BE if the BE being modified is the live one. 'be_name' is an optional string indicating the name to use for the new backup BE.iR4s -backup-1N( RaRRtbeCopyR\tUnableToCopyBEt_BootEnv__get_new_be_nameRStUnableToRenameBER tBENameGivenOnDeadBE(R'R tretR tnot_used((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pytcreate_backup_beys       cCsB||_|io |iƒ|i|ƒtiƒ\}|_}|djotiƒ‚n|oHti |i|ƒ}|djo ||_q®ti |i|ƒ‚nti |i|i ƒdjoti |i|i ƒ‚nti|i ƒ\}|_|i|i dtƒn!|dj oti|ƒ‚ndS(sNInitialize for an update. If a be_name is given, validate it. If we're operating on a live BE then clone the live BE and operate on the clone. If we're operating on a non-live BE we use the already created snapshotit exact_matchN(RRtdestroy_snapshotRaRRqR R\RrRSRttbeMountRtUnableToMountBERRkR RERR Ru(R'RR RvRw((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pytinit_image_recovery“s(        c CsÊddd|iiƒg}y+ti|dttiƒdtiƒ}WnDtj o8}t i t dƒh|d6di |ƒd 6ƒd SX|o2t i t d ƒhdi |ƒd 6|d 6ƒnd S( s­Rebuild the boot archive in the current image. Just report errors; failure of pkg command is not needed, and bootadm problems should be rare.s /sbin/bootadmsupdate-archives-Rtstdouttstderrs6pkg: A system error %(e)s was caught executing %(cmd)stet tcmdNs6pkg: '%(cmd)s' failed. with a return code of %(ret)d.Rv( RRt subprocesstcalltopenRdtdevnulltSTDOUTtOSErrorR#R$R%R2(R'R‚RvR€((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pytupdate_boot_archive½s   cs ‡‡fd†}‡fd†}ˆiƒˆiidˆiƒt}ˆiiot}ˆiiƒnd}y ˆi o |ƒn|ƒWn9t j o-}|}|ot}ˆii ƒqÍnXˆi d|ƒ|oˆii ƒn|o ˆii id|ƒ|‚ndS(sGActivate a clone of the BE being operated on. If were operating on a non-live BE then destroy the snapshot. 'set_active' is an optional boolean indicating that the new BE (if created) should be set as the active one on next boot. cs!ˆo8tiˆiƒdjotitdƒˆiƒdSˆiˆii_ˆi ˆii_ ˆiii dˆii i iƒtiˆiƒdjo0titdƒhˆid6ˆid6ƒdStiˆiƒˆotitdƒˆiƒntitdƒˆiƒdS( Nispkg: unable to activate %st release_notess7unable to unmount BE %(be_name)s mounted at %(be_path)sR tbe_pathsÄ A clone of %(be_name)s exists and has been updated and activated. On the next boot the Boot Environment %(be_name_clone)s will be mounted on '/'. Reboot when ready to switch to this updated BE. sð A clone of %(be_name)s exists and has been updated. To set the new BE as the active one on next boot, execute the following command as a privileged user and reboot when ready to switch to the updated BE: beadm activate %(be_name_clone)s (RRYR R#R$R%RR!toperation_new_beR toperation_new_be_uuidtlog_operation_endt imageplantpdtrelease_notes_namet beUnmountRRdtrmdirtinfot__dict__((t set_activeR'(s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pytactivate_live_beÞs*    csGtitdƒˆiƒtiˆiƒˆiƒdˆi i _ dS(Ns %s has been updated successfully( R#R”R%R RdR“RRzR RR!R"((R'(s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyt activate_bes   t progtrackRFR$N(t_BootEnv__store_image_stateRtcleanup_cached_contentRRtlockedRtunlockR Rt Exceptiontlockt_BootEnv__reset_image_stateR!tlog_operation_error(R'R–R—R˜trelocktcaught_exceptionR€((R–R's8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pytactivate_imageÕs0 (     cCs|io|iiƒn|idtƒ|iotitdƒ|iƒn±y[t i |i |i ƒdjotitdƒ|i ƒn|i ƒti|iƒWn1tj o%}|iiid|ƒ|‚nXtitdƒh|i d6ƒdS( s Restore a failed update attempt.RFs¤The running system has not been modified. Modifications were only made to a clone of the running system. This clone is mounted at %s should you wish to inspect it.is/pkg: unable to rollback BE %s and restore imageR$sI%(bename)s failed to be updated. No changes have been made to %(bename)s.tbenameN(RtflushR RRR#R$R%RRt beRollbackR RRzRdR“RžRR!R¡(R'R€((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyt restore_image7s$     cCsAti|i|iƒdjotitdƒ|iƒndS(s:Destroy a snapshot of the BE being operated on. Note that this will destroy the last created snapshot and does not support destroying multiple snapshots. Create another instance of BootEnv to manage multiple snapshots.is"pkg: unable to destroy snapshot %sN(RtbeDestroySnapshotR RR#R$R%(R'((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyRz]scCsµ|io|iiƒn|io*tid|i|iƒ\}|_}|djon|id|i|_ti|i|i|iƒ\}}}|djot i t dƒ|iƒdSnti |i|i ƒdjo0t i t dƒh|id6|i d6ƒdSt i t dƒh|id6|i d6|id 6ƒncti|i|iƒdjot i d |iƒn|iƒt i t d ƒh|id 6ƒdS( sàRestore a failed install or uninstall attempt. Clone the snapshot, mount the BE and notify user of its existence. Rollback if not operating on a live BEiR%spkg: unable to create BE %sNs1pkg: unable to mount BE %(name)s on %(clone_dir)sRQRsñThe Boot Environment %(name)s failed to be updated. A snapshot was taken before the failed attempt and is mounted here %(clone_dir)s. Use 'beadm unmount %(clone_name)s' and then 'beadm activate %(clone_name)s' if you wish to boot to this BE.t clone_namespkg: unable to rollback BE %ss¦The Boot Environment %(bename)s failed to be updated. A snapshot was taken before the failed attempt and has been restored so no changes have been made to %(bename)s.R¥(RR¦RRRqR R RR R#R$R%R{RR§Rz(R'RvRwt not_used2((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pytrestore_install_uninstallis:  '            cCs|iƒdS(s„Activate an install/uninstall attempt. Which just means destroy the snapshot for the live and non-live case.N(Rz(R'((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pytactivate_install_uninstall¨sN( t__name__t __module__t__doc__R R,RsRšRR RHt staticmethodRIRLRRRVRXRZRaRRkRmRoRpRxR}R‰RR¤R¨RzR¬R­(((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyR3s6  S 1     *  b & ?RfcBsXeZdZd„Zed„ƒZed„ƒZed„ƒZed„ƒZed„ƒZ ed„ƒZ ed„ƒZ ed „ƒZ ed „ƒZ ed „ƒZed „ƒZed „ƒZed„ƒZed„ƒZedd„ƒZedd„ƒZed„ƒZed„ƒZed„ƒZed„ƒZed„ƒZRS(s?BootEnvNull is a class that gets used when libbe doesn't exist.cCsdS(N((R'R((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyR,³scCsdS(N((((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyR‰¶scCstS(N(R(((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyRHºscCstS(N(R(((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyRI¾scCstS(N(R(((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyRLÂscCsdS(N(R (RP((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyRRÆscCsdS(N((RTRU((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyRVÊscCsdS(N((R ((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyRXÎscCsdS(N((R ((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyRZÒscCs|oti|ƒ‚ndS(N(R\R`(R ((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyRaÖscCsgS(N((((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyRÛscCsdS(N(NN(R (Ri((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyRkßscCstiS(N(tmisct EmptyDict(((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyRmãscCsdS(N((((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyRoçscCsdS(N((((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyRpëscCs$|dj oti|ƒ‚ndS(N(R R\Ru(R ((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyRxïs cCs$|dj oti|ƒ‚ndS(N(R R\Ru(RR ((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyR}ôs cCsdS(N((((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyR¤ùscCsdS(N((((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyR¨ýscCsdS(N((((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyRzscCsdS(N((((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyR¬scCsdS(N((((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyR­ sN(R®R¯R°R,R±R‰RHRIRLRRRVRXRZRaRRkRmRoRpR RxR}R¤R¨RzR¬R­(((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyRf¯s2 R(terrnoRdRt pkg.clientRR#tpkg.client.api_errorstclientR\tpkg.miscR²t pkg.portabletportabletpkg.pkgsubprocesst pkgsubprocessRƒtlibbeRt ImportErrortlibbe_pytobjectRRftlocals(((s8/usr/lib/python2.6/vendor-packages/pkg/client/bootenv.pyts*     ÿÿ~^