From c802bc1e792a35f5a89a97aedd353f1ff4972a5e Mon Sep 17 00:00:00 2001 From: botte Date: Sun, 11 Oct 2015 15:26:40 +0000 Subject: All modified files to support the UPDATE CRUD operation. Also a few general tweaks. Change-Id: Ife64166f2d572ee94f2c393af9ae66cfefa62551 --- .../vcpe/evc/evcbase/client/EvcClientTest.java | 38 +++++++++++ .../com/cablelabs/vcpe/evc/evcmgr/EvcService.java | 74 +++++++++++++++++++++- 2 files changed, 109 insertions(+), 3 deletions(-) (limited to 'evc') 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 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); -- cgit 1.2.3-korg