Skip to content

Commit 269c7e2

Browse files
committed
[CE-69] Let network config support more types
Now we use a nework config class to wrap all the network related configurations. This new design will help support multiple network types like fabric v0.6 and fabric v1.0. This patchset also makes other related changes. Change-Id: Idd9661ea3dc90515ea9be1262fc736fc2713c9d9 Signed-off-by: Baohua Yang <yangbaohua@gmail.com>
1 parent 8f3a042 commit 269c7e2

27 files changed

+686
-549
lines changed

api/dashboard.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ paths:
3636
and other details about each cluster, and lists the clusters in the
3737
proper display order.
3838
parameters:
39-
- name: daemon_url
39+
- name: worker_api
4040
in: query
41-
description: Filter clusters with specific daemon_url.
41+
description: Filter clusters with specific worker_api.
4242
required: false
4343
type: string
4444
- name: user_id
@@ -88,9 +88,9 @@ paths:
8888
The endpoint create a specific cluster
8989
The response includes necessary info.
9090
parameters:
91-
- name: daemon_url
91+
- name: worker_api
9292
in: query
93-
description: Given the daemon_url to create at
93+
description: Given the worker_api to create at
9494
required: true
9595
type: string
9696
- name: cluster_name
@@ -144,7 +144,7 @@ definitions:
144144
api_url:
145145
type: string
146146
description: Cluster REST URL representing the cluster.
147-
daemon_url:
147+
worker_api:
148148
type: string
149149
description: Docker host daemon url
150150
name:

api/restserver_v2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Accordingly, the server will return a json response (succeed or fail).
6363
"api_url": "http://192.168.7.62:5004",
6464
"consensus_mode": "batch",
6565
"consensus_plugin": "pbft",
66-
"daemon_url": "tcp://192.168.7.62:2375",
66+
"worker_api": "tcp://192.168.7.62:2375",
6767
"id": "576ba021414b0502864d0306",
6868
"name": "compute2_4",
6969
"size": 4,

docs/db.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ Track the information of a Host.
77

88
A typical host may look like:
99

10-
id | name | daemon_url | create_ts | capacity | status | clusters | type | log_level | log_type | log_server | autofill | schedulable
10+
id | name | worker_api | create_ts | capacity | status | clusters | type | log_level | log_type | log_server | autofill | schedulable
1111
---| ------ | ------------------- | -------------- | -------- | -------- | ------- | ------- | --------- | -------- | ----------- | -------- | -----------
1212
xxx | host_0 | tcp://10.0.0.1:2375 | 20160430101010 | 20 | active | [c1,c2,c3] | single | debug | syslog | udp://10.0.0.2:5000 | true | true
1313

1414
* id (str): uuid of the host instance
1515
* name (str): human-readable name
16-
* daemon_url (str): Through which url to access the Docker/Swarm Daemon
16+
* worker_api (str): Through which url to access the Docker/Swarm Daemon
1717
* create_ts (datetime): When to add the host
1818
* capacity (int): Maximum number of chains on that host
1919
* status (str): 'active' (Can access daemon service) or 'inactive' (disconnected from daemon service)
@@ -30,7 +30,7 @@ Track information of one blockchain.
3030

3131
A typical cluster may look like:
3232

33-
id | service_url | name | user_id | host_id | daemon_url | consensus_plugin | consensus_mode | create_ts | apply_ts | release_ts | duration | size | containers | health
33+
id | service_url | name | user_id | host_id | worker_api | consensus_plugin | consensus_mode | create_ts | apply_ts | release_ts | duration | size | containers | health
3434
--- | --------------- | --------- | -------- | ------- | ------------------- | ---------------- | -------------- | ------------- | -------- | ---------- | ------- | ------- | ------- | ------
3535
xxx | {} | cluster_A | "" | host_xx | tcp://10.0.0.1:2375 | pbft | batch | 20160430101010 | 20160430101010 | | | 4 | [vp0,vp1,vp2,vp3] | OK
3636

@@ -39,7 +39,7 @@ xxx | {} | cluster_A | "" | host_xx | tcp://10.0.0.1:2375 | pbft
3939
* name (str): human-readable name
4040
* user_id (str): Which user occupies this chain, empty for no occupation
4141
* host_id (str): Where the chain exists
42-
* daemon_url (str): Through which url to access the Docker/Swarm Daemon
42+
* worker_api (str): Through which url to access the Docker/Swarm Daemon
4343
* consensus_plugin (str): Consensus plugin name
4444
* consensus_mode (str): Consensus plugin mode name
4545
* create_ts (datetime): When to create the chain

scripts/update_docker_images.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
# SPDX-License-Identifier: Apache-2.0
66
#
77

8-
echo "Pull yeasy/hyperledger:latest and retagging"
9-
docker pull yeasy/hyperledger:latest && \
10-
docker rmi hyperledger/fabric-baseimage:latest && \
11-
docker tag yeasy/hyperledger:latest hyperledger/fabric-baseimage:latest
8+
echo "This script will setup the docker images for master node"
9+
echo "Pull python:3.5, mongo:3.2, mongo-express:0.30 and yeasy/nginx"
1210

