def deploy_ca_certs(file_path_list,
                        remote_ip,
                        user,
                        password,
                        dest_dir,
                        no_delete=None):
        """
        Copy files to remote node and remove local files
        """
        CommonTools.remote_mkdir_with_mode(dest_dir,
                                           Constant.AUTH_COMMON_DIR_STR,
                                           remote_ip, user, password)

        for file_path in file_path_list:
            dest_file_path = os.path.join(dest_dir,
                                          os.path.basename(file_path))
            status, output = CommonTools.remote_copy_files(
                remote_ip, user, password, file_path, dest_file_path)
            if status != 0:
                raise Exception(Errors.EXECUTE_RESULT['gauss_0406'] %
                                (remote_ip, output))
            g.logger.debug('Successfully copy [%s] to remote node[%s]' %
                           (file_path, remote_ip))
        if no_delete:
            file_path_list = [
                file for file in file_path_list if file not in no_delete
            ]
        CommonTools.remove_files(file_path_list)
    def remote_copy_env_file(self):
        """
        Copy env file to remote node.
        """
        for node in self.agent_nodes:
            ip = node.get(Constant.NODE_IP)
            uname = node.get(Constant.NODE_USER)
            pwd = node.get(Constant.NODE_PWD)

            status, output = CommonTools.remote_copy_files(
                ip, uname, pwd, ENV_FILE, ENV_FILE)
            if status != 0:
                raise Exception(Errors.EXECUTE_RESULT['gauss_0406'] %
                                (ip, output))
            else:
                g.logger.info('Successfully copy env file to node[%s].' % ip)
    def remote_copy_manager(self):
        """
        Copy package to remote node.
        """
        manager_from = os.path.dirname(
            os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
        for node in self.agent_nodes:
            ip = node.get(Constant.NODE_IP)
            uname = node.get(Constant.NODE_USER)
            pwd = node.get(Constant.NODE_PWD)

            status, output = CommonTools.remote_copy_files(
                ip, uname, pwd, manager_from, self.manager_path)
            if status != 0:
                raise Exception(Errors.EXECUTE_RESULT['gauss_0406'] %
                                (ip, output))
            else:
                g.logger.info('Successfully copy manager to node[%s].' % ip)
 def _copy_param_file_to_remote_node(self, path_from, path_to):
     """
     Copy params file to remote agent node
     """
     for node in self.agent_nodes:
         ip = node.get(Constant.NODE_IP)
         uname = node.get(Constant.NODE_USER)
         pwd = node.get(Constant.NODE_PWD)
         CommonTools.remote_mkdir_with_mode(os.path.dirname(path_to),
                                            Constant.AUTH_COMMON_DIR_STR,
                                            ip, uname, pwd)
         status, output = CommonTools.remote_copy_files(
             ip, uname, pwd, path_from, path_to)
         if status != 0:
             raise Exception(Errors.EXECUTE_RESULT['gauss_0406'] %
                             (ip, output))
         else:
             g.logger.info(
                 'Successfully copy install param file to node[%s].' % ip)
Beispiel #5
0
 def remote_copy_version_file(self):
     """
     Copy version record file of index advisor to remote node.
     """
     for node in self.install_nodes:
         ip = node.get(Constant.NODE_IP)
         uname = node.get(Constant.NODE_USER)
         pwd = node.get(Constant.NODE_PWD)
         if not any([ip, uname, pwd]):
             raise Exception(Errors.PARAMETER['gauss_0201'] %
                             'remote node info')
         if not os.path.exists(VERSION_RECORD_FILE_INDEX_ADVISOR):
             raise Exception(Errors.FILE_DIR_PATH['gauss_0102'] %
                             VERSION_RECORD_FILE_INDEX_ADVISOR)
         _, output = CommonTools.remote_copy_files(
             ip, uname, pwd, VERSION_RECORD_FILE_INDEX_ADVISOR,
             VERSION_RECORD_FILE_INDEX_ADVISOR)
         g.logger.info(
             'Result of copy version record file to node[%s], output:%s' %
             (ip, output))
Beispiel #6
0
 def remote_copy_module(self):
     """
     Copy package of index advisor to remote node.
     """
     for node in self.install_nodes:
         ip = node.get(Constant.NODE_IP)
         uname = node.get(Constant.NODE_USER)
         pwd = node.get(Constant.NODE_PWD)
         if not any([ip, uname, pwd]):
             raise Exception(Errors.PARAMETER['gauss_0201'] %
                             'remote node info')
         local_module_path = os.path.realpath(
             os.path.join(EXTRACT_DIR, self.module_name))
         if not os.path.exists(local_module_path):
             raise Exception(Errors.FILE_DIR_PATH['gauss_0101'] %
                             'temp index advisor module')
         _, output = CommonTools.remote_copy_files(ip, uname, pwd,
                                                   local_module_path,
                                                   self.module_path)
         g.logger.info(
             'Result of copy index advisor package to node[%s], output:%s' %
             (ip, output))