def get_console_cert(_dir): """get console certs Arguments: _dir {[type]} -- [description] """ LOGGER.info("get console in %s!", _dir) CONSOLER.info("get console in %s!", _dir) meta = '{}/meta'.format(path.get_path()) data = _dir get_sdk_cert() utils.dir_must_exists(data) shutil.copyfile('{}/ca.crt'.format(meta), '{}/ca.crt'.format(data)) shutil.copyfile('{}/sdk/node.key'.format(meta), '{}/node.key'.format(data)) shutil.copyfile('{}/sdk/node.crt'.format(meta), '{}/node.crt'.format(data))
def deploy_key(_get_dir, _send_dir): """[deploy_key] Arguments: _get_dir {[PATH]} -- [description] _send_dir {[PATH]} -- [description] """ utils.dir_must_exists(_get_dir) utils.dir_must_exists(_send_dir) meta_path = _get_dir data_path = _send_dir get_node_list = [] send_node_list = [] for _, dirs, _ in os.walk(meta_path, topdown=True, onerror=None, followlinks=False): for name in dirs: get_node_list.append(name) for _, dirs, _ in os.walk(data_path, topdown=True, onerror=None, followlinks=False): for name in dirs: send_node_list.append(name) LOGGER.info("get cert in %s!", get_node_list) LOGGER.info("send cert to %s!", send_node_list) for node_dir in get_node_list: if not utils.valid_node_dir(node_dir): continue if utils.Status.gm_option: utils.file_must_exists('{}/{}/gmnode.key'.format( meta_path, node_dir)) utils.file_must_exists('{}/{}/gmnode.nodeid'.format( meta_path, node_dir)) if os.path.exists('{}/{}/conf'.format(data_path, node_dir)): LOGGER.info("send cert from %s to %s", data_path, node_dir) shutil.copyfile( '{}/{}/gmnode.key'.format(meta_path, node_dir), '{}/{}/conf/gmnode.key'.format(data_path, node_dir)) shutil.copyfile( '{}/{}/gmnode.nodeid'.format(meta_path, node_dir), '{}/{}/conf/gmnode.nodeid'.format(data_path, node_dir)) shutil.copyfile( '{}/{}/gmennode.key'.format(meta_path, node_dir), '{}/{}/conf/gmennode.key'.format(data_path, node_dir)) shutil.copyfile( '{}/{}/gmennode.crt'.format(meta_path, node_dir), '{}/{}/conf/gmennode.crt'.format(data_path, node_dir)) shutil.copytree( '{}/{}/origin_cert'.format(meta_path, node_dir), '{}/{}/conf/origin_cert'.format(data_path, node_dir)) else: utils.file_must_exists('{}/{}/node.key'.format( meta_path, node_dir)) utils.file_must_exists('{}/{}/node.nodeid'.format( meta_path, node_dir)) if os.path.exists('{}/{}/conf'.format(data_path, node_dir)): LOGGER.info("send cert from %s to %s", data_path, node_dir) shutil.copyfile( '{}/{}/node.key'.format(meta_path, node_dir), '{}/{}/conf/node.key'.format(data_path, node_dir)) shutil.copyfile( '{}/{}/node.nodeid'.format(meta_path, node_dir), '{}/{}/conf/node.nodeid'.format(data_path, node_dir))