ó i'dWc@smddlZddlZddlmZddlmZddljZdej fd„ƒYZ d„Z dS(iÿÿÿÿN(tDataObjectDict(t InstallEnginet TransferFilescBs5eZdZd„Zd„Zd„Zed„ZRS(sè The TransferFiles checkpoint transfers files that are related to an installation that the application wants to preserve Files to be transferred are stored in a DataObjectDict in the volatile section of the Data Object Cache. Each element of the dictionary is a source, destination pair. Where source and destination are either two ordinary files or two directories. The checkpoint performs the following actions when the execute method is called: - For ordinary files, copy the specified source file to the specified destination. - For directories, copy all files contained in the source directory to to the specified destination directory. cCstt|ƒj|ƒdS(s{Initializes the class Parameters: -name - this arg is required by the AbstractCheckpoint N(tsuperRt__init__(tselftname((stransfer_files.pyR6scCsU|jjd||ƒtj|tjƒr>tj||ƒn|jjd|ƒdS(s  Class method to physically copy a file from source to dest only if the file exists. Parameters: - source : Source file to be copied - dest : destination directory to copy to Returns: - Nothing sExecuting: Copy file %s to %ss%s not found -- skippingN(tloggertdebugtostaccesstF_OKtshutiltcopy2(Rtsourcetdest((stransfer_files.pyt copy_file=s cCsR|jjd||ƒtjj|ƒr;tj||ƒn|jjd|ƒdS(s¬ Class method to copy a source directory to a destination only if the source directory exists. This method uses shutil.copytree() to copy the directory, so the desitnation must not already exist. Paramters: - source : Source directory to be copied - dest : destination directory to copy to Returns: - Nothing sExecuting: Copy dir %s to %ss%s not found -- skippingN(RRR tpathtisdirR tcopytree(RRR((stransfer_files.pytcopy_dirPscCs×d}|jjdƒ|jƒ|jjjd|jƒ}|dkr[|jjdƒdSxu|jj ƒD]d\}}t |t ƒrÇ|jjd|j ƒƒt jj|j|djdƒƒ}n=|jjd|jdƒƒt jj|j|jdƒƒ}|skt jj|ƒr/|j||ƒnMt jt jj|ƒt jƒslt jt jj|ƒƒn|j||ƒt |t ƒrÏd |krÏ|jjd ||d fƒt j||d ƒqÏqkqkWdS( s‚ The AbstractCheckpoint class requires this method in sub-classes. 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: Transfer FilesRsNo files specified for transferNsdest_dict is a dictionary (%s)tfilet/sdest_dict is a string %stperms changing permissions of %s to %d(tNoneRRt parse_doctdoctvolatiletget_first_childRt data_dicttitemst isinstancetdicttkeysR Rtjoint target_dirtlstripRRR tdirnameR tmakedirsRtchmod(Rtdry_runttf_dictRt dest_dictR((stransfer_files.pytexecutees4     !! (t__name__t __module__t__doc__RRRtFalseR+(((stransfer_files.pyR#s    cCs{tjƒ}|j}|jjd|ƒ}|dkratƒ}t||ƒ}|jj|ƒn |j }|j |ƒdS(s· Create dataobjectdict dictionary containing src/dest pairs for files to be transferred via transfer-files checkpoint to newly installed boot environment. RN( Rt get_instancetdata_object_cacheRRRR Rtinsert_childrenRtupdate(t transfer_nametfilestengineRt tf_doc_dictR)((stransfer_files.pytadd_transfer_files_to_docœs     ( R R t%solaris_install.data_object.data_dictRtsolaris_install.engineRtsolaris_install.ictticttICTt ICTBaseClassRR8(((stransfer_files.pyts  y