13-
echo "Pull yeasy/hyperledger-peer:latest"
14-
docker pull yeasy/hyperledger-peer:latest
11+
docker pull python:3.5 \
12+
&& docker pull mongo:3.2 \
13+
&& docker pull mongo-express:0.30 \
14+
&& docker pull yeasy/nginx:latest

src/agent/docker/cluster.py

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
compose_restart
1515

1616
from common import NETWORK_TYPES, CONSENSUS_PLUGINS, \
17-
CONSENSUS_MODES, CLUSTER_SIZES
17+
CONSENSUS_MODES, NETWORK_SIZE_FABRIC_PRE_V1
1818

1919
from ..cluster_base import ClusterBase
2020

@@ -32,9 +32,8 @@ def __init__(self):
3232
pass
3333

3434
def create(self, cid, mapped_ports, host, user_id="",
35-
fabric_version=NETWORK_TYPES[0],
36-
consensus_plugin=CONSENSUS_PLUGINS[0],
37-
consensus_mode=CONSENSUS_MODES[0], size=CLUSTER_SIZES[0]):
35+
network_type=NETWORK_TYPES[0],
36+
config=None):
3837
""" Create a cluster based on given data
3938
4039
TODO: maybe need other id generation mechanism
@@ -44,54 +43,42 @@ def create(self, cid, mapped_ports, host, user_id="",
4443
:param start_port: first service port for cluster, will generate
4544
if not given
4645
:param user_id: user_id of the cluster if start to be applied
47-
:param fabric_version: fabric images version
48-
:param consensus_plugin: type of the consensus type
49-
:param size: size of the cluster, int type
46+
:param network_type: fabric images version
47+
:param config: network config
48+
5049
:return: Id of the created cluster or None
5150
"""
5251

5352
# from now on, we should be safe
5453

5554
# start compose project, failed then clean and return
5655
logger.debug("Start compose project with name={}".format(cid))
57-
containers = compose_up(
58-
name=cid, mapped_ports=mapped_ports, host=host,
59-
network_type=fabric_version,
60-
consensus_plugin=consensus_plugin, consensus_mode=consensus_mode,
61-
cluster_size=size)
62-
if not containers or len(containers) != size:
56+
containers = compose_up(name=cid, mapped_ports=mapped_ports, host=host,
57+
network_type=network_type, config=None)
58+
if not containers or len(containers) != config.size:
6359
logger.warning("failed to create cluster, with container={}"
6460
.format(containers))
6561
return []
6662
else:
6763
return containers
6864

69-
def delete(self, id, daemon_url, fabric_version, consensus_plugin,
70-
cluster_size):
71-
return compose_clean(id, daemon_url, fabric_version,
72-
consensus_plugin, cluster_size)
73-
74-
def start(self, name, daemon_url, mapped_ports, fabric_version,
75-
consensus_plugin,
76-
consensus_mode, log_type, log_level, log_server, cluster_size):
77-
return compose_start(name, daemon_url, mapped_ports, fabric_version,
78-
consensus_plugin, consensus_mode, log_type,
79-
log_level, log_server, cluster_size)
80-
81-
def restart(self, name, daemon_url, mapped_ports, fabric_version,
82-
consensus_plugin, consensus_mode, log_type, log_level,
83-
log_server, cluster_size):
84-
return compose_restart(name, daemon_url, mapped_ports, fabric_version,
85-
consensus_plugin, consensus_mode, log_type,
86-
log_level, log_server, cluster_size)
87-
88-
def stop(self, name, daemon_url, mapped_ports, fabric_version,
89-
consensus_plugin, consensus_mode, log_type, log_level,
90-
log_server, cluster_size):
91-
return compose_stop(name, daemon_url, mapped_ports, fabric_version,
92-
consensus_plugin,
93-
consensus_mode, log_type, log_level, log_server,
94-
cluster_size)
65+
def delete(self, id, worker_api, network_type, config):
66+
return compose_clean(id, worker_api, network_type, config)
67+
68+
def start(self, name, worker_api, mapped_ports, network_type,
69+
log_type, log_level, log_server, config):
70+
return compose_start(name, worker_api, mapped_ports, network_type,
71+
log_type, log_level, log_server, config)
72+
73+
def restart(self, name, worker_api, mapped_ports, network_type,
74+
log_type, log_level, log_server, config):
75+
return compose_restart(name, worker_api, mapped_ports, network_type,
76+
log_type, log_level, log_server, config)
77+
78+
def stop(self, name, worker_api, mapped_ports, network_type,
79+
log_type, log_level, log_server, config):
80+
return compose_stop(name, worker_api, mapped_ports, network_type,
81+
log_type, log_level, log_server, config)
9582

9683

9784
cluster_on_docker = ClusterOnDocker()

0 commit comments

Comments
 (0)