예제 #1
0
    def _construct_couchdb_docker_service(self, net_id, couchdb_service_name, \
                                       fabric_version, host_port):
        name_prefix = net_id[:12]
        net_dir = CELLO_WORKER_FABRIC_DIR + net_id
        couchdb_container_name = name_prefix + '_' + couchdb_service_name

        if host_port is None:
            raise Exception("couchdb node needs expose a port to host")
        port_mapping = [(host_port, 5984)]
        couchdb_image = FABRIC_COUCHDB_IMAGE_PREFIX + couchdb_image_version[
            fabric_version]
        couchdb_container_env = ["COUCHDB_USER="******"COUCHDB_PASSWORD="]
        couchdb_hostpath_dir = '{net_dir}/chouchdb/{couchdb}'.format(
            net_dir=net_dir, couchdb=couchdb_service_name)
        volume_mapping = [(couchdb_hostpath_dir, '/opt/couchdb/data')]

        couchdb_service_model = fabricModels.FabricServiceModel(
            service_name=couchdb_service_name,
            image=couchdb_image,
            container_name=couchdb_container_name,
            environment=couchdb_container_env,
            port_mapping=port_mapping,
            command=None,
            volume_mapping=volume_mapping)
        result = couchdb_service_model.to_dict()
        return result
예제 #2
0
    def _construct_peer_docker_service(self, net_id, org_name, org_domain, peer_name,\
                                                    fabric_version, host_ports, depends_on):
        net_dir = CELLO_WORKER_FABRIC_DIR + net_id
        name_prefix = net_id[:12]
        #the chaincode node network which is the same with peer and orderer
        cc_container_network = name_prefix + '_celloNet'
        org_fullDomain_name = '.'.join([org_name, org_domain])
        peer_fullDomain_name = '.'.join([peer_name, org_fullDomain_name])
        peer_service_name = peer_fullDomain_name
        peer_container_name = name_prefix + '_' + peer_service_name

        peer_hostpath_docker = '/var/run/'
        peer_hostpath_msp = '{net_dir}/crypto-config/peerOrganizations/{org_domain}/peers/{peer_domain}/msp'. \
            format(net_dir=net_dir, org_domain=org_fullDomain_name, peer_domain=peer_fullDomain_name)
        peer_hostpath_tls = '{net_dir}/crypto-config/peerOrganizations/{org_domain}/peers/{peer_domain}/tls'. \
            format(net_dir=net_dir, org_domain=org_fullDomain_name, peer_domain=peer_fullDomain_name)

        volume_mapping = [(peer_hostpath_docker, '/var/run/'),\
                          (peer_hostpath_msp, '/etc/hyperledger/fabric/msp'),\
                          (peer_hostpath_tls, '/etc/hyperledger/fabric/tls')]
        if host_ports is None or len(host_ports) != 2:
            raise Exception("peer node needs expose two ports to host")
        port_mapping = [(host_ports[0], 7051), (host_ports[1], 7053)]
        peer_image = FABRIC_PEER_IMAGE_PREFIX + fabric_image_version[
            fabric_version]
        peer_container_env = [
            "CORE_PEER_ID={}".format(peer_service_name),
            "CORE_PEER_LOCALMSPID={}MSP".format(org_name[0:1].upper() +
                                                org_name[1:]),
            'CORE_PEER_ADDRESS={}:7051'.format(peer_service_name),
            "CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE={}".format(
                cc_container_network), "CORE_LOGGING_LEVEL=DEBUG",
            "CORE_PEER_GOSSIP_USELEADERELECTION=true",
            "CORE_PEER_GOSSIP_ORGLEADER=false",
            "CORE_PEER_GOSSIP_SKIPHANDSHAKE=true",
            "CORE_PEER_TLS_ENABLED=true",
            "CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt",
            "CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key",
            "CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt",
            "GODEBUG=netdns=go", "CORE_LEDGER_STATE_STATEDATABASE=CouchDB",
            "CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb.{}:5984".
            format(peer_service_name)
        ]

        peer_service_model = fabricModels.FabricServiceModel(
            service_name=peer_service_name,
            image=peer_image,
            container_name=peer_container_name,
            environment=peer_container_env,
            port_mapping=port_mapping,
            volume_mapping=volume_mapping,
            command=PEER_START_COMMAND,
            depends_on=depends_on)
        result = peer_service_model.to_dict()
        return result
