def build_crypto_config(orderer_cfg, org_list): tmpl = f_env.get_template('crypto-config.yaml.tmpl') result = tmpl.render( orderer=orderer_cfg['orderer'], org_list=org_list, ) save_file(deploy_path, "crypto-config.yaml", result)
def build_configtx_config(orderer_cfg, org_list): tmpl = f_env.get_template('configtx.yaml.tmpl') kafka_brokers = [] if 'kafka' in orderer_cfg: kafka_brokers = orderer_cfg['kafka']['k_ip_ports'] result = tmpl.render( orderer=orderer_cfg['orderer'], org_list=org_list, kafka_brokers=kafka_brokers, ) save_file(deploy_path, "configtx.yaml", result)
def __build_zookeeper(orderer_config): tmpl = env.get_template('docker-zk.yaml.tmpl') if 'zookeeper' not in orderer_config: return if not orderer_config['zookeeper']['is_need_gen']: return for ip in orderer_config['zookeeper']['machines']: zk_list = orderer_config['zookeeper']['machines'][ip] result = tmpl.render( zk_list=zk_list, zoo_servers=orderer_config['zookeeper']['zoo_server'], zk_hosts=orderer_config['zookeeper']['zk_hosts'], single=orderer_config['zookeeper']['single']) folder = machine_path + "/orderer/%s" % ip save_file(folder, "docker-zk.yaml", result)
def __build_kafka(orderer_config): tmpl = env.get_template('docker-kafka.yaml.tmpl') if 'kafka' not in orderer_config: return if not orderer_config['kafka']['is_need_gen']: return for ip in orderer_config['kafka']['machines']: k_list = orderer_config['kafka']['machines'][ip] result = tmpl.render(k_list=k_list, zoo_servers=",".join( orderer_config['zookeeper']['zk_ports']), zk_hosts=orderer_config['zookeeper']['zk_hosts'], kafka_hosts=orderer_config['kafka']['k_hosts'], single=orderer_config['zookeeper']['single']) folder = machine_path + "/orderer/%s" % ip save_file(folder, "docker-kafka.yaml", result)
def __build_couchdb_config(org_list): for org in org_list: for ip, db_list in org['db_ip_dicts'].items(): if len(db_list) == 0: return result = env.get_template( 'docker-compose-couchdb.yaml.tmpl').render( dbs=db_list, network=default_net, ) folder = machine_path + "/%s/%s" % (org['title'], ip) save_file(folder, "docker-compose-couchdb.yaml", result) peer_bash = b_env.get_template('initCouchDB.sh.tmpl').render( network=default_net, volumes=[db['volumes'][0].split(":")[0] for db in db_list], ) save_file(folder + "/scripts", "initCouchDB.sh", peer_bash)
def __build_ca_config(org_list): for org in org_list: for ip, ca_list in org['ca_ip_dicts'].items(): if len(ca_list) == 0: continue ca = ca_list[0].copy() file_list = os.listdir(deploy_path + "crypto-config/peerOrganizations/%s.%s/ca" % (org['title'], org['domain'])) for name in file_list: if '_sk' in name: ca['private_key'] = name ca['domain'] = org['title'] + "." + org['domain'] ca['name'] = 'ca.%s' % ca['domain'] result = env.get_template('docker-compose-ca.yaml.tmpl').render( ca=ca, ) folder = machine_path + "/%s/%s" % (org['title'], ip) save_file(folder, "docker-compose-ca.yaml", result)
def __build_peer_config(org_list, orderer_dict): for org in org_list: for ip, peer_list in org['peer_ip_dicts'].items(): result = env.get_template('docker-compose-peer.yaml.tmpl').render( peers=peer_list, orderer_hosts=orderer_dict['orderer']['orderer_hosts'], peer_hosts=org['peer_hosts'], network=default_net) folder = machine_path + "/%s/%s" % (org['title'], ip) save_file(folder, "docker-compose-peer.yaml", result) result = env.get_template('docker-compose-cli.yaml.tmpl').render( p=peer_list[0], orderer_hosts=orderer_dict['orderer']['orderer_hosts'], peer_hosts=org['peer_hosts'], network=default_net) folder = machine_path + "/%s/%s" % (org['title'], ip) save_file(folder, "docker-compose-cli.yaml", result)
def __build_orderer_config(orderer_config): tmpl = env.get_template('docker-compose-orderer.yaml.tmpl') if not orderer_config['orderer']['is_need_gen']: return orderer_ip_dicts = orderer_config['orderer']['orderer_ip_dicts'] for ip in orderer_ip_dicts.keys(): zk_hosts = [] kafka_hosts = [] kafka_ports = [] if 'zookeeper' in orderer_config: zk_hosts = orderer_config['zookeeper']['zk_hosts'] if 'kafka' in orderer_config: kafka_hosts = orderer_config['kafka']['k_hosts'] kafka_ports = ",".join(orderer_config['kafka']['k_ports']) result = tmpl.render( orderer_list=orderer_ip_dicts[ip], orderer_hosts=orderer_config['orderer']['orderer_hosts'], zk_hosts=zk_hosts, kafka_hosts=kafka_hosts, kafka_ports=kafka_ports) folder = machine_path + "/orderer/%s" % ip save_file(folder, "docker-compose-orderer.yaml", result)
def __build_explorer_config(org_list, orderer_dict): peers = [] orderers = [] for org in org_list: for ip, m_list in org['peer_ip_dicts'].items(): peers.extend(m_list) for ip, m_list in orderer_dict['orderer']['orderer_ip_dicts'].items(): orderers.extend(m_list) for org in org_list: for explorer_cfg in org['explorers']: result = env.get_template( 'docker-compose-explorer.yaml.tmpl').render( e=explorer_cfg, network=default_net) folder = machine_path + "/%s/%s/explorer/" % (org['title'], explorer_cfg['ip']) save_file(folder, "docker-compose-explorer.yaml", result) result = env.get_template( 'docker-compose-explorer-postgres.yaml.tmpl').render( e=explorer_cfg, network=default_net) folder = machine_path + "/%s/%s/explorer/" % (org['title'], explorer_cfg['ip']) save_file(folder, "docker-compose-explorer-postgres.yaml", result) result = b_env.get_template('initPostgresDB.sh.tmpl').render( volumes=explorer_cfg['volumes'], network=default_net) folder = machine_path + "/%s/%s/explorer/" % (org['title'], explorer_cfg['ip']) save_file(folder, "initPostgresDB.sh", result) tmpl = env.get_template('config.json.tmpl') for explorer_cfg in org['explorers']: result = tmpl.render(e=explorer_cfg, org=org, org_list=org_list, network=default_net, channel_name=channel_name, orderer=orderer_dict['orderer'], peers=peers, orderers=orderers) folder = machine_path + "/%s/%s/explorer/" % (org['title'], explorer_cfg['ip']) save_file(folder, "config.json", result)