ó i'dWc@sdddlZddljZddlmZmZmZddlm Z dej fd„ƒYZ dS(i’’’’N(tDisktSlicet Partition(tZvolt SetupSwapcBs,eZdZd„Zd„Zed„ZRS(sgICT checkpoint that sets up the swap in /etc/vfstab on the target during an AI installation cCstt|ƒj|ƒdS(sµInitializes the class Parameters: -name - this arg is required by the AbstractCheckpoint and is not used by the checkpoint. N(tsuperRt__init__(tselftname((s setup_swap.pyR'sc Csń|jjdƒd}tƒ}|jjdtƒ}g|D]}|jr;|^q;}xć|D]Ū}|jd k rµ|jjd k rµt |jt ƒrµd|jjj |j f}nY|jd k rņt |jt ƒrņd|jj |j f}n|jjdt|ƒƒq]d|}|jjd|ƒ|j|ƒq]W|jjdtƒ}g|D]} | jdkrX| ^qX} xq| D]i} | jd k rŠtjjd | jƒ} |jjd |ƒ|j| ƒq€|jjd t| ƒƒq€W|S( s,Get a list of swap devices from DESIRED treesSearching for swap devicestt class_types%ss%ss$Unable to determine path to slice %ss /dev/dsk/%ssFound swap slice %stswaps /dev/zvol/dsksFound swap zvol %ss#Unable to determine path to zvol %sN(tloggertdebugtlistttargettget_descendantsRtis_swaptparenttNonet isinstanceRtctdRRtstrtappendRtusetostpathtjoint full_realname( Rt swap_patht swap_devicestslicestst swap_slicest swap_slicet slice_ctdtzvolstzvolt swap_zvolst swap_zvolt zvol_path((s setup_swap.pyt_get_swap_devices/s@ "     (    cCsń|jjdƒ|jƒtjj|jtjƒ}|j ƒ}|sķySt |dƒ>}x4|D],}|j d|ddddddfƒqcWWdQXWqķt k ré}|jjd|ƒ|jjt |ƒƒtd |ƒ‚qķXndS( sł The AbstractCheckpoint class requires this method in sub-classes. Looks for swap devices in the DESIRED target tree, and adds each of these to the /etc/vfstab. Parameters: - the dry_run keyword paramater. The default value is False. If set to True, the log message describes the checkpoint tasks. Returns: - Nothing On failure, errors raised are managed by the engine. s)ICT current task: Setting up swap devicessa+s%s %s %s %s %s %s %s t-R tnoNs#Failed to open file %s for writing.s'Unable to setup swap devices in file %s(R R t parse_docRRRt target_dirtICTtVFSTABR)topentwritetIOErrorRt RuntimeError(Rtdry_runtvfstabRtvftdevicetioe((s setup_swap.pytexecute_s     +  (t__name__t __module__t__doc__RR)tFalseR9(((s setup_swap.pyR"s  0( Rtsolaris_install.icttictR.tsolaris_install.target.physicalRRRtsolaris_install.target.logicalRt ICTBaseClassR(((s setup_swap.pyts