def generate_archive4composer(config, channel_dir): dir = channel_dir + COMPOSER_PATH local = channel_dir + LOCAL for org in config.peer_orgs: config_file_path = dir + "/" + org.org_name + "/connection" exec_cmd("mkdir -p {}".format(config_file_path)) create_connection_file(config, config_file_path+"/"+COMPOSER_CONFIG_FN) exec_cmd("mkdir -p {}".format(dir + "/" + org.org_name + "/orderer")) orderer_ca_crt = local+"/crypto-config/ordererOrganizations/"+config.orderer_org.domain+"/orderers/"+config.orderer_org.orderers[0].hostname+"/tls/ca.crt" exec_cmd("cp {0} {1}".format(orderer_ca_crt, dir + "/" + org.org_name + "/orderer")) for peer in org.peers: exec_cmd("mkdir -p {}".format(dir + "/" + org.org_name + "/peer/"+ peer.name)) peer_ca_crt = local+"/crypto-config/peerOrganizations/"+org.domain+"/peers/"+peer.name+"."+org.domain+"/tls/ca.crt" exec_cmd("cp {0} {1}".format(peer_ca_crt, dir + "/" + org.org_name + "/peer/"+ peer.name+"/ca.crt")) build_tarfile(dir, channel_dir+"/"+COMPOSER_TAR)
def __generate4composer(channel_dir, config): exec_cmd("mkdir -p {}".format(channel_dir + COMPOSER_PATH)) generate_archive4composer(config, channel_dir)
def __generate4explorer(channel_dir, config): exec_cmd("mkdir -p {}".format(channel_dir + EXPLORER_PATH)) generate_archive4explorer(config, channel_dir)
def __init_folders(channel): logger.info("Initialize archives folders...") channel_dir = root_path+GENERATED+"/"+channel+"/" exec_cmd("rm -Rf {}".format(channel_dir)) exec_cmd("mkdir -p {}".format(channel_dir + LOCAL)) return channel_dir
def generate_configTX(path, channel_name=CHANNEL_NAME): logger.info("Generate configTX file...") channeltx_filename = channel_name + ".tx" cmd_channeltx = "cd " + path + " && " + root_path + CONFIGTXGEN + " -profile OrgsChannel -outputCreateChannelTx " + channeltx_filename + " -channelID " + channel_name exec_cmd(cmd_channeltx)
def generate_genesis_block(path): logger.info("Generate genesis block...") cmd_genesis_block = "cd " + path + " && " + root_path + CONFIGTXGEN + " -profile OrgsOrdererGenesis -outputBlock " + GENESISBLOCKNAME exec_cmd(cmd_genesis_block)
def generate_MSP(path, cryptoconfig_filename): logger.info("Generate MSP...") cmd_cryptogen = "cd " + path + " && " + root_path + CRYPTOGEN + " generate --config=" + path + "/" + cryptoconfig_filename + " --output=crypto-config" exec_cmd(cmd_cryptogen)
def generate_archive4explorer(config, channel_dir): dir = channel_dir + EXPLORER_PATH local = channel_dir + LOCAL config_file_path = dir + "/config" exec_cmd("mkdir -p {}".format(config_file_path)) create_config_file(config, config_file_path + "/" + EXPLORER_CONFIG_FN) for org in config.peer_orgs: exec_cmd("mkdir -p {}".format(dir + "/" + org.org_name + "/admin/keystore")) exec_cmd("mkdir -p {}".format(dir + "/" + org.org_name + "/admin/signcerts")) admin_local_path = local + "/crypto-config/peerOrganizations/" + org.domain + "/users/Admin@" + org.domain + "/msp/" exec_cmd("cp {0} {1}".format( admin_local_path + "/keystore/*", dir + "/" + org.org_name + "/admin/keystore/")) exec_cmd("cp {0} {1}".format( admin_local_path + "/signcerts/*", dir + "/" + org.org_name + "/admin/signcerts/")) for peer in org.peers: exec_cmd("mkdir -p {}".format(dir + "/" + org.org_name + "/peer/" + peer.name)) peer_ca_crt = local + "/crypto-config/peerOrganizations/" + org.domain + "/peers/" + peer.name + "." + org.domain + "/tls/ca.crt" exec_cmd("cp {0} {1}".format( peer_ca_crt, dir + "/" + org.org_name + "/peer/" + peer.name + "/ca.crt")) build_tarfile(dir, channel_dir + "/" + EXPLORER_TAR)