--- /dev/null
+/*
+ * Copyright (c) 2015 CableLabs and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.unimgr.cli;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.opendaylight.unimgr.api.IUnimgrConsoleProvider;
+import org.opendaylight.unimgr.impl.UnimgrConstants;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.EvcAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.EvcAugmentationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.UniAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.evc.EgressBw;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.evc.IngressBw;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.evc.UniDest;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.evc.UniDestBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.evc.UniDestKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.evc.UniSource;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.evc.UniSourceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.evc.UniSourceKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.service.speed.speed.Speed100MBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.service.speed.speed.Speed10GBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.service.speed.speed.Speed10MBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.service.speed.speed.Speed1GBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Command(name = "evc-add",
+scope = "uni",
+description = "Add evc to the controller.")
+
+public class EvcAddShellCommand extends OsgiCommandSupport {
+
+ private static final Logger LOG = LoggerFactory.getLogger(EvcAddShellCommand.class);
+ protected IUnimgrConsoleProvider provider;
+
+ @Option(name = "-IPs",
+ aliases = { "--IP-Address-source-uni" },
+ description = "The IP address of the source UNI.\n-IPs / --IP Address source uni",
+ required = true,
+ multiValued = false)
+ private String IPs = "";
+
+ @Option(name = "-IPd",
+ aliases = { "--IP-Address-destenation-uni" },
+ description = "The IP address of the destenation UNI.\n-IPs / --IP Address destenation uni",
+ required = true,
+ multiValued = false)
+ private String IPd = "";
+
+ @Option(name = "-egress",
+ aliases = { "--egress-speed" },
+ description = "egress speed.\n-s / --speed 10M/100M/1G/10G",
+ required = false,
+ multiValued = true)
+ private String egress = "";
+
+ @Option(name = "-ingress",
+ aliases = { "--ingress-speed" },
+ description = "ingress speed.\n-s / --speed 10M/100M/1G/10G",
+ required = false,
+ multiValued = true)
+ private String ingress = "";
+
+ private Object getSpeed(String speed) {
+ Object speedObject = null;
+ if (speed.equals("10M")) {
+ speedObject = new Speed10MBuilder().build();
+ }
+ else if (speed.equals("100M")) {
+ speedObject = new Speed100MBuilder().build();
+ }
+ else if (speed.equals("1G")) {
+ speedObject = new Speed1GBuilder().build();
+ }
+ else if (speed.equals("10G")) {
+ speedObject = new Speed10GBuilder().build();
+ }
+ return speedObject;
+ }
+
+ public EvcAddShellCommand(IUnimgrConsoleProvider provider) {
+ this.provider = provider;
+ }
+
+ @Override
+ protected Object doExecute() throws Exception {
+ Short order = new Short("0");
+ IpAddress ipAddreSource = new IpAddress(IPs.toCharArray());
+ UniSource uniSource = new UniSourceBuilder()
+ .setIpAddress(ipAddreSource)
+ .setKey(new UniSourceKey(order))
+ .setOrder(order)
+ .build();
+ List<UniSource> uniSourceList = new ArrayList<UniSource>();
+ uniSourceList.add(uniSource);
+ IpAddress ipAddreDest = new IpAddress(IPd.toCharArray());
+ UniDest uniDest = new UniDestBuilder()
+ .setOrder(order)
+ .setKey(new UniDestKey(order))
+ .setIpAddress(ipAddreDest)
+ .build();
+ List<UniDest> uniDestList = new ArrayList<UniDest>();
+ uniDestList.add(uniDest);
+ EvcAugmentation evcAug = new EvcAugmentationBuilder()
+ .setCosId(UnimgrConstants.EVC_PREFIX + 1)
+ .setEgressBw((EgressBw) getSpeed(egress))
+ .setIngressBw((IngressBw) getSpeed(ingress))
+ .setUniDest(uniDestList)
+ .setUniSource(uniSourceList)
+ .build();
+ if (provider.addEvc(evcAug)) {
+ return new String("Evc with Source Uni " +IPs+" and destenation Uni " +IPd+" created");
+ } else {
+ return new String("Error creating new Evc");
+ }
+ }
+}
{
- "id": "623b8dfb-bee0-6b4f-ea75-d9cb57bac9d7",
+ "id": "26020a97-e157-a04b-a038-54298bb2c9a3",
"name": "CableLabs - Unimgr",
"description": "",
"order": [
- "1ee8ee72-a97c-fce1-5d4e-b116351f7e0a",
- "48c0dbba-59ef-3b25-a0a4-eebd6f6749f0",
- "bd9685e0-fa68-2d84-eb9c-f18d996756b6",
- "5be0edfd-89fc-73c1-a8e4-09d045d7cf15",
- "920282c7-c3ad-8650-cc35-61b9cbaca6ca",
- "caf12366-51a9-565b-1391-2610c042b2d4",
- "0751718d-5a99-e2fb-42c6-138619f39dc9",
- "b2ffcca7-cb00-724d-62ef-fc244aaf3690",
- "22c639ed-bb67-c031-2e9c-e3e86a828e8f"
+ "fb420e3d-1156-fadf-ca96-5578c14cee2b",
+ "1cfae229-6b96-7cac-b781-41ba4c6856c5",
+ "b21f0ca2-ea9d-c0ef-813d-6b4a795ade30",
+ "3bab7d59-42a8-b6ac-983e-90e50a4842cd",
+ "c4eaaaec-2f94-189e-d4fb-2c9fe0eaacd2",
+ "ba02b5fc-4d74-31e9-3d6d-40917534a61b",
+ "5c78c309-5d4e-a12c-6293-b981168c2b31",
+ "ec1c4b93-ec1f-041c-acfe-ca45f73d21db",
+ "4da74948-424d-9f3f-b94f-65c1b1e9441c",
+ "106a14b1-4e92-b46d-6a73-610d5edfd885"
],
"folders": [],
"timestamp": 0,
- "owner": "131882",
- "remoteLink": null,
+ "owner": 0,
+ "remoteLink": "",
"public": false,
"requests": [
{
- "id": "0751718d-5a99-e2fb-42c6-138619f39dc9",
+ "id": "106a14b1-4e92-b46d-6a73-610d5edfd885",
"headers": "Content-Type: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
- "url": "http://localhost:8181/restconf/config/network-topology:network-topology/topology/unimgr:evc/link/evc:%2F%2F1",
- "pathVariables": {},
+ "url": "http://localhost:8181/restconf/config/network-topology:network-topology/topology/unimgr:uni/node/uni:%2F%2F192.168.0.100",
"preRequestScript": "",
- "method": "DELETE",
- "collectionId": "623b8dfb-bee0-6b4f-ea75-d9cb57bac9d7",
+ "pathVariables": {},
+ "method": "PUT",
"data": [],
"dataMode": "raw",
- "name": "Delete EVC",
+ "version": 2,
+ "tests": "",
+ "currentHelper": "normal",
+ "helperAttributes": {},
+ "time": 1447876971697,
+ "name": "Create UNI 1 copy",
"description": "",
- "descriptionFormat": "html",
- "time": 1446676591612,
+ "collectionId": "26020a97-e157-a04b-a038-54298bb2c9a3",
+ "rawModeData": "{\n \"network-topology:node\": [\n {\n \"node-id\": \"uni://192.168.0.100\",\n \"speed\": {\n \"speed-1G\": 1\n },\n \"uni:mac-layer\": \"IEEE 802.3-2005\",\n \"uni:physical-medium\": \"UNI TypeFull Duplex 2 Physical Interface\",\n \"uni:mtu-size\": 0,\n \"uni:type\": \"\",\n \"uni:mac-address\": \"68:5b:35:bb:f8:3e\",\n \"uni:ip-address\": \"192.168.0.100\",\n \"uni:mode\": \"Full Duplex\"\n }\n ]\n}"
+ },
+ {
+ "id": "1cfae229-6b96-7cac-b781-41ba4c6856c5",
+ "headers": "Content-Type: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
+ "url": "http://localhost:8181/restconf/config/network-topology:network-topology/topology/unimgr:uni/node/uni:%2F%2F192.168.1.139",
+ "preRequestScript": "",
+ "pathVariables": {},
+ "method": "PUT",
+ "data": [],
+ "dataMode": "raw",
"version": 2,
- "responses": [],
"tests": "",
"currentHelper": "normal",
"helperAttributes": {},
- "rawModeData": ""
+ "time": 1452717046727,
+ "name": "Create UNI 2",
+ "description": "",
+ "collectionId": "26020a97-e157-a04b-a038-54298bb2c9a3",
+ "rawModeData": "{\n \"network-topology:node\": [\n {\n \"node-id\": \"uni://192.168.1.139\",\n \"speed\": {\n \"speed-1G\": 1\n },\n \"uni:mac-layer\": \"IEEE 802.3-2005\",\n \"uni:physical-medium\": \"UNI TypeFull Duplex 2 Physical Interface\",\n \"uni:mtu-size\": 0,\n \"uni:type\": \"\",\n \"uni:mac-address\": \"68:5b:35:bb:f8:3c\",\n \"uni:ip-address\": \"192.168.1.139\",\n \"uni:mode\": \"Full Duplex\"\n }\n ]\n}"
},
{
"folder": null,
- "id": "1ee8ee72-a97c-fce1-5d4e-b116351f7e0a",
- "name": "Create UNI 1",
- "dataMode": "raw",
+ "id": "3bab7d59-42a8-b6ac-983e-90e50a4842cd",
+ "name": "Get Config Topology",
+ "dataMode": "params",
"data": [],
+ "rawModeData": null,
"descriptionFormat": "html",
"description": "",
- "headers": "Content-Type: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
- "method": "PUT",
+ "headers": "Authorization: Basic YWRtaW46YWRtaW4=\n",
+ "method": "GET",
"pathVariables": {},
- "url": "http://localhost:8181/restconf/config/network-topology:network-topology/topology/unimgr:uni/node/uni:%2F%2F192.168.1.30",
+ "url": "http://localhost:8181/restconf/config/network-topology:network-topology",
"preRequestScript": "",
"tests": "",
"currentHelper": "normal",
"helperAttributes": {},
- "collectionId": "623b8dfb-bee0-6b4f-ea75-d9cb57bac9d7",
- "rawModeData": "{\n \"network-topology:node\": [\n {\n \"node-id\": \"uni://192.168.1.30\",\n \"speed\": {\n \"speed-1G\": 1\n },\n \"uni:mac-layer\": \"IEEE 802.3-2005\",\n \"uni:physical-medium\": \"UNI TypeFull Duplex 2 Physical Interface\",\n \"uni:mtu-size\": 0,\n \"uni:type\": \"\",\n \"uni:mac-address\": \"68:5b:35:bb:f8:3e\",\n \"uni:ip-address\": \"192.168.1.30\",\n \"uni:mode\": \"Full Duplex\"\n }\n ]\n}"
+ "collectionId": "26020a97-e157-a04b-a038-54298bb2c9a3"
},
{
- "id": "22c639ed-bb67-c031-2e9c-e3e86a828e8f",
+ "id": "4da74948-424d-9f3f-b94f-65c1b1e9441c",
"headers": "Content-Type: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
- "url": "http://localhost:8181/restconf/config/network-topology:network-topology/topology/unimgr:uni/node/uni:%2F%2F192.168.1.40",
- "pathVariables": {},
+ "url": "http://localhost:8181/restconf/config/network-topology:network-topology/topology/unimgr:uni/node/uni:%2F%2F192.168.1.139",
"preRequestScript": "",
+ "pathVariables": {},
"method": "DELETE",
- "collectionId": "623b8dfb-bee0-6b4f-ea75-d9cb57bac9d7",
"data": [],
"dataMode": "raw",
- "name": "Delete UNI 2",
- "description": "",
- "descriptionFormat": "html",
- "time": 1446676632805,
"version": 2,
- "responses": [],
"tests": "",
"currentHelper": "normal",
"helperAttributes": {},
+ "time": 1452717082525,
+ "name": "Delete UNI 2",
+ "description": "",
+ "collectionId": "26020a97-e157-a04b-a038-54298bb2c9a3",
+ "responses": [],
"rawModeData": ""
},
{
- "folder": null,
- "id": "48c0dbba-59ef-3b25-a0a4-eebd6f6749f0",
- "name": "Create UNI 2",
- "dataMode": "raw",
- "data": [],
- "descriptionFormat": null,
- "description": "",
+ "id": "5c78c309-5d4e-a12c-6293-b981168c2b31",
"headers": "Content-Type: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
- "method": "PUT",
- "pathVariables": {},
- "url": "http://localhost:8181/restconf/config/network-topology:network-topology/topology/unimgr:uni/node/uni:%2F%2F192.168.1.40",
+ "url": "http://localhost:8181/restconf/config/network-topology:network-topology/topology/unimgr:evc/link/evc:%2F%2F1",
"preRequestScript": "",
+ "pathVariables": {},
+ "method": "DELETE",
+ "data": [],
+ "dataMode": "raw",
+ "version": 2,
"tests": "",
"currentHelper": "normal",
"helperAttributes": {},
- "collectionId": "623b8dfb-bee0-6b4f-ea75-d9cb57bac9d7",
- "rawModeData": "{\n \"network-topology:node\": [\n {\n \"node-id\": \"uni://192.168.1.40\",\n \"speed\": {\n \"speed-1G\": 1\n },\n \"uni:mac-layer\": \"IEEE 802.3-2005\",\n \"uni:physical-medium\": \"UNI TypeFull Duplex 2 Physical Interface\",\n \"uni:mtu-size\": 0,\n \"uni:type\": \"\",\n \"uni:mac-address\": \"68:5b:35:bb:f8:3c\",\n \"uni:ip-address\": \"192.168.1.40\",\n \"uni:mode\": \"Full Duplex\"\n }\n ]\n}"
+ "time": 1452717219049,
+ "name": "Delete EVC",
+ "description": "",
+ "collectionId": "26020a97-e157-a04b-a038-54298bb2c9a3",
+ "responses": [],
+ "rawModeData": ""
},
{
"folder": null,
- "id": "5be0edfd-89fc-73c1-a8e4-09d045d7cf15",
- "name": "Get Config Topology",
+ "id": "b21f0ca2-ea9d-c0ef-813d-6b4a795ade30",
+ "name": "Get Operational Topology",
"dataMode": "params",
"data": [],
"rawModeData": null,
"descriptionFormat": "html",
- "description": "",
+ "description": "This restconf request will fetch the operational topology. Operational topology details are fetch by southbound plugin from all the connected ovsdb node.",
"headers": "Authorization: Basic YWRtaW46YWRtaW4=\n",
"method": "GET",
"pathVariables": {},
- "url": "http://localhost:8181/restconf/config/network-topology:network-topology",
+ "url": "http://localhost:8181/restconf/operational/network-topology:network-topology/",
+ "preRequestScript": "",
+ "tests": "",
+ "currentHelper": "normal",
+ "helperAttributes": {},
+ "collectionId": "26020a97-e157-a04b-a038-54298bb2c9a3"
+ },
+ {
+ "id": "ba02b5fc-4d74-31e9-3d6d-40917534a61b",
+ "headers": "Content-Type: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
+ "url": "http://localhost:8181/restconf/config/network-topology:network-topology/topology/unimgr:evc/link/evc:%2F%2F1",
"preRequestScript": "",
+ "pathVariables": {},
+ "method": "PUT",
+ "data": [],
+ "dataMode": "raw",
+ "version": 2,
"tests": "",
"currentHelper": "normal",
"helperAttributes": {},
- "collectionId": "623b8dfb-bee0-6b4f-ea75-d9cb57bac9d7"
+ "time": 1452717130461,
+ "name": "Create EVC",
+ "description": "",
+ "collectionId": "26020a97-e157-a04b-a038-54298bb2c9a3",
+ "responses": [],
+ "rawModeData": "{\n \"link\": [\n {\n \"link-id\": \"evc://1\",\n \"source\": {\n \"source-node\": \"/network-topology/topology/node/uni://192.168.1.106\"\n },\n \"destination\": {\n \"dest-node\": \"/network-topology/topology/node/uni://192.168.1.139\"\n },\n \"cl-unimgr-mef:uni-source\": [\n {\n \"order\": \"0\",\n \"ip-address\": \"192.168.1.106\"\n }\n ],\n \"cl-unimgr-mef:uni-dest\": [\n {\n \"order\": \"0\",\n \"ip-address\": \"192.168.1.139\"\n }\n ],\n \"cl-unimgr-mef:cos-id\": \"string\",\n \"cl-unimgr-mef:ingress-bw\": {\n \"speed-10G\": {}\n },\n \"cl-unimgr-mef:egress-bw\": {\n \"speed-10G\": {}\n }\n }\n ]\n}"
},
{
- "id": "920282c7-c3ad-8650-cc35-61b9cbaca6ca",
+ "id": "c4eaaaec-2f94-189e-d4fb-2c9fe0eaacd2",
"headers": "Authorization: Basic YWRtaW46YWRtaW4=\n",
"url": "http://localhost:8181/restconf/config/network-topology:network-topology/topology/unimgr:uni/node/uni:%2F%2F192.168.1.30",
"preRequestScript": "",
"time": 1446585683690,
"name": "Get Specific Config Uni",
"description": "",
- "collectionId": "623b8dfb-bee0-6b4f-ea75-d9cb57bac9d7",
+ "collectionId": "26020a97-e157-a04b-a038-54298bb2c9a3",
"responses": []
},
{
- "id": "b2ffcca7-cb00-724d-62ef-fc244aaf3690",
+ "id": "ec1c4b93-ec1f-041c-acfe-ca45f73d21db",
"headers": "Content-Type: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
- "url": "http://localhost:8181/restconf/config/network-topology:network-topology/topology/unimgr:uni/node/uni:%2F%2F192.168.1.30",
- "pathVariables": {},
+ "url": "http://localhost:8181/restconf/config/network-topology:network-topology/topology/unimgr:uni/node/uni:%2F%2F192.168.1.106",
"preRequestScript": "",
+ "pathVariables": {},
"method": "DELETE",
- "collectionId": "623b8dfb-bee0-6b4f-ea75-d9cb57bac9d7",
"data": [],
"dataMode": "raw",
- "name": "Delete UNI 1",
- "description": "",
- "descriptionFormat": "html",
- "time": 1446676614395,
"version": 2,
- "responses": [],
"tests": "",
"currentHelper": "normal",
"helperAttributes": {},
+ "time": 1452717066453,
+ "name": "Delete UNI 1",
+ "description": "",
+ "collectionId": "26020a97-e157-a04b-a038-54298bb2c9a3",
+ "responses": [],
"rawModeData": ""
},
{
- "folder": null,
- "id": "bd9685e0-fa68-2d84-eb9c-f18d996756b6",
- "name": "Get Operational Topology",
- "dataMode": "params",
- "data": [],
- "rawModeData": null,
- "descriptionFormat": "html",
- "description": "This restconf request will fetch the operational topology. Operational topology details are fetch by southbound plugin from all the connected ovsdb node.",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\n",
- "method": "GET",
- "pathVariables": {},
- "url": "http://localhost:8181/restconf/operational/network-topology:network-topology/",
- "preRequestScript": "",
- "tests": "",
- "currentHelper": "normal",
- "helperAttributes": {},
- "collectionId": "623b8dfb-bee0-6b4f-ea75-d9cb57bac9d7"
- },
- {
- "id": "caf12366-51a9-565b-1391-2610c042b2d4",
+ "id": "fb420e3d-1156-fadf-ca96-5578c14cee2b",
"headers": "Content-Type: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
- "url": "http://localhost:8181/restconf/config/network-topology:network-topology/topology/unimgr:evc/link/evc:%2F%2F1",
+ "url": "http://localhost:8181/restconf/config/network-topology:network-topology/topology/unimgr:uni/node/uni:%2F%2F192.168.1.106",
"preRequestScript": "",
"pathVariables": {},
"method": "PUT",
"tests": "",
"currentHelper": "normal",
"helperAttributes": {},
- "time": 1446675838419,
- "name": "Create EVC",
+ "time": 1452717059000,
+ "name": "Create UNI 1",
"description": "",
- "collectionId": "623b8dfb-bee0-6b4f-ea75-d9cb57bac9d7",
- "responses": [],
- "rawModeData": "{\n \"network-topology:link\": [\n {\n \"evc:link-id\": \"evc://1\",\n \"evc:uni-dest\": [\n {\n \"order\": 0,\n \"ip-address\": \"192.168.1.30\"\n }\n ],\n \"evc:uni-source\": [\n {\n \"order\": 0,\n \"ip-address\": \"192.168.1.40\"\n }\n ],\n \"evc:cos-id\": \"string\",\n \"evc:ingress-bw\": {\n \"speed-1G\": {}\n },\n \"evc:egress-bw\": {\n \"speed-1G\": {}\n }\n }\n ]\n}"
+ "collectionId": "26020a97-e157-a04b-a038-54298bb2c9a3",
+ "rawModeData": "{\n \"network-topology:node\": [\n {\n \"node-id\": \"uni://192.168.1.106\",\n \"speed\": {\n \"speed-1G\": 1\n },\n \"uni:mac-layer\": \"IEEE 802.3-2005\",\n \"uni:physical-medium\": \"UNI TypeFull Duplex 2 Physical Interface\",\n \"uni:mtu-size\": 0,\n \"uni:type\": \"\",\n \"uni:mac-address\": \"68:5b:35:bb:f8:3e\",\n \"uni:ip-address\": \"192.168.1.106\",\n \"uni:mode\": \"Full Duplex\"\n }\n ]\n}"
}
]
}
\ No newline at end of file