aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2019-04-09 12:26:12 +0000
committerMichaelMorris <michael.morris@est.tech>2019-04-09 12:26:12 +0000
commitc6d3ec1230b2d68548587b28d4a9b02e9e96101f (patch)
treeb9a28221a8263549f9d56bc4fafbb7b93511c131 /adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter
parentb703daf9fb4bc0aeadba09e466c7456fc96667e4 (diff)
Added handling for OAM IP address
Change-Id: Iaae7f17517dc44767b73495e62549765edc4e343 Issue-ID: SO-1637 Signed-off-by: MichaelMorris <michael.morris@est.tech>
Diffstat (limited to 'adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter')
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java11
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/OamIpAddressSource.java59
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java20
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java20
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java12
5 files changed, 115 insertions, 7 deletions
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java
index 9139d5e66c..ee04819ca4 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java
@@ -21,6 +21,8 @@
package org.onap.so.adapters.vnfmadapter.extclients.aai;
import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.aai.domain.yang.EsrVnfm;
@@ -49,6 +51,7 @@ public class AaiHelper {
private static final Logger logger = LoggerFactory.getLogger(AaiHelper.class);
private final AaiServiceProvider aaiServiceProvider;
+ private final Map<String, OamIpAddressSource> mapOfVnfIdToOamIpAddressHolder = new HashMap<>();
@Autowired
public AaiHelper(final AaiServiceProvider aaiServiceProvider) {
@@ -223,4 +226,12 @@ public class AaiHelper {
return relationship;
}
+ public void setOamIpAddressSource(final String vnfId, final OamIpAddressSource oamIpAddressSource) {
+ mapOfVnfIdToOamIpAddressHolder.put(vnfId, oamIpAddressSource);
+ }
+
+ public OamIpAddressSource getOamIpAddressSource(final String vnfId) {
+ return mapOfVnfIdToOamIpAddressHolder.get(vnfId);
+ }
+
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/OamIpAddressSource.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/OamIpAddressSource.java
new file mode 100644
index 0000000000..54b4055276
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/OamIpAddressSource.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.extclients.aai;
+
+import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource.OamIpAddressType;
+
+/**
+ * Represents the source of the value to use as the AAI OAM IP address of a VNF
+ */
+public class OamIpAddressSource {
+
+ private final OamIpAddressType type;
+ private final String value;
+
+ public OamIpAddressSource(final OamIpAddressType type, final String value) {
+ this.type = type;
+ this.value = value;
+ }
+
+ public OamIpAddressType getType() {
+ return type;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public enum OamIpAddressType {
+ /**
+ * The value passed in {@link OamIpAddress#OamIpAddress(OamIpAddressType, String)} is to be used directly as the
+ * OAM IP address
+ */
+ LITERAL,
+ /**
+ * The OAM IP address is to be retrieved from the vnfConfigurableProperties returned from the VNFM using the
+ * value passed in {@link OamIpAddress#OamIpAddress(OamIpAddressType, String)} as the name of a property
+ */
+ CONFIGURABLE_PROPERTY
+ }
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java
index 7f0f9e3b37..7085218c0b 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java
@@ -21,10 +21,13 @@
package org.onap.so.adapters.vnfmadapter.lifecycle;
import com.google.common.base.Optional;
+import java.util.Map;
import org.onap.aai.domain.yang.EsrVnfm;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider;
+import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource;
+import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource.OamIpAddressType;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmHelper;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
@@ -83,6 +86,10 @@ public class LifecycleManager {
}
final String vnfIdInVnfm = sendCreateRequestToVnfm(genericVnf);
+
+ final OamIpAddressSource oamIpAddressSource = extractOamIpAddressSource(request);
+ aaiHelper.setOamIpAddressSource(vnfIdInVnfm, oamIpAddressSource);
+
createNotificationSubscription(vnfm.getVnfmId(), vnfIdInVnfm);
final String operationId = sendInstantiateRequestToVnfm(vnfm, genericVnf, request, vnfIdInAai, vnfIdInVnfm);
@@ -92,6 +99,19 @@ public class LifecycleManager {
return response;
}
+ private OamIpAddressSource extractOamIpAddressSource(final CreateVnfRequest request) {
+ final Map<String, String> additionalParams = request.getAdditionalParams();
+ try {
+ final String sourceType = additionalParams.remove("oamIpAddressSourceType");
+ final String sourceValue = additionalParams.remove("oamIpAddressSourceValue");
+ final OamIpAddressType oamIpAddressType = OamIpAddressType.valueOf(sourceType.toUpperCase());
+ return new OamIpAddressSource(oamIpAddressType, sourceValue);
+ } catch (final NullPointerException | IllegalArgumentException exception) {
+ logger.debug("Additional Params not set for OAM IP address source", exception);
+ return null;
+ }
+ }
+
private void checkIfVnfAlreadyExistsInVnfm(final GenericVnf genericVnf) {
if (genericVnf.getSelflink() != null && !genericVnf.getSelflink().isEmpty()) {
Optional<InlineResponse201> response = Optional.absent();
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java
index a81451b141..506eb8db0e 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java
@@ -30,6 +30,8 @@ import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.Vserver;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider;
+import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource;
+import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource.OamIpAddressType;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification;
@@ -93,9 +95,7 @@ public class NotificationHandler implements Runnable {
private void handleVnfInstantiateCompleted() {
final GenericVnf genericVnf =
aaiServiceProvider.invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).get(0);
- final String ipAddress = getOamIpAddress(vnfInstance);
- logger.debug("Updating " + genericVnf.getVnfId() + " with VNF OAM IP ADDRESS: " + ipAddress);
- genericVnf.setIpv4OamAddress(ipAddress);
+ setOamIpAddress(genericVnf, vnfInstance);
genericVnf.setOrchestrationStatus("Created");
aaiServiceProvider.invokePutGenericVnf(genericVnf);
@@ -106,18 +106,24 @@ public class NotificationHandler implements Runnable {
logger.debug("Finished handling notification for vnfm: " + vnfInstance.getId());
}
- private String getOamIpAddress(final InlineResponse201 vnfInstance) {
+ private void setOamIpAddress(final GenericVnf genericVnf, final InlineResponse201 vnfInstance) {
+ final OamIpAddressSource oamIpAddressSource = aaiHelper.getOamIpAddressSource(vnfInstance.getId());
+ if (oamIpAddressSource == null) {
+ logger.warn("No source indicated for OAM IP address, no value will be set in AAI");
+ return;
+ }
+ if (oamIpAddressSource.getType().equals(OamIpAddressType.LITERAL)) {
+ genericVnf.setIpv4OamAddress(oamIpAddressSource.getValue());
+ }
try {
logger.debug("ConfigurableProperties: " + vnfInstance.getVnfConfigurableProperties());
if (vnfInstance.getVnfConfigurableProperties() == null) {
logger.warn("No ConfigurableProperties, cannot set OAM IP Address");
- return null;
}
final JSONObject properties = new JSONObject((Map) vnfInstance.getVnfConfigurableProperties());
- return properties.get("vnfIpAddress").toString();
+ genericVnf.setIpv4OamAddress(properties.get(oamIpAddressSource.getValue()).toString());
} catch (final JSONException jsonException) {
logger.error("Error getting vnfIpAddress", jsonException);
- return null;
}
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java
index 0f203902c8..aa089e1348 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java
@@ -38,6 +38,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import javax.inject.Inject;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.junit.Before;
@@ -49,6 +50,9 @@ import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.Vserver;
import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication;
+import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper;
+import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource;
+import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource.OamIpAddressType;
import org.onap.so.adapters.vnfmadapter.extclients.vim.model.AccessInfo;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs.ChangeTypeEnum;
@@ -102,6 +106,9 @@ public class Sol003LcnControllerTest {
private Sol003LcnContoller controller;
private final Gson gson = new Gson();
+ @Inject
+ private AaiHelper aaiHelper;
+
@Before
public void setUp() throws Exception {
mockRestServer = MockRestServiceServer.bindTo(testRestTemplate).build();
@@ -269,6 +276,7 @@ public class Sol003LcnControllerTest {
private InlineResponse201 createVnfInstance() {
final InlineResponse201 vnfInstance = new InlineResponse201();
+ vnfInstance.setId("myTestVnfIdOnVnfm");
final InlineResponse201LinksSelf selfLink = new InlineResponse201LinksSelf();
selfLink.setHref("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm");
final InlineResponse201Links VnfInstancelinks = new InlineResponse201Links();
@@ -288,6 +296,10 @@ public class Sol003LcnControllerTest {
vimConnection.setAccessInfo(accessInfo);
vimConnectionInfo.add(vimConnection);
vnfInstance.setVimConnectionInfo(vimConnectionInfo);
+
+ final OamIpAddressSource oamIpAddressSource =
+ new OamIpAddressSource(OamIpAddressType.CONFIGURABLE_PROPERTY, "vnfIpAddress");
+ aaiHelper.setOamIpAddressSource("myTestVnfIdOnVnfm", oamIpAddressSource);
return vnfInstance;
}