Skip to content

Commit

Permalink
small update and comment fabric-operator hyperledger-cello#192
Browse files Browse the repository at this point in the history
Signed-off-by: Dixing (Dex) Xu <dixingxu@gmail.com>
  • Loading branch information
dexhunter committed Nov 17, 2020
1 parent f6b6ad3 commit 93eb816
Show file tree
Hide file tree
Showing 46 changed files with 37 additions and 1,324 deletions.
12 changes: 6 additions & 6 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
24 changes: 0 additions & 24 deletions src/agent/docker-rest-agent/Dockerfile

This file was deleted.

11 changes: 0 additions & 11 deletions src/agent/docker-rest-agent/entrypoint.sh

This file was deleted.

27 changes: 22 additions & 5 deletions src/agent/docker-rest-agent/intergration-test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
5 changes: 0 additions & 5 deletions src/agent/docker-rest-agent/pip/pip.conf

This file was deleted.

19 changes: 2 additions & 17 deletions src/agent/docker-rest-agent/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
Django>=3.0
uwsgi
enum34
djangorestframework
holdup>1.5.0,<=1.6.0
drf-yasg<=1.17.0
swagger_spec_validator<=2.4.1
psycopg2-binary
celery<5.0,>=4.4
redis
Flask
flask-restful
requests
supervisor
django-celery-beat
django-celery-results
django-3-jet
djangorestframework-jwt<=1.11.0
python-jwt # 需要安装,否则会出现token解码失败错误
shortuuid
10 changes: 7 additions & 3 deletions src/agent/docker-rest-agent/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,28 @@ 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/<id>', methods=['GET', 'POST'])
def operate_node(id):

container = client.containers.get(id)
if request.method == 'POST':
act = request.form.get('action') # only with POST

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:
Expand All @@ -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)

Expand Down
Empty file.
3 changes: 0 additions & 3 deletions src/agent/docker-rest-agent/src/api/admin.py

This file was deleted.

5 changes: 0 additions & 5 deletions src/agent/docker-rest-agent/src/api/apps.py

This file was deleted.

67 changes: 0 additions & 67 deletions src/agent/docker-rest-agent/src/api/auth.py

This file was deleted.

Empty file.
Empty file.

This file was deleted.

Empty file.
1 change: 0 additions & 1 deletion src/agent/docker-rest-agent/src/api/models/__init__.py

This file was deleted.

42 changes: 0 additions & 42 deletions src/agent/docker-rest-agent/src/api/models/user.py

This file was deleted.

Empty file.
Empty file.
40 changes: 0 additions & 40 deletions src/agent/docker-rest-agent/src/api/routes/hello/views.py

This file was deleted.

1 change: 0 additions & 1 deletion src/agent/docker-rest-agent/src/api/tasks/__init__.py

This file was deleted.

Empty file.
12 changes: 0 additions & 12 deletions src/agent/docker-rest-agent/src/api/tasks/task/example.py

This file was deleted.

3 changes: 0 additions & 3 deletions src/agent/docker-rest-agent/src/api/tests.py

This file was deleted.

Empty file.
2 changes: 0 additions & 2 deletions src/agent/docker-rest-agent/src/api/utils/common/__init__.py

This file was deleted.

26 changes: 0 additions & 26 deletions src/agent/docker-rest-agent/src/api/utils/common/db.py

This file was deleted.

Loading

0 comments on commit 93eb816

Please sign in to comment.