예제 #3
0
    def _construct_orderer_docker_service(self, net_id, org_name, org_domain,
                                          orderer_hostname, fabric_version,
                                          host_port):
        net_dir = CELLO_WORKER_FABRIC_DIR + net_id
        name_prefix = net_id[:12]
        orderer_fullDomain_name = '.'.join([orderer_hostname, org_domain])
        orderer_service_name = '-'.join([orderer_hostname, org_name])
        orderer_container_name = name_prefix + '_' + orderer_service_name
        orderer_hostpath_msp = '{net_dir}/crypto-config/ordererOrganizations/{org_domain}/orderers/{full_domain}/msp'. \
            format(net_dir=net_dir, org_domain=org_domain, full_domain=orderer_fullDomain_name)
        orderer_hostpath_tls = '{net_dir}/crypto-config/ordererOrganizations/{org_domain}/orderers/{full_domain}/tls'. \
            format(net_dir=net_dir, org_domain=org_domain, full_domain=orderer_fullDomain_name)
        orderer_hostpath_genesisblock = '{net_dir}/channel-artifacts/genesis.block'. \
            format(net_dir=net_dir)
        volume_mapping = [
            (orderer_hostpath_msp, '/var/hyperledger/orderer/msp'),
            (orderer_hostpath_tls, '/var/hyperledger/orderer/tls'),
            (orderer_hostpath_genesisblock,
             '/var/hyperledger/orderer/orderer.genesis.block')
        ]
        port_mapping = [(host_port, host_port)]
        orderer_image = FABRIC_ORDERER_IMAGE_PREFIX + fabric_version
        orderer_container_env = [
            "ORDERER_GENERAL_LOGLEVEL=DEBUG",
            "ORDERER_GENERAL_LISTENADDRESS=0.0.0.0",
            "ORDERER_GENERAL_LISTENPORT={}".format(host_port),
            "ORDERER_GENERAL_GENESISMETHOD=file",
            "ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block",
            "ORDERER_GENERAL_LOCALMSPID={}MSP".format(org_name[0:1].upper() +
                                                      org_name[1:]),
            "ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp",
            "ORDERER_GENERAL_TLS_ENABLED=true",
            "ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key",
            "ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt",
            "ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]",
            "ORDERER_GENERAL_CLUSTER_CLIENTCERTIFICATE=/var/hyperledger/orderer/tls/server.crt",
            "ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/var/hyperledger/orderer/tls/server.key",
            "ORDERER_GENERAL_CLUSTER_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]"
        ]

        orderer_service_model = fabricModels.FabricServiceModel(
            service_name=orderer_service_name,
            image=orderer_image,
            container_name=orderer_container_name,
            environment=orderer_container_env,
            port_mapping=port_mapping,
            volume_mapping=volume_mapping,
            command=ORDERER_START_COMMAND,
        )
        result = orderer_service_model.to_dict()
        return result
예제 #4
0
    def _construct_ca_docker_service(self, net_id, org_name, org_domain,
                                     ca_key_file, fabric_version, host_port):

        org_fullDomain_name = org_name + '.' + org_domain
        ca_service_name = "ca." + org_fullDomain_name
        name_prefix = net_id[:12]
        ca_container_name = name_prefix + '_' + ca_service_name
        ca_image = FABRIC_CA_IMAGE_PREFIX + fabric_image_version[fabric_version]
        ca_container_env = ["FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server",
                             "FABRIC_CA_SERVER_CA_NAME=ca-{}".format(org_name),
                             "FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.{org_domain}-cert.pem". \
                                 format(org_domain=org_fullDomain_name),
                             "FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/{key_file}". \
                                 format(key_file=ca_key_file),
                             "FABRIC_CA_SERVER_TLS_ENABLED=true",
                             "FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.{org_domain}-cert.pem". \
                                 format(org_domain=org_fullDomain_name),
                             "FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/{key_file}". \
                                 format(key_file=ca_key_file)
                             ]
        port_mapping = [(host_port, 7054)]
        net_fabric_path = CELLO_WORKER_FABRIC_DIR + net_id
        host_volume_path = "{hp}/crypto-config/peerOrganizations/{org_domain}/ca/". \
            format(hp=net_fabric_path, org_domain=org_fullDomain_name)
        volume_mapping = [(host_volume_path,
                           '/etc/hyperledger/fabric-ca-server-config')]

        ca_service_model = fabricModels.FabricServiceModel(
            service_name=ca_service_name,
            image=ca_image,
            container_name=ca_container_name,
            environment=ca_container_env,
            port_mapping=port_mapping,
            volume_mapping=volume_mapping,
            command=FABRIC_CA_SERVER_STARTCOMMAND)
        result = ca_service_model.to_dict()
        return result