ó ð v_c@sŠddlZddlZddlZddlmZddlZddlmZyrddlZejƒZ e j ƒdZ e j dƒdZ e e e e j dƒƒƒZ e dkrÁdZnWndZdZ nXedk r dd lmZd efd „ƒYZndZd „Zd „Zd„Zd„Zd„Zdd„Zd„Zd„Zd„Zd„Zdefd„ƒYZdS(iÿÿÿÿN(tdatetime(t_it(t.iic(t LibLVMErrort _ResultErrorcBseZdZRS(s>Exception raised for LVM calls resulting in bad return values.(t__name__t __module__t__doc__(((s3/usr/lib/python2.7/site-packages/yum/fssnapshots.pyRscCs,|jƒ}|dsdS|dddkS(NitotO(R R (tgetAttrtNone(tlvtsnap((s3/usr/lib/python2.7/site-packages/yum/fssnapshots.pyt _is_origin%s  cCs,|jƒ}|dsdS|dddkS(NitstS(RR(R R (R R((s3/usr/lib/python2.7/site-packages/yum/fssnapshots.pyt_is_snap,s  cCs,|jƒ}|dsdS|dddkS(Nitv(R R (R R((s3/usr/lib/python2.7/site-packages/yum/fssnapshots.pyt_is_virt3s  cCs y|j|ƒSWndSXdS(N(t lvFromNameR (tvgtlvname((s3/usr/lib/python2.7/site-packages/yum/fssnapshots.pyt _vg_name2lv:scCs ytjƒ}Wntk r)g}nX|stjddddgdtjdtjƒ}|jƒ}|r„ttdƒƒ‚n|j ƒd}|j d ƒ}|s­gS|dj ƒ}|d krÍgSg}x2|d D]#}|sîPn|j |j ƒƒqÞWn|S( Ns /sbin/lvmtvgss-otvg_nametstdouttstderrs#Failed to obtain volume group namesis tVGi( tlvmt listVgNamesRt subprocesstPopentPIPEtwaitRRt communicatetsplittstriptappend(tnamestpterrtoutputtheadertname((s3/usr/lib/python2.7/site-packages/yum/fssnapshots.pyt_list_vg_names@s.    cCs‹t|ƒdkr‡t|dd!ƒd}|t|dd!ƒ7}|d9}|ddkrg||8}n|ddkr‡||7}q‡n|S(Niiii<it+t-(tlentint(tztctimetoff((s3/usr/lib/python2.7/site-packages/yum/fssnapshots.pyt_z_off]s  cCs£y|jƒ\}}}tj|d|dƒ}tj|ƒ}trŽtjdƒ}||krŽt|ƒ}t|ƒ}|||7}qŽnWn d}nX|S(Nt s%Y-%m-%d %H:%M:%Ss%zi(R%ttimetstrptimetmktimetFalsetstrftimeR6(R4tdttR3tcur_z((s3/usr/lib/python2.7/site-packages/yum/fssnapshots.pyt _lv_ctime2utchs    c Csá|jƒ}|jƒ}|jƒ}|jdƒd}|jƒ}t|jdƒdƒ}|jdƒd}t|ƒ}|d}id||fd6|d 6|d6d||fd 6|jƒd 6|d 6|d 6|d6} | S(Ntoriginitlv_timet snap_percentiiès%s/%stdevR4t origin_devtfreettagstsizetusedièi@B(tgetNametgetSizet getPropertytgetTagsR@tfloatt getFreeSize( RR tvgnameRRHRARGR4RItdata((s3/usr/lib/python2.7/site-packages/yum/fssnapshots.pyt_lv_data{s$        cs‡fd†}|S(s7Decorator for _FSSnap methods that logs LVM tracebacks.csSyˆ|||ŽSWn8tk rN}|jdk rH|jj|ƒn‚nXdS(N(Rt_loggerR t exception(tselftargstkwargste(tfunc(s3/usr/lib/python2.7/site-packages/yum/fssnapshots.pytwrap–s ((RYRZ((RYs3/usr/lib/python2.7/site-packages/yum/fssnapshots.pyt_log_traceback”scCs@t|ƒtkr2t|jƒdkr2|jdSt|ƒSdS(s;Convert a LibLVMError instance to a readable error message.iiN(ttypeRR1RVtstr(texc((s3/usr/lib/python2.7/site-packages/yum/fssnapshots.pyt lvmerr2strŸs' t_FSSnapcBs†eZded d d„Zed„ƒZd d„Zedd„ƒZ eddd id „ƒZ ed „ƒZ egd „ƒZ RS(t/s!*/swaps !*/lv_swapcCst stjƒrg}nt|_tto=tjjdƒƒ|_d|_ d|_ ||_ ||_ d|_||_|j s‰dSdS(Ns /sbin/lvmt_yum_(Rtostgeteuidt_vertversiontbooltpathtexistst availabletpostfix_staticR t_postfixt_roott_devst _vgname_listRS(RUtroott lookup_mountstdevicestlogger((s3/usr/lib/python2.7/site-packages/yum/fssnapshots.pyt__init__­s  !       cCs4|jdkr-|jr!tƒng|_n|jS(N(RoR RjR.(RU((s3/usr/lib/python2.7/site-packages/yum/fssnapshots.pyt_vgnamesÀsc Cs|dk r+t|ƒs$t|ƒr+tSnt}xÛ|jD]Ð}d|krSq;nt}|ddkr‚t}t}|d}n|jddƒ\}}d|kr¬q;ntj||ƒsÄq;n|dkrÕ| S|dkrådS|jƒ}tj||ƒs q;n| SW|S(NRait!it*( R RRR;RntTrueR%tfnmatchRJ( RURPR t found_negRDtnegtvgntlvnR((s3/usr/lib/python2.7/site-packages/yum/fssnapshots.pyt_use_devÆs4       idc Csüt}xï|jD]ä}|j|ƒ}|dk r>| r>qntj|dƒ}|sottdƒ|ƒ‚n|jƒ}d}x<|j ƒD].}|j||ƒs¬qŽn||j ƒ7}qŽW|j ƒ|sÖqnt }||d|krtSqW|S(s0 See if we have enough space to try a snapshot. trs(Unknown error when opening volume group iidN( R;RuR~R RtvgOpenRRROtlistLVsRKtcloseRx( RUt percentagetretRPtuseRtvgfsizetlvssizeR ((s3/usr/lib/python2.7/site-packages/yum/fssnapshots.pyt has_spaceís,  tcCs|d kr1d|jtjƒjdƒf}ng}xÑ|jD]Æ}|j|ƒ}|d k ro| roqAntj|dƒ}|s t t dƒ|ƒ‚nxZ|j ƒD]L} | j ƒ} |j|| ƒs×q­nd|| |f} | j | | jƒ|dƒ} | s3|jƒt t dƒ| ƒ‚nd|| f} d|| f}tƒ}x‡|| d fD]v}xm|j|gƒD]Y}d |krÑ|jd d ƒ\}}||krÁq…n|j|ƒn| j|ƒq…WqlW|j| |fƒq­W|jƒqAW|S( sc Attempt to take a snapshot, note that errors can happen after this function succeeds. s%s%ss%Y%m%d%H%M%S.%ftws(Unknown error when opening volume group s%s%s%sids%Unknown error when creating snapshot s%s/%sRwt=iN(R RkRtnowR<RuR~RR€RRRRJtsnapshotRKR‚tsettgetR%taddtaddTagR'(RURƒtprefixtpostfixRGR„RPR…RR Rtnlvnametnlvtodevtndevteq_tagstvalttagt eq_tag_keyt eq_tag_val((s3/usr/lib/python2.7/site-packages/yum/fssnapshots.pyRsF %      cCs˜g}x‹|jD]€}tj|dƒ}|sGttdƒ|ƒ‚nx<|jƒD].}t|ƒslqTn|jt||ƒƒqTW|j ƒqW|S(s List data for old snapshots. RŠs(Unknown error when opening volume group ( RuRR€RRRRR'RRR‚(RUR„RPRR ((s3/usr/lib/python2.7/site-packages/yum/fssnapshots.pyt old_snapshotsFs c Cs!ts gSg}i}xV|D]N}|jdƒ\}}||krZt|gƒ||s>