From 634b640f2aa3779b94ab54ebf959030b563fb072 Mon Sep 17 00:00:00 2001 From: "Agarwal, Ruchira(ra1926)" Date: Mon, 20 Aug 2018 16:13:20 +0000 Subject: add LCM DistributeTraffic LCM API for DistributeTraffic Change-Id: I4b3c323d46bd088421d0d6d66fc23982bf086679 Issue-ID: CCSDK-477 Signed-off-by: Agarwal, Ruchira(ra1926) --- .../org/onap/ccsdk/sli/northbound/LcmProvider.java | 21 +++++++++++++ .../onap/ccsdk/sli/northbound/TestLcmProvider.java | 36 ++++++++++++++++++++++ .../graphs/lcm/LCM_distribute-traffic.xml | 30 ++++++++++++++++++ .../src/test/resources/graphs/lcm/graph.versions | 1 + 4 files changed, 88 insertions(+) create mode 100644 lcm/provider/src/test/resources/graphs/lcm/LCM_distribute-traffic.xml (limited to 'lcm/provider') diff --git a/lcm/provider/src/main/java/org/onap/ccsdk/sli/northbound/LcmProvider.java b/lcm/provider/src/main/java/org/onap/ccsdk/sli/northbound/LcmProvider.java index 787a94e2..939836be 100644 --- a/lcm/provider/src/main/java/org/onap/ccsdk/sli/northbound/LcmProvider.java +++ b/lcm/provider/src/main/java/org/onap/ccsdk/sli/northbound/LcmProvider.java @@ -350,6 +350,27 @@ public class LcmProvider implements AutoCloseable, LCMService { return Futures.immediateFuture(rpcResult); } + @Override + public Future> distributeTraffic(DistributeTrafficInput input) { + DistributeTrafficInputBuilder iBuilder = new DistributeTrafficInputBuilder(input); + DistributeTrafficOutputBuilder oBuilder = new DistributeTrafficOutputBuilder(); + + try { + CommonLcmFields retval = callDG("distribute-traffic", iBuilder.build()); + oBuilder.setStatus(retval.getStatusBuilder().build()); + oBuilder.setCommonHeader(retval.getCommonHeaderBuilder().build()); + } catch (LcmRpcInvocationException e) { + LOG.debug("Caught exception", e); + oBuilder.setCommonHeader(e.getCommonHeader()); + oBuilder.setStatus(e.getStatus()); + } + + RpcResult rpcResult = + RpcResultBuilder. status(true).withResult(oBuilder.build()).build(); + // return error + return Futures.immediateFuture(rpcResult); + } + @Override public Future> configure(ConfigureInput input) { ConfigureInputBuilder iBuilder = new ConfigureInputBuilder(input); diff --git a/lcm/provider/src/test/java/org/onap/ccsdk/sli/northbound/TestLcmProvider.java b/lcm/provider/src/test/java/org/onap/ccsdk/sli/northbound/TestLcmProvider.java index 38920e0b..234eb615 100644 --- a/lcm/provider/src/test/java/org/onap/ccsdk/sli/northbound/TestLcmProvider.java +++ b/lcm/provider/src/test/java/org/onap/ccsdk/sli/northbound/TestLcmProvider.java @@ -73,6 +73,8 @@ import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329. import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.ConfigureOutput; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.DetachVolumeInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.DetachVolumeOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.DistributeTrafficInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.DistributeTrafficOutput; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.EvacuateInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.EvacuateOutput; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.HealthCheckInputBuilder; @@ -526,6 +528,40 @@ public class TestLcmProvider { } } + @Test + public void testDistributeTraffic() { + DistributeTrafficInputBuilder builder = new DistributeTrafficInputBuilder(); + + CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder(); + hdrBuilder.setApiVer("1"); + hdrBuilder.setFlags(null); + hdrBuilder.setOriginatorId("jUnit"); + hdrBuilder.setRequestId("123"); + hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date()))); + builder.setCommonHeader(hdrBuilder.build()); + + ActionIdentifiersBuilder aBuilder = new ActionIdentifiersBuilder(); + aBuilder.setServiceInstanceId("SVCID-123"); + aBuilder.setVfModuleId("vf-module-1"); + aBuilder.setVnfcName("my-vnfc"); + aBuilder.setVnfId("123"); + aBuilder.setVserverId("123"); + builder.setActionIdentifiers(aBuilder.build()); + + builder.setAction(Action.DistributeTraffic); + builder.setPayload(mock(Payload.class)); + + + try { + DistributeTrafficOutput results = provider.distributeTraffic(builder.build()).get().getResult(); + LOG.info("DistributeTraffic returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage()); + assert(results.getStatus().getCode() == 400); + } catch (InterruptedException | ExecutionException e) { + LOG.error("Caught exception", e); + fail("DistributeTraffic threw exception"); + } + } + @Test public void testConfigure() { ConfigureInputBuilder builder = new ConfigureInputBuilder(); diff --git a/lcm/provider/src/test/resources/graphs/lcm/LCM_distribute-traffic.xml b/lcm/provider/src/test/resources/graphs/lcm/LCM_distribute-traffic.xml new file mode 100644 index 00000000..14ff1134 --- /dev/null +++ b/lcm/provider/src/test/resources/graphs/lcm/LCM_distribute-traffic.xml @@ -0,0 +1,30 @@ + + + + + + + + + + diff --git a/lcm/provider/src/test/resources/graphs/lcm/graph.versions b/lcm/provider/src/test/resources/graphs/lcm/graph.versions index 4ca21daf..233aa459 100644 --- a/lcm/provider/src/test/resources/graphs/lcm/graph.versions +++ b/lcm/provider/src/test/resources/graphs/lcm/graph.versions @@ -27,6 +27,7 @@ LCM stop-application 1.0.0 sync LCM start-application 1.0.0 sync LCM quiesce-traffic 1.0.0 sync LCM resume-traffic 1.0.0 sync +LCM distribute-traffic 1.0.0 sync LCM upgrade-pre-check 1.0.0 sync LCM upgrade-software 1.0.0 sync LCM upgrade-post-check 1.0.0 sync -- cgit 1.2.3-korg