Ñò i'dWc@sdZddkZddkZddkZddklZddklZddkl Z ddk l Z ddk l Z ddklZdd klZdd klZlZlZlZlZlZlZlZdd klZlZlZl Z d efd „ƒYZ!dS(su instantiation.py - target instantiation checkpoint. Parses the Data Object Cache for physical and logical targets. iÿÿÿÿN(tcopy(tV_ROOT(t DKIOCSETWCE(tApplicationData(t InstallEngine(tAbstractCheckpoint(tTarget(tBEtDatasetOptionst FilesystemtOptionst PoolOptionstVdevtZvoltZpool(tDiskt GPTPartitiont PartitiontSlicetTargetInstantiationcBsƒeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z dd d „Z d „Z d „Zed „ZRS(s" class to instantiate targets cCs\tt|ƒi|ƒtƒ|_tƒ|_tƒ|_tƒ|_t|_ d|_ dS(Ns/system/volatile( tsuperRt__init__tlistt logical_listt physical_listt swap_listt dump_listtFalset live_installtwork_dir(tselftname((s../instantiation.pyR4s     cCsdS(sZ Returns an estimate of the time this checkpoint will take in seconds i((R((s../instantiation.pytget_progress_estimate?scCs=tiƒi|_|iidtidtdtƒd|_|iidt ƒ|_ |iidt ƒ|_ t ƒ|_t ƒ|_|iidtƒ}|o]xZ|D]N}|idjo|ii|ƒn|idjo|ii|ƒq¨q¨Wn|iiidtƒ}|o|i|_|i|_ndS(s^ method for parsing data object cache (DOC) objects for use by the checkpoint Rt class_typetnot_found_is_erritswaptdumpN(Rt get_instancetdata_object_cachetdoctget_descendantsRtDESIREDtTruettargetRRRRRRRR tusetappendt persistenttget_first_childRRR(Rt zvol_listtzvoltapp_data((s../instantiation.pyt parse_docEs*    csHxA|iD]6}|ioq n|io¼ti|ititiBƒ}zˆyF|ii d|i ƒt i dƒ}t i|tt i|ƒƒWn;tj o/}|ii dƒ|ii t|ƒƒnXWdti|ƒXn|idtƒ}|idtƒ}|idtƒ}t}t} |o³t|ƒ} x¤| D]˜} | idjotddt| ƒƒ‚n| idjo t} qC| id jo |i|i | ƒƒt} qC| id jo t}qCqCWnt} |o¯t|ƒ} x | D]”}|idjotd t|ƒƒ‚n|idjo t} q|id jo |i|i |ƒƒt} q|idjo t}qqWnt}t!ƒ}|oèt|ƒ}x|D]…}|idjo t}nK|id jo |i|i |ƒƒt}n|idjo t}n|i"o|i#|ƒqÈqÈWt$d„|i%Dƒdƒ‰x-t&‡fd†|ƒD]}t'|_(q†Wn| o|i)||i*ƒn|i+djo|o|i,|i*ƒn| o|i-||i*ƒn|o|i.||i*ƒn|o|i/||i*ƒq q WdS(sg method used to parse the list of disks and create the desired physical configuration. senabling write-cache on %sisunable to enable write-cache:NR!sInvalid name for GPT s Partition: tcreatetdeletetpreservesInvalid name for Partition: tuse_existing_solaris2t use_existingcss*x#|]}|io |iVqqWdS(N(tis_rootR(t.0trp((s../instantiation.pys Ðs trpoolcs |iˆjS((tin_zpool(tslc(trpn(s../instantiation.pytÒstVTOC(R6R7(R6R8(0Rt whole_diskt write_cachetostopentopathtO_RDWRtO_NDELAYtloggertdebugtctdtCtc_inttfcntltioctlRt addressoft ExceptiontstrtcloseR(RRRR*RRRtNonet RuntimeErrortactiontpoptindexRtis_swapR-tnextRtfilterRttagt_update_partition_tabletdry_runtlabelt _label_diskt_update_gptpartition_tablet_update_slicest_create_ufs_swap(Rtdisktfdtnumberterrtgptpartition_listtpartition_listt slice_listt label_disktupdate_gptpartition_tabletdup_gptpartition_listt gptpartitiontupdate_partition_tabletdup_partition_listt partitiont update_vtoctswap_slice_listtdup_slice_listR>((R?s../instantiation.pytsetup_physicales¤                     cCsh|ioZxW|iD]H}|idjo2|i|iƒ|ip|i|iƒq\qqWndS(se method used to parse the dump (zvol) targets and create the objects marked 'create' R4N(RRVR4R^Rt add_to_system(RR$((s../instantiation.pyt create_dumpçs   cCsX|ioJxG|iD]8}|idjo"|io|i|iƒqLqqWndS(sf method used to parse the dump (zvol) targets and destroy the objects marked 'delete' R5R4N(sdeletescreate(RRVtexiststdestroyR^(RR$((s../instantiation.pyt destroy_dumpòs    cCsh|ioZxW|iD]H}|idjo2|i|iƒ|ip|i|iƒq\qqWndS(se method used to parse the swap (zvol) targets and create the objects marked 'create' R4N(RRVR4R^RRv(RR#((s../instantiation.pyt create_swapüs   cCsX|ioJxG|iD]8}|idjo"|io|i|iƒqLqqWndS(s¶ method used to parse the swap (zvol) targets and destroy the objects marked 'delete' or 'create' (since 'create' has an implicit destroy associated with it) R5R4N(sdeletescreate(RRVRxRyR^(RR#((s../instantiation.pyt destroy_swaps    R=c CsÄtƒ}xttttgD]{}|iid|ƒ}x]g}|D]!}|i|jo ||qEqE~D]&} |djp|djo| i|joöt | tƒo|i | i ƒq“t | tƒo"|i | i i d| i ƒq“t | tƒo"|i | i i d| i ƒq“t | tƒoZt | i tƒo%|i | i i i d| i ƒq|i | i i d| i ƒq“qmqmWqW|djo| otdƒ‚n|S(sp method to extract all of the physical device names for a given zpool or vdev name from the DOC R!R=tin_vdevss%ssp%ss-in_vdev attribute requires in_zpool attribute(RRRRRR+R(R=R}t isinstanceR-RKtparentRRU( Rt zpool_namet vdev_nametin_typet vdev_listR!tdev_listt_[1]tdtdev((s../instantiation.pytget_vdev_namess, 6 "".cCsàxÙ|iD]Î}|idjo|i|iƒq |idtƒ}|o9x6|D]*}|idjo|i|iƒqTqTWn|idtƒ}|o9x6|D]*}|idjo|i|iƒq¦q¦Wq q WdS(sº method used to parse the logical targets and destroy the objects with action of 'delete' or 'create' (since 'create' has an implicit destroy associated with it) R5R4R!N(sdeletescreate(sdeletescreate(sdeletescreate(RRVRyR^t get_childrenR R (Rtzpooltfs_listtfsR0R1((s../instantiation.pytdestroy_logicals5s  cCsåxÞ|iD]Ó}|io|iid|iƒq n|idtƒ}|idtƒ}tƒ}|o>tƒ}x!|D]}|i |i ƒƒq|W|i |ƒn|o>tƒ}x!|D]}|i |i ƒƒqÁW|i |ƒn|idt ƒ}tƒ} |o‘x |D]‚} | i i ƒdjoA| i i ƒdjo| i ddgƒqu| i| i ƒn| i |i|i| iddƒƒqWn|i|iƒ} | |_d} |iotii|i|iƒ} n|id jo|i|i|d | ƒn<|id jo+|ip|i|i|d | ƒqTn|idtƒ} x™g} | D]'}|iiƒd jo | |qtqt~ D]\}|id jo|i|iƒq¢|id jo"|ip|i|iƒqþq¢q¢W|idtƒ}|idtƒ}tƒ}tƒ}tƒ}tƒ}xN|D]F}|id jp|id jo |i o|o£|i dt!ƒ}|i"o;|o|i"|i#d s   :"