aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2019-09-24 11:52:32 +0000
committerGerrit Code Review <gerrit@onap.org>2019-09-24 11:52:32 +0000
commit1cba9f989d964aeb716a0f5746a6485996d3e7f8 (patch)
tree6b23249b1ba69bb11104f50e098321b93cc0fbe9 /adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main
parent0c8e7966a2d1c54fd298d161d2e36604175f62ef (diff)
parent5c869b76bc052104f6720a304344e9c0a4494f1d (diff)
Merge "VNFM adapter relationship handling improvements"
Diffstat (limited to 'adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main')
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java88
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java27
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java18
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java12
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java22
5 files changed, 64 insertions, 103 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 110bbabdb2..fc9efef947 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
@@ -31,14 +31,10 @@ import org.onap.aai.domain.yang.EsrVnfmList;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.RelationshipData;
-import org.onap.aai.domain.yang.RelationshipList;
import org.onap.aai.domain.yang.Vserver;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs;
import org.onap.so.adapters.vnfmadapter.rest.exceptions.TenantNotFoundException;
import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmNotFoundException;
-import org.onap.so.client.aai.AAIObjectType;
-import org.onap.so.client.aai.AAIVersion;
-import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.vnfmadapter.v1.model.Tenant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -61,38 +57,6 @@ public class AaiHelper {
}
/**
- * Add a relationship to the given generic VNF to the given VNFM.
- *
- * @param vnf the generic VNF
- * @param vnfmId the ID of the VNFM
- */
- public void addRelationshipFromGenericVnfToVnfm(final GenericVnf vnf, final String vnfmId) {
- if (vnf.getRelationshipList() == null) {
- vnf.setRelationshipList(new RelationshipList());
- }
- final RelationshipList vnfmRelationshiplist = vnf.getRelationshipList();
- vnfmRelationshiplist.getRelationship().add(createRelationshipToVnfm(vnfmId));
-
- }
-
- private Relationship createRelationshipToVnfm(final String vnfmId) {
- final Relationship relationship = new Relationship();
- relationship.setRelatedTo("esr-vnfm");
- relationship.setRelationshipLabel("tosca.relationships.DependsOn");
- relationship.setRelatedLink("/aai/" + AAIVersion.LATEST
- + AAIUriFactory.createResourceUri(AAIObjectType.VNFM, vnfmId).build().toString());
- relationship.getRelationshipData().add(createRelationshipData("esr-vnfm.vnfm-id", vnfmId));
- return relationship;
- }
-
- private RelationshipData createRelationshipData(final String key, final String value) {
- final RelationshipData data = new RelationshipData();
- data.setRelationshipKey(key);
- data.setRelationshipValue(value);
- return data;
- }
-
- /**
* Get the VNFM assigned for use for the given generic VNF.
*
* @param vnf the generic VNF
@@ -242,30 +206,6 @@ public class AaiHelper {
return vserver;
}
- /**
- * Add a relationship to the given vserver to the given VNF.
- *
- * @param vnf the vserver
- * @param vnfmId the ID of the VNF
- */
- public void addRelationshipFromVserverVnfToGenericVnf(final Vserver vserver, final String vnfId) {
- if (vserver.getRelationshipList() == null) {
- vserver.setRelationshipList(new RelationshipList());
- }
- final RelationshipList vserverRelationshiplist = vserver.getRelationshipList();
- vserverRelationshiplist.getRelationship().add(createRelationshipToGenericVnf(vnfId));
- }
-
- private Relationship createRelationshipToGenericVnf(final String vnfId) {
- final Relationship relationship = new Relationship();
- relationship.setRelatedTo("generic-vnf");
- relationship.setRelationshipLabel("tosca.relationships.HostedOn");
- relationship.setRelatedLink("/aai/" + AAIVersion.LATEST
- + AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).build().toString());
- relationship.getRelationshipData().add(createRelationshipData("generic-vnf.vnf-id", vnfId));
- return relationship;
- }
-
public void setOamIpAddressSource(final String vnfId, final OamIpAddressSource oamIpAddressSource) {
mapOfVnfIdToOamIpAddressHolder.put(vnfId, oamIpAddressSource);
}
@@ -274,32 +214,4 @@ public class AaiHelper {
return mapOfVnfIdToOamIpAddressHolder.get(vnfId);
}
- /**
- * Add a relationship to the given tenant to the given VNF.
- *
- * @param vnf the generic vnf
- * @param tenant the Tenant
- */
-
- public void addRelationshipFromGenericVnfToTenant(final GenericVnf vnf, final Tenant tenant) {
- if (vnf.getRelationshipList() == null) {
- vnf.setRelationshipList(new RelationshipList());
- }
- final RelationshipList vnfmRelationshiplist = vnf.getRelationshipList();
- vnfmRelationshiplist.getRelationship().add(createRelationshipToTenant(tenant));
- }
-
- private Relationship createRelationshipToTenant(final Tenant tenant) {
- final Relationship relationship = new Relationship();
- relationship.setRelatedTo("tenant");
- relationship.setRelatedLink("/aai/" + AAIVersion.LATEST + AAIUriFactory.createResourceUri(AAIObjectType.TENANT,
- tenant.getCloudOwner(), tenant.getRegionName(), tenant.getTenantId()).build().toString());
- relationship.getRelationshipData()
- .add(createRelationshipData("cloud-region.cloud-owner", tenant.getCloudOwner()));
- relationship.getRelationshipData()
- .add(createRelationshipData("cloud-region.cloud-region-id", tenant.getRegionName()));
- relationship.getRelationshipData().add(createRelationshipData("tenant.tenant-id", tenant.getTenantId()));
- return relationship;
- }
-
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java
index 7021c02511..d19190d88e 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java
@@ -72,12 +72,22 @@ public interface AaiServiceProvider {
EsrVnfm invokeGetVnfm(final String vnfmId);
/**
- * Invoke a PUT request for a generic vnf.
+ * Invoke a PATCH request for a generic vnf.
*
* @param vnf the generic vnf
* @return
*/
- void invokePutGenericVnf(GenericVnf vnf);
+ void invokePatchGenericVnf(GenericVnf vnf);
+
+ /**
+ * Invoke a PUT request for a relationship from a generic vnf to a VNFM.
+ *
+ * @param vnf the generic vnf
+ * @param vnfmId the ID of the VNFM
+ * @return
+ */
+ void invokePutGenericVnfToVnfmRelationship(GenericVnf vnf, final String vnfmId);
+
/**
* Invoke a PUT request for a vserver.
@@ -92,6 +102,19 @@ public interface AaiServiceProvider {
final Vserver vserver);
/**
+ * Invoke a PUT request for a relationship from a vserver to a generic vnf.
+ *
+ * @param cloudOwner the cloud owner
+ * @param cloudRegion the cloud region the vserver is deployed on
+ * @param tenantId the ID of the tenant the vserver is deployed on
+ * @param vserver the vserver
+ * @param vnfId the ID of the generic vnf
+ * @return
+ */
+ void invokePutVserverToVnfRelationship(final String cloudOwner, final String cloudRegion, final String tenantId,
+ final Vserver vserver, final String vnfId);
+
+ /**
* Invoke a DELETE request for a vserver.
*
* @param cloudOwner the cloud owner
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java
index 019a08af78..6dc6020834 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java
@@ -98,12 +98,18 @@ public class AaiServiceProviderImpl implements AaiServiceProvider {
}
@Override
- public void invokePutGenericVnf(final GenericVnf vnf) {
+ public void invokePatchGenericVnf(final GenericVnf vnf) {
aaiClientProvider.getAaiClient()
.update(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()), vnf);
}
@Override
+ public void invokePutGenericVnfToVnfmRelationship(final GenericVnf vnf, final String vnfmId) {
+ aaiClientProvider.getAaiClient().connect(AAIUriFactory.createResourceUri(AAIObjectType.VNFM, vnfmId),
+ AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()));
+ }
+
+ @Override
public void invokePutVserver(final String cloudOwner, final String cloudRegion, final String tenant,
final Vserver vserver) {
aaiClientProvider.getAaiClient().create(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner,
@@ -111,6 +117,16 @@ public class AaiServiceProviderImpl implements AaiServiceProvider {
}
@Override
+ public void invokePutVserverToVnfRelationship(final String cloudOwner, final String cloudRegion,
+ final String tenant, final Vserver vserver, final String vnfId) {
+ aaiClientProvider.getAaiClient()
+ .connect(
+ AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, cloudRegion, tenant,
+ vserver.getVserverId()),
+ AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId));
+ }
+
+ @Override
public void invokeDeleteVserver(final String cloudOwner, final String cloudRegion, final String tenant,
final String vserverId) {
aaiClientProvider.getAaiClient().delete(
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 0aad91e5be..461c15a512 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
@@ -81,21 +81,25 @@ public class LifecycleManager {
* @return the response to the request
*/
public CreateVnfResponse createVnf(final String vnfIdInAai, final CreateVnfRequest request) {
- final GenericVnf genericVnf = getGenericVnfFromAai(vnfIdInAai);
+ GenericVnf genericVnf = getGenericVnfFromAai(vnfIdInAai);
EsrVnfm vnfm = aaiHelper.getAssignedVnfm(genericVnf);
checkIfVnfAlreadyExistsInVnfm(vnfm, genericVnf);
if (vnfm == null) {
vnfm = aaiHelper.selectVnfm(genericVnf);
- aaiHelper.addRelationshipFromGenericVnfToVnfm(genericVnf, vnfm.getVnfmId());
+ aaiServiceProvider.invokePutGenericVnfToVnfmRelationship(genericVnf, vnfm.getVnfmId());
}
- aaiHelper.addRelationshipFromGenericVnfToTenant(genericVnf, request.getTenant());
final InlineResponse201 vnfmResponse = sendCreateRequestToVnfm(request, genericVnf, vnfIdInAai, vnfm);
logger.info("Create response: {}", vnfmResponse);
genericVnf.setSelflink(getSelfLink(vnfmResponse, vnfm));
- aaiServiceProvider.invokePutGenericVnf(genericVnf);
+
+ GenericVnf genericVnfPatch = new GenericVnf();
+ genericVnfPatch.setVnfId(genericVnf.getVnfId());
+ genericVnfPatch.setSelflink(genericVnf.getSelflink());
+ aaiServiceProvider.invokePatchGenericVnf(genericVnfPatch);
+
final String vnfIdInVnfm = vnfmResponse.getId();
final OamIpAddressSource oamIpAddressSource = extractOamIpAddressSource(request);
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 eb912c8775..7a6bbfe0d9 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
@@ -97,10 +97,12 @@ public class NotificationHandler implements Runnable {
private void handleVnfInstantiateCompleted() {
final GenericVnf genericVnf = aaiServiceProvider
.invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).getGenericVnf().get(0);
- setOamIpAddress(genericVnf, vnfInstance);
- genericVnf.setOrchestrationStatus("Created");
- aaiServiceProvider.invokePutGenericVnf(genericVnf);
+ final GenericVnf genericVnfPatch = new GenericVnf();
+ genericVnfPatch.setVnfId(genericVnf.getVnfId());
+ setOamIpAddress(genericVnfPatch, vnfInstance);
+ genericVnfPatch.setOrchestrationStatus("Created");
+ aaiServiceProvider.invokePatchGenericVnf(genericVnfPatch);
addVservers(vnfLcmOperationOccurrenceNotification, genericVnf.getVnfId(), vnfInstance.getVimConnectionInfo());
@@ -162,9 +164,12 @@ public class NotificationHandler implements Runnable {
jobManager.notificationProcessedForOperation(vnfLcmOperationOccurrenceNotification.getVnfLcmOpOccId(),
deleteSuccessful);
jobManager.vnfDeleted(vnfLcmOperationOccurrenceNotification.getVnfLcmOpOccId());
- genericVnf.setOrchestrationStatus("Assigned");
- genericVnf.setSelflink("");
- aaiServiceProvider.invokePutGenericVnf(genericVnf);
+
+ final GenericVnf genericVnfPatch = new GenericVnf();
+ genericVnfPatch.setVnfId(genericVnf.getVnfId());
+ genericVnfPatch.setOrchestrationStatus("Assigned");
+ genericVnfPatch.setSelflink("");
+ aaiServiceProvider.invokePatchGenericVnf(genericVnfPatch);
}
}
@@ -180,10 +185,11 @@ public class NotificationHandler implements Runnable {
getVimConnectionInfo(vimConnectionIdToVimConnectionInfo, vnfc);
if (ChangeTypeEnum.ADDED.equals(vnfc.getChangeType())) {
final Vserver vserver = aaiHelper.createVserver(vnfc);
- aaiHelper.addRelationshipFromVserverVnfToGenericVnf(vserver, vnfId);
-
aaiServiceProvider.invokePutVserver(getCloudOwner(vimConnectionInfo), getCloudRegion(vimConnectionInfo),
getTenant(vimConnectionInfo), vserver);
+
+ aaiServiceProvider.invokePutVserverToVnfRelationship(getCloudOwner(vimConnectionInfo),
+ getCloudRegion(vimConnectionInfo), getTenant(vimConnectionInfo), vserver, vnfId);
}
}
}