From 31bccb96650b7ea6c8477aefd339055a45f517c5 Mon Sep 17 00:00:00 2001 From: eabasan Date: Mon, 9 Jan 2017 09:08:17 +0100 Subject: [PATCH] Modified JSON files in resources to adapt them to deprecated fields in Service Functions Added one configuration example using bidirectional field in SF type Change-Id: I10d872873f6a1f56855788f159b5ac31ac8cf797 Signed-off-by: eabasan --- resources/configuration-examples/README.md | 1 + .../json/02-service_functions.json | 2 - .../json/04-service_function_chains.json | 2 - .../json/08-rendered_service_path_1.json | 3 +- .../json/09-rendered_service_path_2.json | 3 +- .../logical-sff.postman_collection.json | 10 +- .../sfc103/json/02-service_functions.json | 2 - .../json/04-service_function_chains.json | 2 - .../sfc103/json/08-rendered_service_path.json | 3 +- .../sfc103/sfc103.postman_collection.json | 10 +- .../simple/json/02-service_functions.json | 1 - .../json/04-service_function_chains.json | 1 - .../simple/json/08-rendered_service_path.json | 3 +- .../simple/simple.postman_collection.json | 10 +- .../symmetricRSPs/cleanup.py | 94 ++++++++++++ .../symmetricRSPs/json/01-service_nodes.json | 44 ++++++ .../json/02a-service_function_types.json | 11 ++ .../json/02b-service_functions.json | 36 +++++ .../json/03-service_function_forwarders.json | 136 ++++++++++++++++++ .../json/04-service_function_chains.json | 28 ++++ .../json/05-service_function_metadata.json | 13 ++ .../json/06-service_function_paths.json | 30 ++++ .../json/07-service_function_acls.json | 56 ++++++++ .../json/08-rendered_service_path.json | 6 + .../json/09-service_function_classifiers.json | 32 +++++ .../symmetricRSPs/setup.py | 124 ++++++++++++++++ 26 files changed, 630 insertions(+), 33 deletions(-) create mode 100755 resources/configuration-examples/symmetricRSPs/cleanup.py create mode 100644 resources/configuration-examples/symmetricRSPs/json/01-service_nodes.json create mode 100644 resources/configuration-examples/symmetricRSPs/json/02a-service_function_types.json create mode 100644 resources/configuration-examples/symmetricRSPs/json/02b-service_functions.json create mode 100644 resources/configuration-examples/symmetricRSPs/json/03-service_function_forwarders.json create mode 100644 resources/configuration-examples/symmetricRSPs/json/04-service_function_chains.json create mode 100644 resources/configuration-examples/symmetricRSPs/json/05-service_function_metadata.json create mode 100644 resources/configuration-examples/symmetricRSPs/json/06-service_function_paths.json create mode 100644 resources/configuration-examples/symmetricRSPs/json/07-service_function_acls.json create mode 100644 resources/configuration-examples/symmetricRSPs/json/08-rendered_service_path.json create mode 100644 resources/configuration-examples/symmetricRSPs/json/09-service_function_classifiers.json create mode 100755 resources/configuration-examples/symmetricRSPs/setup.py diff --git a/resources/configuration-examples/README.md b/resources/configuration-examples/README.md index f7fcb3462..d665f4e65 100644 --- a/resources/configuration-examples/README.md +++ b/resources/configuration-examples/README.md @@ -7,4 +7,5 @@ Content simple - basic configuration of SFC sfc103 - the same configuration used for sfc-demo/sfc103 logical-sff - configuration used for logical SFF +symmetricRSPs - configuration with SF bidirectional field ``` diff --git a/resources/configuration-examples/logical-sff/json/02-service_functions.json b/resources/configuration-examples/logical-sff/json/02-service_functions.json index 9e82e0986..4b0ba41c9 100644 --- a/resources/configuration-examples/logical-sff/json/02-service_functions.json +++ b/resources/configuration-examples/logical-sff/json/02-service_functions.json @@ -4,7 +4,6 @@ { "name": "firewall-1", "type": "firewall", - "nsh-aware": "true", "sf-data-plane-locator": [ { "name": "firewall-dpl", @@ -17,7 +16,6 @@ { "name": "dpi-1", "type": "dpi", - "nsh-aware": "true", "sf-data-plane-locator": [ { "name": "dpi-dpl", diff --git a/resources/configuration-examples/logical-sff/json/04-service_function_chains.json b/resources/configuration-examples/logical-sff/json/04-service_function_chains.json index d3f2de65f..1152de13a 100644 --- a/resources/configuration-examples/logical-sff/json/04-service_function_chains.json +++ b/resources/configuration-examples/logical-sff/json/04-service_function_chains.json @@ -3,7 +3,6 @@ "service-function-chain": [ { "name": "SFC1", - "symmetric": "true", "sfc-service-function": [ { "name": "dpi-abstract1", @@ -17,7 +16,6 @@ }, { "name": "SFC2", - "symmetric": "true", "sfc-service-function": [ { "name": "dpi-abstract1", diff --git a/resources/configuration-examples/logical-sff/json/08-rendered_service_path_1.json b/resources/configuration-examples/logical-sff/json/08-rendered_service_path_1.json index d962f519b..bf379b6a2 100644 --- a/resources/configuration-examples/logical-sff/json/08-rendered_service_path_1.json +++ b/resources/configuration-examples/logical-sff/json/08-rendered_service_path_1.json @@ -1,7 +1,6 @@ { "input": { "name": "RSP1", - "parent-service-function-path": "SFP1", - "symmetric": "true" + "parent-service-function-path": "SFP1" } } diff --git a/resources/configuration-examples/logical-sff/json/09-rendered_service_path_2.json b/resources/configuration-examples/logical-sff/json/09-rendered_service_path_2.json index 8b40707f7..d0df54909 100644 --- a/resources/configuration-examples/logical-sff/json/09-rendered_service_path_2.json +++ b/resources/configuration-examples/logical-sff/json/09-rendered_service_path_2.json @@ -1,7 +1,6 @@ { "input": { "name": "RSP2", - "parent-service-function-path": "SFP2", - "symmetric": "true" + "parent-service-function-path": "SFP2" } } diff --git a/resources/configuration-examples/logical-sff/logical-sff.postman_collection.json b/resources/configuration-examples/logical-sff/logical-sff.postman_collection.json index 0281cdc03..b4068d3c9 100644 --- a/resources/configuration-examples/logical-sff/logical-sff.postman_collection.json +++ b/resources/configuration-examples/logical-sff/logical-sff.postman_collection.json @@ -113,7 +113,7 @@ "name": "02-configure-service_functions", "dataMode": "raw", "data": [], - "rawModeData": "{\n \"service-functions\": {\n \"service-function\": [\n {\n \"name\": \"firewall-1\",\n \"type\": \"firewall\",\n \"nsh-aware\": \"true\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"firewall-dpl\",\n \"interface-name\": \"eccb57ae-5a2e-467f-823e-45d7bb2a6a9a\",\n \"transport\": \"service-locator:eth-nsh\",\n \"service-function-forwarder\": \"sfflogical1\"\n }\n ]\n },\n {\n \"name\": \"dpi-1\",\n \"type\": \"dpi\",\n \"nsh-aware\": \"true\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"dpi-dpl\",\n \"interface-name\": \"df15ac52-e8ef-4e9a-8340-ae0738aba0c0\",\n \"transport\": \"service-locator:eth-nsh\",\n \"service-function-forwarder\": \"sfflogical1\"\n }\n ]\n }\n ]\n }\n}", + "rawModeData": "{\n \"service-functions\": {\n \"service-function\": [\n {\n \"name\": \"firewall-1\",\n \"type\": \"firewall\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"firewall-dpl\",\n \"interface-name\": \"eccb57ae-5a2e-467f-823e-45d7bb2a6a9a\",\n \"transport\": \"service-locator:eth-nsh\",\n \"service-function-forwarder\": \"sfflogical1\"\n }\n ]\n },\n {\n \"name\": \"dpi-1\",\n \"type\": \"dpi\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"dpi-dpl\",\n \"interface-name\": \"df15ac52-e8ef-4e9a-8340-ae0738aba0c0\",\n \"transport\": \"service-locator:eth-nsh\",\n \"service-function-forwarder\": \"sfflogical1\"\n }\n ]\n }\n ]\n }\n}", "descriptionFormat": null, "description": "Configurarion of Service Functions", "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", @@ -164,7 +164,7 @@ "description": "Configuration of Service Function Chains", "collectionId": "22d0d04f-5c1b-0ab4-b3b2-52185dac189d", "responses": [], - "rawModeData": "{\n \"service-function-chains\": {\n \"service-function-chain\": [\n {\n \"name\": \"SFC1\",\n \"symmetric\": \"true\",\n \"sfc-service-function\": [\n {\n \"name\": \"dpi-abstract1\",\n \"type\": \"dpi\"\n },\n {\n \"name\": \"firewall-abstract1\",\n \"type\": \"firewall\"\n }\n ]\n },\n {\n \"name\": \"SFC2\",\n \"symmetric\": \"true\",\n \"sfc-service-function\": [\n {\n \"name\": \"dpi-abstract1\",\n \"type\": \"dpi\"\n }\n ]\n }\n ]\n }\n}" + "rawModeData": "{\n \"service-function-chains\": {\n \"service-function-chain\": [\n {\n \"name\": \"SFC1\",\n \"sfc-service-function\": [\n {\n \"name\": \"dpi-abstract1\",\n \"type\": \"dpi\"\n },\n {\n \"name\": \"firewall-abstract1\",\n \"type\": \"firewall\"\n }\n ]\n },\n {\n \"name\": \"SFC2\",\n \"sfc-service-function\": [\n {\n \"name\": \"dpi-abstract1\",\n \"type\": \"dpi\"\n }\n ]\n }\n ]\n }\n}" }, { "folder": "b79c3d5e-39d5-1474-0433-492745ee3b4f", @@ -212,7 +212,7 @@ "name": "get-service_functions", "dataMode": "raw", "data": [], - "rawModeData": "{\n \"service-functions\": {\n \"service-function\": [\n {\n \"name\": \"dpi-1\",\n \"ip-mgmt-address\": \"192.168.1.30\",\n \"rest-uri\": \"http://192.168.1.30:5000\",\n \"type\": \"dpi\",\n \"nsh-aware\": \"true\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"dpi-1-dpl\",\n \"port\": 6633,\n \"ip\": \"192.168.1.30\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"SFF1\"\n }\n ]\n },\n {\n \"name\": \"firewall-1\",\n \"ip-mgmt-address\": \"192.168.1.40\",\n \"rest-uri\": \"http://192.168.1.40:5000\",\n \"type\": \"firewall\",\n \"nsh-aware\": \"true\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"firewall-1-dpl\",\n \"port\": 6633,\n \"ip\": \"192.168.1.40\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"SFF2\"\n }\n ]\n }\n ]\n }\n}", + "rawModeData": "{\n \"service-functions\": {\n \"service-function\": [\n {\n \"name\": \"dpi-1\",\n \"ip-mgmt-address\": \"192.168.1.30\",\n \"rest-uri\": \"http://192.168.1.30:5000\",\n \"type\": \"dpi\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"dpi-1-dpl\",\n \"port\": 6633,\n \"ip\": \"192.168.1.30\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"SFF1\"\n }\n ]\n },\n {\n \"name\": \"firewall-1\",\n \"ip-mgmt-address\": \"192.168.1.40\",\n \"rest-uri\": \"http://192.168.1.40:5000\",\n \"type\": \"firewall\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"firewall-1-dpl\",\n \"port\": 6633,\n \"ip\": \"192.168.1.40\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"SFF2\"\n }\n ]\n }\n ]\n }\n}", "descriptionFormat": null, "description": "Shows the configured Service Functions", "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", @@ -283,7 +283,7 @@ "description": "Get the configured Service Function Chains", "collectionId": "22d0d04f-5c1b-0ab4-b3b2-52185dac189d", "responses": [], - "rawModeData": "{\n \"service-function-chains\": {\n \"service-function-chain\": [\n {\n \"name\": \"SFC1\",\n \"symmetric\": \"true\",\n \"sfc-service-function\": [\n {\n \"name\": \"dpi-abstract1\",\n \"type\": \"dpi\"\n },\n {\n \"name\": \"firewall-abstract1\",\n \"type\": \"firewall\"\n }\n ]\n },\n {\n \"name\": \"SFC2\",\n \"symmetric\": \"true\",\n \"sfc-service-function\": [\n {\n \"name\": \"dpi-abstract1\",\n \"type\": \"dpi\"\n }\n ]\n }\n ]\n }\n}" + "rawModeData": "{\n \"service-function-chains\": {\n \"service-function-chain\": [\n {\n \"name\": \"SFC1\",\n \"sfc-service-function\": [\n {\n \"name\": \"dpi-abstract1\",\n \"type\": \"dpi\"\n },\n {\n \"name\": \"firewall-abstract1\",\n \"type\": \"firewall\"\n }\n ]\n },\n {\n \"name\": \"SFC2\",\n \"sfc-service-function\": [\n {\n \"name\": \"dpi-abstract1\",\n \"type\": \"dpi\"\n }\n ]\n }\n ]\n }\n}" }, { "folder": "1bbae1f7-1ffc-e38b-c4d5-a0038424a70f", @@ -291,7 +291,7 @@ "name": "08-rendered_service_path_1", "dataMode": "raw", "data": [], - "rawModeData": "{\n \"input\": {\n \"name\": \"RSP1\",\n \"parent-service-function-path\": \"SFP1\",\n \"symmetric\": \"true\"\n }\n}\n", + "rawModeData": "{\n \"input\": {\n \"name\": \"RSP1\",\n \"parent-service-function-path\": \"SFP1\"\n }\n}\n", "descriptionFormat": null, "description": "Emulation of RSP 1 creation in Operational data model", "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", diff --git a/resources/configuration-examples/sfc103/json/02-service_functions.json b/resources/configuration-examples/sfc103/json/02-service_functions.json index d1c7228e5..8cf451e6b 100644 --- a/resources/configuration-examples/sfc103/json/02-service_functions.json +++ b/resources/configuration-examples/sfc103/json/02-service_functions.json @@ -6,7 +6,6 @@ "ip-mgmt-address": "192.168.1.30", "rest-uri": "http://192.168.1.30:5000", "type": "dpi", - "nsh-aware": "true", "sf-data-plane-locator": [ { "name": "dpi-1-dpl", @@ -22,7 +21,6 @@ "ip-mgmt-address": "192.168.1.40", "rest-uri": "http://192.168.1.40:5000", "type": "firewall", - "nsh-aware": "true", "sf-data-plane-locator": [ { "name": "firewall-1-dpl", diff --git a/resources/configuration-examples/sfc103/json/04-service_function_chains.json b/resources/configuration-examples/sfc103/json/04-service_function_chains.json index d3f2de65f..1152de13a 100644 --- a/resources/configuration-examples/sfc103/json/04-service_function_chains.json +++ b/resources/configuration-examples/sfc103/json/04-service_function_chains.json @@ -3,7 +3,6 @@ "service-function-chain": [ { "name": "SFC1", - "symmetric": "true", "sfc-service-function": [ { "name": "dpi-abstract1", @@ -17,7 +16,6 @@ }, { "name": "SFC2", - "symmetric": "true", "sfc-service-function": [ { "name": "dpi-abstract1", diff --git a/resources/configuration-examples/sfc103/json/08-rendered_service_path.json b/resources/configuration-examples/sfc103/json/08-rendered_service_path.json index d962f519b..bf379b6a2 100644 --- a/resources/configuration-examples/sfc103/json/08-rendered_service_path.json +++ b/resources/configuration-examples/sfc103/json/08-rendered_service_path.json @@ -1,7 +1,6 @@ { "input": { "name": "RSP1", - "parent-service-function-path": "SFP1", - "symmetric": "true" + "parent-service-function-path": "SFP1" } } diff --git a/resources/configuration-examples/sfc103/sfc103.postman_collection.json b/resources/configuration-examples/sfc103/sfc103.postman_collection.json index a00d11f8c..1671618b4 100644 --- a/resources/configuration-examples/sfc103/sfc103.postman_collection.json +++ b/resources/configuration-examples/sfc103/sfc103.postman_collection.json @@ -55,7 +55,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"service-functions\": {\n \"service-function\": [\n {\n \"name\": \"dpi-1\",\n \"ip-mgmt-address\": \"192.168.1.30\",\n \"rest-uri\": \"http://192.168.1.30:5000\",\n \"type\": \"dpi\",\n \"nsh-aware\": \"true\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"dpi-1-dpl\",\n \"port\": 6633,\n \"ip\": \"192.168.1.30\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"SFF1\"\n }\n ]\n },\n {\n \"name\": \"firewall-1\",\n \"ip-mgmt-address\": \"192.168.1.40\",\n \"rest-uri\": \"http://192.168.1.40:5000\",\n \"type\": \"firewall\",\n \"nsh-aware\": \"true\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"firewall-1-dpl\",\n \"port\": 6633,\n \"ip\": \"192.168.1.40\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"SFF2\"\n }\n ]\n }\n ]\n }\n}" + "raw": "{\n \"service-functions\": {\n \"service-function\": [\n {\n \"name\": \"dpi-1\",\n \"ip-mgmt-address\": \"192.168.1.30\",\n \"rest-uri\": \"http://192.168.1.30:5000\",\n \"type\": \"dpi\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"dpi-1-dpl\",\n \"port\": 6633,\n \"ip\": \"192.168.1.30\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"SFF1\"\n }\n ]\n },\n {\n \"name\": \"firewall-1\",\n \"ip-mgmt-address\": \"192.168.1.40\",\n \"rest-uri\": \"http://192.168.1.40:5000\",\n \"type\": \"firewall\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"firewall-1-dpl\",\n \"port\": 6633,\n \"ip\": \"192.168.1.40\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"SFF2\"\n }\n ]\n }\n ]\n }\n}" }, "description": "Configurarion of Service Functions" }, @@ -105,7 +105,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"service-function-chains\": {\n \"service-function-chain\": [\n {\n \"name\": \"SFC1\",\n \"symmetric\": \"true\",\n \"sfc-service-function\": [\n {\n \"name\": \"dpi-abstract1\",\n \"type\": \"dpi\"\n },\n {\n \"name\": \"firewall-abstract1\",\n \"type\": \"firewall\"\n }\n ]\n },\n {\n \"name\": \"SFC2\",\n \"symmetric\": \"true\",\n \"sfc-service-function\": [\n {\n \"name\": \"dpi-abstract1\",\n \"type\": \"dpi\"\n }\n ]\n }\n ]\n }\n}" + "raw": "{\n \"service-function-chains\": {\n \"service-function-chain\": [\n {\n \"name\": \"SFC1\",\n \"sfc-service-function\": [\n {\n \"name\": \"dpi-abstract1\",\n \"type\": \"dpi\"\n },\n {\n \"name\": \"firewall-abstract1\",\n \"type\": \"firewall\"\n }\n ]\n },\n {\n \"name\": \"SFC2\",\n \"sfc-service-function\": [\n {\n \"name\": \"dpi-abstract1\",\n \"type\": \"dpi\"\n }\n ]\n }\n ]\n }\n}" }, "description": "Configuration of Service Function Chains" }, @@ -205,7 +205,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"input\": {\n \"name\": \"RSP1\",\n \"parent-service-function-path\": \"SFP1\",\n \"symmetric\": \"true\"\n }\n}" + "raw": "{\n \"input\": {\n \"name\": \"RSP1\",\n \"parent-service-function-path\": \"SFP1\"\n }\n}" }, "description": "Emulation of RSP creation in Operational data model" }, @@ -261,7 +261,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"service-functions\": {\n \"service-function\": [\n {\n \"name\": \"dpi-1\",\n \"ip-mgmt-address\": \"192.168.1.30\",\n \"rest-uri\": \"http://192.168.1.30:5000\",\n \"type\": \"dpi\",\n \"nsh-aware\": \"true\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"dpi-1-dpl\",\n \"port\": 6633,\n \"ip\": \"192.168.1.30\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"SFF1\"\n }\n ]\n },\n {\n \"name\": \"firewall-1\",\n \"ip-mgmt-address\": \"192.168.1.40\",\n \"rest-uri\": \"http://192.168.1.40:5000\",\n \"type\": \"firewall\",\n \"nsh-aware\": \"true\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"firewall-1-dpl\",\n \"port\": 6633,\n \"ip\": \"192.168.1.40\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"SFF2\"\n }\n ]\n }\n ]\n }\n}" + "raw": "{\n \"service-functions\": {\n \"service-function\": [\n {\n \"name\": \"dpi-1\",\n \"ip-mgmt-address\": \"192.168.1.30\",\n \"rest-uri\": \"http://192.168.1.30:5000\",\n \"type\": \"dpi\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"dpi-1-dpl\",\n \"port\": 6633,\n \"ip\": \"192.168.1.30\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"SFF1\"\n }\n ]\n },\n {\n \"name\": \"firewall-1\",\n \"ip-mgmt-address\": \"192.168.1.40\",\n \"rest-uri\": \"http://192.168.1.40:5000\",\n \"type\": \"firewall\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"firewall-1-dpl\",\n \"port\": 6633,\n \"ip\": \"192.168.1.40\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"SFF2\"\n }\n ]\n }\n ]\n }\n}" }, "description": "Shows the configured Service Functions" }, @@ -286,7 +286,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"service-function-chains\": {\n \"service-function-chain\": [\n {\n \"name\": \"SFC1\",\n \"symmetric\": \"true\",\n \"sfc-service-function\": [\n {\n \"name\": \"dpi-abstract1\",\n \"type\": \"dpi\"\n },\n {\n \"name\": \"firewall-abstract1\",\n \"type\": \"firewall\"\n }\n ]\n },\n {\n \"name\": \"SFC2\",\n \"symmetric\": \"true\",\n \"sfc-service-function\": [\n {\n \"name\": \"dpi-abstract1\",\n \"type\": \"dpi\"\n }\n ]\n }\n ]\n }\n}" + "raw": "{\n \"service-function-chains\": {\n \"service-function-chain\": [\n {\n \"name\": \"SFC1\",\n \"sfc-service-function\": [\n {\n \"name\": \"dpi-abstract1\",\n \"type\": \"dpi\"\n },\n {\n \"name\": \"firewall-abstract1\",\n \"type\": \"firewall\"\n }\n ]\n },\n {\n \"name\": \"SFC2\",\n \"sfc-service-function\": [\n {\n \"name\": \"dpi-abstract1\",\n \"type\": \"dpi\"\n }\n ]\n }\n ]\n }\n}" }, "description": "Get the configured Service Function Chains" }, diff --git a/resources/configuration-examples/simple/json/02-service_functions.json b/resources/configuration-examples/simple/json/02-service_functions.json index 3cd85c048..c35c4ce6b 100644 --- a/resources/configuration-examples/simple/json/02-service_functions.json +++ b/resources/configuration-examples/simple/json/02-service_functions.json @@ -4,7 +4,6 @@ { "name": "sf1", "type": "http-header-enrichment", - "nsh-aware": true, "ip-mgmt-address": "10.0.0.10", "sf-data-plane-locator": [ { diff --git a/resources/configuration-examples/simple/json/04-service_function_chains.json b/resources/configuration-examples/simple/json/04-service_function_chains.json index cc36cf859..a46915d60 100644 --- a/resources/configuration-examples/simple/json/04-service_function_chains.json +++ b/resources/configuration-examples/simple/json/04-service_function_chains.json @@ -3,7 +3,6 @@ "service-function-chain": [ { "name": "sfc-chain-1sf1sff", - "symmetric": true, "sfc-service-function": [ { "name": "hdr-enrich-abstract1", diff --git a/resources/configuration-examples/simple/json/08-rendered_service_path.json b/resources/configuration-examples/simple/json/08-rendered_service_path.json index a54c8ac9d..0b7d4a591 100644 --- a/resources/configuration-examples/simple/json/08-rendered_service_path.json +++ b/resources/configuration-examples/simple/json/08-rendered_service_path.json @@ -1,7 +1,6 @@ { "input": { "name": "sfc-path-1sf1sff", - "parent-service-function-path": "sfc-path-1sf1sff", - "symmetric": true + "parent-service-function-path": "sfc-path-1sf1sff" } } diff --git a/resources/configuration-examples/simple/simple.postman_collection.json b/resources/configuration-examples/simple/simple.postman_collection.json index 670ab578f..a7bef6bf7 100644 --- a/resources/configuration-examples/simple/simple.postman_collection.json +++ b/resources/configuration-examples/simple/simple.postman_collection.json @@ -30,7 +30,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"service-functions\": {\n \"service-function\": [\n {\n \"name\": \"sf1\",\n \"type\": \"http-header-enrichment\",\n \"nsh-aware\": true,\n \"ip-mgmt-address\": \"10.0.0.10\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"sff1\",\n \"ip\": \"10.0.0.10\",\n \"port\": 6633,\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"sff1\",\n \"service-function-ovs:ovs-port\" : {\"port-id\" : \"veth1\"}\n }\n ]\n }\n ]\n }\n}" + "raw": "{\n \"service-functions\": {\n \"service-function\": [\n {\n \"name\": \"sf1\",\n \"type\": \"http-header-enrichment\",\n \"ip-mgmt-address\": \"10.0.0.10\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"sff1\",\n \"ip\": \"10.0.0.10\",\n \"port\": 6633,\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"sff1\",\n \"service-function-ovs:ovs-port\" : {\"port-id\" : \"veth1\"}\n }\n ]\n }\n ]\n }\n}" }, "description": "Configurarion of Service Functions" }, @@ -80,7 +80,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"service-function-chains\": {\n \"service-function-chain\": [\n {\n \"name\": \"sfc-chain-1sf1sff\",\n \"symmetric\": true,\n \"sfc-service-function\": [\n {\n \"name\": \"hdr-enrich-abstract1\",\n \"type\": \"http-header-enrichment\"\n }\n ]\n }\n \n ]\n }\n}" + "raw": "{\n \"service-function-chains\": {\n \"service-function-chain\": [\n {\n \"name\": \"sfc-chain-1sf1sff\",\n \"sfc-service-function\": [\n {\n \"name\": \"hdr-enrich-abstract1\",\n \"type\": \"http-header-enrichment\"\n }\n ]\n }\n \n ]\n }\n}" }, "description": "Configuration of Service Function Chains" }, @@ -130,7 +130,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"input\": {\n \"name\": \"sfc-path-1sf1sff\",\n \"parent-service-function-path\": \"sfc-path-1sf1sff\",\n \"symmetric\": true\n }\n}" + "raw": "{\n \"input\": {\n \"name\": \"sfc-path-1sf1sff\",\n \"parent-service-function-path\": \"sfc-path-1sf1sff\"\n }\n}" }, "description": "Emulation of RSP creation in Operational data model" }, @@ -161,7 +161,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"service-functions\": {\n \"service-function\": [\n {\n \"name\": \"dpi-1\",\n \"ip-mgmt-address\": \"192.168.1.30\",\n \"rest-uri\": \"http://192.168.1.30:5000\",\n \"type\": \"dpi\",\n \"nsh-aware\": \"true\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"dpi-1-dpl\",\n \"port\": 6633,\n \"ip\": \"192.168.1.30\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"SFF1\"\n }\n ]\n },\n {\n \"name\": \"firewall-1\",\n \"ip-mgmt-address\": \"192.168.1.40\",\n \"rest-uri\": \"http://192.168.1.40:5000\",\n \"type\": \"firewall\",\n \"nsh-aware\": \"true\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"firewall-1-dpl\",\n \"port\": 6633,\n \"ip\": \"192.168.1.40\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"SFF2\"\n }\n ]\n }\n ]\n }\n}" + "raw": "{\n \"service-functions\": {\n \"service-function\": [\n {\n \"name\": \"dpi-1\",\n \"ip-mgmt-address\": \"192.168.1.30\",\n \"rest-uri\": \"http://192.168.1.30:5000\",\n \"type\": \"dpi\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"dpi-1-dpl\",\n \"port\": 6633,\n \"ip\": \"192.168.1.30\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"SFF1\"\n }\n ]\n },\n {\n \"name\": \"firewall-1\",\n \"ip-mgmt-address\": \"192.168.1.40\",\n \"rest-uri\": \"http://192.168.1.40:5000\",\n \"type\": \"firewall\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"firewall-1-dpl\",\n \"port\": 6633,\n \"ip\": \"192.168.1.40\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"SFF2\"\n }\n ]\n }\n ]\n }\n}" }, "description": "Shows the configured Service Functions" }, @@ -186,7 +186,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"service-function-chains\": {\n \"service-function-chain\": [\n {\n \"name\": \"SFC1\",\n \"symmetric\": \"true\",\n \"sfc-service-function\": [\n {\n \"name\": \"dpi-abstract1\",\n \"type\": \"dpi\"\n },\n {\n \"name\": \"firewall-abstract1\",\n \"type\": \"firewall\"\n }\n ]\n },\n {\n \"name\": \"SFC2\",\n \"symmetric\": \"true\",\n \"sfc-service-function\": [\n {\n \"name\": \"dpi-abstract1\",\n \"type\": \"dpi\"\n }\n ]\n }\n ]\n }\n}" + "raw": "{\n \"service-function-chains\": {\n \"service-function-chain\": [\n {\n \"name\": \"SFC1\",\n \"sfc-service-function\": [\n {\n \"name\": \"dpi-abstract1\",\n \"type\": \"dpi\"\n },\n {\n \"name\": \"firewall-abstract1\",\n \"type\": \"firewall\"\n }\n ]\n },\n {\n \"name\": \"SFC2\",\n \"sfc-service-function\": [\n {\n \"name\": \"dpi-abstract1\",\n \"type\": \"dpi\"\n }\n ]\n }\n ]\n }\n}" }, "description": "Get the configured Service Function Chains" }, diff --git a/resources/configuration-examples/symmetricRSPs/cleanup.py b/resources/configuration-examples/symmetricRSPs/cleanup.py new file mode 100755 index 000000000..446df6943 --- /dev/null +++ b/resources/configuration-examples/symmetricRSPs/cleanup.py @@ -0,0 +1,94 @@ +#!/usr/bin/python +import argparse +import requests,json +from requests.auth import HTTPBasicAuth +from subprocess import call +import time +import sys +import os + +controller='192.168.56.102' +DEFAULT_PORT='8181' + + +USERNAME='admin' +PASSWORD='admin' + +def delete(host, port, uri): + url='http://'+host+":"+port+uri + r = requests.delete(url, auth=HTTPBasicAuth(USERNAME, PASSWORD)) + #r.raise_for_status() + +def get_service_nodes_uri(): + return "/restconf/config/service-node:service-nodes" + +def get_service_function_types_uri(): + return "/restconf/config/service-function-type:service-function-types" + +def get_service_functions_uri(): + return "/restconf/config/service-function:service-functions" + +def get_service_function_forwarders_uri(): + return "/restconf/config/service-function-forwarder:service-function-forwarders" + +def get_service_function_chains_uri(): + return "/restconf/config/service-function-chain:service-function-chains/" + +def get_service_function_paths_uri(): + return "/restconf/config/service-function-path:service-function-paths/" + +def get_service_function_metadata_uri(): + return "/restconf/config/service-function-path-metadata:service-function-metadata/" + +def get_service_function_paths_uri(): + return "/restconf/config/service-function-path:service-function-paths/" + +def get_rendered_service_path_uri(): + return "/restconf/operations/rendered-service-path:create-rendered-path/" + +def get_service_function_acl_uri(): + return "/restconf/config/ietf-access-control-list:access-lists/" + +def get_service_function_classifiers_uri(): + return "/restconf/config/service-function-classifier:service-function-classifiers/" + +if __name__ == "__main__": + + print "deleting service function classifiers" + delete(controller, DEFAULT_PORT, get_service_function_classifiers_uri()) + time.sleep(.5) + + print "deleting rendered service path" + delete(controller, DEFAULT_PORT, get_rendered_service_path_uri()) + time.sleep(.5) + + print "deleting service function acl" + delete(controller, DEFAULT_PORT, get_service_function_acl_uri()) + time.sleep(.5) + + print "deleting service function paths" + delete(controller, DEFAULT_PORT, get_service_function_paths_uri()) + time.sleep(.5) + + print "deleting service function metadata" + delete(controller, DEFAULT_PORT, get_service_function_metadata_uri()) + time.sleep(.5) + + print "deleting service function chains" + delete(controller, DEFAULT_PORT, get_service_function_chains_uri()) + time.sleep(.5) + + print "deleting service function forwarders" + delete(controller, DEFAULT_PORT, get_service_function_forwarders_uri()) + time.sleep(.5) + + print "deleting service functions" + delete(controller, DEFAULT_PORT, get_service_functions_uri()) + time.sleep(.5) + + print "deleting service function types" + delete(controller, DEFAULT_PORT, get_service_function_types_uri()) + time.sleep(.5) + + print "deleting service nodes" + delete(controller, DEFAULT_PORT, get_service_nodes_uri()) diff --git a/resources/configuration-examples/symmetricRSPs/json/01-service_nodes.json b/resources/configuration-examples/symmetricRSPs/json/01-service_nodes.json new file mode 100644 index 000000000..8ba4ed508 --- /dev/null +++ b/resources/configuration-examples/symmetricRSPs/json/01-service_nodes.json @@ -0,0 +1,44 @@ +{ + "service-nodes": { + "service-node": [ + { + "name": "classifier1", + "service-function": [ + ], + "ip-mgmt-address": "192.168.1.10" + }, + { + "name": "sff1", + "service-function": [ + ], + "ip-mgmt-address": "192.168.1.20" + }, + { + "name": "sf1", + "service-function": [ + "dpi-1" + ], + "ip-mgmt-address": "192.168.1.30" + }, + { + "name": "sf2", + "service-function": [ + "firewall-1" + ], + "ip-mgmt-address": "192.168.1.40" + }, + { + "name": "sff2", + "service-function": [ + ], + "ip-mgmt-address": "192.168.1.50" + }, + { + "name": "classifier2", + "service-function": [ + ], + "ip-mgmt-address": "192.168.1.60" + } + ] + } +} diff --git a/resources/configuration-examples/symmetricRSPs/json/02a-service_function_types.json b/resources/configuration-examples/symmetricRSPs/json/02a-service_function_types.json new file mode 100644 index 000000000..43d0cc385 --- /dev/null +++ b/resources/configuration-examples/symmetricRSPs/json/02a-service_function_types.json @@ -0,0 +1,11 @@ +{ + "service-function-types": { + "service-function-type": [ + { + "type": "dpi", + "bidirectional": "true", + "nsh-aware": "true" + } + ] + } +} diff --git a/resources/configuration-examples/symmetricRSPs/json/02b-service_functions.json b/resources/configuration-examples/symmetricRSPs/json/02b-service_functions.json new file mode 100644 index 000000000..8cf451e6b --- /dev/null +++ b/resources/configuration-examples/symmetricRSPs/json/02b-service_functions.json @@ -0,0 +1,36 @@ +{ + "service-functions": { + "service-function": [ + { + "name": "dpi-1", + "ip-mgmt-address": "192.168.1.30", + "rest-uri": "http://192.168.1.30:5000", + "type": "dpi", + "sf-data-plane-locator": [ + { + "name": "dpi-1-dpl", + "port": 6633, + "ip": "192.168.1.30", + "transport": "service-locator:vxlan-gpe", + "service-function-forwarder": "SFF1" + } + ] + }, + { + "name": "firewall-1", + "ip-mgmt-address": "192.168.1.40", + "rest-uri": "http://192.168.1.40:5000", + "type": "firewall", + "sf-data-plane-locator": [ + { + "name": "firewall-1-dpl", + "port": 6633, + "ip": "192.168.1.40", + "transport": "service-locator:vxlan-gpe", + "service-function-forwarder": "SFF2" + } + ] + } + ] + } +} diff --git a/resources/configuration-examples/symmetricRSPs/json/03-service_function_forwarders.json b/resources/configuration-examples/symmetricRSPs/json/03-service_function_forwarders.json new file mode 100644 index 000000000..f8ade963e --- /dev/null +++ b/resources/configuration-examples/symmetricRSPs/json/03-service_function_forwarders.json @@ -0,0 +1,136 @@ +{ + "service-function-forwarders": { + "service-function-forwarder": [ + { + "name": "Classifier1", + "service-node": "classifier1", + "service-function-forwarder-ovs:ovs-bridge": { + "bridge-name": "br-sfc" + }, + "sff-data-plane-locator": [ + { + "name": "sff0-dpl", + "data-plane-locator": { + "transport": "service-locator:vxlan-gpe", + "port": 6633, + "ip": "192.168.1.10" + }, + "service-function-forwarder-ovs:ovs-options": { + "remote-ip": "flow", + "dst-port": "6633", + "key": "flow", + "nsp": "flow", + "nsi": "flow", + "nshc1": "flow", + "nshc2": "flow", + "nshc3": "flow", + "nshc4": "flow" + } + } + ] + }, + { + "name": "SFF1", + "service-node": "sff1", + "service-function-forwarder-ovs:ovs-bridge": { + "bridge-name": "br-sfc" + }, + "sff-data-plane-locator": [ + { + "name": "sff1-dpl", + "data-plane-locator": { + "transport": "service-locator:vxlan-gpe", + "port": 6633, + "ip": "192.168.1.20" + }, + "service-function-forwarder-ovs:ovs-options": { + "remote-ip": "flow", + "dst-port": "6633", + "key": "flow", + "nsp": "flow", + "nsi": "flow", + "nshc1": "flow", + "nshc2": "flow", + "nshc3": "flow", + "nshc4": "flow" + } + } + ], + "service-function-dictionary": [ + { + "name": "dpi-1", + "sff-sf-data-plane-locator": { + "sf-dpl-name": "dpi-1-dpl", + "sff-dpl-name": "sff1-dpl" + } + } + ] + }, + { + "name": "SFF2", + "service-node": "sff2", + "service-function-forwarder-ovs:ovs-bridge": { + "bridge-name": "br-sfc" + }, + "sff-data-plane-locator": [ + { + "name": "sff2-dpl", + "data-plane-locator": { + "transport": "service-locator:vxlan-gpe", + "port": 6633, + "ip": "192.168.1.50" + }, + "service-function-forwarder-ovs:ovs-options": { + "remote-ip": "flow", + "dst-port": "6633", + "key": "flow", + "nsp": "flow", + "nsi": "flow", + "nshc1": "flow", + "nshc2": "flow", + "nshc3": "flow", + "nshc4": "flow" + } + } + ], + "service-function-dictionary": [ + { + "name": "firewall-1", + "sff-sf-data-plane-locator": { + "sf-dpl-name": "firewall-1-dpl", + "sff-dpl-name": "sff2-dpl" + } + } + ] + }, + { + "name": "Classifier2", + "service-node": "classifier2", + "service-function-forwarder-ovs:ovs-bridge": { + "bridge-name": "br-sfc" + }, + "sff-data-plane-locator": [ + { + "name": "sff3-dpl", + "data-plane-locator": { + "transport": "service-locator:vxlan-gpe", + "port": 6633, + "ip": "192.168.1.60" + }, + "service-function-forwarder-ovs:ovs-options": { + "remote-ip": "flow", + "dst-port": "6633", + "key": "flow", + "nsp": "flow", + "nsi": "flow", + "nshc1": "flow", + "nshc2": "flow", + "nshc3": "flow", + "nshc4": "flow" + } + } + ] + } + ] + } +} diff --git a/resources/configuration-examples/symmetricRSPs/json/04-service_function_chains.json b/resources/configuration-examples/symmetricRSPs/json/04-service_function_chains.json new file mode 100644 index 000000000..1152de13a --- /dev/null +++ b/resources/configuration-examples/symmetricRSPs/json/04-service_function_chains.json @@ -0,0 +1,28 @@ +{ + "service-function-chains": { + "service-function-chain": [ + { + "name": "SFC1", + "sfc-service-function": [ + { + "name": "dpi-abstract1", + "type": "dpi" + }, + { + "name": "firewall-abstract1", + "type": "firewall" + } + ] + }, + { + "name": "SFC2", + "sfc-service-function": [ + { + "name": "dpi-abstract1", + "type": "dpi" + } + ] + } + ] + } +} diff --git a/resources/configuration-examples/symmetricRSPs/json/05-service_function_metadata.json b/resources/configuration-examples/symmetricRSPs/json/05-service_function_metadata.json new file mode 100644 index 000000000..c73f3eec9 --- /dev/null +++ b/resources/configuration-examples/symmetricRSPs/json/05-service_function_metadata.json @@ -0,0 +1,13 @@ +{ + "service-function-metadata": { + "context-metadata": [ + { + "name": "NSH1", + "context-header1": "1", + "context-header2": "2", + "context-header3": "3", + "context-header4": "4" + } + ] + } +} diff --git a/resources/configuration-examples/symmetricRSPs/json/06-service_function_paths.json b/resources/configuration-examples/symmetricRSPs/json/06-service_function_paths.json new file mode 100644 index 000000000..9cc0683d6 --- /dev/null +++ b/resources/configuration-examples/symmetricRSPs/json/06-service_function_paths.json @@ -0,0 +1,30 @@ +{ + "service-function-paths": { + "service-function-path": [ + { + "name": "SFP1", + "service-chain-name": "SFC1", + "starting-index": 255, + "context-metadata": "NSH1", + "service-path-hop": [ + { + "hop-number": 0, + "service-function-name": "dpi-1" + } + ] + }, + { + "name": "SFP2", + "service-chain-name": "SFC2", + "starting-index": 255, + "context-metadata": "NSH1", + "service-path-hop": [ + { + "hop-number": 0, + "service-function-name": "dpi-1" + } + ] + } + ] + } +} diff --git a/resources/configuration-examples/symmetricRSPs/json/07-service_function_acls.json b/resources/configuration-examples/symmetricRSPs/json/07-service_function_acls.json new file mode 100644 index 000000000..3fb7a35ad --- /dev/null +++ b/resources/configuration-examples/symmetricRSPs/json/07-service_function_acls.json @@ -0,0 +1,56 @@ +{ + "access-lists": { + "acl": [ + { + "acl-name": "ACL1", + "acl-type": "ietf-access-control-list:ipv4-acl", + "access-list-entries": { + "ace": [ + { + "rule-name": "ACE1", + "actions": { + "service-function-acl:rendered-service-path": "RSP1" + }, + "matches": { + "destination-ipv4-network": "192.168.2.0/24", + "source-ipv4-network": "192.168.2.0/24", + "protocol": "6", + "source-port-range": { + "lower-port": 0 + }, + "destination-port-range": { + "lower-port": 80 + } + } + } + ] + } + }, + { + "acl-name": "ACL2", + "acl-type": "ietf-access-control-list:ipv4-acl", + "access-list-entries": { + "ace": [ + { + "rule-name": "ACE2", + "actions": { + "service-function-acl:rendered-service-path": "RSP1-Reverse" + }, + "matches": { + "destination-ipv4-network": "192.168.2.0/24", + "source-ipv4-network": "192.168.2.0/24", + "protocol": "6", + "source-port-range": { + "lower-port": 80 + }, + "destination-port-range": { + "lower-port": 0 + } + } + } + ] + } + } + ] + } +} diff --git a/resources/configuration-examples/symmetricRSPs/json/08-rendered_service_path.json b/resources/configuration-examples/symmetricRSPs/json/08-rendered_service_path.json new file mode 100644 index 000000000..bf379b6a2 --- /dev/null +++ b/resources/configuration-examples/symmetricRSPs/json/08-rendered_service_path.json @@ -0,0 +1,6 @@ +{ + "input": { + "name": "RSP1", + "parent-service-function-path": "SFP1" + } +} diff --git a/resources/configuration-examples/symmetricRSPs/json/09-service_function_classifiers.json b/resources/configuration-examples/symmetricRSPs/json/09-service_function_classifiers.json new file mode 100644 index 000000000..70e1c1208 --- /dev/null +++ b/resources/configuration-examples/symmetricRSPs/json/09-service_function_classifiers.json @@ -0,0 +1,32 @@ +{ + "service-function-classifiers": { + "service-function-classifier": [ + { + "name": "Classifier1", + "scl-service-function-forwarder": [ + { + "name": "Classifier1", + "interface": "veth-br" + } + ], + "acl": { + "name": "ACL1", + "type": "ietf-access-control-list:ipv4-acl" + } + }, + { + "name": "Classifier2", + "scl-service-function-forwarder": [ + { + "name": "Classifier2", + "interface": "veth-br" + } + ], + "acl": { + "name": "ACL2", + "type": "ietf-access-control-list:ipv4-acl" + } + } + ] + } +} diff --git a/resources/configuration-examples/symmetricRSPs/setup.py b/resources/configuration-examples/symmetricRSPs/setup.py new file mode 100755 index 000000000..c979fce42 --- /dev/null +++ b/resources/configuration-examples/symmetricRSPs/setup.py @@ -0,0 +1,124 @@ +#!/usr/bin/python +import argparse +import requests,json, ast +from requests.auth import HTTPBasicAuth +from subprocess import call +import time +import sys +import os + +controller='192.168.56.102' +DEFAULT_PORT='8181' + + +USERNAME='admin' +PASSWORD='admin' + +def get(host, port, uri): + url='http://'+host+":"+port+uri + r = requests.get(url, auth=HTTPBasicAuth(USERNAME, PASSWORD)) + jsondata=json.loads(r.text) + return jsondata + +def put(host, port, uri, data, debug=False): + '''Perform a PUT rest operation, using the URL and data provided''' + + url='http://'+host+":"+port+uri + + headers = {'Content-type': 'application/yang.data+json', + 'Accept': 'application/yang.data+json'} + if debug == True: + print "PUT %s" % url + print json.dumps(data, indent=4, sort_keys=True) + r = requests.put(url, data=json.dumps(data), headers=headers, auth=HTTPBasicAuth(USERNAME, PASSWORD)) + if debug == True: + print r.text + r.raise_for_status() + time.sleep(3) + +def post(host, port, uri, data, debug=False): + '''Perform a POST rest operation, using the URL and data provided''' + + url='http://'+host+":"+port+uri + headers = {'Content-type': 'application/yang.data+json', + 'Accept': 'application/yang.data+json'} + if debug == True: + print "POST %s" % url + print json.dumps(data, indent=4, sort_keys=True) + r = requests.post(url, data=json.dumps(data), headers=headers, auth=HTTPBasicAuth(USERNAME, PASSWORD)) + if debug == True: + print r.text + r.raise_for_status() + time.sleep(3) + +def get_data(file_to_read): + '''returns a python object (e.g. a dict) with the data read from file_to_read''' + with open(file_to_read, 'r') as f: + data = f.read() + return ast.literal_eval(data) + +def get_service_nodes_uri(): + return "/restconf/config/service-node:service-nodes" + +def get_service_function_types_uri(): + return "/restconf/config/service-function-type:service-function-types" + +def get_service_functions_uri(): + return "/restconf/config/service-function:service-functions" + +def get_service_function_forwarders_uri(): + return "/restconf/config/service-function-forwarder:service-function-forwarders" + +def get_service_function_chains_uri(): + return "/restconf/config/service-function-chain:service-function-chains/" + +def get_service_function_paths_uri(): + return "/restconf/config/service-function-path:service-function-paths/" + +def get_service_function_metadata_uri(): + return "/restconf/config/service-function-path-metadata:service-function-metadata/" + +def get_service_function_paths_uri(): + return "/restconf/config/service-function-path:service-function-paths/" + +def get_rendered_service_path_uri(): + return "/restconf/operations/rendered-service-path:create-rendered-path/" + +def get_service_function_acl_uri(): + return "/restconf/config/ietf-access-control-list:access-lists/" + +def get_service_function_classifiers_uri(): + return "/restconf/config/service-function-classifier:service-function-classifiers/" + +if __name__ == "__main__": + + print "sending service nodes" + put(controller, DEFAULT_PORT, get_service_nodes_uri(), + get_data('json/01-service_nodes.json'), True) + print "sending service function types" + put(controller, DEFAULT_PORT, get_service_function_types_uri(), + get_data('json/02a-service_function_types.json'), True) + print "sending service functions" + put(controller, DEFAULT_PORT, get_service_functions_uri(), + get_data('json/02b-service_functions.json'), True) + print "sending service function forwarders" + put(controller, DEFAULT_PORT, get_service_function_forwarders_uri(), + get_data('json/03-service_function_forwarders.json'), True) + print "sending service function chains" + put(controller, DEFAULT_PORT, get_service_function_chains_uri(), + get_data('json/04-service_function_chains.json'), True) + print "sending service function metadata" + put(controller, DEFAULT_PORT, get_service_function_metadata_uri(), + get_data('json/05-service_function_metadata.json'), True) + print "sending service function paths" + put(controller, DEFAULT_PORT, get_service_function_paths_uri(), + get_data('json/06-service_function_paths.json'), True) + print "sending service function acl" + put(controller, DEFAULT_PORT, get_service_function_acl_uri(), + get_data('json/07-service_function_acls.json'), True) + print "sending rendered service path" + post(controller, DEFAULT_PORT, get_rendered_service_path_uri(), + get_data('json/08-rendered_service_path.json'), True) + print "sending service function classifiers" + put(controller, DEFAULT_PORT, get_service_function_classifiers_uri(), + get_data('json/09-service_function_classifiers.json'), True) -- 2.36.6