From c34b7ba04f8ca102a4f09cf7d60dc6f273464946 Mon Sep 17 00:00:00 2001 From: Denes Nemeth Date: Tue, 8 May 2018 22:33:57 +0200 Subject: [PATCH 1/1] Fix VNFM driver not sending LCN to VF-C Change-Id: I340881a322aefcb353f6d18989f931e1495cbdec Signed-off-by: Denes Nemeth Issue-ID: VFC-728 --- .../nokia/onap/vfc/VfcNotificationSender.java | 16 ++++++--- .../vnfm/svnfm/nokia/vnfm/LifecycleManager.java | 2 +- .../nokia/onap/vfc/TestVfcNotificationSender.java | 42 +++++++++++++--------- 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcNotificationSender.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcNotificationSender.java index b44c1531..caecee02 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcNotificationSender.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcNotificationSender.java @@ -54,7 +54,7 @@ public class VfcNotificationSender implements INotificationSender { @Override public void processNotification(VnfLifecycleChangeNotification recievedNotification, OperationExecution operationExecution, Optional affectedCps, String vimId, String vnfmId) { - VNFLCMNotification notificationToSend = new VNFLCMNotification(); + VNFLCMNotification notificationToSend = buildNotification(); notificationToSend.setJobId(extractOnapJobId(operationExecution.getOperationParams())); notificationToSend.setOperation(getOperation(operationExecution, recievedNotification.getOperation())); notificationToSend.setVnfInstanceId(recievedNotification.getVnfInstanceId()); @@ -69,12 +69,21 @@ public class VfcNotificationSender implements INotificationSender { sendNotification(vnfmId, notificationToSend); } + private VNFLCMNotification buildNotification() { + VNFLCMNotification notificationToSend = new VNFLCMNotification(); + notificationToSend.setAffectedVirtualStorage(new ArrayList<>()); + notificationToSend.setAffectedVnfc(new ArrayList<>()); + notificationToSend.setAffectedVl(new ArrayList<>()); + notificationToSend.setAffectedCp(new ArrayList<>()); + return notificationToSend; + } + private void sendNotification(String vnfmId, VNFLCMNotification notification) { try { if (logger.isInfoEnabled()) { logger.info("Sending LCN: {}", new Gson().toJson(notification)); } - vfcRestApiProvider.getNsLcmApi().vNFLCMNotification(vnfmId, notification.getVnfInstanceId(), notification); + vfcRestApiProvider.getNsLcmApi().vNFLCMNotification(vnfmId, notification.getVnfInstanceId(), notification).blockingFirst(null); } catch (Exception e) { throw buildFatalFailure(logger, "Unable to send LCN to VF-C", e); } @@ -102,7 +111,6 @@ public class VfcNotificationSender implements INotificationSender { private void addAffectedVnfcs(String vimId, String vnfId, VNFLCMNotification notificationToSend, VnfLifecycleChangeNotification request) { if (request.getAffectedVnfcs() != null) { - notificationToSend.setAffectedVnfc(new ArrayList<>()); for (com.nokia.cbam.lcm.v32.model.AffectedVnfc affectedVnfc : request.getAffectedVnfcs()) { org.onap.vnfmdriver.model.AffectedVnfc onapVnfc = new org.onap.vnfmdriver.model.AffectedVnfc(); onapVnfc.setChangeType(getChangeType(affectedVnfc.getChangeType())); @@ -118,7 +126,6 @@ public class VfcNotificationSender implements INotificationSender { private void addAffectedVirtualLinks(VnfLifecycleChangeNotification request, VNFLCMNotification notification) { if (request.getAffectedVirtualLinks() != null) { - notification.setAffectedVl(new ArrayList<>()); for (com.nokia.cbam.lcm.v32.model.AffectedVirtualLink affectedVirtualLink : request.getAffectedVirtualLinks()) { org.onap.vnfmdriver.model.AffectedVirtualLink onapVirtualLink = new org.onap.vnfmdriver.model.AffectedVirtualLink(); onapVirtualLink.setVlInstanceId(request.getVnfInstanceId() + SEPARATOR + affectedVirtualLink.getId()); @@ -146,7 +153,6 @@ public class VfcNotificationSender implements INotificationSender { private void addAffectedCps(String vimId, VNFLCMNotification notificationToSend, Optional affectedCps) { if (affectedCps.isPresent()) { - notificationToSend.setAffectedCp(new ArrayList<>()); for (ReportedAffectedCp pre : affectedCps.get().getPre()) { Optional changeType = getChangeType(affectedCps.get(), pre); if (of(VnfCpNotificationType.REMOVED).equals(changeType)) { diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java index 5115aefd..1312b9d6 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java @@ -491,7 +491,7 @@ public class LifecycleManager { */ public void deleteVnf(String vnfmId, String vnfId) { logger.info("Deleting VNF with {} identifier", vnfId); - cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdDelete(vnfId, NOKIA_LCM_API_VERSION).blockingFirst(); + cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdDelete(vnfId, NOKIA_LCM_API_VERSION).blockingFirst(null); logger.info("The VNF with {} identifier has been deleted", vnfId); } diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java index 06cb6434..ed6375fa 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java @@ -62,7 +62,7 @@ public class TestVfcNotificationSender extends TestBase { public void init() throws Exception { vfcNotificationSender = new VfcNotificationSender(vfcRestApiProvider); setField(VfcNotificationSender.class, "logger", logger); - when(nsLcmApi.vNFLCMNotification(eq(VNFM_ID), eq(VNF_ID), sentLcnToVfc.capture())).thenReturn(null); + when(nsLcmApi.vNFLCMNotification(eq(VNFM_ID), eq(VNF_ID), sentLcnToVfc.capture())).thenReturn(VOID_OBSERVABLE.value()); instantiationOperation.setId("instantiationOperationExecutionId"); instantiationOperation.setStartTime(OffsetDateTime.now()); instantiationOperation.setOperationType(OperationType.INSTANTIATE); @@ -115,15 +115,16 @@ public class TestVfcNotificationSender extends TestBase { vfcNotificationSender.processNotification(recievedLcn, instantiationOperation, empty(), VIM_ID, VNFM_ID); //verify assertEquals(1, sentLcnToVfc.getAllValues().size()); - assertNull(sentLcnToVfc.getValue().getAffectedVl()); - assertNull(sentLcnToVfc.getValue().getAffectedVnfc()); - assertNull(sentLcnToVfc.getValue().getAffectedCp()); - assertNull(sentLcnToVfc.getValue().getAffectedVirtualStorage()); + assertEquals(0, sentLcnToVfc.getValue().getAffectedVl().size()); + assertEquals(0, sentLcnToVfc.getValue().getAffectedVnfc().size()); + assertEquals(0, sentLcnToVfc.getValue().getAffectedCp().size()); + assertEquals(0, sentLcnToVfc.getValue().getAffectedVirtualStorage().size()); assertEquals(JOB_ID, sentLcnToVfc.getValue().getJobId()); assertEquals(org.onap.vnfmdriver.model.OperationType.INSTANTIATE, sentLcnToVfc.getValue().getOperation()); assertEquals(VnfLcmNotificationStatus.START, sentLcnToVfc.getValue().getStatus()); assertEquals(VNF_ID, sentLcnToVfc.getValue().getVnfInstanceId()); + VOID_OBSERVABLE.assertCalled(); } /** @@ -223,11 +224,12 @@ public class TestVfcNotificationSender extends TestBase { assertEquals("myPortName", actualAffectedCp.getPortResource().getResourceName()); assertEquals(VnfCpNotificationType.ADDED, actualAffectedCp.getChangeType()); - assertNull(sentLcnToVfc.getValue().getAffectedVirtualStorage()); + assertEquals(0, sentLcnToVfc.getValue().getAffectedVirtualStorage().size()); assertEquals(JOB_ID, sentLcnToVfc.getValue().getJobId()); assertEquals(org.onap.vnfmdriver.model.OperationType.INSTANTIATE, sentLcnToVfc.getValue().getOperation()); assertEquals(VnfLcmNotificationStatus.RESULT, sentLcnToVfc.getValue().getStatus()); assertEquals(VNF_ID, sentLcnToVfc.getValue().getVnfInstanceId()); + VOID_OBSERVABLE.assertCalled(); } /** @@ -288,6 +290,7 @@ public class TestVfcNotificationSender extends TestBase { assertEquals("portProviderId", actualAffectedCp.getPortResource().getResourceid()); assertEquals("myPortName", actualAffectedCp.getPortResource().getResourceName()); assertEquals(VnfCpNotificationType.ADDED, actualAffectedCp.getChangeType()); + VOID_OBSERVABLE.assertCalled(); } /** @@ -387,11 +390,12 @@ public class TestVfcNotificationSender extends TestBase { assertEquals("portProviderId", actualAffectedCp.getPortResource().getResourceid()); assertEquals("myPortName", actualAffectedCp.getPortResource().getResourceName()); - assertNull(sentLcnToVfc.getValue().getAffectedVirtualStorage()); + assertEquals(0, sentLcnToVfc.getValue().getAffectedVirtualStorage().size()); assertEquals(JOB_ID, sentLcnToVfc.getValue().getJobId()); assertEquals(org.onap.vnfmdriver.model.OperationType.TERMINAL, sentLcnToVfc.getValue().getOperation()); assertEquals(VnfLcmNotificationStatus.RESULT, sentLcnToVfc.getValue().getStatus()); assertEquals(VNF_ID, sentLcnToVfc.getValue().getVnfInstanceId()); + VOID_OBSERVABLE.assertCalled(); } /** @@ -508,11 +512,12 @@ public class TestVfcNotificationSender extends TestBase { assertEquals("myPortName", actualAffectedCp.getPortResource().getResourceName()); assertEquals(VnfCpNotificationType.CHANGED, actualAffectedCp.getChangeType()); - assertNull(sentLcnToVfc.getValue().getAffectedVirtualStorage()); + assertEquals(0, sentLcnToVfc.getValue().getAffectedVirtualStorage().size()); assertEquals(JOB_ID, sentLcnToVfc.getValue().getJobId()); assertEquals(org.onap.vnfmdriver.model.OperationType.HEAL, sentLcnToVfc.getValue().getOperation()); assertEquals(VnfLcmNotificationStatus.RESULT, sentLcnToVfc.getValue().getStatus()); assertEquals(VNF_ID, sentLcnToVfc.getValue().getVnfInstanceId()); + VOID_OBSERVABLE.assertCalled(); } /** @@ -620,11 +625,12 @@ public class TestVfcNotificationSender extends TestBase { assertEquals("myPortName", actualAffectedCp.getPortResource().getResourceName()); assertEquals(VnfCpNotificationType.ADDED, actualAffectedCp.getChangeType()); - assertNull(sentLcnToVfc.getValue().getAffectedVirtualStorage()); + assertEquals(0, sentLcnToVfc.getValue().getAffectedVirtualStorage().size()); assertEquals(JOB_ID, sentLcnToVfc.getValue().getJobId()); assertEquals(org.onap.vnfmdriver.model.OperationType.SCALEOUT, sentLcnToVfc.getValue().getOperation()); assertEquals(VnfLcmNotificationStatus.RESULT, sentLcnToVfc.getValue().getStatus()); assertEquals(VNF_ID, sentLcnToVfc.getValue().getVnfInstanceId()); + VOID_OBSERVABLE.assertCalled(); } /** @@ -733,11 +739,12 @@ public class TestVfcNotificationSender extends TestBase { assertEquals("myPortName", actualAffectedCp.getPortResource().getResourceName()); assertEquals(VnfCpNotificationType.REMOVED, actualAffectedCp.getChangeType()); - assertNull(sentLcnToVfc.getValue().getAffectedVirtualStorage()); + assertEquals(0, sentLcnToVfc.getValue().getAffectedVirtualStorage().size()); assertEquals(JOB_ID, sentLcnToVfc.getValue().getJobId()); assertEquals(org.onap.vnfmdriver.model.OperationType.SCALEIN, sentLcnToVfc.getValue().getOperation()); assertEquals(VnfLcmNotificationStatus.RESULT, sentLcnToVfc.getValue().getStatus()); assertEquals(VNF_ID, sentLcnToVfc.getValue().getVnfInstanceId()); + VOID_OBSERVABLE.assertCalled(); } @@ -764,15 +771,16 @@ public class TestVfcNotificationSender extends TestBase { //verify assertEquals(1, sentLcnToVfc.getAllValues().size()); - assertNull(sentLcnToVfc.getValue().getAffectedVl()); - assertNull(sentLcnToVfc.getValue().getAffectedVnfc()); - assertNull(sentLcnToVfc.getValue().getAffectedCp()); - assertNull(sentLcnToVfc.getValue().getAffectedVirtualStorage()); + assertEquals(0, sentLcnToVfc.getValue().getAffectedVl().size()); + assertEquals(0, sentLcnToVfc.getValue().getAffectedVnfc().size()); + assertEquals(0, sentLcnToVfc.getValue().getAffectedCp().size()); + assertEquals(0, sentLcnToVfc.getValue().getAffectedVirtualStorage().size()); assertEquals(JOB_ID, sentLcnToVfc.getValue().getJobId()); assertEquals(org.onap.vnfmdriver.model.OperationType.SCALEIN, sentLcnToVfc.getValue().getOperation()); assertEquals(VnfLcmNotificationStatus.RESULT, sentLcnToVfc.getValue().getStatus()); assertEquals(VNF_ID, sentLcnToVfc.getValue().getVnfInstanceId()); verify(logger, never()).info(eq("Sending LCN: {}"), anyString()); + VOID_OBSERVABLE.assertCalled(); } /** @@ -823,10 +831,10 @@ public class TestVfcNotificationSender extends TestBase { //verify assertEquals(1, sentLcnToVfc.getAllValues().size()); - assertNull(sentLcnToVfc.getValue().getAffectedVl()); - assertNull(sentLcnToVfc.getValue().getAffectedVnfc()); + assertEquals(0, sentLcnToVfc.getValue().getAffectedVl().size()); + assertEquals(0, sentLcnToVfc.getValue().getAffectedVnfc().size()); assertEquals(0, sentLcnToVfc.getValue().getAffectedCp().size()); - assertNull(sentLcnToVfc.getValue().getAffectedVirtualStorage()); + assertEquals(0, sentLcnToVfc.getValue().getAffectedVirtualStorage().size()); assertEquals(JOB_ID, sentLcnToVfc.getValue().getJobId()); assertEquals(org.onap.vnfmdriver.model.OperationType.HEAL, sentLcnToVfc.getValue().getOperation()); assertEquals(VnfLcmNotificationStatus.RESULT, sentLcnToVfc.getValue().getStatus()); -- 2.16.6