ó i'dWc@s¹dZddlZddlZddlZddlmZmZmZddlm Z ddl m Z ddl m Z ddlmZddlmZdd lmZdd lmZmZmZmZd Zd Zd ZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+de,fd„ƒYZ-d „Z.dd!„Z0d"„Z1d#„Z2d$„Z3d%„Z4d&e fd'„ƒYZ5d(e fd)„ƒYZ6dS(*s? media transfer checkpoint. Sub-class of the checkpoint class. iÿÿÿÿN(tPopentruntdownload_files(tDataObjectCache(t InstallEngine(tAbstractCheckpoint(tINSTALL_LOGGER_NAME(tManifestParser(tSize(tSoftwaretSourcet DestinationtDirs.transfer-manifest.xmls transfer-roots transfer-miscstransfer-medias{INSTALL_TARGET}s{MEDIA}s/as(svc:/system/filesystem/root-assembly:nets*svc:/system/filesystem/root-assembly:medias /bin/svcstdisabledtonlines/usr/sbin/prtconfs/sbin/dhcpinfos/usr/sbin/mounts/usr/sbin/umounts .image_infot IMAGE_SIZEt GRUB_TITLEtInvalidInstallEnvErrorcBseZdZRS(s&Invalid install environment error (t__name__t __module__t__doc__(((smedia_transfer.pyRIscCstdddtg}tj|dtjdtjd|ƒ}|jjƒ}|jdt|fƒtdddtg}tj|dtjdtjd|ƒ}|jjƒ}|jdt|fƒ|t krà|t kràt S|t krü|t krüt St dt|t|fƒ‚d S( sˆDetermine whether the application is running from a media booted environment or a net booted environment. The following SMF services are examined: svc:/system/filesystem/root-assembly:net svc:/system/filesystem/root-assembly:media If root-assembly:net is online and root-assembly:media is disabled. The image is running from a net booted environment. This function will return True. If root-assembly:net is disabled and root-assembly:media is online. The image is running from a media booted environment. This function will return False. If both root-assembly:net and root-assembly:media are online or disabled, that's considered an error condition. Exception: InvalidInstallEnvError: if both filesystem/root:media and filesystem/root:net SMF services are online or disabled. s-Hs-otSTATEtstdouttstderrtloggers%s: %ss%s is %s, %s is %sN(tSVCS_CMDtNET_SVCRt check_calltSTORERtstriptdebugt MEDIA_SVCtSVC_STATUS_ENABLEDtSVC_STATUS_DISABLEDtTruetFalseR(Rtcmdtproct net_statust media_status((smedia_transfer.pyt is_net_bootedOs&       cCsü|dkrNt|ƒr3tjjtjtƒ}qNtjjtjtƒ}nd}t |dƒI}x?|D]7}|j dƒ\}}|t krm|j ƒ}PqmqmWWdQX|dk rçt |ƒdkrç|jd||fƒ|S|jd|ƒdS(sµSpecific boot title of the software in the image is stored in the .image_info indicated by the keywoard GRUB_TITLE. This function retrieves that string value from the .image_info file Inputs: logger: Instance of Logger to use for logging. image_info_file: An alternative .image_info file path to use. Useful for unit testing. The default value of None uses a .image_info file value to be determined based on the boot method used to boot the media (network or local media boot). Returns: GRUB_TITLE string value retrieved from .image_info file or None trt=Nis%Read GRUB_TITLE from %s of value '%s'sGRUB_TITLE not specifed in %s(tNoneR(tostpathtjointNetPrepareMediaTransfert MEDIA_SOURCEtIMAGE_INFO_FILENAMEtPrepareMediaTransfertopentsplittIMAGE_GRUB_TITLE_KEYWORDRtlenR(Rtimage_info_filet grub_titletfobjtlinetopttval((smedia_transfer.pytget_image_grub_title€s*          cCst|ƒr'tjjtjtƒ}ntjjtjtƒ}d}t|dƒR}xH|D]@}|j dƒ\}}|t kr^t |j dƒƒ}Pq^q^WWdQX|dkrÍ|j d|ƒt‚n|jd||fƒtt|ƒtjƒjtjƒS(s¨Total size of the software in the image is stored in the .image_info indicated by the keywoard IMAGE_SIZE. This function retrieves that value from the .image_file The size recorded in the .image_file is in KB, other functions in this file uses the value in MB, so, this function will return the size in MB Returns: size of retrieved from the .image_info file in MB iR)R*s Ns%Unable to read the image size from %ssRead from %s size of %s(R(R,R-R.R/R0R1R2R3R4tIMAGE_SIZE_KEYWORDtinttrstripterrort RuntimeErrorRRtstrtkb_unitstgettmb_units(RR7timg_sizeR9R:R;R<((smedia_transfer.pytget_image_size¬s"       cCsMtjtƒ}t|ƒr2|jdƒt|ƒS|jdƒt|ƒSdS(sThis function instantiates either the PrepareMediaTransfer or the NetePrepareMediaTransfer checkpoint depending on how the image is booted. If the image is booted from the media, the PrepareMediaTransfer checkpoint is instantiated. If the image is booted from the net, the NetPrepareMediaTransfer checkpoint is instantiated. Arguments: None Returns: An instantiated instance of PrepareMediaTransfer checkpoint or NetPrepareMediaTransfer checkpoint s%Going to init NetPrepareMediaTransfers"Going to init PrepareMediaTransferN(tloggingt getLoggerRR(RR/R2(tnameR((smedia_transfer.pytinit_prepare_media_transferÔs     c Csitƒ}td|dtƒ}|jd|ƒ|jdtƒ}t|ƒdkrktdt|ƒƒ‚nxØ|D]Ð}|jdt dt ƒd}|jdt dt ƒd}|j }|j ttƒ}||_ |jtkrr|jdtdt ƒd} | jdt dt ƒd}|j }|j t|ƒ}||_ qrqrWtjƒj} | jj|ƒd S( s´Loads the content of media manifest into a SEPARATE DOC instance. Then, copy the data into the DOC that's used by the application, engine and other checkpoints. smanifest-parsertvalidate_from_docinfotdoct class_typeis)3 software nodes expected. Only %d foundtnot_found_is_erriN(RRR#tparsetget_descendantsR R6RBt get_childrenR R"R tdir_pathtreplacetINSTALL_TARGET_VARtINSTALL_TARGETt_nametTRANSFER_MEDIAR t MEDIA_DIR_VARRt get_instancetdata_object_cachetvolatiletinsert_children( t manifest_namet media_sourcet another_doctmanifest_parsertsoftware_nodestsoftwaretdst_nodetdir_nodeR-tsrc_nodeRN((smedia_transfer.pytsetup_doc_contentðs4           cCsNttgd|ƒ}d|jkrJ|jdƒttdgd|ƒndS(sIf the processor optimized libc is mounted on top of the base libc on /lib/libc.so.1, unmount the optimized libc overlay so the one without processor optimization can be copied into the install target by subsequent cpio transfer checkpoints. Rs/lib/libc.so.1 ons(Optimized libc is mounted, unmounting...s/lib/libc.so.1N(RtMOUNTRRtUMOUNT(RR%((smedia_transfer.pytunmount_libc_overlays R2cBs2eZdZdZd„Zd„Zed„ZRS(s:This checkpoint is used by installation environments booted from the media. It prepares the DOC for CPIO based transfer. This checkpoint will load the /.cdrom/.transfer-manifest.xml content into the transient subtree of the DOC and fill in values of various mountpoints in the DOC s/.cdromcCs*tt|ƒj|ƒ|jjdƒdS(NsPrepareMediaTransfer init(tsuperR2t__init__RR(tselfRK((smedia_transfer.pyRm:scCsdS(Ni((Rn((smedia_transfer.pytget_progress_estimate>scCs9tjjtjtƒ}t|tjƒt|jƒdS(N( R,R-R.R2R0tTRANSFER_MANIFEST_NAMERhRkR(Rntdry_runR_((smedia_transfer.pytexecuteAs (RRRR0RmRoR#Rr(((smedia_transfer.pyR20s   R/cBsAeZdZdZdZd„Zd„Zd„Zed„Z RS(s™ The NetPrepareMediaTransfer checkpoint is instantiated by the init_prepare_media_transfer() function for installation environments booted from the net. This checkpoint will first download the transfer-manifest.xml from the server, then, load it into the DOC. Based on content of the DOC, the checkpoint will also download any other files that needs to be copied into the install target, but not yet present in the booted environment. Similar to PrepareMediaTransfer, this checkpoint will also download and mount the root archives we are not booted with and fill in values of mountpoints. s/etc/netboot/wanboot.confs/tmpcCs*tt|ƒj|ƒ|jjdƒdS(NsNetPrepareMediaTransfer init(RlR/RmRR(RnRK((smedia_transfer.pyRm_scCsdS(Ni((Rn((smedia_transfer.pyRocsc Cs@tjƒdkruttjƒO}d}d}xï|D]ç}|jdƒrÇ|jdƒ\}}|jddƒ}|j|dƒ|j j ddj |ƒƒdj |ƒ}|j j d|ƒq7|jdƒr7|jdƒ\}}|j dd ƒ}|d }|j j d |ƒq7q7W|dkrCt d tjƒ‚n|dkrdt d tjƒ‚n||SWdQXnÇtddg}tj|dtjdtjd|j ƒ} t} d}x_| jjƒD]N}|jƒ}|j j d|ƒ| r|}Pn|jdƒrÊt} qÊqÊW|dkr7t dƒ‚n|j j d|ƒ|jdƒ\}} | jdƒ} t| ƒd kr”t d|ƒ‚n| jdƒd kr$tdg}tj|dtjdtjd|j ƒ} | jjƒ} t| ƒd krt dƒ‚n| jd| ƒ} n|j j d| ƒ| SdS(s%Get server URL for downloading files tsparcs root_server=R*t/isURL: s ai_server: s root_file=iis ai_image: s&Unable to find AI server value from %ss%Unable to find AI image value from %sNs-vs/devicesRRRsline: sname='install_media's!Unable to find install_media lines found line: t's#Unable to find url, found string = s $serverIPtBootSrvAs Unable to find server IP addresssGoing to return URL: (tplatformt processorR3R/t WANBOOT_CONFR+t startswithR4tremoveRRR.trsplitRBtPRTCONFRRRR#Rt splitlinesRR"R6tfindtDHCPINFORU( Rnt wanboot_conft ai_servertai_imageR:t_noneR<t split_valR$R%t use_next_lineturltip_out((smedia_transfer.pytget_server_urlfsl        cCsz|jƒ}|jjd|ƒtjjtjtƒ}t |dt||jdt ƒt |tjƒt |jƒdS(Ns server URL: Rttallow_insecure( R‰RRR,R-R.R/R0RpRR"RhRk(RnRqt server_urlR_((smedia_transfer.pyRrºs  ( RRRRyR0RmRoR‰R#Rr(((smedia_transfer.pyR/Ks    T(7RRIR,Rwtsolaris_installRRRt!solaris_install.data_object.cacheRtsolaris_install.engineRt!solaris_install.engine.checkpointRtsolaris_install.loggerRtsolaris_install.manifest.parserRtsolaris_install.target.sizeRtsolaris_install.transfer.infoR R R R Rpt TRANSFER_ROOTt TRANSFER_MISCRYRVRZRWRRRR!R R}R€RiRjR1R>R5t ExceptionRR(R+R=RHRLRhRkR2R/(((smedia_transfer.pytsN   " 1 , (  /