Skip to content
This repository was archived by the owner on Oct 17, 2022. It is now read-only.

Commit

Permalink
Updated to python3 restconf tapi grpc
Browse files Browse the repository at this point in the history
  • Loading branch information
rvilalta committed Oct 9, 2019
1 parent 34fe59a commit df3af55
Show file tree
Hide file tree
Showing 50 changed files with 1,558 additions and 188 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__pycache__/

*.pyc
92 changes: 88 additions & 4 deletions commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,34 @@ $ python3 clientTopology.py

== RESTCONF

=== YANG2SWAGGER

$ cd /root/OFC_SC472/restconf
$ wget https://github.com/bartoszm/yang2swagger/releases/download/1.1.11/swagger-generator-cli-1.1.11-executable.jar
$ java -jar swagger-generator-cli-1.1.11-executable.jar -yang-dir ../yang/ -output topology.yaml topology
$ java -jar swagger-generator-cli-1.1.11-executable.jar -yang-dir ../yang/ -output connection.yaml connection

=== SERVER
$ cd /root/OFC_SC472/restconf
$ wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.11/swagger-codegen-cli-3.0.11.jar -O swagger-codegen-cli.jar
Create the server:
$ java -jar swagger-codegen-cli.jar generate -i connection.yaml -l python-flask -o server/
Run the server:
$ cd /root/OFC_SC472/restconf/server
$ pip3 install -r requirements.txt
(Open /root/OFC_SC472/restconfserver/swagger_server/swagger/swagger.yaml and modify all: "name: connection_id" for "name: connection-id")
RUN AUTOGENERATED SERVER
$ python3 -m swagger_server

RUN CONNECTION SERVER
$ cd /root/OFC_SC472/restconf/connectionserver
$ python3 -m swagger_server

RUN CURL AS CLIENT (In another window)
$ cd /root/OFC_SC472/restconf/
$ curl -X POST -H "Content-Type: application/yang-data+json" http://127.0.0.1:8080/data/connection/ [email protected]
$ curl -X GET -H "Content-Type: application/yang-data+json" http://127.0.0.1:8080/data/connection=0/
$ curl -X DELETE -H "Content-Type: application/yang-data+json" http://127.0.0.1:8080/data/connection=0/


== RUN ONOS
Expand All @@ -53,17 +81,73 @@ $ cd /root/OFC_SC472/onos_api/
$ python3 onos_topology.py

== TAPI
RUN TAPI SERVER:
$ cd /root/OFC_SC472/tapi/server
$ python3 tapi_server.py

RUN TAPI CLIENT (In a new window):
$ cd /root/OFC_SC472/tapi/client
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/service-interface-point/
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/service-interface-point/sip-pe1-uni1/
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/topology/
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/topology/topo-nwk/
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/topology/topo-nwk/node/
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/topology/topo-nwk/node/node-mul-pe-1/
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/topology/topo-pe1/node/node-eth-pe-1/owned-node-edge-point/
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/topology/topo-pe1/node/node-eth-pe-1/owned-node-edge-point/nep-pe1-eth-uni1/
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/topology/topo-nwk/link/link-pe1-odu4-nni1-pi4-odu4-nni2/
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/topology/topo-pe1/link/link-pe1-eth-pool-pe1-odu2-pool/

RUN TAPI_APP
$ cd /root/OFC_SC472/tapi/tapi_app
$ python3 tapi_app.py

RUN TAPI CLIENT
$ cd /root/OFC_SC472/tapi/client
$ curl -X POST -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/connectivity-service/cs1/ -d @cs1.json
$ curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8080/restconf/config/context/connection/cs1/


== GRPC
$ cd /root/OFC_SC472/grpc

COMPILE connection.proto:
$ python -m grpc_tools.protoc -I=. --python_out=connection/ connection.proto

== OPENCONFIG
RUN CREATE AND LIST CONNECTION
$ cd /root/OFC_SC472/grpc/connection
$ python3 create.py connection.txt
$ python3 list.py connection.txt

COMPILE connectionService.proto
$ python -m grpc_tools.protoc -I=. --python_out=connectionService/ --grpc_python_out=connectionService/ connectionService.proto

RUN SERVER
$ cd /root/OFC_SC472/grpc/connectionService
$ python3 connectionService_server.py

RUN CLIENT (in another window)
$ cd /root/OFC_SC472/grpc/connectionService
$ python3 connectionService_client.py

COMPILE connectionServiceWithNotif.proto
$ cd /root/OFC_SC472/grpc/
$ python -m grpc_tools.protoc -I=. --python_out=connectionServiceWithNotif/ --grpc_python_out=connectionServiceWithNotif/ connectionServiceWithNotif.proto

RUN SERVER
$ cd /root/OFC_SC472/grpc/connectionServiceWithNotif
$ python3 connectionServiceWithNotif_server.py

RUN CLIENT (in another window)
$ cd /root/OFC_SC472/grpc/connectionServiceWithNotif
$ python3 connectionServiceWithNotif_client.py


== OPENCONFIG

== APPENDICES

=== CONFD
== APPENDIX: CONFD
$ cd /root/OFC_SC472/netconf
$ unzip confd-basic-6.4.linux.x86_64.zip
$ cd confd-basic-6.4.linux.x86_64/
Expand Down Expand Up @@ -93,7 +177,7 @@ $ ./confd_cli
> exit
> exit

== NETCONF EDIT-CONFIG
== APPENDIX: NETCONF EDIT-CONFIG

Run server:
$ cd /root/OFC_SC472/netconf/connection
Expand Down
5 changes: 5 additions & 0 deletions grpc/connection/connection.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@

%
conn2node2node1"portB*portA0


conn3ab"1*20d

con4fb"2*30o
30 changes: 15 additions & 15 deletions grpc/connection/connection_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion grpc/connection/create.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python3
import connection_pb2
import sys

Expand Down
4 changes: 2 additions & 2 deletions grpc/connection/list.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python3
from __future__ import print_function
import connection_pb2
import sys
Expand Down Expand Up @@ -30,4 +30,4 @@ def ListConnections(connectionList):
with open(sys.argv[1], "rb") as f:
connectionList.ParseFromString(f.read())

ListConnections(connectionList)
ListConnections(connectionList)
4 changes: 2 additions & 2 deletions restconf/connection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ paths:
description: "Internal error"
409:
description: "Object already exists"
/data/connection={connectionid}/:
/data/connection={connection-id}/:
get:
tags:
- "connection"
description: "returns connection.Connection"
parameters:
- name: "connectionid"
- name: "connection-id"
in: "path"
description: "Id of connection"
required: true
Expand Down
72 changes: 72 additions & 0 deletions restconf/connectionserver/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
.travis.yaml
.swagger-codegen-ignore
README.md
tox.ini
git_push.sh
test-requirements.txt
setup.py

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
venv/
.python-version

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

#Ipython Notebook
.ipynb_checkpoints
Loading

0 comments on commit df3af55

Please sign in to comment.