From: Ryan Vail Date: Mon, 26 Oct 2015 15:49:43 +0000 (-0600) Subject: Updated model yang file to use recommended practices found on wiki, then updated... X-Git-Tag: release/beryllium~24 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F24%2F28824%2F1;p=packetcable.git Updated model yang file to use recommended practices found on wiki, then updated binding aware code. ODL wiki recommends - All lists should be in a container - The name just after the list should be singular since it is the element name not the list name - The outer container should be plural Updated yang file to do the recommended things, then updated code to match the updated yang generated bindings. Change-Id: Idafb6b3205fa5ca5d99acc56c7c2b19b8eb4200f Signed-off-by: Ryan Vail --- diff --git a/packetcable-policy-model/src/main/yang/packetcable.yang b/packetcable-policy-model/src/main/yang/packetcable.yang index 52dbed4..d9562f4 100644 --- a/packetcable-policy-model/src/main/yang/packetcable.yang +++ b/packetcable-policy-model/src/main/yang/packetcable.yang @@ -8,7 +8,10 @@ module packetcable description "This module contains the PCMM Converged Cable Access Platform (CCAP) definitions"; organization "OpenDaylight Project"; - + + revision 2015-10-26 { + description "Corrected pluralization of containers/lists and added containers around lists where needed"; + } revision 2015-03-27 { description "Initial revision of PCMM CCAP definitions"; } @@ -43,8 +46,8 @@ module packetcable // CCAP devices - container ccap { - list ccaps { + container ccaps { + list ccap { description " CCAP devices are known by their network name which is any string. Each CCAP device has a network address:port, a list of subscriber IP subnets, @@ -117,27 +120,33 @@ module packetcable } grouping pcmm-qos-gates { - list apps { - key "appId"; - leaf appId { - type string; - description "Application Identity"; - } - list subs { - key "subId"; - leaf subId { - type string; - description "Subscriber Identity -- must be a CM or CPE IP address"; + container apps { + list app { + key "appId"; + leaf appId { + type string; + description "Application Identity"; } - list gates { - key "gateId"; - leaf gateId { - type string; - description "Qos Gate Identity"; - } - uses pcmm-qos-gate-attributes; - } - } + container subscribers { + list subscriber { + key "subscriberId"; + leaf subscriberId { + type string; + description "Subscriber Identity -- must be a CM or CPE IP address"; + } + container gates { + list gate { + key "gateId"; + leaf gateId { + type string; + description "Qos Gate Identity"; + } + uses pcmm-qos-gate-attributes; + } + } + } + } + } } } diff --git a/packetcable-policy-server/doc/restconf-samples/ODL-PCMM.json.postman_collection b/packetcable-policy-server/doc/restconf-samples/ODL-PCMM.json.postman_collection index 20ae51b..98b9d7e 100644 --- a/packetcable-policy-server/doc/restconf-samples/ODL-PCMM.json.postman_collection +++ b/packetcable-policy-server/doc/restconf-samples/ODL-PCMM.json.postman_collection @@ -1,65 +1,54 @@ { - "id": "ea685ec8-aa6d-22e9-e501-b608a6705634", + "id": "5c57b040-54e7-d5bf-296d-d5a4afdd39bc", "name": "ODL-PCMM", "description": "Sample PCMM REST configuration calls.", "order": [], "folders": [ { - "id": "70229253-b083-d28b-aa49-5b4aa4a5f603", + "id": "f9e5223f-35d2-95a8-4cfe-b250938e6c12", "name": "CCAP/CMTS", "description": "Sample PUT, GET, & DELETE of CMTS into ODL", - "write": true, "order": [ - "e54c5cfc-1b5d-498b-a341-00297488427b", - "81287e06-ee1c-1ab3-ac6c-a5c0e7ef304b", - "351b4a09-547a-bcca-7209-a9ce69e3c041", - "e72c8671-ea27-6bbe-800f-3e16d4af4e46", - "1f72bd2d-9ffc-da53-adad-2a664b9c30b2", - "a104537c-f394-388f-aa75-4bd5026b60d7" + "44ba6dfe-ca0c-376a-0322-b3db2af6eb2f", + "0c1e6f25-e33b-e3ed-fc59-02f2b569a9ed", + "a817933b-9398-23d1-b269-68f81ba51bc7", + "f403ebfd-d7d7-c94e-0ee5-3bc864098250", + "672adfee-68a5-5281-d638-72c2964b35cc", + "1142817c-9007-f0a1-92cd-644935c1fa85", + "07f16f27-6ef1-b022-1921-02a3baf40d91", + "1f68f1dc-1d2b-8d04-b7be-0e6fc03fd90a" ], - "collection_name": "ODL-PCMM", - "collection_owner": 0, - "collection_id": "ea685ec8-aa6d-22e9-e501-b608a6705634", - "collection": "ea685ec8-aa6d-22e9-e501-b608a6705634", "owner": 0 }, { - "id": "b49599b4-7506-16dd-6128-b57a71263441", + "id": "8454f1d3-bf11-01d5-3c17-1c635512818b", "name": "Gates", "description": "Sample PUT, GET, DELETE for PCMM Gates", - "write": true, "order": [ - "2b0350e0-0c15-0546-6b67-51b5b75247b6", - "c6a3ffc4-b4dd-6b53-016c-41efaf165197", - "890d8808-c924-6ae4-7d4e-48ecffe18cbd", - "69836325-d4ed-671c-309c-a766df3307f7", - "69ae25d5-9c99-2a26-ab69-68b6f15cfa56", - "975c6bd4-76bc-8a72-c9a6-2f6a9306dd9f", - "338ae37d-fbe3-8c1f-f49e-7670c76c58fd", - "73c2e665-bd3e-8406-92a4-fecadf23b922", - "dcc4b130-7f5c-1247-678c-cb2f44ae4eaa" + "0f01c73b-c17a-b53b-3694-1d746edcd2a2", + "11ef539e-26d3-77ab-3828-321c3f7bf6a3", + "03bebe64-27ff-1df3-5b6b-9237f6c8e229", + "611db01a-e1e3-51fc-606d-5364477f8983", + "fbf5671a-ae7d-4413-a22b-8334c4f5c35e", + "a782c414-e6ad-a247-63f8-f1353e462870", + "ec1b0f8c-371d-a0bd-ce5f-d30aa31237cb", + "dc932ee9-1acd-9efe-cc83-de07894516bb", + "9d80f0da-4500-e843-31c5-808c91d9249b", + "b8031ee0-b6e0-dcbe-fff3-a924cbe295a4" ], - "collection_name": "ODL-PCMM", - "collection_owner": 0, - "collection_id": "ea685ec8-aa6d-22e9-e501-b608a6705634", - "collection": "ea685ec8-aa6d-22e9-e501-b608a6705634", "owner": 0, "collectionId": "ea685ec8-aa6d-22e9-e501-b608a6705634" } ], "timestamp": 1431957020452, - "synced": false, "owner": 0, - "sharedWithTeam": false, - "subscribed": false, "remoteLink": "", "public": false, - "write": true, "requests": [ { - "id": "1f72bd2d-9ffc-da53-adad-2a664b9c30b2", + "id": "03bebe64-27ff-1df3-5b6b-9237f6c8e229", "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:ccap/ccaps/{{ccapId-1}}", + "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:qos/apps/app/{{appId-classifier}}/subscribers/subscriber/{{subId-classifier}}/gates/gate/{{gateId-classifier}}/", "preRequestScript": "", "pathVariables": {}, "method": "DELETE", @@ -69,17 +58,16 @@ "tests": "", "currentHelper": "normal", "helperAttributes": {}, - "time": 1431959545466, - "name": "Delete CCAP 1", - "description": "Deletes a specific managed CCAP/CMTS", - "collectionId": "ea685ec8-aa6d-22e9-e501-b608a6705634", - "responses": [], - "synced": false + "time": 1445872033293, + "name": "Gate w/ classifier", + "description": "Delete QoS gate with classifier", + "collectionId": "5c57b040-54e7-d5bf-296d-d5a4afdd39bc", + "responses": [] }, { - "id": "2b0350e0-0c15-0546-6b67-51b5b75247b6", + "id": "07f16f27-6ef1-b022-1921-02a3baf40d91", "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:qos/apps/{{appId-classifier}}/subs/{{subId-classifier}}/gates/{{gateId-classifier}}/", + "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:ccaps/ccap/{{ccapId-1}}", "preRequestScript": "", "pathVariables": {}, "method": "PUT", @@ -89,39 +77,36 @@ "tests": "", "currentHelper": "normal", "helperAttributes": {}, - "time": 1431970132797, - "name": "Gate w/ classifier", - "description": "PUT gate with standard classifier", - "collectionId": "ea685ec8-aa6d-22e9-e501-b608a6705634", + "time": 1445618651730, + "name": "Add CCAP 1 - Bad", + "description": "tries to add a CCAP/CMTS to manage with out providing all the required fields", + "collectionId": "5c57b040-54e7-d5bf-296d-d5a4afdd39bc", "responses": [], - "synced": false, - "rawModeData": "{\n \"gates\": [{\n \"gateId\": \"{{gateId-classifier}}\",\n \"gate-spec\": {\n \"dscp-tos-overwrite\": \"0xa0\",\n \"dscp-tos-mask\": \"0xff\"\n },\n \"traffic-profile\": {\n \"service-class-name\": \"{{scnUp}}\"\n },\n \"classifier\": {\n \"srcIp\": \"{{srcIp-1a}}\",\n \"dstIp\": \"{{dstIp-1a}}\",\n \"protocol\": \"0\",\n \"srcPort\": \"{{srcPort-1a}}\",\n \"dstPort\": \"{{dstPort-1a}}\",\n \"tos-byte\": \"0xa0\",\n \"tos-mask\": \"0xe0\"\n }\n }]\n}\n" + "rawModeData": "{\n \"ccap\": [{\n \"ccapId\": \"{{ccapId-1}}\",\n \"amId\": {\n \"am-type\": \"1\"\n },\n \"connection\": {\n \"ipAddress\": \"{{ccapIp-1}}\",\n \"port\": \"{{ccapPort-1}}\"\n },\n \"subscriber-subnets\": [\n \"10.32.110.1/24\"\n ],\n \"downstream-scns\": [\n \"extrm_dn\"\n ],\n \"upstream-scns\": [\n \"extrm_up\"\n ]\n }]\n}\n" }, { - "id": "338ae37d-fbe3-8c1f-f49e-7670c76c58fd", + "id": "0c1e6f25-e33b-e3ed-fc59-02f2b569a9ed", "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:qos/apps/{{appId-ipv6}}/subs/{{subId-ipv6}}/gates/{{gateId-ipv6}}/", + "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:ccaps", "preRequestScript": "", "pathVariables": {}, - "method": "PUT", + "method": "DELETE", "data": [], - "dataMode": "raw", + "dataMode": "params", "version": 2, "tests": "", "currentHelper": "normal", "helperAttributes": {}, - "time": 1431970170183, - "name": "Gate w/ IPv6 classifier", - "description": "PUT gate with IPv6 classifier", - "collectionId": "ea685ec8-aa6d-22e9-e501-b608a6705634", - "responses": [], - "synced": false, - "rawModeData": "{\n \"gates\": [{\n \"gateId\": \"{{gateId-ipv6}}\",\n \"gate-spec\": {\n \"dscp-tos-overwrite\": \"0xa0\",\n \"dscp-tos-mask\": \"0xff\"\n },\n \"traffic-profile\": {\n \"service-class-name\": \"{{scnDn}}\"\n },\n \"ipv6-classifier\": {\n \"srcIp6\": \"{{srcIp-IPv6}}\",\n \"dstIp6\": \"{{dstIp-IPv6}}\",\n \"flow-label\": \"101\",\n \"tc-low\": \"0xa0\",\n \"tc-high\": \"0xc0\",\n \"tc-mask\": \"0xe0\",\n \"next-hdr\": \"256\",\n \"srcPort-start\": \"{{srcPort-1a}}\",\n \"srcPort-end\": \"{{srcPort-1b}}\",\n \"dstPort-start\": \"{{dstPort-1a}}\",\n \"dstPort-end\": \"{{dstPort-1b}}\"\n }\n }]\n}\n" + "time": 1445616322776, + "name": "Delete All CCAPs", + "description": "Removes all managed CCAPs/CMTSs", + "collectionId": "5c57b040-54e7-d5bf-296d-d5a4afdd39bc", + "responses": [] }, { - "id": "351b4a09-547a-bcca-7209-a9ce69e3c041", + "id": "0f01c73b-c17a-b53b-3694-1d746edcd2a2", "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:ccap/ccaps/{{ccapId-1}}", + "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:qos/apps/app/{{appId-classifier}}/subscribers/subscriber/{{subId-classifier}}/gates/gate/{{gateId-classifier}}/", "preRequestScript": "", "pathVariables": {}, "method": "PUT", @@ -131,18 +116,17 @@ "tests": "", "currentHelper": "normal", "helperAttributes": {}, - "time": 1431959533066, - "name": "Add CCAP 1", - "description": "Adds a CCAP/CMTS to manage", - "collectionId": "ea685ec8-aa6d-22e9-e501-b608a6705634", + "time": 1445871971575, + "name": "Gate w/ classifier", + "description": "PUT gate with standard classifier", + "collectionId": "5c57b040-54e7-d5bf-296d-d5a4afdd39bc", "responses": [], - "synced": false, - "rawModeData": "{\n \"ccaps\": [{\n \"ccapId\": \"{{ccapId-1}}\",\n \"amId\": {\n \"am-tag\": \"0xcada\",\n \"am-type\": \"1\"\n },\n \"connection\": {\n \"ipAddress\": \"{{ccapIp-1}}\",\n \"port\": \"{{ccapPort-1}}\"\n },\n \"subscriber-subnets\": [\n \"10.32.110.1/24\"\n ],\n \"downstream-scns\": [\n \"extrm_dn\"\n ],\n \"upstream-scns\": [\n \"extrm_up\"\n ]\n }]\n}\n" + "rawModeData": "{\n \"gate\": [{\n \"gateId\": \"{{gateId-classifier}}\",\n \"gate-spec\": {\n \"dscp-tos-overwrite\": \"0xa0\",\n \"dscp-tos-mask\": \"0xff\"\n },\n \"traffic-profile\": {\n \"service-class-name\": \"{{scnUp}}\"\n },\n \"classifier\": {\n \"srcIp\": \"{{srcIp-1a}}\",\n \"dstIp\": \"{{dstIp-1a}}\",\n \"protocol\": \"0\",\n \"srcPort\": \"{{srcPort-1a}}\",\n \"dstPort\": \"{{dstPort-1a}}\",\n \"tos-byte\": \"0xa0\",\n \"tos-mask\": \"0xe0\"\n }\n }]\n}\n" }, { - "id": "69836325-d4ed-671c-309c-a766df3307f7", + "id": "1142817c-9007-f0a1-92cd-644935c1fa85", "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:qos/apps/{{appId-ext}}/subs/{{subId-ext}}/gates/{{gateId-ext}}/", + "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:ccaps", "preRequestScript": "", "pathVariables": {}, "method": "PUT", @@ -152,18 +136,17 @@ "tests": "", "currentHelper": "normal", "helperAttributes": {}, - "time": 1431970160007, - "name": "Gate w/ ext classifier", - "description": "PUT gate with ext classifier", - "collectionId": "ea685ec8-aa6d-22e9-e501-b608a6705634", + "time": 1445618622845, + "name": "PUT Multiple", + "description": "Adds 2 CCAPs/CMTSs to manage", + "collectionId": "5c57b040-54e7-d5bf-296d-d5a4afdd39bc", "responses": [], - "synced": false, - "rawModeData": "{\n \"gates\": [{\n \"gateId\": \"{{gateId-ext}}\",\n \"gate-spec\": {\n \"dscp-tos-overwrite\": \"0xa0\",\n \"dscp-tos-mask\": \"0xff\"\n },\n \"traffic-profile\": {\n \"service-class-name\": \"{{scnDn}}\"\n },\n \"ext-classifier\": {\n \"srcIp\": \"{{srcIp-1a}}\",\n \"srcIpMask\": \"{{srcIpMask}}\",\n \"dstIp\": \"{{dstIp-1a}}\",\n \"dstIpMask\": \"{{dstIpMask}}\",\n \"tos-byte\": \"0xa0\",\n \"tos-mask\": \"0xe0\",\n \"protocol\": \"0\",\n \"srcPort-start\": \"{{srcPort-1a}}\",\n \"srcPort-end\": \"{{srcPort-1b}}\",\n \"dstPort-start\": \"{{dstPort-1a}}\",\n \"dstPort-end\": \"{{dstPort-1b}}\"\n }\n }]\n}\n" + "rawModeData": "{ \"ccaps\": {\n \"ccap\": [\n { \"ccapId\": \"{{ccapId-1}}\",\n \"amId\": {\n \"am-tag\": \"0xcada\",\n \"am-type\": \"1\"\n },\n \"connection\": {\n \"ipAddress\": \"{{ccapIp-1}}\",\n \"port\": \"{{ccapPort-1}}\"\n },\n \"subscriber-subnets\": [\n \"44.137.0.0/16\",\n \"2001:4978:030d:1000:0:0:0:0/52\"\n ],\n \"downstream-scns\": [\n \"ipvideo_dn\",\n \"extrm_dn\",\n \"SCNC\"\n ],\n \"upstream-scns\": [\n \"SCNA\",\n \"extrm_up\"\n ]\n },\n { \"ccapId\": \"{{ccapId-2}}\",\n \"amId\": {\n \"am-tag\": \"0xcada\",\n \"am-type\": \"1\"\n },\n \"connection\": {\n \"ipAddress\": \"{{ccapIp-2}}\",\n \"port\": \"{{ccapPort-2}}\"\n },\n \"subscriber-subnets\": [\n \"44.133.0.0/19\"\n ],\n \"downstream-scns\": [\n \"ipvideo_dn\",\n \"extrm_dn\",\n \"SCNC\"\n ],\n \"upstream-scns\": [\n \"SCNA\",\n \"extrm_up\"\n ]\n }]\n}}\n" }, { - "id": "69ae25d5-9c99-2a26-ab69-68b6f15cfa56", + "id": "11ef539e-26d3-77ab-3828-321c3f7bf6a3", "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:qos/apps/{{appId-ext}}/subs/{{subId-ext}}/gates/{{gateId-ext}}/", + "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:qos/apps/app/{{appId-classifier}}/subscribers/subscriber/{{subId-classifier}}/gates/gate/{{gateId-classifier}}/", "preRequestScript": "", "pathVariables": {}, "method": "GET", @@ -173,17 +156,16 @@ "tests": "", "currentHelper": "normal", "helperAttributes": {}, - "time": 1431968587699, - "name": "Gate w/ ext classifier", - "description": "Retrieves the gate with ext classifier.", - "collectionId": "ea685ec8-aa6d-22e9-e501-b608a6705634", - "responses": [], - "synced": false + "time": 1445872017430, + "name": "Gate w/ classifier", + "description": "Retrieves the gate with classifier.", + "collectionId": "5c57b040-54e7-d5bf-296d-d5a4afdd39bc", + "responses": [] }, { - "id": "73c2e665-bd3e-8406-92a4-fecadf23b922", + "id": "1f68f1dc-1d2b-8d04-b7be-0e6fc03fd90a", "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:qos/apps/{{appId-ipv6}}/subs/{{subId-ipv6}}/gates/{{gateId-ipv6}}/", + "url": "http://{{odlHost}}:{{odlPort}}/restconf/operational/packetcable:ccaps", "preRequestScript": "", "pathVariables": {}, "method": "GET", @@ -193,17 +175,55 @@ "tests": "", "currentHelper": "normal", "helperAttributes": {}, - "time": 1431968601897, - "name": "Gate w/ IPv6 classifier", - "description": "Retrieves the gate with IPv6 classifier.", - "collectionId": "ea685ec8-aa6d-22e9-e501-b608a6705634", + "time": 1445616352829, + "name": "Operational - Get All CCAPs", + "description": "Retrieves all managed CCAPs/CMTSs", + "collectionId": "5c57b040-54e7-d5bf-296d-d5a4afdd39bc", + "responses": [] + }, + { + "id": "44ba6dfe-ca0c-376a-0322-b3db2af6eb2f", + "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", + "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:ccaps", + "preRequestScript": "", + "pathVariables": {}, + "method": "GET", + "data": [], + "dataMode": "params", + "version": 2, + "tests": "", + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1445616319736, + "name": "Get All CCAPs", + "description": "Retrieves all managed CCAPs/CMTSs", + "collectionId": "5c57b040-54e7-d5bf-296d-d5a4afdd39bc", + "responses": [] + }, + { + "id": "611db01a-e1e3-51fc-606d-5364477f8983", + "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", + "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:qos/apps/app/{{appId-ext}}/subscribers/subscriber/{{subId-ext}}/gates/gate/{{gateId-ext}}/", + "preRequestScript": "", + "pathVariables": {}, + "method": "PUT", + "data": [], + "dataMode": "raw", + "version": 2, + "tests": "", + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1445872070412, + "name": "Gate w/ ext classifier", + "description": "PUT gate with ext classifier", + "collectionId": "5c57b040-54e7-d5bf-296d-d5a4afdd39bc", "responses": [], - "synced": false + "rawModeData": "{\n \"gate\": [{\n \"gateId\": \"{{gateId-ext}}\",\n \"gate-spec\": {\n \"dscp-tos-overwrite\": \"0xa0\",\n \"dscp-tos-mask\": \"0xff\"\n },\n \"traffic-profile\": {\n \"service-class-name\": \"{{scnDn}}\"\n },\n \"ext-classifier\": {\n \"srcIp\": \"{{srcIp-1a}}\",\n \"srcIpMask\": \"{{srcIpMask}}\",\n \"dstIp\": \"{{dstIp-1a}}\",\n \"dstIpMask\": \"{{dstIpMask}}\",\n \"tos-byte\": \"0xa0\",\n \"tos-mask\": \"0xe0\",\n \"protocol\": \"0\",\n \"srcPort-start\": \"{{srcPort-1a}}\",\n \"srcPort-end\": \"{{srcPort-1b}}\",\n \"dstPort-start\": \"{{dstPort-1a}}\",\n \"dstPort-end\": \"{{dstPort-1b}}\"\n }\n }]\n}\n" }, { - "id": "81287e06-ee1c-1ab3-ac6c-a5c0e7ef304b", + "id": "672adfee-68a5-5281-d638-72c2964b35cc", "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:ccap", + "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:ccaps/ccap/{{ccapId-1}}", "preRequestScript": "", "pathVariables": {}, "method": "DELETE", @@ -213,17 +233,16 @@ "tests": "", "currentHelper": "normal", "helperAttributes": {}, - "time": 1431959527893, - "name": "Delete All CCAPs", - "description": "Removes all managed CCAPs/CMTSs", - "collectionId": "ea685ec8-aa6d-22e9-e501-b608a6705634", - "responses": [], - "synced": false + "time": 1445616338656, + "name": "Delete CCAP 1", + "description": "Deletes a specific managed CCAP/CMTS", + "collectionId": "5c57b040-54e7-d5bf-296d-d5a4afdd39bc", + "responses": [] }, { - "id": "890d8808-c924-6ae4-7d4e-48ecffe18cbd", + "id": "9d80f0da-4500-e843-31c5-808c91d9249b", "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:qos/apps/{{appId-classifier}}/subs/{{subId-classifier}}/gates/{{gateId-classifier}}/", + "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:qos/apps/app/{{appId-ipv6}}/subscribers/subscriber/{{subId-ipv6}}/gates/gate/{{gateId-ipv6}}/", "preRequestScript": "", "pathVariables": {}, "method": "DELETE", @@ -233,17 +252,16 @@ "tests": "", "currentHelper": "normal", "helperAttributes": {}, - "time": 1431968580172, - "name": "Gate w/ classifier", - "description": "Delete QoS gate with classifier", - "collectionId": "ea685ec8-aa6d-22e9-e501-b608a6705634", - "responses": [], - "synced": false + "time": 1445872203499, + "name": "Gate w/ IPv6 classifier", + "description": "Delete QoS gate with IPv6 classifier", + "collectionId": "5c57b040-54e7-d5bf-296d-d5a4afdd39bc", + "responses": [] }, { - "id": "975c6bd4-76bc-8a72-c9a6-2f6a9306dd9f", + "id": "a782c414-e6ad-a247-63f8-f1353e462870", "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:qos/apps/{{appId-ext}}/subs/{{subId-ext}}/gates/{{gateId-ext}}/", + "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:qos/apps/app/{{appId-ext}}/subscribers/subscriber/{{subId-ext}}/gates/gate/{{gateId-ext}}/", "preRequestScript": "", "pathVariables": {}, "method": "DELETE", @@ -253,17 +271,16 @@ "tests": "", "currentHelper": "normal", "helperAttributes": {}, - "time": 1431968592188, + "time": 1445872124553, "name": "Gate w/ ext classifier", "description": "Delete QoS gate with ext classifier", - "collectionId": "ea685ec8-aa6d-22e9-e501-b608a6705634", - "responses": [], - "synced": false + "collectionId": "5c57b040-54e7-d5bf-296d-d5a4afdd39bc", + "responses": [] }, { - "id": "a104537c-f394-388f-aa75-4bd5026b60d7", + "id": "a817933b-9398-23d1-b269-68f81ba51bc7", "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:ccap", + "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:ccaps/ccap/{{ccapId-1}}", "preRequestScript": "", "pathVariables": {}, "method": "PUT", @@ -273,18 +290,17 @@ "tests": "", "currentHelper": "normal", "helperAttributes": {}, - "time": 1431959551170, - "name": "PUT Multiple", - "description": "Adds 2 CCAPs/CMTSs to manage", - "collectionId": "ea685ec8-aa6d-22e9-e501-b608a6705634", + "time": 1445616876070, + "name": "Add CCAP 1", + "description": "Adds a CCAP/CMTS to manage", + "collectionId": "5c57b040-54e7-d5bf-296d-d5a4afdd39bc", "responses": [], - "synced": false, - "rawModeData": "{ \"ccap\": {\n \"ccaps\": [\n { \"ccapId\": \"{{ccapId-1}}\",\n \"amId\": {\n \"am-tag\": \"0xcada\",\n \"am-type\": \"1\"\n },\n \"connection\": {\n \"ipAddress\": \"{{ccapIp-1}}\",\n \"port\": \"{{ccapPort-1}}\"\n },\n \"subscriber-subnets\": [\n \"44.137.0.0/16\",\n \"2001:4978:030d:1000:0:0:0:0/52\"\n ],\n \"downstream-scns\": [\n \"ipvideo_dn\",\n \"extrm_dn\",\n \"SCNC\"\n ],\n \"upstream-scns\": [\n \"SCNA\",\n \"extrm_up\"\n ]\n },\n { \"ccapId\": \"{{ccapId-2}}\",\n \"amId\": {\n \"am-tag\": \"0xcada\",\n \"am-type\": \"1\"\n },\n \"connection\": {\n \"ipAddress\": \"{{ccapIp-2}}\",\n \"port\": \"{{ccapPort-2}}\"\n },\n \"subscriber-subnets\": [\n \"44.133.0.0/19\"\n ],\n \"downstream-scns\": [\n \"ipvideo_dn\",\n \"extrm_dn\",\n \"SCNC\"\n ],\n \"upstream-scns\": [\n \"SCNA\",\n \"extrm_up\"\n ]\n }]\n}}\n" + "rawModeData": "{\n \"ccap\": [{\n \"ccapId\": \"{{ccapId-1}}\",\n \"amId\": {\n \"am-tag\": \"0xcada\",\n \"am-type\": \"1\"\n },\n \"connection\": {\n \"ipAddress\": \"{{ccapIp-1}}\",\n \"port\": \"{{ccapPort-1}}\"\n },\n \"subscriber-subnets\": [\n \"10.32.110.1/24\"\n ],\n \"downstream-scns\": [\n \"extrm_dn\"\n ],\n \"upstream-scns\": [\n \"extrm_up\"\n ]\n }]\n}\n" }, { - "id": "c6a3ffc4-b4dd-6b53-016c-41efaf165197", + "id": "b8031ee0-b6e0-dcbe-fff3-a924cbe295a4", "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:qos/apps/{{appId-classifier}}/subs/{{subId-classifier}}/gates/{{gateId-classifier}}/", + "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:qos/", "preRequestScript": "", "pathVariables": {}, "method": "GET", @@ -294,57 +310,55 @@ "tests": "", "currentHelper": "normal", "helperAttributes": {}, - "time": 1431968576112, - "name": "Gate w/ classifier", - "description": "Retrieves the gate with classifier.", - "collectionId": "ea685ec8-aa6d-22e9-e501-b608a6705634", - "responses": [], - "synced": false + "time": 1445372731369, + "name": "All Gates", + "description": "Retrieves all gates.", + "collectionId": "5c57b040-54e7-d5bf-296d-d5a4afdd39bc", + "responses": [] }, { - "id": "dcc4b130-7f5c-1247-678c-cb2f44ae4eaa", + "id": "dc932ee9-1acd-9efe-cc83-de07894516bb", "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:qos/apps/{{appId-ipv6}}/subs/{{subId-ipv6}}/gates/{{gateId-ipv6}}/", + "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:qos/apps/app/{{appId-ipv6}}/subscribers/subscriber/{{subId-ipv6}}/gates/gate/{{gateId-ipv6}}/", "preRequestScript": "", "pathVariables": {}, - "method": "DELETE", + "method": "GET", "data": [], "dataMode": "params", "version": 2, "tests": "", "currentHelper": "normal", "helperAttributes": {}, - "time": 1431968605935, + "time": 1445872183035, "name": "Gate w/ IPv6 classifier", - "description": "Delete QoS gate with IPv6 classifier", - "collectionId": "ea685ec8-aa6d-22e9-e501-b608a6705634", - "responses": [], - "synced": false + "description": "Retrieves the gate with IPv6 classifier.", + "collectionId": "5c57b040-54e7-d5bf-296d-d5a4afdd39bc", + "responses": [] }, { - "id": "e54c5cfc-1b5d-498b-a341-00297488427b", + "id": "ec1b0f8c-371d-a0bd-ce5f-d30aa31237cb", "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:ccap", + "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:qos/apps/app/{{appId-ipv6}}/subscribers/subscriber/{{subId-ipv6}}/gates/gate/{{gateId-ipv6}}/", "preRequestScript": "", "pathVariables": {}, - "method": "GET", + "method": "PUT", "data": [], - "dataMode": "params", + "dataMode": "raw", "version": 2, "tests": "", "currentHelper": "normal", "helperAttributes": {}, - "time": 1431959521698, - "name": "Get All CCAPs", - "description": "Retrieves all managed CCAPs/CMTSs", - "collectionId": "ea685ec8-aa6d-22e9-e501-b608a6705634", + "time": 1445872149650, + "name": "Gate w/ IPv6 classifier", + "description": "PUT gate with IPv6 classifier", + "collectionId": "5c57b040-54e7-d5bf-296d-d5a4afdd39bc", "responses": [], - "synced": false + "rawModeData": "{\n \"gate\": [{\n \"gateId\": \"{{gateId-ipv6}}\",\n \"gate-spec\": {\n \"dscp-tos-overwrite\": \"0xa0\",\n \"dscp-tos-mask\": \"0xff\"\n },\n \"traffic-profile\": {\n \"service-class-name\": \"{{scnDn}}\"\n },\n \"ipv6-classifier\": {\n \"srcIp6\": \"{{srcIp-IPv6}}\",\n \"dstIp6\": \"{{dstIp-IPv6}}\",\n \"flow-label\": \"101\",\n \"tc-low\": \"0xa0\",\n \"tc-high\": \"0xc0\",\n \"tc-mask\": \"0xe0\",\n \"next-hdr\": \"256\",\n \"srcPort-start\": \"{{srcPort-1a}}\",\n \"srcPort-end\": \"{{srcPort-1b}}\",\n \"dstPort-start\": \"{{dstPort-1a}}\",\n \"dstPort-end\": \"{{dstPort-1b}}\"\n }\n }]\n}\n" }, { - "id": "e72c8671-ea27-6bbe-800f-3e16d4af4e46", + "id": "f403ebfd-d7d7-c94e-0ee5-3bc864098250", "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", - "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:ccap/ccaps/{{ccapId-1}}", + "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:ccaps/ccap/{{ccapId-1}}", "preRequestScript": "", "pathVariables": {}, "method": "GET", @@ -354,12 +368,30 @@ "tests": "", "currentHelper": "normal", "helperAttributes": {}, - "time": 1431959538008, + "time": 1445616333775, "name": "Get CCAP 1", "description": "Retrieves a specific managed CCAP/CMTS", - "collectionId": "ea685ec8-aa6d-22e9-e501-b608a6705634", - "responses": [], - "synced": false + "collectionId": "5c57b040-54e7-d5bf-296d-d5a4afdd39bc", + "responses": [] + }, + { + "id": "fbf5671a-ae7d-4413-a22b-8334c4f5c35e", + "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n", + "url": "http://{{odlHost}}:{{odlPort}}/restconf/config/packetcable:qos/apps/app/{{appId-ext}}/subscribers/subscriber/{{subId-ext}}/gates/gate/{{gateId-ext}}/", + "preRequestScript": "", + "pathVariables": {}, + "method": "GET", + "data": [], + "dataMode": "params", + "version": 2, + "tests": "", + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1445872097422, + "name": "Gate w/ ext classifier", + "description": "Retrieves the gate with ext classifier.", + "collectionId": "5c57b040-54e7-d5bf-296d-d5a4afdd39bc", + "responses": [] } ] } \ No newline at end of file diff --git a/packetcable-policy-server/src/main/java/org/opendaylight/controller/packetcable/provider/PCMMGateReqBuilder.java b/packetcable-policy-server/src/main/java/org/opendaylight/controller/packetcable/provider/PCMMGateReqBuilder.java index 79523ab..a06702d 100644 --- a/packetcable-policy-server/src/main/java/org/opendaylight/controller/packetcable/provider/PCMMGateReqBuilder.java +++ b/packetcable-policy-server/src/main/java/org/opendaylight/controller/packetcable/provider/PCMMGateReqBuilder.java @@ -3,14 +3,14 @@ */ package org.opendaylight.controller.packetcable.provider; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ServiceFlowDirection; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.TosByte; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ccap.attributes.AmId; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.classifier.Classifier; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.ext.classifier.ExtClassifier; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.gate.spec.GateSpec; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.ipv6.classifier.Ipv6Classifier; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.traffic.profile.TrafficProfile; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ServiceFlowDirection; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.TosByte; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ccap.attributes.AmId; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.classifier.Classifier; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.ext.classifier.ExtClassifier; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.gate.spec.GateSpec; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.ipv6.classifier.Ipv6Classifier; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.traffic.profile.TrafficProfile; import org.pcmm.gates.IClassifier; import org.pcmm.gates.IClassifier.Protocol; import org.pcmm.gates.IExtendedClassifier.ActivationState; @@ -42,19 +42,19 @@ public class PCMMGateReqBuilder { private IClassifier classifier = null; private PCMMError error = null; - public PCMMGateReq getGateReq() { + public PCMMGateReq build() { return new PCMMGateReq(amid, subscriberID, transactionID, gateSpec, trafficProfile, classifier, gateID, error); } - public void build(final AmId qosAmId) { + public void setAmId(final AmId qosAmId) { amid = new AMID(qosAmId.getAmType().shortValue(), qosAmId.getAmTag().shortValue()); } - public void build(final InetAddress qosSubId) { + public void setSubscriberId(final InetAddress qosSubId) { subscriberID = new SubscriberID(qosSubId); } - public void build(final GateSpec qosGateSpec, final ServiceFlowDirection scnDirection) { + public void setGateSpec(final GateSpec qosGateSpec, final ServiceFlowDirection scnDirection) { final ServiceFlowDirection qosDir; if (scnDirection != null) { @@ -96,7 +96,7 @@ public class PCMMGateReqBuilder { gateSpec = new org.pcmm.gates.impl.GateSpec(gateDir, dscptos, gateTosMask); } - public void build(final TrafficProfile qosTrafficProfile) { + public void setTrafficProfile(final TrafficProfile qosTrafficProfile) { if (qosTrafficProfile.getServiceClassName() != null) { trafficProfile = new DOCSISServiceClassNameTrafficProfile(qosTrafficProfile.getServiceClassName().getValue()); @@ -112,7 +112,7 @@ public class PCMMGateReqBuilder { return null; } - public void build(final Classifier qosClassifier) { + public void setClassifier(final Classifier qosClassifier) { // TODO - try and make these variables immutable Protocol protocol = null; byte tosOverwrite = 0; @@ -160,7 +160,7 @@ public class PCMMGateReqBuilder { dstPort, priority); } - public void build(final ExtClassifier qosExtClassifier) { + public void setExtClassifier(final ExtClassifier qosExtClassifier) { // Extended classifier final byte priority = (byte) 64; final ActivationState activationState = ActivationState.ACTIVE; @@ -247,7 +247,7 @@ public class PCMMGateReqBuilder { return null; } - public void build(final Ipv6Classifier qosIpv6Classifier) { + public void setIpv6Classifier(final Ipv6Classifier qosIpv6Classifier) { // Next Header final short nextHdr; if (qosIpv6Classifier.getNextHdr() != null) { diff --git a/packetcable-policy-server/src/main/java/org/opendaylight/controller/packetcable/provider/PCMMService.java b/packetcable-policy-server/src/main/java/org/opendaylight/controller/packetcable/provider/PCMMService.java index f2a4fe0..09f481b 100644 --- a/packetcable-policy-server/src/main/java/org/opendaylight/controller/packetcable/provider/PCMMService.java +++ b/packetcable-policy-server/src/main/java/org/opendaylight/controller/packetcable/provider/PCMMService.java @@ -5,12 +5,15 @@ package org.opendaylight.controller.packetcable.provider; import com.google.common.collect.Maps; +import java.net.InetAddress; +import java.util.Map; +import javax.annotation.concurrent.ThreadSafe; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ServiceClassName; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ServiceFlowDirection; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ccap.Ccaps; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.gates.apps.subs.Gates; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ServiceClassName; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ServiceFlowDirection; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ccaps.Ccap; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.gates.apps.app.subscribers.subscriber.gates.Gate; import org.pcmm.PCMMPdpAgent; import org.pcmm.PCMMPdpDataProcess; import org.pcmm.PCMMPdpMsgSender; @@ -21,10 +24,6 @@ import org.umu.cops.prpdp.COPSPdpException; import org.umu.cops.stack.COPSError; import org.umu.cops.stack.COPSError.ErrorTypes; -import javax.annotation.concurrent.ThreadSafe; -import java.net.InetAddress; -import java.util.Map; - /** * Class responsible for managing the gates for a single CCAP. */ @@ -32,7 +31,7 @@ import java.util.Map; public class PCMMService { private Logger logger = LoggerFactory.getLogger(PCMMService.class); - private final Ccaps ccap; + private final Ccap ccap; private final IpAddress ipAddr; private final PortNumber portNum; protected final CcapClient ccapClient; @@ -40,7 +39,7 @@ public class PCMMService { private final short clientType; - public PCMMService(final short clientType, final Ccaps ccap) { + public PCMMService(final short clientType, final Ccap ccap) { this.clientType = clientType; this.ccap = ccap; ipAddr = ccap.getConnection().getIpAddress(); @@ -69,33 +68,33 @@ public class PCMMService { } // TODO - Consider creating an object to return that contains a success flag, message, and gate ID or gate object - public String sendGateSet(final String gatePathStr, final InetAddress subId, final Gates qosGate, + public String sendGateSet(final String gatePathStr, final InetAddress subId, final Gate qosGate, final ServiceFlowDirection scnDir) { logger.info("Sending gate to CCAP with ID - " + ccap.getCcapId()); // assemble the gate request for this subId final PCMMGateReqBuilder gateBuilder = new PCMMGateReqBuilder(); - gateBuilder.build(ccap.getAmId()); - gateBuilder.build(subId); + gateBuilder.setAmId(ccap.getAmId()); + gateBuilder.setSubscriberId(subId); // force gateSpec.Direction to align with SCN direction final ServiceClassName scn = qosGate.getTrafficProfile().getServiceClassName(); if (scn != null) { - gateBuilder.build(qosGate.getGateSpec(), scnDir); + gateBuilder.setGateSpec(qosGate.getGateSpec(), scnDir); } else { // not an SCN gate - gateBuilder.build(qosGate.getGateSpec(), null); + gateBuilder.setGateSpec(qosGate.getGateSpec(), null); } - gateBuilder.build(qosGate.getTrafficProfile()); + gateBuilder.setTrafficProfile(qosGate.getTrafficProfile()); // pick a classifier type (only one for now) if (qosGate.getClassifier() != null) { - gateBuilder.build(qosGate.getClassifier()); + gateBuilder.setClassifier(qosGate.getClassifier()); } else if (qosGate.getExtClassifier() != null) { - gateBuilder.build(qosGate.getExtClassifier()); + gateBuilder.setExtClassifier(qosGate.getExtClassifier()); } else if (qosGate.getIpv6Classifier() != null) { - gateBuilder.build(qosGate.getIpv6Classifier()); + gateBuilder.setIpv6Classifier(qosGate.getIpv6Classifier()); } // assemble the final gate request - final PCMMGateReq gateReq = gateBuilder.getGateReq(); + final PCMMGateReq gateReq = gateBuilder.build(); if (gateRequests.get(gatePathStr) == null) { // and remember it diff --git a/packetcable-policy-server/src/main/java/org/opendaylight/controller/packetcable/provider/PacketcableProvider.java b/packetcable-policy-server/src/main/java/org/opendaylight/controller/packetcable/provider/PacketcableProvider.java index 5a0f2b4..894eccc 100644 --- a/packetcable-policy-server/src/main/java/org/opendaylight/controller/packetcable/provider/PacketcableProvider.java +++ b/packetcable-policy-server/src/main/java/org/opendaylight/controller/packetcable/provider/PacketcableProvider.java @@ -1,5 +1,16 @@ package org.opendaylight.controller.packetcable.provider; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutionException; +import javax.annotation.concurrent.ThreadSafe; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; @@ -8,19 +19,19 @@ import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderCo import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.Ccap; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.Qos; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ServiceClassName; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ServiceFlowDirection; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ccap.Ccaps; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ccap.CcapsKey; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ccap.attributes.Connection; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.gates.Apps; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.gates.AppsKey; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.gates.apps.Subs; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.gates.apps.SubsKey; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.gates.apps.subs.Gates; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.gates.apps.subs.GatesKey; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.Ccaps; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.Qos; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ServiceClassName; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ServiceFlowDirection; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ccap.attributes.Connection; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ccaps.Ccap; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ccaps.CcapKey; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.gates.apps.App; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.gates.apps.AppKey; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.gates.apps.app.subscribers.Subscriber; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.gates.apps.app.subscribers.SubscriberKey; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.gates.apps.app.subscribers.subscriber.gates.Gate; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.gates.apps.app.subscribers.subscriber.gates.GateKey; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -28,13 +39,6 @@ import org.pcmm.rcd.IPCMMClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.annotation.concurrent.ThreadSafe; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutionException; - /** * Called by ODL framework to start this bundle. * @@ -47,7 +51,7 @@ public class PacketcableProvider implements BindingAwareProvider, DataChangeList private static final Logger logger = LoggerFactory.getLogger(PacketcableProvider.class); // keys to the /restconf/config/packetcable:ccap and /restconf/config/packetcable:qos config datastore - public static final InstanceIdentifier ccapIID = InstanceIdentifier.builder(Ccap.class).build(); + public static final InstanceIdentifier ccapIID = InstanceIdentifier.builder(Ccaps.class).build(); public static final InstanceIdentifier qosIID = InstanceIdentifier.builder(Qos.class).build(); /** @@ -61,12 +65,12 @@ public class PacketcableProvider implements BindingAwareProvider, DataChangeList private ListenerRegistration qosDataChangeListenerRegistration; // TODO - Revisit these maps and remove the ones no longer necessary - private final Map ccapMap = new ConcurrentHashMap<>(); - private final Map gateMap = new ConcurrentHashMap<>(); + private final Map ccapMap = new ConcurrentHashMap<>(); + private final Map gateMap = new ConcurrentHashMap<>(); private final Map gateCcapMap = new ConcurrentHashMap<>(); - private final Map subscriberSubnetsMap = new ConcurrentHashMap<>(); - private final Map> downstreamScnMap = new ConcurrentHashMap<>(); - private final Map> upstreamScnMap = new ConcurrentHashMap<>(); + private final Map subscriberSubnetsMap = new ConcurrentHashMap<>(); + private final Map> downstreamScnMap = new ConcurrentHashMap<>(); + private final Map> upstreamScnMap = new ConcurrentHashMap<>(); /** * Holds a PCMMService object for each CCAP being managed. @@ -128,7 +132,7 @@ public class PacketcableProvider implements BindingAwareProvider, DataChangeList } } - private void updateCcapMaps(final Ccaps ccap) { + private void updateCcapMaps(final Ccap ccap) { // add ccap to the subscriberSubnets map for (final IpPrefix ipPrefix : ccap.getSubscriberSubnets()) { try { @@ -142,7 +146,7 @@ public class PacketcableProvider implements BindingAwareProvider, DataChangeList if (upstreamScnMap.containsKey(scn)) { upstreamScnMap.get(scn).add(ccap); } else { - final List ccapList = new ArrayList<>(); + final List ccapList = new ArrayList<>(); ccapList.add(ccap); upstreamScnMap.put(scn, ccapList); } @@ -152,32 +156,32 @@ public class PacketcableProvider implements BindingAwareProvider, DataChangeList if (downstreamScnMap.containsKey(scn)) { downstreamScnMap.get(scn).add(ccap); } else { - final List ccapList = new ArrayList<>(); + final List ccapList = new ArrayList<>(); ccapList.add(ccap); downstreamScnMap.put(scn, ccapList); } } } - private void removeCcapFromAllMaps(final Ccaps ccap) { + private void removeCcapFromAllMaps(final Ccap ccap) { // remove the ccap from all maps // subscriberSubnets map - for (final Map.Entry entry : subscriberSubnetsMap.entrySet()) { + for (final Map.Entry entry : subscriberSubnetsMap.entrySet()) { if (entry.getValue() == ccap) { subscriberSubnetsMap.remove(entry.getKey()); } } // ccap to upstream SCN map - for (final Map.Entry> entry : upstreamScnMap.entrySet()) { - final List ccapList = entry.getValue(); + for (final Map.Entry> entry : upstreamScnMap.entrySet()) { + final List ccapList = entry.getValue(); ccapList.remove(ccap); if (ccapList.isEmpty()) { upstreamScnMap.remove(entry.getKey()); } } // ccap to downstream SCN map - for (final Map.Entry> entry : downstreamScnMap.entrySet()) { - final List ccapList = entry.getValue(); + for (final Map.Entry> entry : downstreamScnMap.entrySet()) { + final List ccapList = entry.getValue(); ccapList.remove(ccap); if (ccapList.isEmpty()) { downstreamScnMap.remove(entry.getKey()); @@ -188,10 +192,10 @@ public class PacketcableProvider implements BindingAwareProvider, DataChangeList if (service != null) service.disconect(); } - private Ccaps findCcapForSubscriberId(final InetAddress inetAddr) { - Ccaps matchedCcap = null; + private Ccap findCcapForSubscriberId(final InetAddress inetAddr) { + Ccap matchedCcap = null; int longestPrefixLen = -1; - for (final Map.Entry entry : subscriberSubnetsMap.entrySet()) { + for (final Map.Entry entry : subscriberSubnetsMap.entrySet()) { final Subnet subnet = entry.getKey(); if (subnet.isInNet(inetAddr)) { int prefixLen = subnet.getPrefixLen(); @@ -204,14 +208,14 @@ public class PacketcableProvider implements BindingAwareProvider, DataChangeList return matchedCcap; } - private ServiceFlowDirection findScnOnCcap(final ServiceClassName scn, final Ccaps ccap) { + private ServiceFlowDirection findScnOnCcap(final ServiceClassName scn, final Ccap ccap) { if (upstreamScnMap.containsKey(scn)) { - final List ccapList = upstreamScnMap.get(scn); + final List ccapList = upstreamScnMap.get(scn); if (ccapList.contains(ccap)) { return ServiceFlowDirection.Us; } } else if (downstreamScnMap.containsKey(scn)) { - final List ccapList = downstreamScnMap.get(scn); + final List ccapList = downstreamScnMap.get(scn); if (ccapList.contains(ccap)) { return ServiceFlowDirection.Ds; } @@ -225,13 +229,13 @@ public class PacketcableProvider implements BindingAwareProvider, DataChangeList private class InstanceData { // CCAP Identity - public final Map, Ccaps> ccapIidMap = new HashMap<>(); + public final Map, Ccap> ccapIidMap = new HashMap<>(); // Gate Identity public String subId; public final Map gatePathMap = new HashMap<>(); public String gatePath; - public final Map, Gates> gateIidMap = new HashMap<>(); - // remove path for either CCAP or Gates + public final Map, Gate> gateIidMap = new HashMap<>(); + // remove path for either CCAP or Gate public final Set removePathList = new HashSet<>(); public final Set> reqCcapIds = new HashSet<>(); @@ -263,32 +267,32 @@ public class PacketcableProvider implements BindingAwareProvider, DataChangeList private void getGatePathMap(final InstanceIdentifier thisInstance) { logger.info("onDataChanged().getGatePathMap(): " + thisInstance); try { - final InstanceIdentifier ccapInstance = thisInstance.firstIdentifierOf(Ccaps.class); + final InstanceIdentifier ccapInstance = thisInstance.firstIdentifierOf(Ccap.class); if (ccapInstance != null) { - final CcapsKey ccapKey = InstanceIdentifier.keyOf(ccapInstance); + final CcapKey ccapKey = InstanceIdentifier.keyOf(ccapInstance); if (ccapKey != null) { gatePathMap.put("ccapId", ccapKey.getCcapId()); } } else { // get the gate path keys from the InstanceIdentifier Map key set if they are there - final InstanceIdentifier appsInstance = thisInstance.firstIdentifierOf(Apps.class); - if (appsInstance != null) { - final AppsKey appKey = InstanceIdentifier.keyOf(appsInstance); + final InstanceIdentifier appInstance = thisInstance.firstIdentifierOf(App.class); + if (appInstance != null) { + final AppKey appKey = InstanceIdentifier.keyOf(appInstance); if (appKey != null) { gatePathMap.put("appId", appKey.getAppId()); } } - final InstanceIdentifier subsInstance = thisInstance.firstIdentifierOf(Subs.class); - if (subsInstance != null) { - final SubsKey subKey = InstanceIdentifier.keyOf(subsInstance); + final InstanceIdentifier subInstance = thisInstance.firstIdentifierOf(Subscriber.class); + if (subInstance != null) { + final SubscriberKey subKey = InstanceIdentifier.keyOf(subInstance); if (subKey != null) { - subId = subKey.getSubId(); + subId = subKey.getSubscriberId(); gatePathMap.put("subId", subId); } } - final InstanceIdentifier gatesInstance = thisInstance.firstIdentifierOf(Gates.class); + final InstanceIdentifier gatesInstance = thisInstance.firstIdentifierOf(Gate.class); if (gatesInstance != null) { - final GatesKey gateKey = InstanceIdentifier.keyOf(gatesInstance); + final GateKey gateKey = InstanceIdentifier.keyOf(gatesInstance); if (gateKey != null) { gatePathMap.put("gateId", gateKey.getGateId()); } @@ -303,14 +307,14 @@ public class PacketcableProvider implements BindingAwareProvider, DataChangeList logger.info("onDataChanged().getCcaps(): " + thisData); for (final Map.Entry, DataObject> entry : thisData.entrySet()) { - if (entry.getKey().getTargetType().equals(Ccaps.class)) { - Ccaps ccaps = ((Ccaps) entry.getValue()); - InstanceIdentifier ccapsIid = InstanceIdentifier.builder(Ccap.class).child(Ccaps.class, new CcapsKey(ccaps.getCcapId())).build(); + if (entry.getKey().getTargetType().equals(Ccap.class)) { + Ccap ccaps = ((Ccap) entry.getValue()); + InstanceIdentifier ccapsIid = InstanceIdentifier.builder(Ccaps.class).child(Ccap.class, new CcapKey(ccaps.getCcapId())).build(); ccapIidMap.put(ccapsIid, ccaps); } if (entry.getKey().getTargetType().equals(Connection.class) || - entry.getKey().getTargetType().equals(Ccaps.class)) { + entry.getKey().getTargetType().equals(Ccap.class)) { reqCcapIds.add(entry.getKey()); } } @@ -319,11 +323,11 @@ public class PacketcableProvider implements BindingAwareProvider, DataChangeList private void getGates(final Map, DataObject> thisData) { logger.info("onDataChanged().getGates(): " + thisData); for (final Map.Entry, DataObject> entry : thisData.entrySet()) { - if (entry.getValue() instanceof Gates) { - final Gates gate = (Gates)entry.getValue(); + if (entry.getValue() instanceof Gate) { + final Gate gate = (Gate)entry.getValue(); // TODO FIXME - Potential ClassCastException thrown here!!! - final InstanceIdentifier gateIID = (InstanceIdentifier)entry.getKey(); + final InstanceIdentifier gateIID = (InstanceIdentifier)entry.getKey(); getGatePathMap(gateIID); if (!gateIidMap.containsKey(gateIID)){ gateIidMap.put(gateIID, gate); @@ -337,8 +341,8 @@ public class PacketcableProvider implements BindingAwareProvider, DataChangeList // if (apps.getSubs() != null) { // for (Subs subs : apps.getSubs()) { // if (subs.getGates() != null) { -// for (Gates gates : subs.getGates()) { -// final InstanceIdentifier gateIID = (InstanceIdentifier)entry.getKey(); +// for (Gate gates : subs.getGates()) { +// final InstanceIdentifier gateIID = (InstanceIdentifier)entry.getKey(); // getGatePathMap(gateIID); // if (!gateIidMap.containsKey(gateIID)){ // gateIidMap.put(gateIID, gates); @@ -381,8 +385,8 @@ public class PacketcableProvider implements BindingAwareProvider, DataChangeList // get the CCAP parameters String message; if (! thisData.reqCcapIds.isEmpty()) { - for (Map.Entry, Ccaps> entry : thisData.ccapIidMap.entrySet()) { - final Ccaps thisCcap = entry.getValue(); + for (Map.Entry, Ccap> entry : thisData.ccapIidMap.entrySet()) { + final Ccap thisCcap = entry.getValue(); // get the CCAP node identity from the Instance Data final String ccapId = thisCcap.getCcapId(); @@ -414,14 +418,14 @@ public class PacketcableProvider implements BindingAwareProvider, DataChangeList } } else { // get the PCMM gate parameters from the ccapId/appId/subId/gateId path in the Maps entry (if new gate) - for (final Map.Entry, Gates> entry : thisData.gateIidMap.entrySet()) { + for (final Map.Entry, Gate> entry : thisData.gateIidMap.entrySet()) { message = null; - final Gates gate = entry.getValue(); + final Gate gate = entry.getValue(); final String gateId = gate.getGateId(); final String gatePathStr = thisData.gatePath + "/" + gateId ; final InetAddress subId = getInetAddress(thisData.subId); if (subId != null) { - final Ccaps thisCcap = findCcapForSubscriberId(subId); + final Ccap thisCcap = findCcapForSubscriberId(subId); if (thisCcap != null) { final String ccapId = thisCcap.getCcapId(); // verify SCN exists on CCAP and force gateSpec.Direction to align with SCN direction @@ -485,10 +489,10 @@ public class PacketcableProvider implements BindingAwareProvider, DataChangeList logger.info("onRemove(): " + thisData); for (final String gatePathStr: thisData.removePathList) { if (gateMap.containsKey(gatePathStr)) { - final Gates thisGate = gateMap.remove(gatePathStr); + final Gate thisGate = gateMap.remove(gatePathStr); final String gateId = thisGate.getGateId(); final String ccapId = gateCcapMap.remove(gatePathStr); - final Ccaps thisCcap = ccapMap.get(ccapId); + final Ccap thisCcap = ccapMap.get(ccapId); final PCMMService service = pcmmServiceMap.get(thisCcap.getCcapId()); if (service != null) { service.sendGateDelete(gatePathStr); @@ -501,7 +505,7 @@ public class PacketcableProvider implements BindingAwareProvider, DataChangeList } for (final String ccapIdStr: thisData.removePathList) { if (ccapMap.containsKey(ccapIdStr)) { - final Ccaps thisCcap = ccapMap.remove(ccapIdStr); + final Ccap thisCcap = ccapMap.remove(ccapIdStr); removeCcapFromAllMaps(thisCcap); } } @@ -511,16 +515,16 @@ public class PacketcableProvider implements BindingAwareProvider, DataChangeList logger.info("onUpdate(): " + oldData); // update operation not allowed -- restore the original config object and complain if (! oldData.ccapIidMap.isEmpty()) { - for (final Map.Entry, Ccaps> entry : oldData.ccapIidMap.entrySet()) { - final Ccaps ccap = entry.getValue(); + for (final Map.Entry, Ccap> entry : oldData.ccapIidMap.entrySet()) { + final Ccap ccap = entry.getValue(); final String ccapId = ccap.getCcapId(); // restores the original data - although I don't think this is what is done here! I think the update data is put into the DS/config mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, entry.getKey(), ccap); logger.error("onDataChanged(): CCAP update not permitted {}/{}", ccapId, ccap); } } else { - for (final Map.Entry, Gates> entry : oldData.gateIidMap.entrySet()) { - final Gates gate = entry.getValue(); + for (final Map.Entry, Gate> entry : oldData.gateIidMap.entrySet()) { + final Gate gate = entry.getValue(); final String gatePathStr = oldData.gatePath + "/" + gate.getGateId() ; // restores the original data - although I don't think this is what is done here! I think the update data is put into the DS/config mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, entry.getKey(), gate); diff --git a/packetcable-policy-server/src/main/java/org/opendaylight/controller/packetcable/provider/ValidateInstanceData.java b/packetcable-policy-server/src/main/java/org/opendaylight/controller/packetcable/provider/ValidateInstanceData.java index b930d6c..49afb8c 100644 --- a/packetcable-policy-server/src/main/java/org/opendaylight/controller/packetcable/provider/ValidateInstanceData.java +++ b/packetcable-policy-server/src/main/java/org/opendaylight/controller/packetcable/provider/ValidateInstanceData.java @@ -14,35 +14,34 @@ import java.lang.reflect.Method; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; - import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ServiceClassName; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ServiceFlowDirection; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.TosByte; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.TpProtocol; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ccap.Ccaps; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ccap.CcapsBuilder; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ccap.attributes.AmId; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ccap.attributes.AmIdBuilder; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ccap.attributes.Connection; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ccap.attributes.ConnectionBuilder; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.classifier.Classifier; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.classifier.ClassifierBuilder; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.ext.classifier.ExtClassifier; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.ext.classifier.ExtClassifierBuilder; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.gate.spec.GateSpec; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.gate.spec.GateSpecBuilder; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.gates.apps.subs.Gates; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.gates.apps.subs.GatesBuilder; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.ipv6.classifier.Ipv6Classifier; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.ipv6.classifier.Ipv6ClassifierBuilder; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.traffic.profile.TrafficProfile; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.traffic.profile.TrafficProfileBuilder; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ServiceClassName; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ServiceFlowDirection; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.TosByte; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.TpProtocol; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ccap.attributes.AmId; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ccap.attributes.AmIdBuilder; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ccap.attributes.Connection; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ccap.attributes.ConnectionBuilder; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ccaps.Ccap; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ccaps.CcapBuilder; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.classifier.Classifier; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.classifier.ClassifierBuilder; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.ext.classifier.ExtClassifier; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.ext.classifier.ExtClassifierBuilder; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.gate.spec.GateSpec; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.gate.spec.GateSpecBuilder; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.gates.apps.app.subscribers.subscriber.gates.Gate; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.gates.apps.app.subscribers.subscriber.gates.GateBuilder; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.ipv6.classifier.Ipv6Classifier; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.ipv6.classifier.Ipv6ClassifierBuilder; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.traffic.profile.TrafficProfile; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.traffic.profile.TrafficProfileBuilder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; @@ -56,11 +55,11 @@ public class ValidateInstanceData { private final MdsalUtils mdsalUtils; // Gate Identities - private final Map, Gates> gateIidMap; + private final Map, Gate> gateIidMap; // CCAP Identity - private transient Ccaps ccap; - private transient InstanceIdentifier ccapIID; + private transient Ccap ccap; + private transient InstanceIdentifier ccapIID; public ValidateInstanceData(final MdsalUtils mdsalUtils, final Map, DataObject> thisData) { this.mdsalUtils = mdsalUtils; @@ -83,9 +82,9 @@ public class ValidateInstanceData { return false; } } else if (! gateIidMap.isEmpty()) { - for (Map.Entry, Gates> entry : gateIidMap.entrySet()) { - InstanceIdentifier gateIID = entry.getKey(); - Gates gate = entry.getValue(); + for (Map.Entry, Gate> entry : gateIidMap.entrySet()) { + InstanceIdentifier gateIID = entry.getKey(); + Gate gate = entry.getValue(); if (! validateGate(gate)) { logger.error("Validate Gate {} failed - {}", gate.getGateId()); mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, gateIID); @@ -98,20 +97,20 @@ public class ValidateInstanceData { private void getCcap(final Map, DataObject> thisData) { for (final Map.Entry, DataObject> entry : thisData.entrySet()) { - if (entry.getValue() instanceof Ccaps) { - ccap = (Ccaps)entry.getValue(); + if (entry.getValue() instanceof Ccap) { + ccap = (Ccap)entry.getValue(); // TODO FIXME - ClassCastException waiting to occur here!!! - ccapIID = (InstanceIdentifier) entry.getKey(); + ccapIID = (InstanceIdentifier) entry.getKey(); } } } private void getGates(final Map, DataObject> thisData) { for (final Map.Entry, DataObject> entry : thisData.entrySet()) { - if (entry.getValue() instanceof Gates) { - final Gates gate = (Gates)entry.getValue(); + if (entry.getValue() instanceof Gate) { + final Gate gate = (Gate)entry.getValue(); // TODO FIXME - ClassCastException waiting to occur here!!! - final InstanceIdentifier gateIID = (InstanceIdentifier)entry.getKey(); + final InstanceIdentifier gateIID = (InstanceIdentifier)entry.getKey(); gateIidMap.put(gateIID, gate); } } @@ -129,7 +128,7 @@ public class ValidateInstanceData { return null; } - private boolean validateGateSpec(final Gates gate, final GatesBuilder gateBuilder) { + private boolean validateGateSpec(final Gate gate, final GateBuilder gateBuilder) { // gate-spec String message = ""; String error; @@ -190,7 +189,7 @@ public class ValidateInstanceData { return valid; } - private boolean validateTrafficProfile(final Gates gate, final GatesBuilder gateBuilder) { + private boolean validateTrafficProfile(final Gate gate, final GateBuilder gateBuilder) { // traffic-profile String message = ""; boolean valid = true; @@ -228,7 +227,7 @@ public class ValidateInstanceData { } // TODO FIXME - Break this method apart - private boolean validateClassifier(final Gates gate, final GatesBuilder gateBuilder) { + private boolean validateClassifier(final Gate gate, final GateBuilder gateBuilder) { // validate classifier String message = ""; boolean valid = true; @@ -334,7 +333,7 @@ public class ValidateInstanceData { } // TODO FIXME - breakup this method - private boolean validateExtClassifier(final Gates gate, final GatesBuilder gateBuilder) { + private boolean validateExtClassifier(final Gate gate, final GateBuilder gateBuilder) { // validate ext-classifier String message = ""; String error; @@ -505,7 +504,7 @@ public class ValidateInstanceData { } // TODO FIXME - break apart this method. - private boolean validateIpv6Classifier(final Gates gate, final GatesBuilder gateBuilder) { + private boolean validateIpv6Classifier(final Gate gate, final GateBuilder gateBuilder) { // validate ipv6-classifier String message = ""; String error; @@ -682,9 +681,9 @@ public class ValidateInstanceData { } // TODO FIXME - Do we really want the gate parameter object to be muted by this method? - private boolean validateGate(Gates gate) { + private boolean validateGate(Gate gate) { // validate gate elements and null out invalid elements as we go - final GatesBuilder gateBuilder = new GatesBuilder(); + final GateBuilder gateBuilder = new GateBuilder(); String message = ""; boolean rebuild = false; // gate-spec @@ -739,7 +738,7 @@ public class ValidateInstanceData { return (! rebuild); } - private boolean validateAmId(final Ccaps ccap, final CcapsBuilder ccapBuilder) { + private boolean validateAmId(final Ccap ccap, final CcapBuilder ccapBuilder) { // amId String message = ""; String error; @@ -789,7 +788,7 @@ public class ValidateInstanceData { return valid; } - private boolean validateConnection(final Ccaps ccap, final CcapsBuilder ccapBuilder) { + private boolean validateConnection(final Ccap ccap, final CcapBuilder ccapBuilder) { // connection String message = ""; String error; @@ -837,13 +836,13 @@ public class ValidateInstanceData { return valid; } - private boolean validateSubscriberSubnets(final Ccaps ccap, final CcapsBuilder ccapBuilder) { + private boolean validateSubscriberSubnets(final Ccap ccap, final CcapBuilder ccapBuilder) { // subscriber-subnets String message = ""; String error; boolean valid = true; List subnets = null; - error = validateMethod(Ccaps.class, ccap, "getSubscriberSubnets"); + error = validateMethod(Ccap.class, ccap, "getSubscriberSubnets"); if (error == null) { subnets = ccap.getSubscriberSubnets(); if (subnets == null) { @@ -862,13 +861,13 @@ public class ValidateInstanceData { return valid; } - private boolean validateUpstreamScns(final Ccaps ccap, final CcapsBuilder ccapBuilder) { + private boolean validateUpstreamScns(final Ccap ccap, final CcapBuilder ccapBuilder) { // upstream-scns String message = ""; String error; boolean valid = true; List usScns = null; - error = validateMethod(Ccaps.class, ccap, "getUpstreamScns"); + error = validateMethod(Ccap.class, ccap, "getUpstreamScns"); if (error == null) { usScns = ccap.getUpstreamScns(); if (usScns == null) { @@ -887,12 +886,12 @@ public class ValidateInstanceData { return valid; } - private boolean validateDownstreamScns(final Ccaps ccap, final CcapsBuilder ccapBuilder) { + private boolean validateDownstreamScns(final Ccap ccap, final CcapBuilder ccapBuilder) { // downstream-scns String message = ""; boolean valid = true; List dsScns = null; - final String error = validateMethod(Ccaps.class, ccap, "getDownstreamScns"); + final String error = validateMethod(Ccap.class, ccap, "getDownstreamScns"); if (error == null) { dsScns = ccap.getDownstreamScns(); if (dsScns == null) { @@ -913,9 +912,9 @@ public class ValidateInstanceData { // TODO FIXME - Do we really want the ccap parameter object to be muted by this method? - private boolean validateCcap(Ccaps ccap) { + private boolean validateCcap(Ccap ccap) { // validate ccap and null out invalid elements as we go - final CcapsBuilder ccapBuilder = new CcapsBuilder(); + final CcapBuilder ccapBuilder = new CcapBuilder(); String message = ""; boolean rebuild = false; // amId diff --git a/packetcable-policy-server/src/test/java/org/opendaylight/controller/packetcable/provider/PCMMServiceTest.java b/packetcable-policy-server/src/test/java/org/opendaylight/controller/packetcable/provider/PCMMServiceTest.java index 55b9e6e..8225e4d 100644 --- a/packetcable-policy-server/src/test/java/org/opendaylight/controller/packetcable/provider/PCMMServiceTest.java +++ b/packetcable-policy-server/src/test/java/org/opendaylight/controller/packetcable/provider/PCMMServiceTest.java @@ -4,6 +4,17 @@ package org.opendaylight.controller.packetcable.provider; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.InetAddress; +import java.net.Socket; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -12,37 +23,36 @@ import org.mockito.Mockito; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ServiceClassName; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ServiceFlowDirection; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.TosByte; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.TpProtocol; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ccap.Ccaps; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ccap.attributes.AmId; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.ccap.attributes.Connection; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.classifier.Classifier; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.gate.spec.GateSpec; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.gates.apps.subs.Gates; -import org.opendaylight.yang.gen.v1.urn.packetcable.rev150327.pcmm.qos.traffic.profile.TrafficProfile; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ServiceClassName; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ServiceFlowDirection; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.TosByte; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.TpProtocol; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ccap.attributes.AmId; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ccap.attributes.Connection; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.ccaps.Ccap; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.classifier.Classifier; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.gate.spec.GateSpec; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.gates.apps.app.subscribers.subscriber.gates.Gate; +import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.traffic.profile.TrafficProfile; import org.pcmm.PCMMPdpAgent; import org.pcmm.gates.IGateSpec.Direction; import org.pcmm.gates.IPCMMGate; import org.pcmm.rcd.IPCMMClient; import org.pcmm.rcd.impl.CMTS; -import org.umu.cops.stack.*; +import org.umu.cops.stack.COPSClientSI; +import org.umu.cops.stack.COPSContext; import org.umu.cops.stack.COPSContext.RType; +import org.umu.cops.stack.COPSData; +import org.umu.cops.stack.COPSDecision; import org.umu.cops.stack.COPSDecision.Command; import org.umu.cops.stack.COPSDecision.DecisionFlag; +import org.umu.cops.stack.COPSDecisionMsg; +import org.umu.cops.stack.COPSHandle; +import org.umu.cops.stack.COPSMsg; +import org.umu.cops.stack.COPSMsgParser; import org.umu.cops.stack.COPSObjHeader.CNum; import org.umu.cops.stack.COPSObjHeader.CType; -import java.io.*; -import java.net.InetAddress; -import java.net.Socket; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - /** * Tests the PCMMService's ability to connect to a CMTS. Gate additions will not properly work as there is currently * not any other means to receive acknowledgements. This functionality must be tested by the PCMMService's client @@ -85,7 +95,7 @@ public class PCMMServiceTest { /** * Defines the CMTS to add to the PCMMService */ - private Ccaps ccap; + private Ccap ccap; /** * The class under test @@ -109,7 +119,7 @@ public class PCMMServiceTest { // Use me when testing against a CMTS or emulator not running in the same JVM cmtsAddr = new Ipv4Address("10.32.10.3"); - ccap = makeCcapsObj(PCMMPdpAgent.WELL_KNOWN_PDP_PORT, cmtsAddr, ccapId); + ccap = makeCcapObj(PCMMPdpAgent.WELL_KNOWN_PDP_PORT, cmtsAddr, ccapId); } else { cmAddrInet = InetAddress.getByAddress(new byte[] {10, 32, 110, (byte)180}); invalidCmAddrInet = InetAddress.getByAddress(new byte[] {99, 99, 99, 99}); @@ -117,13 +127,13 @@ public class PCMMServiceTest { // Use me for automated testing and the CMTS emulator running in the same JVM cmtsAddr = new Ipv4Address("127.0.0.1"); - final Set upGates = new HashSet<>(); - upGates.add("extrm_up"); - final Set dnGates = new HashSet<>(); - dnGates.add("extrm_dn"); + final Set upGate = new HashSet<>(); + upGate.add("extrm_up"); + final Set dnGate = new HashSet<>(); + dnGate.add("extrm_dn"); final Map> gates = new HashMap<>(); - gates.put(Direction.UPSTREAM, upGates); - gates.put(Direction.DOWNSTREAM, dnGates); + gates.put(Direction.UPSTREAM, upGate); + gates.put(Direction.DOWNSTREAM, dnGate); final Map cmStatus = new HashMap<>(); cmStatus.put(cmAddrInet.getHostAddress(), true); @@ -131,7 +141,7 @@ public class PCMMServiceTest { icmts = new CMTS(gates, cmStatus); icmts.startServer(); - ccap = makeCcapsObj(icmts.getPort(), cmtsAddr, ccapId); + ccap = makeCcapObj(icmts.getPort(), cmtsAddr, ccapId); } service = new PCMMService(IPCMMClient.CLIENT_TYPE, ccap); @@ -153,7 +163,7 @@ public class PCMMServiceTest { final int port; if (icmts != null) port = icmts.getPort() + 1; else port = PCMMPdpAgent.WELL_KNOWN_PDP_PORT + 1; - ccap = makeCcapsObj(port, cmtsAddr, ccapId); + ccap = makeCcapObj(port, cmtsAddr, ccapId); service = new PCMMService(IPCMMClient.CLIENT_TYPE, ccap); final String message = service.addCcap(); Assert.assertNotNull(message); @@ -264,7 +274,7 @@ public class PCMMServiceTest { final Socket socket = new MockSocket(); final ServiceFlowDirection direction = ServiceFlowDirection.Us; - final Gates gate = makeGateObj("extrm_up", cmtsAddr, direction, new Ipv4Address("127.0.0.1")); + final Gate gate = makeGateObj("extrm_up", cmtsAddr, direction, new Ipv4Address("127.0.0.1")); final IPCMMGate gateReq = makeGateRequest(ccap, gate, InetAddress.getByName("localhost"), direction); final byte[] data = gateReq.getData(); @@ -328,7 +338,7 @@ public class PCMMServiceTest { final Ipv4Address dstAddr, final ServiceFlowDirection direction, final InetAddress cmAddrInet, final String gatePath, final String expGateSetMsgStart) { - final Gates gate = makeGateObj(scnName, srcAddr, direction, dstAddr); + final Gate gate = makeGateObj(scnName, srcAddr, direction, dstAddr); final String gateSetMsg = service.sendGateSet(gatePath, cmAddrInet, gate, direction); Assert.assertNotNull(gateSetMsg); @@ -356,14 +366,14 @@ public class PCMMServiceTest { } /** - * Creates a mock Ccaps object that can be used for connecting to a CMTS + * Creates a mock Ccap object that can be used for connecting to a CMTS * @param inPort - the CMTS port number * @param ipAddr - the CMTS IPv4 address string * @param ccapId - the ID of the CCAP - * @return - the mock Ccaps object + * @return - the mock Ccap object */ - private Ccaps makeCcapsObj(final int inPort, final Ipv4Address ipAddr, final String ccapId) { - final Ccaps ccap = Mockito.mock(Ccaps.class); + private Ccap makeCcapObj(final int inPort, final Ipv4Address ipAddr, final String ccapId) { + final Ccap ccap = Mockito.mock(Ccap.class); final Connection conn = Mockito.mock(Connection.class); Mockito.when(ccap.getConnection()).thenReturn(conn); final PortNumber port = Mockito.mock(PortNumber.class); @@ -384,14 +394,14 @@ public class PCMMServiceTest { } /** - * Creates a mock Gates object + * Creates a mock Gate object * @param scnValue - the service class name defined on the CMTS * @param dstAddr - the CM address this gate should be set against * @return - the gate request */ - private Gates makeGateObj(final String scnValue, final Ipv4Address srcAddr, final ServiceFlowDirection direction, + private Gate makeGateObj(final String scnValue, final Ipv4Address srcAddr, final ServiceFlowDirection direction, final Ipv4Address dstAddr) { - final Gates gate = Mockito.mock(Gates.class); + final Gate gate = Mockito.mock(Gate.class); final GateSpec gateSpec = Mockito.mock(GateSpec.class); Mockito.when(gate.getGateSpec()).thenReturn(gateSpec); Mockito.when(gateSpec.getDirection()).thenReturn(direction); @@ -430,31 +440,31 @@ public class PCMMServiceTest { return gate; } - private IPCMMGate makeGateRequest(final Ccaps ccap, final Gates gateReq, final InetAddress addrSubId, + private IPCMMGate makeGateRequest(final Ccap ccap, final Gate gateReq, final InetAddress addrSubId, final ServiceFlowDirection direction) { final PCMMGateReqBuilder gateBuilder = new PCMMGateReqBuilder(); - gateBuilder.build(ccap.getAmId()); - gateBuilder.build(addrSubId); + gateBuilder.setAmId(ccap.getAmId()); + gateBuilder.setSubscriberId(addrSubId); // force gateSpec.Direction to align with SCN direction final ServiceClassName scn = gateReq.getTrafficProfile().getServiceClassName(); if (scn != null) { - gateBuilder.build(gateReq.getGateSpec(), direction); + gateBuilder.setGateSpec(gateReq.getGateSpec(), direction); } else { // not an SCN gate - gateBuilder.build(gateReq.getGateSpec(), null); + gateBuilder.setGateSpec(gateReq.getGateSpec(), null); } - gateBuilder.build(gateReq.getTrafficProfile()); + gateBuilder.setTrafficProfile(gateReq.getTrafficProfile()); // pick a classifier type (only one for now) if (gateReq.getClassifier() != null) { - gateBuilder.build(gateReq.getClassifier()); + gateBuilder.setClassifier(gateReq.getClassifier()); } else if (gateReq.getExtClassifier() != null) { - gateBuilder.build(gateReq.getExtClassifier()); + gateBuilder.setExtClassifier(gateReq.getExtClassifier()); } else if (gateReq.getIpv6Classifier() != null) { - gateBuilder.build(gateReq.getIpv6Classifier()); + gateBuilder.setIpv6Classifier(gateReq.getIpv6Classifier()); } // assemble the final gate request - return gateBuilder.getGateReq(); + return gateBuilder.build(); } private class MockSocket extends Socket {