diff options
Diffstat (limited to 'nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification')
7 files changed, 47 insertions, 54 deletions
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AAINotificationProcessor.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AAINotificationProcessor.java index 86517435..e419407d 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AAINotificationProcessor.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AAINotificationProcessor.java @@ -23,14 +23,14 @@ import java.util.HashSet; import java.util.Optional; import java.util.Set; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.INotificationSender; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.ReportedAffectedConnectionPoints; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.ReportedAffectedCp; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Component; +import static java.util.Optional.empty; + import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.tryFind; import static com.nokia.cbam.lcm.v32.model.ChangeType.*; @@ -43,7 +43,6 @@ import static org.springframework.util.StringUtils.isEmpty; * Responsible for providing information related to the VNFM from VF-C source */ @Component -@Conditional(value = Conditions.UseForDirect.class) public class AAINotificationProcessor implements INotificationSender { private static Logger logger = getLogger(AAINotificationProcessor.class); private final GenericVnfManager genericVnfManager; @@ -62,9 +61,9 @@ public class AAINotificationProcessor implements INotificationSender { } @Override - public void processNotification(VnfLifecycleChangeNotification receivedNotification, OperationExecution operationExecution, Optional<ReportedAffectedConnectionPoints> affectedConnectionPoints, String vimId) { + public void processNotification(VnfLifecycleChangeNotification receivedNotification, OperationExecution operationExecution, Optional<ReportedAffectedConnectionPoints> affectedConnectionPoints, String vimId, String vnfmId) { boolean inMaintenance = STARTED.equals(receivedNotification.getStatus()); - genericVnfManager.createOrUpdate(receivedNotification.getVnfInstanceId(), inMaintenance); + genericVnfManager.createOrUpdate(receivedNotification.getVnfInstanceId(), inMaintenance, vnfmId, empty()); addOrUpdateVls(receivedNotification, vimId); addOrUpdateVnfcs(receivedNotification, vimId, inMaintenance); processCps(receivedNotification, affectedConnectionPoints, vimId, inMaintenance); diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AbstractManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AbstractManager.java index ee7a3feb..16800fbd 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AbstractManager.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AbstractManager.java @@ -24,7 +24,6 @@ import org.onap.aai.model.Relationship; import org.onap.aai.model.RelationshipData; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties; import org.slf4j.Logger; import static com.google.common.collect.Iterables.find; @@ -36,12 +35,10 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.SEPARATOR abstract class AbstractManager { protected final AAIRestApiProvider aaiRestApiProvider; protected final CbamRestApiProvider cbamRestApiProvider; - protected final DriverProperties driverProperties; - AbstractManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProvider cbamRestApiProvider, DriverProperties driverProperties) { + AbstractManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProvider cbamRestApiProvider) { this.aaiRestApiProvider = aaiRestApiProvider; this.cbamRestApiProvider = cbamRestApiProvider; - this.driverProperties = driverProperties; } /** diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java index 52e9151d..953eda95 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java @@ -18,17 +18,17 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification; import com.nokia.cbam.lcm.v32.model.VnfInfo; import java.util.ArrayList; import java.util.NoSuchElementException; +import java.util.Optional; import org.onap.aai.model.GenericVnf; import org.onap.aai.model.Relationship; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProviderForSo; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Component; +import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager.SERVICE_NAME; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions.systemFunctions; @@ -36,14 +36,13 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions.sys * Responsible for managing the {@link GenericVnf} in AAI */ @Component -@Conditional(value = Conditions.UseForDirect.class) -class GenericVnfManager extends AbstractManager { +public class GenericVnfManager extends AbstractManager { private static final long MAX_MS_TO_WAIT_FOR_VNF_TO_APPEAR = 30 * 1000L; private static Logger logger = org.slf4j.LoggerFactory.getLogger(GenericVnfManager.class); @Autowired - GenericVnfManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProvider cbamRestApiProvider, DriverProperties driverProperties) { - super(aaiRestApiProvider, cbamRestApiProvider, driverProperties); + GenericVnfManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProviderForSo cbamRestApiProvider) { + super(aaiRestApiProvider, cbamRestApiProvider); } static Relationship linkTo(String vnfId) { @@ -54,43 +53,54 @@ class GenericVnfManager extends AbstractManager { return relationship; } + private static Relationship linkToNs(String nsId) { + Relationship relationship = new Relationship(); + relationship.setRelatedTo("service-instance"); + relationship.setRelationshipData(new ArrayList<>()); + relationship.getRelationshipData().add(buildRelationshipData("service-instance.service-instance-id", nsId)); + return relationship; + } + @Override protected Logger getLogger() { return logger; } - void createOrUpdate(String vnfId, boolean inMaintenance) { + public void createOrUpdate(String vnfId, boolean inMaintenance, String vnfmId, Optional<String> nsId) { try { GenericVnf vnf = waitForVnfToAppearInAai(vnfId); - updateFields(vnf, vnfId, inMaintenance); + updateFields(vnf, vnfId, inMaintenance, vnfmId, nsId); } catch (NoSuchElementException e) { try { logger.warn("The VNF with " + vnfId + " identifier did not appear in time", e); - updateFields(new GenericVnf(), vnfId, inMaintenance); + updateFields(new GenericVnf(), vnfId, inMaintenance, vnfmId, nsId); } catch (Exception e2) { logger.warn("The VNF with " + vnfId + " identifier has been created since after the maximal wait for VNF to appear timeout", e2); //the VNF might have been created since the last poll - updateFields(getExistingVnf(vnfId), vnfId, inMaintenance); + updateFields(getExistingVnf(vnfId), vnfId, inMaintenance, vnfmId, nsId); } } } - private GenericVnf getExistingVnf(String vnfId) { - return aaiRestApiProvider.getNetworkApi().getNetworkGenericVnfsGenericVnf(vnfId, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null).blockingFirst(); - } - - private void updateFields(GenericVnf vnf, String vnfId, boolean inMaintenance) { + private void updateFields(GenericVnf vnf, String vnfId, boolean inMaintenance, String vnfmId, Optional<String> nsId) { try { - VnfInfo vnfInfo = cbamRestApiProvider.getCbamLcmApi(driverProperties.getVnfmId()).vnfsVnfInstanceIdGet(vnfId, CbamRestApiProvider.NOKIA_LCM_API_VERSION).blockingFirst(); + VnfInfo vnfInfo = cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdGet(vnfId, CbamRestApiProvider.NOKIA_LCM_API_VERSION).blockingFirst(); vnf.setVnfName(vnfInfo.getName()); } catch (RuntimeException e) { throw buildFatalFailure(logger, "Unable to query VNF with " + vnfId + " identifier from CBAM", e); } vnf.setVnfId(vnfId); vnf.setInMaint(inMaintenance); + vnf.setNfType(SERVICE_NAME); //FIXME whould be good to know if this parameter is relevant or not? (mandatory) vnf.setVnfType("NokiaVNF"); vnf.setIsClosedLoopDisabled(inMaintenance); + if (vnf.getRelationshipList() == null) { + vnf.setRelationshipList(new ArrayList<>()); + } + if (nsId.isPresent()) { + addSingletonRelation(vnf.getRelationshipList(), linkTo(nsId.get())); + } aaiRestApiProvider.getNetworkApi().createOrUpdateNetworkGenericVnfsGenericVnf(vnf.getVnfId(), vnf).blockingFirst(); } @@ -107,4 +117,7 @@ class GenericVnfManager extends AbstractManager { throw new NoSuchElementException(); } + private GenericVnf getExistingVnf(String vnfId) { + return aaiRestApiProvider.getNetworkApi().getNetworkGenericVnfsGenericVnf(vnfId, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null).blockingFirst(); + } }
\ No newline at end of file diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/L3NetworkManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/L3NetworkManager.java index f1c47d5b..04f601d5 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/L3NetworkManager.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/L3NetworkManager.java @@ -21,12 +21,9 @@ import java.util.ArrayList; import org.onap.aai.model.L3Network; import org.onap.aai.model.Relationship; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProviderForSo; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Component; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.SEPARATOR; @@ -37,13 +34,12 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.ge * Responsible for managing the {@link L3Network} in AAI */ @Component -@Conditional(value = Conditions.UseForDirect.class) class L3NetworkManager extends AbstractManager { private static Logger logger = org.slf4j.LoggerFactory.getLogger(L3NetworkManager.class); @Autowired - L3NetworkManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProvider cbamRestApiProvider, DriverProperties driverProperties) { - super(aaiRestApiProvider, cbamRestApiProvider, driverProperties); + L3NetworkManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProviderForSo cbamRestApiProvider) { + super(aaiRestApiProvider, cbamRestApiProvider); } @Override diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/LInterfaceManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/LInterfaceManager.java index 37a6993a..6e37cd1e 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/LInterfaceManager.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/LInterfaceManager.java @@ -21,13 +21,10 @@ import org.onap.aai.model.L3InterfaceIpv4AddressList; import org.onap.aai.model.L3InterfaceIpv6AddressList; import org.onap.aai.model.LInterface; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProviderForSo; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.ReportedAffectedCp; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Component; import static java.lang.String.format; @@ -39,13 +36,12 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.ge * Responsible for managing the {@link LInterface} in AAI */ @Component -@Conditional(value = Conditions.UseForDirect.class) class LInterfaceManager extends AbstractManager { private static Logger logger = org.slf4j.LoggerFactory.getLogger(LInterfaceManager.class); @Autowired - LInterfaceManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProvider cbamRestApiProvider, DriverProperties driverProperties) { - super(aaiRestApiProvider, cbamRestApiProvider, driverProperties); + LInterfaceManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProviderForSo cbamRestApiProvider) { + super(aaiRestApiProvider, cbamRestApiProvider); } static String buildUrl(String vimId, ReportedAffectedCp affectedCp) { diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VnfcManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VnfcManager.java index db65d2f1..80d7eb7d 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VnfcManager.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VnfcManager.java @@ -19,12 +19,9 @@ import io.reactivex.Observable; import java.util.ArrayList; import org.onap.aai.model.Vnfc; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProviderForSo; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Component; import static com.google.common.base.Splitter.on; @@ -35,13 +32,12 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.SEPARATOR * Responsible for managing {@link Vnfc} in AAI */ @Component -@Conditional(value = Conditions.UseForDirect.class) public class VnfcManager extends AbstractManager { private static Logger logger = org.slf4j.LoggerFactory.getLogger(VnfcManager.class); @Autowired - VnfcManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProvider cbamRestApiProvider, DriverProperties driverProperties) { - super(aaiRestApiProvider, cbamRestApiProvider, driverProperties); + VnfcManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProviderForSo cbamRestApiProvider) { + super(aaiRestApiProvider, cbamRestApiProvider); } private static String buildId(String vnfId, String cbamVnfcId) { diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VserverManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VserverManager.java index 6aeefd77..05f5f6f5 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VserverManager.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VserverManager.java @@ -27,13 +27,10 @@ import org.onap.aai.model.Relationship; import org.onap.aai.model.Volume; import org.onap.aai.model.Vserver; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProviderForSo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Component; import static com.google.common.collect.Iterables.find; @@ -45,13 +42,12 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.ge * Responsible for managing {@link Vserver} in AAI */ @Component -@Conditional(value = Conditions.UseForDirect.class) class VserverManager extends AbstractManager { private static Logger logger = LoggerFactory.getLogger(AbstractManager.class); @Autowired - VserverManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProvider cbamRestApiProvider, DriverProperties driverProperties) { - super(aaiRestApiProvider, cbamRestApiProvider, driverProperties); + VserverManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProviderForSo cbamRestApiProvider) { + super(aaiRestApiProvider, cbamRestApiProvider); } static Relationship linkTo(String vimId, String tenantId, String serverProviderId) { |