Skip to content

Commit

Permalink
[CE-212] Change mongodb library to mongoengine
Browse files Browse the repository at this point in the history
Add port export in fabric docker compose file
Add ENABLE_EMAIL_ACTIVE support for register user
Add user search api
Add user password change/reset api
Add clean docker network after delete fabric

Change-Id: I1d5c1716443658a04708db3ec77026bbc260c9c0
Signed-off-by: Haitao Yue <hightall@me.com>
  • Loading branch information
hightall committed Jan 6, 2018
1 parent d634fd3 commit 41a9103
Show file tree
Hide file tree
Showing 19 changed files with 753 additions and 307 deletions.
28 changes: 16 additions & 12 deletions src/agent/docker/_compose_files/fabric-1.0/local/fabric-solo-4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ services:
container_name: ${COMPOSE_PROJECT_NAME}_fabric-ca
hostname: ca
# command: /go/src/github.com/hyperledger/fabric-ca/bin/ca server start -ca testdata/ec.pem -ca-key testdata/ec-key.pem -config testdata/testconfig.json
expose:
- "7054"
ports:
- ${CA_ORG1_ECAP_PORT}:7054
command: fabric-ca-server start -b admin:adminpw

orderer.example.com: # There can be multiple orderers
Expand Down Expand Up @@ -46,8 +46,8 @@ services:
- 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]
expose:
- "7050"
ports:
- ${ORDERER_PORT}:7050
volumes: # docker.sock is mapped as the default CORE_VM_ENDPOINT
#- /var/run/docker.sock:/var/run/docker.sock
- ${COMPOSE_PROJECT_PATH}/channel-artifacts/orderer.genesis.block:/var/hyperledger/orderer/orderer.genesis.block
Expand Down Expand Up @@ -91,9 +91,10 @@ services:
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
expose:
- "7051" # Grpc
- "7052" # Peer CLI
- "7053" # Peer Event
ports:
- ${PEER0_ORG1_GRPC_PORT}:7051
- ${PEER0_ORG1_EVENT_PORT}:7053
volumes: # docker.sock is mapped as the default CORE_VM_ENDPOINT
- /var/run/docker.sock:/var/run/docker.sock
- ${COMPOSE_PROJECT_PATH}/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp
Expand Down Expand Up @@ -137,9 +138,10 @@ services:
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
expose:
- "7051" # Grpc
- "7052" # Peer CLI
- "7053" # Peer Event
ports:
- ${PEER1_ORG1_GRPC_PORT}:7051
- ${PEER1_ORG1_EVENT_PORT}:7053
volumes: # docker.sock is mapped as the default CORE_VM_ENDPOINT
- /var/run/docker.sock:/var/run/docker.sock
- ${COMPOSE_PROJECT_PATH}/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/fabric/msp
Expand Down Expand Up @@ -183,9 +185,10 @@ services:
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:7051
- CORE_PEER_LOCALMSPID=Org2MSP
expose:
- "7051" # Grpc
- "7052" # Peer CLI
- "7053" # Peer Event
ports:
- ${PEER0_ORG2_GRPC_PORT}:7051
- ${PEER0_ORG2_EVENT_PORT}:7053
volumes: # docker.sock is mapped as the default CORE_VM_ENDPOINT
- /var/run/docker.sock:/var/run/docker.sock
- ${COMPOSE_PROJECT_PATH}/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp
Expand Down Expand Up @@ -229,9 +232,10 @@ services:
- CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org2.example.com:7051
- CORE_PEER_LOCALMSPID=Org2MSP
expose:
- "7051" # Grpc
- "7052" # Peer CLI
- "7053" # Peer Event
ports:
- ${PEER1_ORG2_GRPC_PORT}:7051
- ${PEER1_ORG2_EVENT_PORT}:7053
volumes: # docker.sock is mapped as the default CORE_VM_ENDPOINT
- /var/run/docker.sock:/var/run/docker.sock
- ${COMPOSE_PROJECT_PATH}/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp:/etc/hyperledger/fabric/msp
Expand Down
30 changes: 30 additions & 0 deletions src/agent/docker/docker_swarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,27 @@ def _clean_project_containers(worker_api, name_prefix, timeout=5):
logger.debug("Remove container {}".format(_))


def _clean_project_networks(worker_api, name_prefix, timeout=5):
"""
Clean cluster node networks
All containers with the name prefix will be removed.
:param worker_api: Docker daemon url
:param name_prefix: image name prefix
:param timeout: Time to wait for the response
:return: None
"""
logger.debug("Clean project networks, worker_api={}, prefix={}".format(
worker_api, name_prefix))
client = Client(base_url=worker_api, version="auto", timeout=timeout)
networks = client.networks(names=["%s_default" % name_prefix])
id_removes = [e['Id'] for e in networks]
for network_id in id_removes:
client.remove_network(network_id)
logger.debug("Remove network id {}".format(network_id))


def start_containers(worker_api, name_prefix, timeout=5):
"""Start containers with given prefix
Expand Down Expand Up @@ -365,6 +386,8 @@ def _compose_set_env(name, worker_api, mapped_ports=SERVICE_PORTS,
'PBFT_GENERAL_MODE': config['consensus_mode'],
'PBFT_GENERAL_N': str(config['size']),
})
envs.update(config.get("env", {}))
logger.debug("envs {}".format(envs))
os.environ.update(envs)

for k, v in mapped_ports.items():
Expand Down Expand Up @@ -401,6 +424,7 @@ def compose_up(name, host, mapped_ports, config=None, timeout=5):
try:
template_path = COMPOSE_FILE_PATH + os.sep + config['network_type'] + \
os.sep + log_type
logger.debug('template path {}'.format(template_path))
project = get_project(template_path)
containers = project.up(detached=True, timeout=timeout)
except Exception as e:
Expand Down Expand Up @@ -438,6 +462,12 @@ def compose_clean(name, worker_api, config):
logger.error("Error in clean compose project containers")
logger.error(e)
has_exception = True
try:
_clean_project_networks(worker_api=worker_api, name_prefix=name)
except Exception as e:
logger.error("Error in clean compose project networks")
logger.error(e)
has_exception = True
try:
_clean_chaincode_images(worker_api=worker_api, name_prefix=name)
except Exception as e:
Expand Down
1 change: 1 addition & 0 deletions src/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .log import log_handler, LOG_LEVEL
from .utils import \
PEER_SERVICE_PORTS, CA_SERVICE_PORTS, SERVICE_PORTS, \
ORDERER_SERVICE_PORTS, \
NETWORK_TYPES, NETWORK_TYPE_FABRIC_V1, NETWORK_TYPE_FABRIC_PRE_V1, \
CONSENSUS_PLUGINS_FABRIC_V1, CONSENSUS_PLUGIN_SOLO, \
CONSENSUS_MODES, CONSENSUS_TYPES_FABRIC_V1, \
Expand Down
4 changes: 4 additions & 0 deletions src/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
'tlscaa': 7059,
}

ORDERER_SERVICE_PORTS = {
'orderer': 7050
}

EXPLORER_PORT = {
'dashboard': 7060
}
Expand Down
Loading

0 comments on commit 41a9103

Please sign in to comment.