diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 58878f1cc..c570497fc 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -40,9 +40,9 @@ stages: images: - imagename: "hyperledger/cello-ansible-agent" dockerfile: "build_image/docker/agent/ansible/Dockerfile.in" - - name: fabricoperator - images: - - imagename: "hyperledger/cello-k8s-operator-agent" - dockerfile: "src/agent/fabric-operator/agent/Dockerfile" - - imagename: "hyperledger/cello-k8s-operator-controller" - dockerfile: "src/agent/fabric-operator/Dockerfile" +# - name: fabricoperator +# images: +# - imagename: "hyperledger/cello-k8s-operator-agent" +# dockerfile: "src/agent/fabric-operator/agent/Dockerfile" +# - imagename: "hyperledger/cello-k8s-operator-controller" +# dockerfile: "src/agent/fabric-operator/Dockerfile" diff --git a/src/agent/docker-rest-agent/intergration-test/test.py b/src/agent/docker-rest-agent/intergration-test/test.py index afc24f13f..57d2c2f9c 100644 --- a/src/agent/docker-rest-agent/intergration-test/test.py +++ b/src/agent/docker-rest-agent/intergration-test/test.py @@ -18,28 +18,45 @@ 'name': 'cello-hlf-peer' } -# Test creating a node +print('-'*20) +print('Test creating a node') +print() n = post('http://localhost:5001/api/v1/nodes', data=data) print(n.text) txt = json.loads(n.text) nid = txt['data']['id'] +print('-'*20) -# Test starting a node +print('Test starting a node') +print() data = {'action': 'start'} response = post('http://localhost:5001/api/v1/nodes/'+nid, data=data) print(response.text) +print('-'*20) -# Test restarting a node +print('Test restarting a node') +print() data = {'action': 'restart'} response = post('http://localhost:5001/api/v1/nodes/'+nid, data=data) print(response.text) +print('-'*20) -# Test stopping a node +print('Test stopping a node') +print() data = {'action': 'stop'} response = post('http://localhost:5001/api/v1/nodes/'+nid, data=data) print(response.text) +print('-'*20) -# Test deleting a node + +print('Get status of a node') +print() +response = get('http://localhost:5001/api/v1/nodes/'+nid) +print(response.text) +print('-'*20) + +print('Test deleting a node') +print() data = {'action': 'delete'} response = post('http://localhost:5001/api/v1/nodes/'+nid, data=data) print(response.text) diff --git a/src/agent/docker-rest-agent/requirements.txt b/src/agent/docker-rest-agent/requirements.txt index 94f0dc9a6..a01dd920d 100644 --- a/src/agent/docker-rest-agent/requirements.txt +++ b/src/agent/docker-rest-agent/requirements.txt @@ -1,3 +1,3 @@ Flask flask-restful -requests \ No newline at end of file +requests diff --git a/src/agent/docker-rest-agent/server.py b/src/agent/docker-rest-agent/server.py index 136394019..a1603bdb1 100644 --- a/src/agent/docker-rest-agent/server.py +++ b/src/agent/docker-rest-agent/server.py @@ -41,11 +41,11 @@ def create_node(): res['data']['id'] = container.id res['data']['public-grpc'] = '127.0.0.1:7050' # TODO: read the info from config file res['data']['public-raft'] = '127.0.0.1:7052' + res['msg'] = 'node created' return jsonify(res) @app.route('/api/v1/nodes/', methods=['GET', 'POST']) def operate_node(id): - container = client.containers.get(id) if request.method == 'POST': act = request.form.get('action') # only with POST @@ -53,12 +53,16 @@ def operate_node(id): try: if act == 'start': container.start() + res['msg'] = 'node started' elif act == 'restart': container.restart() + res['msg'] = 'node restarted' elif act == 'stop': container.stop() + res['msg'] = 'node stopped' elif act == 'delete': container.remove() + res['msg'] = 'node deleted' else: res['msg'] = 'undefined action' except: @@ -69,8 +73,8 @@ def operate_node(id): raise else: # GET - res['data']['status'] = container.status() - + res['data']['status'] = container.status + res['code'] = PASS_CODE return jsonify(res)