aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbotte <b.otte@cablelabs.com>2015-10-11 15:26:40 +0000
committerbotte <b.otte@cablelabs.com>2015-10-13 17:42:28 +0000
commitc802bc1e792a35f5a89a97aedd353f1ff4972a5e (patch)
tree8038148375dfa63dedabe6c64dea6057d868d2be
parentb785b70b994f7910635195b40e8ce96ac5e0effe (diff)
All modified files to support the UPDATE CRUD operation. Also a few general tweaks.
Change-Id: Ife64166f2d572ee94f2c393af9ae66cfefa62551
-rwxr-xr-xdeploy.sh20
-rw-r--r--evc/evcbase/src/test/java/com/cablelabs/vcpe/evc/evcbase/client/EvcClientTest.java38
-rw-r--r--evc/evcmgr/src/main/java/com/cablelabs/vcpe/evc/evcmgr/EvcService.java74
-rw-r--r--svc/svcmgr/src/main/java/com/cablelabs/vcpe/svc/svcmgr/EplService.java37
-rw-r--r--uni/pom.xml9
-rw-r--r--uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/client/UniClient.java116
-rw-r--r--uni/unibase/src/main/java/com/cablelabs/vcpe/uni/unibase/model/Uni.java27
7 files changed, 278 insertions, 43 deletions
diff --git a/deploy.sh b/deploy.sh
index e267f4b..b5c62ef 100755
--- a/deploy.sh
+++ b/deploy.sh
@@ -1,12 +1,13 @@
#!/bin/bash
-echo ... stopping tomcat
-/Library/Tomcat/bin/shutdown.sh
+export LIBRARY=/home/ubuntu/apache-tomcat-8.0.24
+#echo ... stopping tomcat
+#$LIBRARY/bin/shutdown.sh
declare -a services=('cos' 'evc' 'svc')
for svc in "${services[@]}"
do
- for del in `ls -d /Library/Tomcat/webapps/${svc}*`; do
+ for del in `ls -d $LIBRARY/webapps/${svc}*`; do
echo ... removing $del
rm -rf $del
done
@@ -16,10 +17,11 @@ echo ... building new war files
mvn clean install
echo ... moving war files to tomcat root
-cp ./cos/cosmgr/target/cosmgr.war /Library/Tomcat/webapps/.
-cp ./evc/evcmgr/target/evcmgr.war /Library/Tomcat/webapps/.
-cp ./svc/svcmgr/target/svcmgr.war /Library/Tomcat/webapps/.
-ls -l /Library/Tomcat/webapps/*.war
+cp ./svc/svcmgr/target/svcmgr.war $LIBRARY/webapps/.
+cp ./evc/evcmgr/target/evcmgr.war $LIBRARY/webapps/.
+cp ./cos/cosmgr/target/cosmgr.war $LIBRARY/webapps/.
+ls -l $LIBRARY/webapps/*.war
-echo ... starting tomcat
-/Library/Tomcat/bin/startup.sh
+#echo ... starting tomcat
+#$LIBRARY/bin/shutdown.sh
+#$LIBRARY/bin/startup.sh
diff --git a/evc/evcbase/src/test/java/com/cablelabs/vcpe/evc/evcbase/client/EvcClientTest.java b/evc/evcbase/src/test/java/com/cablelabs/vcpe/evc/evcbase/client/EvcClientTest.java
index 357b102..c6e7eb8 100644
--- a/evc/evcbase/src/test/java/com/cablelabs/vcpe/evc/evcbase/client/EvcClientTest.java
+++ b/evc/evcbase/src/test/java/com/cablelabs/vcpe/evc/evcbase/client/EvcClientTest.java
@@ -153,6 +153,44 @@ public class EvcClientTest {
assertNotNull(evcList);
assertEquals(evcList.size(),0);
Evc.dumpList(evcList);
+
+/*
+ // Test update
+ // Add silver service to CoS layer
+ CoS silver = new CoS();
+ silver.setAllProps("silver", 100, 0.99, 17.43, 2.43, 0.01);
+ Dbg.p("silver svc being created in CoS");
+
+ silver = coSClient.create(silver);
+ assertNotNull(silver);
+
+ Evc evc_4 = new Evc();
+
+ evc_4.setAllNonPerfProps("id-unset-1",
+ Evc.EvcType.POINT_TO_POINT, 2, uniIdList1, uniMacList1, ipList1,
+ Evc.FrameDelivery.UNCONDITIONAL,
+ Evc.FrameDelivery.UNCONDITIONAL,
+ Evc.FrameDelivery.UNCONDITIONAL,
+ true, true, 1600, gold.getId());
+
+ EvcClient evcClient2 = new EvcClient();
+ Dbg.p(evc_4.getId()+" being created via evcmgr");
+ evc_4.dump(1);
+
+ evc_4 = evcClient2.create(evc_4);
+ assertNotNull(evc_4);
+
+ evc_4.setCosId("silver");
+
+ evc_4 = evcClient2.update(evc_4);
+ assertNotNull(evc_4);
+
+ retrievedEvc = evcClient2.get(evc_4.getId());
+ assertNotNull(retrievedEvc);
+ Dbg.p("evc just retrieved from Evc Service");
+ retrievedEvc.dump(1);
+ retrievedEvc = null;
+*/
}
@Test
diff --git a/evc/evcmgr/src/main/java/com/cablelabs/vcpe/evc/evcmgr/EvcService.java b/evc/evcmgr/src/main/java/com/cablelabs/vcpe/evc/evcmgr/EvcService.java
index 43409bb..2d9798e 100644
--- a/evc/evcmgr/src/main/java/com/cablelabs/vcpe/evc/evcmgr/EvcService.java
+++ b/evc/evcmgr/src/main/java/com/cablelabs/vcpe/evc/evcmgr/EvcService.java
@@ -149,6 +149,7 @@ public class EvcService {
@Produces(MediaType.APPLICATION_JSON)
//--------------------------------------------------------
public Response update(Evc evc)
+ throws Exception
//--------------------------------------------------------
{
Dbg.p("\nUPDATING [" + evc.getId()+"]");
@@ -160,12 +161,75 @@ public class EvcService {
return Response.status(Response.Status.NOT_FOUND).build();
}
- evc.setOneWayFrameDelay(cos.getFrameDelay());
- evc.setOneWayFrameLossRatio(cos.getFrameLoss());
- evc.setOneWayAvailability(cos.getAvailbility());
+ evc.setAllPerfProps( cos.getFrameDelay(),
+ cos.getFrameLoss(),
+ cos.getAvailbility());
+
+ Dbg.p("... EVC SVC: retrieved following cos info");
+ cos.dump(1);
+
+
+ // Retrieve the UNIs in ODL
+ Uni uni1 = null;
+ Uni uni2 = null;
+ UniClient uniClient = new UniClient();
+
+ List<String> uniIdList = evc.getUniIdList();
+
+ if ( uniIdList != null && uniIdList.size() > 0 )
+ uni1 = uniClient.get(uniIdList.get(0));
+ else return Response.status(Response.Status.BAD_REQUEST).build();
+
+ if ( uniIdList != null && uniIdList.size() > 1 )
+ uni2 = uniClient.get(uniIdList.get(1));
+ else return Response.status(Response.Status.BAD_REQUEST).build();
+
+
+ // Update the UNIs in ODL
+ Uni.SvcSpeed svcSpeed = Uni.cirToSvcSpeed( cos.getCommitedInfoRate());
+ Uni.PhysMedium physMedium = Uni.svcSpeedToPhysMedium(svcSpeed ); // just for demo
+ // for production need to pull from host
+ uni1.setAllProps(uni1.getId(),
+ svcSpeed,
+ evc.getUniIpList().get(0),
+ evc.getUniMacList().get(0),
+ physMedium,
+ Uni.MacLayer.IEEE_802_3,
+ Uni.SyncMode.ENABLED,
+ Uni.Type.UNITYPE,
+ 1600);
+
+ uni2.setAllProps(uni2.getId(),
+ svcSpeed,
+ evc.getUniIpList().get(1),
+ evc.getUniMacList().get(1),
+ physMedium,
+ Uni.MacLayer.IEEE_802_3,
+ Uni.SyncMode.ENABLED,
+ Uni.Type.UNITYPE,
+ 1600);
+ uniClient.update(uni1);
+ uniClient.update(uni2);
+
+
+ // Give ODL a chance to finish updating the UNIs before moving on
+ try {
+ Thread.sleep(1000);
+ } catch(InterruptedException ex) {
+ Thread.currentThread().interrupt();
+ }
+
+
+ // Update the evc path in ODL
+ EvcPath evcPath = new EvcPath(evc.getId(), uni1, uni2, svcSpeed, svcSpeed, cos.getId());
+ EvcPathClient evcPathClient = new EvcPathClient();
+ evcPathClient.update(evcPath);
+
+ // Finish up with the evc
EvcRespositoryInMem.INSTANCE.update(evc);
EvcRespositoryInMem.INSTANCE.dump(0);
+
return Response.ok().entity(evc).build();
}
@@ -237,8 +301,12 @@ public class EvcService {
UniClient uniClient = new UniClient();
if ( uniIdList != null && uniIdList.size() > 0 )
uniClient.delete(uniIdList.get(0));
+ else return Response.status(Response.Status.BAD_REQUEST).build();
+
if ( uniIdList != null && uniIdList.size() > 1 )
uniClient.delete(uniIdList.get(1));
+ else return Response.status(Response.Status.BAD_REQUEST).build();
+
// OK, now we can delete the EVC itself
EvcRespositoryInMem.INSTANCE.delete(evcId);
diff --git a/svc/svcmgr/src/main/java/com/cablelabs/vcpe/svc/svcmgr/EplService.java b/svc/svcmgr/src/main/java/com/cablelabs/vcpe/svc/svcmgr/EplService.java
index f2c5343..5734374 100644
--- a/svc/svcmgr/src/main/java/com/cablelabs/vcpe/svc/svcmgr/EplService.java
+++ b/svc/svcmgr/src/main/java/com/cablelabs/vcpe/svc/svcmgr/EplService.java
@@ -65,7 +65,7 @@ public class EplService {
return Response.status(Response.Status.BAD_REQUEST).build();
}
- // Transfer EPLs I{P list to EVC
+ // Transfer EPLs IP list to EVC
List<String> uniIpList = new ArrayList<String>();
if (epl.getUniHostIpList() != null && epl.getUniHostIpList().size() == 2) {
uniIpList.add(epl.getUniHostIpList().get(0) );
@@ -111,7 +111,42 @@ public class EplService {
//--------------------------------------------------------
{
Dbg.p("\nUPDATING [" + epl.getId()+"]");
+ if ( epl == null) {
+ return Response.status(Response.Status.BAD_REQUEST).build();
+ }
+
+ // Retrieve EVC associated with EPL
+ EvcClient evcClient = new EvcClient();
+ Evc evc = evcClient.get(epl.getEvcId());
+
+ // Transfer EPLs mac list to EVC
+ List<String> uniMacList = new ArrayList<String>();
+ if (epl.getUniHostMacList() != null && epl.getUniHostMacList().size() == 2) {
+ uniMacList.add(epl.getUniHostMacList().get(0) );
+ uniMacList.add(epl.getUniHostMacList().get(1));
+ }
+ else {
+ return Response.status(Response.Status.BAD_REQUEST).build();
+ }
+
+ // Transfer EPLs IP list to EVC
+ List<String> uniIpList = new ArrayList<String>();
+ if (epl.getUniHostIpList() != null && epl.getUniHostIpList().size() == 2) {
+ uniIpList.add(epl.getUniHostIpList().get(0) );
+ uniIpList.add(epl.getUniHostIpList().get(1));
+ }
+ else {
+ return Response.status(Response.Status.BAD_REQUEST).build();
+ }
+
+ evc.setUniMacList(uniMacList);
+ evc.setUniIpList(uniIpList);
+ evc.setCosId(epl.getCos());
+
+ // send update request to EVC mgr
+ evc = evcClient.update(evc);
+ // update the EPL to our local repo
EplRespositoryInMem.INSTANCE.update(epl);
EplRespositoryInMem.INSTANCE.dump(0);
return Response.ok().entity(epl).build();
diff --git a/uni/pom.xml b/uni/pom.xml
index 32d568d..902e48c 100644
--- a/uni/pom.xml
+++ b/uni/pom.xml
@@ -26,6 +26,11 @@ http://www.apache.org/licenses/LICENSE-2.0-->
<module>unibase</module>
</modules>
- <dependencies></dependencies>
-
+ <dependencies>
+ <dependency>
+ <groupId>org.glassfish</groupId>
+ <artifactId>javax.json</artifactId>
+ <version>1.0.4</version>
+ </dependency>
+ </dependencies>
</project>
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 a97146f..08994fe 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
@@ -19,6 +19,9 @@ import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import javax.json.*;
+import javax.json.stream.*;
+import java.io.StringReader;
import java.util.List;
import javax.xml.bind.DatatypeConverter;
@@ -31,6 +34,7 @@ public class UniClient {
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 Client client; // provided by Jersey
@@ -108,6 +112,7 @@ public class UniClient {
.request(MediaType.APPLICATION_JSON)
.header("Authorization", authorizationHeaderValue)
.delete();
+
if (response.getStatus() != 200) // figure out how to use Status.OK
{
// in production you can be more specific based on reponse code, id, etc
@@ -120,29 +125,126 @@ public class UniClient {
//
//--------------------------------------------------------
- public Uni get(String uniId)
+ public Uni get(String uniId) throws Exception
//--------------------------------------------------------
// get Uni of specified ID
{
- WebTarget target = client.target("http://localhost:9090/unimgr/webapi/");
-
- Response response = target.path("uni/"+uniId).request(MediaType.APPLICATION_JSON).get(Response.class);
+ WebTarget target =client.target("http://"+uniMgrServer+":" + uniMgrPort + uniMgrOpRESTPath);
+ Response response = target.path("uni/" + uniId).request(MediaType.APPLICATION_JSON).get(Response.class);
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;
- return response.readEntity(Uni.class);
+ Uni uni = new Uni();
+ uni.setId(uniId);
+ String uniJson = response.readEntity(String.class);
+ return JsonToUni(uni, uniJson);
+ }
+
+
+ //--------------------------------------------------------
+ public Uni JsonToUni(Uni uni, String uniJson) {
+ //--------------------------------------------------------
+ // Parser utility encapsulation
+
+ try {
+ JsonParser parser = Json.createParser(new StringReader(uniJson));
+ JsonParser.Event event = null;
+
+ while (parser.hasNext()) {
+ event = parser.next();
+ switch(event) {
+ case KEY_NAME:
+ if (parser.getString().equals("speed")) {
+ event = parser.next();
+ if (parser.getString().equals("speed-10M")) {
+ uni.setSpeed(Uni.SvcSpeed.TEN_MEG);
+ } else
+ if (parser.getString().equals("speed-100M")) {
+ uni.setSpeed(Uni.SvcSpeed.HUNDRED_MEG);
+ } else
+ if (parser.getString().equals("speed-1G")) {
+ uni.setSpeed(Uni.SvcSpeed.ONE_GIG);
+ } else
+ if (parser.getString().equals("speed-10G")) {
+ uni.setSpeed(Uni.SvcSpeed.TEN_GIG);
+ } else {
+ uni.setSpeed(Uni.SvcSpeed.UNASSIGNED);
+ }
+ }
+ if (parser.getString().equals("mac-layer")) {
+ event = parser.next();
+ uni.setMacLayer(Uni.MacLayer.UNASSIGNED);
+ if (parser.getString().equals("IEEE 802.3-2005")) {
+ uni.setMacLayer(Uni.MacLayer.IEEE_802_3);
+ }
+ }
+ if (parser.getString().equals("physical-medium")) {
+ event = parser.next();
+ if (parser.getString().equals("10BASE-T")) {
+ uni.setPhysicalMedium(Uni.PhysMedium.TEN_BASE_T);
+ } else
+ if (parser.getString().equals("100BASE-T")) {
+ uni.setPhysicalMedium(Uni.PhysMedium.HUNDERED_BASE_T);
+ } else
+ if (parser.getString().equals("100BASE-T")) {
+ uni.setPhysicalMedium(Uni.PhysMedium.GIG_BASE_T);
+ } else
+ if (parser.getString().equals("10GBASE-T")) {
+ uni.setPhysicalMedium(Uni.PhysMedium.TEN_GIG_BASE_T);
+ } else {
+ uni.setPhysicalMedium(Uni.PhysMedium.UNASSIGNED);
+ }
+ }
+ if (parser.getString().equals("mtu-size")) {
+ uni.setMtuSize(parser.getLong());
+ event = parser.next();
+ }
+ if (parser.getString().equals("type")) {
+ event = parser.next();
+ uni.setType(Uni.Type.UNASSIGNED);
+ if (parser.getString().equals("IEEE 802.3-2005")) {
+ uni.setType(Uni.Type.UNITYPE);
+ }
+ }
+ if (parser.getString().equals("mac-address")) {
+ uni.setMacAddress(parser.getString());
+ event = parser.next();
+ }
+ if (event.toString().equals("ip-address")) {
+ uni.setIpAddress(parser.getString());
+ event = parser.next();
+ }
+ if (event.toString().equals("mode")) {
+ event = parser.next();
+ if (parser.getString().equals("syncEnabled")) {
+ uni.setMode(Uni.SyncMode.ENABLED);
+ } else
+ if (parser.getString().equals("syncDisabled")) {
+ uni.setMode(Uni.SyncMode.DISABLED);
+ } else {
+ uni.setMode(Uni.SyncMode.UNASSIGNED);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ } catch(Exception e) {
+ Dbg.p("\n, JsonReader:" + e);
+ }
+ return uni;
}
+
//--------------------------------------------------------
public List<Uni> getAll()
//--------------------------------------------------------
// get a list of all Uni instances
{
-
WebTarget target = client.target("http://localhost:9090/unimgr/webapi/");
// Can I do this with a Response, so that I can check for errors
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 0fc8100..cec4d80 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
@@ -38,10 +38,10 @@ public class Uni
public enum PhysMedium { // just a sampling of 802.3 phys layers
UNASSIGNED ("UNASSIGNED"),
- TEN_BASE_T ("10BASE‑T"),
- HUNDERED_BASE_T("100BASE‑T"),
- GIG_BASE_T ("1000BASE‑T"),
- TEN_GIG_BASE_T ("10GBASE‑T");
+ TEN_BASE_T ("10BASE-T"),
+ HUNDERED_BASE_T("100BASE-T"),
+ GIG_BASE_T ("1000BASE-T"),
+ TEN_GIG_BASE_T ("10GBASE-T");
private final String s;
private PhysMedium(final String s) {this.s = s;}
@Override public String toString() { return s; }
@@ -72,33 +72,18 @@ public class Uni
@Override public String toString() { return s; }
}
- @XmlElement(name="id")
- private String id;
- @XmlTransient // This does not get written to JSON body
+ private String id;
private SvcSpeed speed;
-
- @XmlElement(name="ip-address")
private String ipAddress;
-
- @XmlElement(name="mac-address")
private String macAddress;
-
- @XmlElement(name="physical-medium")
private PhysMedium physicalMedium;
-
- @XmlElement(name="mac-layer")
private MacLayer macLayer;
-
- @XmlElement(name="mode")
private SyncMode mode;
-
- @XmlElement(name="type")
private Type type;
-
- @XmlElement(name="mtu-size")
private long mtuSize;
+
// no argument constructor required for JAX-RS
public Uni() {
this.id = "unset";