diff options
author | Steven Saunders <steve@sentosatech.com> | 2015-12-16 14:31:40 -0700 |
---|---|---|
committer | Steven Saunders <steve@sentosatech.com> | 2015-12-16 14:33:44 -0700 |
commit | 754851249b5722222a84e5a821f6edea095e72e7 (patch) | |
tree | 72f1abf438e8fb877ebf0be5aa65e2a2c56888fc | |
parent | b123b74d81d20efbb594db5eb1fb17ed79953c58 (diff) |
make create, delete, get work with new topology based REST callsHEADstable/brahmaputramaster
Change-Id: Iad6fa28971ad61003d34ed38ab2e2d8647dc31bd
Signed-off-by: Steven Saunders <steve@sentosatech.com>
9 files changed, 179 insertions, 159 deletions
diff --git a/demo-ui/app/config.json b/demo-ui/app/config.json index 56c74c6..05e2f47 100644 --- a/demo-ui/app/config.json +++ b/demo-ui/app/config.json @@ -9,24 +9,14 @@ "uniList" : [ { - "ip" : "10.1.1.11", - "mac" : "00:11:11:11:11:11", - "address" : "Denver" + "ip" : "10.36.0.21", + "mac" : "00:21:21:21:21:21", + "address" : "pi-left" }, { - "ip" : "10.1.1.12", + "ip" : "10.36.0.22", "mac" : "00:22:22:22:22:22", - "address" : "Paris" - }, - { - "ip" : "10.1.1.13", - "mac" : "00:33:33:33:33:33", - "address" : "Tokyo" - }, - { - "ip" : "10.1.1.14", - "mac" : "00:44:44:44:44:44", - "address" : "Quebec" + "address" : "pi-right" } ] }
\ No newline at end of file diff --git a/demo-ui/app/controllers/MefController.js b/demo-ui/app/controllers/MefController.js index 9d89589..fd615de 100644 --- a/demo-ui/app/controllers/MefController.js +++ b/demo-ui/app/controllers/MefController.js @@ -31,11 +31,11 @@ var MefController = function($scope, $log, mefServices, model, dbg ) { $scope.uniToSpeedString = function(uni) { if (uni) { - speed = uni.uni[0].speed; - return Object.getOwnPropertyNames(speed)[0];s + speed = uni.node[0]["cl-unimgr-mef:speed"]; + return Object.getOwnPropertyNames(speed)[0]; } else - return ""; + return "error: no uni supplied"; } // // HTTP Response Handlers diff --git a/demo-ui/app/services/mefServices.js b/demo-ui/app/services/mefServices.js index 0ecfb6a..6bbe8e3 100644 --- a/demo-ui/app/services/mefServices.js +++ b/demo-ui/app/services/mefServices.js @@ -14,10 +14,10 @@ var _evcBasePath = "/evcmgr/webapi/evc" var _evcUrl = "unset"; - var _uniBasePath = "/restconf/operational/cl-vcpe-mef:unis/uni" + var _uniBasePath = "/restconf/config/network-topology:network-topology/topology/unimgr:uni/node" var _uniUrl = "unset"; - var _evcPathBasePath = "/restconf/operational/cl-vcpe-mef:evcs" + var _evcPathBasePath = "/restconf/config/network-topology:network-topology/topology/unimgr:evc/link" var _evcPathUrl = "unset"; // diff --git a/demo-ui/app/views/css/vcpe.css b/demo-ui/app/views/css/vcpe.css index 0d08734..4e81462 100644 --- a/demo-ui/app/views/css/vcpe.css +++ b/demo-ui/app/views/css/vcpe.css @@ -26,7 +26,7 @@ input[type='number'] { background-color: none; } .selected-item-idle { - background-color: #e3e3e3; + background-color: #E3E3E3; } .selected-item-delete { background-color: #FFE4E1; @@ -36,7 +36,7 @@ input[type='number'] { } .primary-container { border: 3px solid black; - background-color: #e3e3e3; + background-color: #E3E3E3; border-radius: 15px; padding: 10px; height: 400px; @@ -169,7 +169,7 @@ input[type='number'] { } .frame .content .action-container .cos-container { border: 3px solid black; - background-color: #e3e3e3; + background-color: #E3E3E3; border-radius: 15px; padding: 10px; height: 400px; @@ -206,7 +206,7 @@ input[type='number'] { } .frame .content .action-container .epl-container { border: 3px solid black; - background-color: #e3e3e3; + background-color: #E3E3E3; border-radius: 15px; padding: 10px; height: 400px; @@ -243,7 +243,7 @@ input[type='number'] { } .frame .content .monitor-container .mef-container { border: 3px solid black; - background-color: #e3e3e3; + background-color: #E3E3E3; border-radius: 15px; padding: 10px; height: 400px; @@ -266,7 +266,7 @@ input[type='number'] { font-size: small; font-weight: bold; text-align: center; - background-color: #e3e3e3; + background-color: #E3E3E3; } .frame .content .monitor-container .mef-container .mef-data-label { color: purple; diff --git a/demo-ui/app/views/mef-panel.html b/demo-ui/app/views/mef-panel.html index df9f60b..9a88e88 100644 --- a/demo-ui/app/views/mef-panel.html +++ b/demo-ui/app/views/mef-panel.html @@ -27,7 +27,7 @@ To Do <div class="uni-label-col">Uni ID:</div> <div class="data-col" ng-show="showEvcValues()"> <span class="data-item"> - {{ currentEvcUnis[0].uni[0]["id"] }} + {{ currentEvcUnis[0].node[0]["node-id"] }} </span> </div> </div> @@ -36,7 +36,7 @@ To Do <div class="uni-label-col">IP Address:</div> <div class="data-col" ng-show="showEvcValues()"> <span class="data-item"> - {{ currentEvcUnis[0].uni[0]["ip-address"] }} + {{ currentEvcUnis[0].node[0]["cl-unimgr-mef:ip-address"] }} </span> </div> </div> @@ -45,7 +45,7 @@ To Do <div class="uni-label-col">MAC Address:</div> <div class="data-col" ng-show="showEvcValues()"> <span class="data-item"> - {{ currentEvcUnis[0].uni[0]["mac-address"] }} + {{ currentEvcUnis[0].node[0]["cl-unimgr-mef:mac-address"] }} </span> </div> </div> @@ -63,7 +63,7 @@ To Do <div class="uni-label-col">Mac Layer:</div> <div class="data-col" ng-show="showEvcValues()"> <span class="data-item"> - {{ currentEvcUnis[0].uni[0]["mac-layer"] }} + {{ currentEvcUnis[0].node[0]["cl-unimgr-mef:mac-layer"] }} </span> </div> </div> @@ -72,7 +72,7 @@ To Do <div class="uni-label-col">Phys Medium:</div> <div class="data-col" ng-show="showEvcValues()"> <span class="data-item"> - {{ currentEvcUnis[0].uni[0]["physical-medium"] }} + {{ currentEvcUnis[0].node[0]["cl-unimgr-mef:physical-medium"] }} </span> </div> </div> @@ -81,7 +81,7 @@ To Do <div class="uni-label-col">MTU Size:</div> <div class="data-col" ng-show="showEvcValues()"> <span class="data-item"> - {{ currentEvcUnis[0].uni[0]["mtu-size"] }} + {{ currentEvcUnis[0].node[0]["cl-unimgr-mef:mtu-size"] }} </span> </div> </div> @@ -90,7 +90,7 @@ To Do <div class="uni-label-col">Mode:</div> <div class="data-col" ng-show="showEvcValues()"> <span class="data-item"> - {{ currentEvcUnis[0].uni[0]["mode"] }} + {{ currentEvcUnis[0].node[0]["cl-unimgr-mef:mode"] }} </span> </div> </div> @@ -99,7 +99,7 @@ To Do <div class="uni-label-col">Type:</div> <div class="data-col" ng-show="showEvcValues()"> <span class="data-item"> - {{ currentEvcUnis[0].uni[0]["type"] }} + {{ currentEvcUnis[0].node[0]["cl-unimgr-mef:type"] }} </span> </div> </div> @@ -289,7 +289,7 @@ To Do <div class="uni-label-col">Uni ID:</div> <div class="data-col" ng-show="showEvcValues()"> <span class="data-item"> - {{ currentEvcUnis[1].uni[0]["id"] }} + {{ currentEvcUnis[1].node[0]["node-id"] }} </span> </div> </div> @@ -298,7 +298,7 @@ To Do <div class="uni-label-col">IP Address:</div> <div class="data-col" ng-show="showEvcValues()"> <span class="data-item"> - {{ currentEvcUnis[1].uni[0]["ip-address"] }} + {{ currentEvcUnis[1].node[0]["cl-unimgr-mef:ip-address"] }} </span> </div> </div> @@ -307,7 +307,7 @@ To Do <div class="uni-label-col">MAC Address:</div> <div class="data-col" ng-show="showEvcValues()"> <span class="data-item"> - {{ currentEvcUnis[1].uni[0]["mac-address"] }} + {{ currentEvcUnis[1].node[0]["cl-unimgr-mef:mac-address"] }} </span> </div> </div> @@ -325,7 +325,7 @@ To Do <div class="uni-label-col">Mac Layer:</div> <div class="data-col" ng-show="showEvcValues()"> <span class="data-item"> - {{ currentEvcUnis[1].uni[0]["mac-layer"] }} + {{ currentEvcUnis[1].node[0]["cl-unimgr-mef:mac-layer"] }} </span> </div> </div> @@ -334,7 +334,7 @@ To Do <div class="uni-label-col">Phys Medium:</div> <div class="data-col" ng-show="showEvcValues()"> <span class="data-item"> - {{ currentEvcUnis[1].uni[0]["physical-medium"] }} + {{ currentEvcUnis[1].node[0]["cl-unimgr-mef:physical-medium"] }} </span> </div> </div> @@ -343,7 +343,7 @@ To Do <div class="uni-label-col">MTU Size:</div> <div class="data-col" ng-show="showEvcValues()"> <span class="data-item"> - {{ currentEvcUnis[0].uni[0]["mtu-size"] }} + {{ currentEvcUnis[1].node[0]["cl-unimgr-mef:mtu-size"] }} </span> </div> </div> @@ -352,7 +352,7 @@ To Do <div class="uni-label-col">Mode:</div> <div class="data-col" ng-show="showEvcValues()"> <span class="data-item"> - {{ currentEvcUnis[1].uni[0]["mode"] }} + {{ currentEvcUnis[1].node[0]["cl-unimgr-mef:mode"] }} </span> </div> </div> @@ -361,7 +361,7 @@ To Do <div class="uni-label-col">Type:</div> <div class="data-col" ng-show="showEvcValues()"> <span class="data-item"> - {{ currentEvcUnis[1].uni[0]["type"] }} + {{ currentEvcUnis[1].node[0]["cl-unimgr-mef:type"] }} </span> </div> </div> diff --git a/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/client/EvcPathClient.java b/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/client/EvcPathClient.java index 0fb47d1..50feb6c 100644 --- a/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/client/EvcPathClient.java +++ b/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/client/EvcPathClient.java @@ -29,9 +29,10 @@ import java.util.List; public class EvcPathClient { + // private String evcMgrServer = "10.36.0.20"; private String evcMgrServer = "localhost"; private String evcMgrPort = "8181"; - private String evcMgrCfgRESTPath = "/restconf/config/cl-vcpe-mef:evcs/"; + private String evcMgrCfgRESTPath = "/restconf/config/network-topology:network-topology/topology/unimgr:evc/link/"; private Client client; // provided by Jersey @@ -49,7 +50,7 @@ public class EvcPathClient { Dbg.p("\nEVC Create JSON:"); Dbg.p(json); - Response response = target.path("evc") + Response response = target.path("") .request(MediaType.APPLICATION_JSON) .post(Entity.entity(json, MediaType.APPLICATION_JSON)); @@ -74,7 +75,7 @@ public class EvcPathClient { Dbg.p("\nEVC Create/Update JSON:"); Dbg.p(json); - Response response = target.path("evc/"+evcPath.getId()) + Response response = target.path(evcPath.getId()) .request(MediaType.APPLICATION_JSON) .header("Authorization", authorizationHeaderValue) .put(Entity.entity(json, MediaType.APPLICATION_JSON)); @@ -97,7 +98,7 @@ public class EvcPathClient { String authorizationHeaderValue = "Basic " + DatatypeConverter.printBase64Binary(uNameAndPass.getBytes("UTF-8")); - Response response = target.path("evc/" + evcPathId) + Response response = target.path(evcPathId) .request(MediaType.APPLICATION_JSON) .header("Authorization", authorizationHeaderValue) .delete(); diff --git a/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/client/UniClient.java b/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/client/UniClient.java index 08994fe..a61f0d9 100644 --- a/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/client/UniClient.java +++ b/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/client/UniClient.java @@ -31,10 +31,15 @@ import javax.xml.bind.DatatypeConverter; public class UniClient { + // put this in config file + // private String uniMgrServer = "localhost"; + + //private String uniMgrServer = "10.36.0.20"; private String uniMgrServer = "localhost"; private String uniMgrPort = "8181"; - private String uniMgrCfgRESTPath = "/restconf/config/cl-vcpe-mef:unis/"; - private String uniMgrOpRESTPath = "/restconf/operational/cl-vcpe-mef:unis/"; + + private String uniMgrCfgRESTPath = "/restconf/config/network-topology:network-topology/topology/unimgr:uni/node/"; + private String uniMgrOpRESTPath = "/restconf/operational/network-topology:network-topology/topology/unimgr:uni/node/"; private Client client; // provided by Jersey @@ -43,37 +48,9 @@ public class UniClient { } //-------------------------------------------------------- - public Response create(Uni uni ) throws Exception - //-------------------------------------------------------- - // create Uni - { - WebTarget target =client.target("http://"+uniMgrServer+":" + uniMgrPort + uniMgrCfgRESTPath); - - String json = uni.toJson(); - Dbg.p("\nUNI Create JSON:"); - Dbg.p(json); - - String uNameAndPass = "admin:admin"; - String authorizationHeaderValue = "Basic " + - DatatypeConverter.printBase64Binary(uNameAndPass.getBytes("UTF-8")); - Response response = target.path("uni") - .request(MediaType.APPLICATION_JSON) - .header("Authorization", authorizationHeaderValue) - .post(Entity.entity(json, MediaType.APPLICATION_JSON)); - - if (response.getStatus() != 200 ) // figure out how to use Status.OK - { - // in production you can be more specific based on reponse code, id, etc - throw new RuntimeException(response.getStatus() + ": there was an error on the server."); - } - //return response.readEntity(Uni.class); - return response; - } - - //-------------------------------------------------------- public Response update(Uni uni) throws Exception //-------------------------------------------------------- - // create/update Uni. This seems to be how OLD expects uni creation + // create/update Uni. This seems to be how ODL expects uni creation { WebTarget target =client.target("http://"+uniMgrServer+":" + uniMgrPort + uniMgrCfgRESTPath); @@ -84,7 +61,7 @@ public class UniClient { String uNameAndPass = "admin:admin"; String authorizationHeaderValue = "Basic " + DatatypeConverter.printBase64Binary(uNameAndPass.getBytes("UTF-8")); - Response response = target.path("uni/"+uni.getId()) + Response response = target.path(uni.getId()) .request(MediaType.APPLICATION_JSON) .header("Authorization", authorizationHeaderValue) .put(Entity.entity(json, MediaType.APPLICATION_JSON)); @@ -108,7 +85,7 @@ public class UniClient { String authorizationHeaderValue = "Basic " + DatatypeConverter.printBase64Binary(uNameAndPass.getBytes("UTF-8")); - Response response = target.path("uni/" + uniId) + Response response = target.path(uniId) .request(MediaType.APPLICATION_JSON) .header("Authorization", authorizationHeaderValue) .delete(); @@ -120,10 +97,6 @@ public class UniClient { } } - // - // Code from here below requires work in order to work with ODL - // - //-------------------------------------------------------- public Uni get(String uniId) throws Exception //-------------------------------------------------------- @@ -143,7 +116,6 @@ public class UniClient { return JsonToUni(uni, uniJson); } - //-------------------------------------------------------- public Uni JsonToUni(Uni uni, String uniJson) { //-------------------------------------------------------- @@ -239,6 +211,39 @@ public class UniClient { return uni; } + // + // Code from here below requires work in order to work with ODL + // Currently none of the calls below are being invoked + // Consider removing these from the source + // + + //-------------------------------------------------------- + public Response create(Uni uni ) throws Exception + //-------------------------------------------------------- + // create Uni + { + WebTarget target =client.target("http://"+uniMgrServer+":" + uniMgrPort + uniMgrCfgRESTPath); + + String json = uni.toJson(); + Dbg.p("\nUNI Create JSON:"); + Dbg.p(json); + + String uNameAndPass = "admin:admin"; + String authorizationHeaderValue = "Basic " + + DatatypeConverter.printBase64Binary(uNameAndPass.getBytes("UTF-8")); + Response response = target.path("uni") + .request(MediaType.APPLICATION_JSON) + .header("Authorization", authorizationHeaderValue) + .post(Entity.entity(json, MediaType.APPLICATION_JSON)); + + if (response.getStatus() != 200 ) // figure out how to use Status.OK + { + // in production you can be more specific based on reponse code, id, etc + throw new RuntimeException(response.getStatus() + ": there was an error on the server."); + } + //return response.readEntity(Uni.class); + return response; + } //-------------------------------------------------------- public List<Uni> getAll() diff --git a/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/model/EvcPath.java b/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/model/EvcPath.java index 469b05b..6c97cf8 100644 --- a/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/model/EvcPath.java +++ b/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/model/EvcPath.java @@ -36,71 +36,72 @@ public class EvcPath { public String toJson() { -//{ -// "evc": -// { -// "evc:id": "822f8284-2b35-11e5-b345-feff819cdc9f", -// "evc:uni-dest": -// [ -// { -// "order": 0, -// "uni": "822f7eec-2b35-11e5-b345-feff819cdc9f" -// } -// ], -// "evc:uni-source": -// [ -// { -// "order": 0, -// "uni": "111f7eec-2c35-11e5-b345-feff819cdc9f" -// } -// ], -// "evc:cos-id": "string", -// "evc:ingress-bw": -// { -// "speed-1G": {} -// }, -// "evc:egress-bw": -// { -// "speed-1G": {} -// } -// } -//} - - String json = "{\n"+ - " \"evc\":\n"+ - " {\n"+ - " \"evc:id\": \""+ this.getId() +"\",\n"+ - " \"evc:uni-dest\":\n"+ - " [\n"+ - " {\n"+ - " \"order\": 0,\n"+ - " \"uni\": \""+ this.uni1.getId() +"\"\n"+ - " }\n"+ - " ],\n"+ - " \"evc:uni-source\":\n"+ - " [\n"+ - " {\n"+ - " \"order\": 0,\n"+ - " \"uni\": \""+ this.uni2.getId() +"\"\n"+ - " }\n"+ - " ],\n"+ - " \"evc:cos-id\": \""+ this.getCos() +"\",\n"+ - " \"evc:ingress-bw\":\n"+ - " {\n"+ -// " \"speed-1G\": {}\n"+ - " \"" + this.getIngressBW() + "\": {}\n"+ - " },\n"+ - " \"evc:egress-bw\":\n"+ + // { + // "network-topology:link": + // [ + // { + // "evc:link-id": "evc1", + // "evc:uni-dest": [ + // { + // "order": 0, + // "ip-address": "10.36.0.21" + // } + // ], + + // "evc:uni-source": [ + // { + // "order": 0, + // "ip-address": "10.36.0.22" + // } + // ], + + // "evc:cos-id": "string", + // "evc:ingress-bw": { + // "speed-1G": {} + // }, + // "evc:egress-bw": { + // "speed-1G": {} + // } + // } + // ] + // } + + String json = + + "{\n"+ + " \"network-topology:link\":\n" + + " [" + " {\n"+ -// " \"speed-1G\": {}\n"+ - " \"" + this.getEgressBW() + "\": {}\n"+ + " \"evc:link-id\": \""+ this.getId() +"\",\n"+ + " \"evc:uni-dest\":\n"+ + " [\n"+ + " {\n"+ + " \"order\": 0,\n"+ + " \"ip-address\": \""+ this.uni1.getIpAddress() +"\"\n"+ + " }\n"+ + " ],\n"+ + " \"evc:uni-source\":\n"+ + " [\n"+ + " {\n"+ + " \"order\": 0,\n"+ + " \"ip-address\": \""+ this.uni2.getIpAddress() +"\"\n"+ + " }\n"+ + " ],\n"+ + " \"evc:cos-id\": \""+ this.getCos() +"\",\n"+ + " \"evc:ingress-bw\":\n"+ + " {\n"+ + " \"" + this.getIngressBW() + "\": {}\n"+ + " },\n"+ + " \"evc:egress-bw\":\n"+ + " {\n"+ + " \"" + this.getEgressBW() + "\": {}\n"+ + " }\n"+ " }\n"+ - " }\n"+ + " ]" + "}"; return json; } - public String getId() { return id; } public void setId(String id) { this.id = id; } diff --git a/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/model/Uni.java b/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/model/Uni.java index cec4d80..0edf3db 100644 --- a/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/model/Uni.java +++ b/uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/model/Uni.java @@ -126,22 +126,45 @@ public class Uni public String toJson() { - String json = "{\n"+ - " \"uni\":\n"+ - " {\n"+ - " \"uni:id\": \""+ this.getId() +"\",\n"+ - " \"speed\":\n" + - " {\n" + - " \"" + this.getSpeed() + "\": "+"\"1\"\n"+ - " },\n"+ - " \"uni:mac-layer\": \""+ this.getMacLayer() +"\",\n"+ - " \"uni:physical-medium\": \""+ this.getPhysicalMedium() +"\",\n"+ - " \"uni:mtu-size\": \""+ this.getMtuSize() +"\",\n"+ - " \"uni:type\": \"\",\n"+ - " \"uni:mac-address\": \""+ this.getMacAddress() +"\",\n"+ - " \"uni:ip-address\": \""+ this.getIpAddress() +"\",\n"+ - " \"uni:mode\": \""+ this.getMode() +"\"\n"+ - " }\n"+ + /* + { + "network-topology:node": [ + { + "node-id": "uni1", + "speed": { + "speed-1G": 1 + }, + "uni:mac-layer": "IEEE 802.3-2005", + "uni:physical-medium": "UNI TypeFull Duplex 2 Physical Interface", + "uni:mtu-size": 0, + "uni:type": "", + "uni:mac-address": "b8:27:eb:c9:a9:66", + "uni:ip-address": "10.36.0.21", + "uni:mode": "Full Duplex" + } + ] + } + */ + + String json = + "{\n"+ + " \"network-topology:node\":\n" + + " [" + + " {\n"+ + " \"node-id\": \""+ this.getId() +"\",\n"+ + " \"speed\":\n" + + " {\n" + + " \"" + this.getSpeed() + "\": "+"\"1\"\n"+ + " },\n"+ + " \"uni:mac-layer\": \""+ this.getMacLayer() +"\",\n"+ + " \"uni:physical-medium\": \""+ this.getPhysicalMedium() +"\",\n"+ + " \"uni:mtu-size\": \""+ this.getMtuSize() +"\",\n"+ + " \"uni:type\": \"\",\n"+ + " \"uni:mac-address\": \""+ this.getMacAddress() +"\",\n"+ + " \"uni:ip-address\": \""+ this.getIpAddress() +"\",\n"+ + " \"uni:mode\": \""+ this.getMode() +"\"\n"+ + " }\n"+ + " ]" + "}"; return json; |