Ejemplo n.º 1
0
 def _generate_key_file(self, password):
     """
     Create key file
     """
     key_file_path = os.path.join(self.module_path, Constant.PWF_PATH)
     CommonTools.mkdir_with_mode(key_file_path,
                                 Constant.AUTH_COMMON_DIR_STR)
     CommonTools.clean_dir(key_file_path)
     encrypt_path = os.path.join(
         os.path.dirname(
             os.path.dirname(
                 os.path.dirname(
                     os.path.dirname(
                         os.path.dirname(os.path.realpath(__file__)))))),
         Constant.ENCRYPT_TOOL)
     lib_path = os.path.join(
         os.path.dirname(
             os.path.dirname(
                 os.path.dirname(
                     os.path.dirname(
                         os.path.dirname(
                             os.path.dirname(
                                 os.path.realpath(__file__))))))), 'lib')
     CommonTools.encrypt_with_path(password, key_file_path, encrypt_path,
                                   lib_path)
     g.logger.info('Successfully generate key files with path [%s].' %
                   key_file_path)
     return key_file_path
Ejemplo n.º 2
0
 def _clean_manager_dir(self):
     """
     Clean install path before unpack.
     """
     file_list = os.listdir(self.ai_manager_path)
     if file_list:
         g.logger.info('Start clean install path, file list:[%s]' % file_list)
         CommonTools.clean_dir(self.ai_manager_path)
Ejemplo n.º 3
0
 def unpack_file_to_temp_dir(self):
     """
     Unpack file to temp dir on remote node.
     """
     # mk temp extract dir if not exist
     CommonTools.mkdir_with_mode(EXTRACT_DIR, Constant.AUTH_COMMON_DIR_STR)
     # clean extract dir
     CommonTools.clean_dir(EXTRACT_DIR)
     # extract package file to temp dir
     CommonTools.extract_file_to_dir(self.package_path, EXTRACT_DIR)
     g.logger.info('Success unpack files to temp dir.')
Ejemplo n.º 4
0
 def clean_module_path(self):
     """
     Delete files in install path.
     """
     status, output = CommonTools.clean_dir(self.module_path)
     if status != 0:
         g.logger.warning('Failed clean path:[%s]' % self.module_path)
     else:
         g.logger.info('Successfully clean install path:[%s]' % self.module_path)
Ejemplo n.º 5
0
 def deploy_agent_certs(self):
     """
     Copy file from temp dir to config path.
     """
     file_list = self.read_ca_cert_path(agent_only=True)
     file_list.append(os.path.join(self.module_path, Constant.PWF_PATH))
     temp_cert_list = os.listdir(TMP_CA_FILE)
     for dest_path in file_list:
         CommonTools.mkdir_with_mode(os.path.dirname(dest_path),
                                     Constant.AUTH_COMMON_DIR_STR)
     CommonTools.remove_files(file_list)
     g.logger.info('Successfully prepare the path:%s' % str(file_list))
     for file_name in temp_cert_list:
         for dest_file in file_list:
             if file_name in dest_file:
                 from_path = os.path.join(TMP_CA_FILE, file_name)
                 CommonTools.copy_file_to_dest_path(from_path, dest_file)
     CommonTools.clean_dir(TMP_CA_FILE)
Ejemplo n.º 6
0
 def _get_install_path(self, pack_path):
     """
     Extract version info and assembling install path.
     """
     g.logger.info('Start getting install path.')
     # mk temp extract dir if not exist
     CommonTools.mkdir_with_mode(EXTRACT_DIR, Constant.AUTH_COMMON_DIR_STR)
     # clean extract dir
     CommonTools.clean_dir(EXTRACT_DIR)
     # extract package file to temp dir
     CommonTools.extract_file_to_dir(pack_path, EXTRACT_DIR)
     g.logger.info('Success extract files to temp dir.')
     # get version info from version file
     version_file = os.path.realpath(os.path.join(EXTRACT_DIR, Constant.VERSION_FILE))
     version = CommonTools.get_version_info_from_file(version_file)
     g.logger.info('Got version info:%s' % version)
     base_dir = Constant.PACK_PATH_PREFIX + version
     install_path = os.path.join(self.project_path, base_dir)
     g.logger.info('Got install path:%s.' % install_path)
     CommonTools.check_path_valid(install_path)
     g.logger.info('Successfully to get install path.')
     return install_path, version
Ejemplo n.º 7
0
 def clean_temp_extract_dir():
     """
     Clean temp unpack dir
     """
     CommonTools.clean_dir(EXTRACT_DIR)
     g.logger.info('Successfully clean temp unpack dir.')