summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientImpl.java4
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java2
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java20
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java8
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java4
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NeutronClientImpl.java4
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java12
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoCommonUtilsTest.java4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/DuplicateNameException.java18
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java14
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java18
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java7
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java29
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java40
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java22
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java24
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/Format.java3
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryResourcesClient.java18
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryUri.java1
20 files changed, 216 insertions, 44 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientImpl.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientImpl.java
index 567f849b36..b0c2d9430a 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientImpl.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientImpl.java
@@ -76,7 +76,7 @@ public class CinderClientImpl extends MsoCommonUtils {
// list is set to false, otherwise an invalid URL is appended
OpenStackRequest<Volumes> request =
cinderClient.volumes().list(false).queryParam("limit", limit).queryParam("marker", marker);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Cinder Client", e);
throw new CinderClientException("Error building Cinder Client", e);
@@ -90,7 +90,7 @@ public class CinderClientImpl extends MsoCommonUtils {
Cinder cinderClient = getCinderClient(cloudSiteId, tenantId);
// list is set to false, otherwise an invalid URL is appended
OpenStackRequest<Volume> request = cinderClient.volumes().show(volumeId);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Cinder Client", e);
throw new CinderClientException("Error building Cinder Client", e);
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java
index 57faaac717..698b605be3 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java
@@ -74,7 +74,7 @@ public class GlanceClientImpl extends MsoCommonUtils {
// list is set to false, otherwise an invalid URL is appended
OpenStackRequest<Images> request = glanceClient.images().list(false).queryParam("visibility", visibility)
.queryParam("limit", limit).queryParam("marker", marker).queryParam("name", name);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Glance Client", e);
throw new GlanceClientException("Error building Glance Client", e);
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java
index 4ea205a8e1..576784ae3e 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java
@@ -98,19 +98,23 @@ public class MsoCommonUtils {
*/
protected <T> T executeAndRecordOpenstackRequest(OpenStackRequest<T> request) {
+ return executeAndRecordOpenstackRequest(request, true);
+ }
- String requestType;
- if (request.getClass().getEnclosingClass() != null) {
- requestType =
- request.getClass().getEnclosingClass().getSimpleName() + "." + request.getClass().getSimpleName();
- } else {
- requestType = request.getClass().getSimpleName();
- }
+ /*
+ * Method to execute an Openstack command and track its execution time. For the metrics log, a category of
+ * "Openstack" is used along with a sub-category that identifies the specific call (using the real
+ * openstack-java-sdk classname of the OpenStackRequest<T> parameter). boolean isNoRetry - true if No retry; and
+ * false if Retry.
+ */
+ protected <T> T executeAndRecordOpenstackRequest(OpenStackRequest<T> request, boolean shouldRetry) {
int retryDelay = poConfig.getRetryDelay();
int retryCount = poConfig.getRetryCount();
String retryCodes = poConfig.getRetryCodes();
-
+ if (!shouldRetry) {
+ retryCodes = null;
+ }
// Run the actual command. All exceptions will be propagated
while (true) {
try {
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
index 6db0a58e3f..7174bc0e31 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
@@ -1249,7 +1249,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
Heat heatClient = getHeatClient(cloudSiteId, tenantId);
OpenStackRequest<Resources> request =
heatClient.getResources().listResources(stackName).queryParam("nested_depth", nestedDepth);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
}
public Events queryStackEvents(String cloudSiteId, String tenantId, String stackName, String stackId,
@@ -1257,7 +1257,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
Heat heatClient = getHeatClient(cloudSiteId, tenantId);
OpenStackRequest<Events> request =
heatClient.getEvents().listEvents(stackName, stackId).queryParam("nested_depth", nestedDepth);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
}
public Stacks queryStacks(String cloudSiteId, String tenantId, int limit, String marker)
@@ -1271,14 +1271,14 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
}
OpenStackRequest<Stacks> request =
heatClient.getStacks().list().queryParam("limit", limit).queryParam("marker", marker);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
}
public <R> R executeHeatClientRequest(String url, String cloudSiteId, String tenantId, Class<R> returnType)
throws MsoException {
Heat heatClient = getHeatClient(cloudSiteId, tenantId);
OpenStackRequest<R> request = heatClient.get(url, returnType);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
}
protected void sleep(long time) {
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java
index 6f08afc55f..069c6c7c5b 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java
@@ -382,7 +382,7 @@ public class MsoNeutronUtils extends MsoCommonUtils {
Authentication credentials = authenticationMethodFactory.getAuthenticationFor(cloudIdentity);
OpenStackRequest<Access> request =
keystoneTenantClient.tokens().authenticate(credentials).withTenantId(tenantId);
- access = executeAndRecordOpenstackRequest(request);
+ access = executeAndRecordOpenstackRequest(request, true);
try {
@@ -499,7 +499,7 @@ public class MsoNeutronUtils extends MsoCommonUtils {
try {
OpenStackRequest<Port> request = neutronClient.ports().show(neutronPortId);
- Port port = executeAndRecordOpenstackRequest(request);
+ Port port = executeAndRecordOpenstackRequest(request, false);
return port;
} catch (OpenStackResponseException e) {
if (e.getStatus() == 404) {
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NeutronClientImpl.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NeutronClientImpl.java
index 93745de54a..938a888bbd 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NeutronClientImpl.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NeutronClientImpl.java
@@ -75,7 +75,7 @@ public class NeutronClientImpl extends MsoCommonUtils {
Quantum neutronClient = getNeutronClient(cloudSiteId, tenantId);
OpenStackRequest<Networks> request = neutronClient.networks().list().queryParam("id", id)
.queryParam("limit", limit).queryParam("marker", marker).queryParam("name", name);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Neutron Client", e);
throw new NeutronClientException("Error building Neutron Client", e);
@@ -103,7 +103,7 @@ public class NeutronClientImpl extends MsoCommonUtils {
Quantum neutronClient = getNeutronClient(cloudSiteId, tenantId);
OpenStackRequest<Subnets> request = neutronClient.subnets().list().queryParam("id", id)
.queryParam("limit", limit).queryParam("marker", marker).queryParam("name", name);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Neutron Client", e);
throw new NeutronClientException("Error building Neutron Client", e);
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java
index 6cd79de476..99e8b589b1 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java
@@ -78,7 +78,7 @@ public class NovaClientImpl extends MsoCommonUtils {
Nova novaClient = getNovaClient(cloudSiteId, tenantId);
OpenStackRequest<Flavors> request =
novaClient.flavors().list(false).queryParam("limit", limit).queryParam("marker", marker);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Nova Client", e);
throw new NovaClientException("Error building Nova Client", e);
@@ -103,7 +103,7 @@ public class NovaClientImpl extends MsoCommonUtils {
Nova novaClient = getNovaClient(cloudSiteId, tenantId);
novaClient = getNovaClient(cloudSiteId, tenantId);
OpenStackRequest<Flavor> request = novaClient.flavors().show(id);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Nova Client", e);
throw new NovaClientException("Error building Nova Client", e);
@@ -128,7 +128,7 @@ public class NovaClientImpl extends MsoCommonUtils {
Nova novaClient = getNovaClient(cloudSiteId, tenantId);
OpenStackRequest<HostAggregates> request =
novaClient.aggregates().list().queryParam("limit", limit).queryParam("marker", marker);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Nova Client", e);
throw new NovaClientException("Error building Nova Client", e);
@@ -152,7 +152,7 @@ public class NovaClientImpl extends MsoCommonUtils {
try {
Nova novaClient = getNovaClient(cloudSiteId, tenantId);
OpenStackRequest<HostAggregate> request = novaClient.aggregates().showAggregate(id);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Nova Client", e);
throw new NovaClientException("Error building Nova Client", e);
@@ -176,7 +176,7 @@ public class NovaClientImpl extends MsoCommonUtils {
try {
Nova novaClient = getNovaClient(cloudSiteId, tenantId);
OpenStackRequest<QuotaSet> request = novaClient.quotaSets().showQuota(tenantId);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Nova Client", e);
throw new NovaClientException("Error building Nova Client", e);
@@ -198,7 +198,7 @@ public class NovaClientImpl extends MsoCommonUtils {
try {
Nova novaClient = getNovaClient(cloudSiteId, tenantId);
OpenStackRequest<Void> request = novaClient.keyPairs().delete(keyPairName);
- executeAndRecordOpenstackRequest(request);
+ executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Nova Client", e);
throw new NovaClientException("Error building Nova Client", e);
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoCommonUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoCommonUtilsTest.java
index 5cf7c86522..622ad4f94f 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoCommonUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoCommonUtilsTest.java
@@ -69,6 +69,7 @@ public class MsoCommonUtilsTest extends BaseTest {
Mockito.when(openstackRequest.path()).thenReturn("/test");
// TODO:Must try a real connection
assertNull(commonUtils.executeAndRecordOpenstackRequest(openstackRequest));
+ assertNull(commonUtils.executeAndRecordOpenstackRequest(openstackRequest, true));
}
@Test
@@ -78,6 +79,7 @@ public class MsoCommonUtilsTest extends BaseTest {
doThrow(OpenStackResponseException.class).when(openstackRequest).execute();
commonUtils.executeAndRecordOpenstackRequest(openstackRequest);
+ commonUtils.executeAndRecordOpenstackRequest(openstackRequest, true);
}
@Test
@@ -86,7 +88,7 @@ public class MsoCommonUtilsTest extends BaseTest {
doThrow(OpenStackConnectException.class).when(openstackRequest).execute();
- commonUtils.executeAndRecordOpenstackRequest(openstackRequest);
+ commonUtils.executeAndRecordOpenstackRequest(openstackRequest, true);
}
@Test
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/DuplicateNameException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/DuplicateNameException.java
new file mode 100644
index 0000000000..2f2a116526
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/DuplicateNameException.java
@@ -0,0 +1,18 @@
+package org.onap.so.bpmn.servicedecomposition.tasks.exceptions;
+
+public class DuplicateNameException extends Exception {
+
+ private static final long serialVersionUID = -2850043981787600326L;
+
+ public DuplicateNameException() {
+ super();
+ }
+
+ public DuplicateNameException(String message) {
+ super(message);
+ }
+
+ public DuplicateNameException(String objectType, String name) {
+ super(objectType + " with name " + name + " already exists. The name must be unique.");
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
index 28d5363ad2..524098bcb7 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
@@ -50,6 +50,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException;
import org.onap.so.client.aai.AAIObjectPlurals;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
@@ -76,6 +77,7 @@ public class AAICreateTasks {
private static final Logger logger = LoggerFactory.getLogger(AAICreateTasks.class);
private static final String networkTypeProvider = "PROVIDER";
+ private static final String A_LA_CARTE = "aLaCarte";
private static String NETWORK_COLLECTION_NAME = "networkCollectionName";
private static String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList";
private static String HEAT_STACK_ID = "heatStackId";
@@ -193,7 +195,11 @@ public class AAICreateTasks {
public void createVnf(BuildingBlockExecution execution) {
try {
+ Boolean alaCarte = execution.getVariable(A_LA_CARTE);
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ if (Boolean.TRUE.equals(alaCarte) && aaiVnfResources.checkNameInUse(vnf.getVnfName())) {
+ throw new DuplicateNameException("generic-vnf", vnf.getVnfName());
+ }
ServiceInstance serviceInstance =
extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
execution.setVariable("homing", Boolean.TRUE.equals(vnf.isCallHoming()));
@@ -252,6 +258,10 @@ public class AAICreateTasks {
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
CloudRegion cloudRegion = gBBInput.getCloudRegion();
+ Boolean alaCarte = execution.getVariable(A_LA_CARTE);
+ if (Boolean.TRUE.equals(alaCarte) && aaiVolumeGroupResources.checkNameInUse(volumeGroup)) {
+ throw new DuplicateNameException("volume-group", volumeGroup.getVolumeGroupName());
+ }
aaiVolumeGroupResources.createVolumeGroup(volumeGroup, cloudRegion);
aaiVolumeGroupResources.connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion);
aaiVolumeGroupResources.connectVolumeGroupToTenant(volumeGroup, cloudRegion);
@@ -264,6 +274,10 @@ public class AAICreateTasks {
try {
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ Boolean alaCarte = execution.getVariable(A_LA_CARTE);
+ if (Boolean.TRUE.equals(alaCarte) && aaiVfModuleResources.checkNameInUse(vfModule)) {
+ throw new DuplicateNameException("vf-module", vfModule.getVfModuleName());
+ }
int moduleIndex = 0;
if (vfModule.getModelInfoVfModule() != null
&& !Boolean.TRUE.equals(vfModule.getModelInfoVfModule().getIsBaseBoolean())) {
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java
index 514f48ffc8..4d1a6dce38 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java
@@ -23,12 +23,15 @@
package org.onap.so.client.orchestration;
import java.util.Optional;
+import org.onap.aai.domain.yang.VfModules;
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
+import org.onap.so.client.aai.AAIObjectPlurals;
import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.aai.mapper.AAIObjectMapper;
@@ -108,4 +111,19 @@ public class AAIVfModuleResources {
cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
injectionHelper.getAaiClient().connect(vfModuleURI, volumeGroupURI);
}
+
+ public boolean checkNameInUse(VfModule vfModule) {
+ boolean nameInUse = false;
+ AAIResourceUri vfModuleUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VF_MODULE)
+ .queryParam("vf-module-name", vfModule.getVfModuleName());
+ AAIResourceUri vfModuleUriWithCustomization = vfModuleUri.clone().queryParam("model-customization-id",
+ vfModule.getModelInfoVfModule().getModelCustomizationUUID());
+ if (injectionHelper.getAaiClient().exists(vfModuleUriWithCustomization)) {
+ // assume it's a resume case and return false
+ nameInUse = false;
+ } else {
+ nameInUse = injectionHelper.getAaiClient().exists(vfModuleUri);
+ }
+ return nameInUse;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java
index eb66f6bef5..a9635d1e34 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java
@@ -30,8 +30,10 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.client.aai.AAIObjectPlurals;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIValidatorImpl;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.aai.mapper.AAIObjectMapper;
@@ -152,4 +154,10 @@ public class AAIVnfResources {
return aaiValidatorImpl.isPhysicalServerLocked(vnf.getVnfId());
}
+
+ public boolean checkNameInUse(String vnfName) {
+ AAIResourceUri vnfUri =
+ AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName);
+ return injectionHelper.getAaiClient().exists(vnfUri);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java
index f4c285fdb3..b9e4aeb888 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java
@@ -26,6 +26,7 @@ import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
+import org.onap.so.client.aai.AAIObjectPlurals;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
@@ -93,4 +94,10 @@ public class AAIVolumeGroupResources {
copiedVolumeGroup.setHeatStackId(volumeGroup.getHeatStackId());
injectionHelper.getAaiClient().update(uri, aaiObjectMapper.mapVolumeGroup(copiedVolumeGroup));
}
+
+ public boolean checkNameInUse(VolumeGroup volumeGroup) {
+ AAIResourceUri volumeGroupUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VOLUME_GROUP)
+ .queryParam("volume-group-name", volumeGroup.getVolumeGroupName());
+ return injectionHelper.getAaiClient().exists(volumeGroupUri);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
index b054cc17bb..d5159975a9 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
@@ -60,6 +60,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
+import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException;
import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
@@ -140,7 +141,7 @@ public class AAICreateTasksTest extends BaseTaskTest {
@Test
public void createVolumeGroupTest() throws Exception {
volumeGroup.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
-
+ execution.setVariable("aLaCarte", Boolean.FALSE);
doNothing().when(aaiVolumeGroupResources).createVolumeGroup(volumeGroup, cloudRegion);
doNothing().when(aaiVolumeGroupResources).connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion);
@@ -152,6 +153,14 @@ public class AAICreateTasksTest extends BaseTaskTest {
}
@Test
+ public void createVolumeGroupDuplicateNameTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ execution.setVariable("aLaCarte", Boolean.TRUE);
+ doReturn(true).when(aaiVolumeGroupResources).checkNameInUse(volumeGroup);
+ aaiCreateTasks.createVolumeGroup(execution);
+ }
+
+ @Test
public void createVolumeGroupExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
@@ -325,11 +334,20 @@ public class AAICreateTasksTest extends BaseTaskTest {
@Test
public void createVnfTest() throws Exception {
doNothing().when(aaiVnfResources).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
+ execution.setVariable("aLaCarte", Boolean.FALSE);
aaiCreateTasks.createVnf(execution);
verify(aaiVnfResources, times(1)).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
}
@Test
+ public void createVnfDuplicateNameTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doReturn(true).when(aaiVnfResources).checkNameInUse(genericVnf.getVnfName());
+ execution.setVariable("aLaCarte", Boolean.TRUE);
+ aaiCreateTasks.createVnf(execution);
+ }
+
+ @Test
public void createVnfExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "notfound");
@@ -352,12 +370,21 @@ public class AAICreateTasksTest extends BaseTaskTest {
.thenReturn(newVfModule);
assertEquals(null, newVfModule.getModuleIndex());
+ execution.setVariable("aLaCarte", Boolean.FALSE);
aaiCreateTasks.createVfModule(execution);
assertEquals(1, newVfModule.getModuleIndex().intValue());
verify(aaiVfModuleResources, times(1)).createVfModule(newVfModule, genericVnf);
}
@Test
+ public void createVfModuleDuplicateNameTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ execution.setVariable("aLaCarte", Boolean.TRUE);
+ doReturn(true).when(aaiVfModuleResources).checkNameInUse(vfModule);
+ aaiCreateTasks.createVfModule(execution);
+ }
+
+ @Test
public void createServiceSubscriptionTest() {
doNothing().when(aaiServiceInstanceResources).createServiceSubscription(customer);
aaiCreateTasks.createServiceSubscription(execution);
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java
index ae3ebeddbd..9e3bc4f552 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java
@@ -21,7 +21,10 @@
package org.onap.so.client.orchestration;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
@@ -41,8 +44,10 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
+import org.onap.so.client.aai.AAIObjectPlurals;
import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
@@ -154,4 +159,39 @@ public class AAIVfModuleResourcesTest extends TestDataSetup {
assertEquals("testContrailServiceInstanceFqdn", vfModule.getContrailServiceInstanceFqdn());
}
+
+ @Test
+ public void checkNameInUseTrueTest() throws Exception {
+ AAIResourceUri vfModuleUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VF_MODULE)
+ .queryParam("vf-module-name", vfModule.getVfModuleName());
+ AAIResourceUri vfModuleUriWithCustomization = vfModuleUri.clone().queryParam("model-customization-id",
+ vfModule.getModelInfoVfModule().getModelCustomizationUUID());
+ doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(vfModuleUriWithCustomization));
+ doReturn(true).when(MOCK_aaiResourcesClient).exists(eq(vfModuleUri));
+ boolean nameInUse = aaiVfModuleResources.checkNameInUse(vfModule);
+ assertTrue(nameInUse);
+ }
+
+ @Test
+ public void checkNameInUseFalseIsResumeTest() throws Exception {
+ AAIResourceUri vfModuleUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VF_MODULE)
+ .queryParam("vf-module-name", vfModule.getVfModuleName());
+ AAIResourceUri vfModuleUriWithCustomization = vfModuleUri.clone().queryParam("model-customization-id",
+ vfModule.getModelInfoVfModule().getModelCustomizationUUID());
+ doReturn(true).when(MOCK_aaiResourcesClient).exists(eq(vfModuleUriWithCustomization));
+ boolean nameInUse = aaiVfModuleResources.checkNameInUse(vfModule);
+ assertFalse(nameInUse);
+ }
+
+ @Test
+ public void checkNameInUseFalseTest() throws Exception {
+ AAIResourceUri vfModuleUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VF_MODULE)
+ .queryParam("vf-module-name", vfModule.getVfModuleName());
+ AAIResourceUri vfModuleUriWithCustomization = vfModuleUri.clone().queryParam("model-customization-id",
+ vfModule.getModelInfoVfModule().getModelCustomizationUUID());
+ doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(vfModuleUriWithCustomization));
+ doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(vfModuleUri));
+ boolean nameInUse = aaiVfModuleResources.checkNameInUse(vfModule);
+ assertFalse(nameInUse);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java
index cdc601c1e4..0d48a29ca9 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java
@@ -21,6 +21,7 @@
package org.onap.so.client.orchestration;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
@@ -45,9 +46,11 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.client.aai.AAIObjectPlurals;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.AAIValidatorImpl;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.aai.mapper.AAIObjectMapper;
@@ -227,4 +230,23 @@ public class AAIVnfResourcesTest extends TestDataSetup {
verify(MOCK_aaiValidatorImpl, times(1)).isPhysicalServerLocked(isA(String.class));
assertTrue(isVnfPserversLockedFlag);
}
+
+
+ @Test
+ public void checkNameInUseTrueTest() {
+ AAIResourceUri vnfUri =
+ AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", "vnfName");
+ doReturn(true).when(MOCK_aaiResourcesClient).exists(eq(vnfUri));
+ boolean nameInUse = aaiVnfResources.checkNameInUse("vnfName");
+ assertTrue(nameInUse);
+ }
+
+ @Test
+ public void checkNameInUseFalseTest() {
+ AAIResourceUri vnfUri =
+ AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", "vnfName");
+ doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(vnfUri));
+ boolean nameInUse = aaiVnfResources.checkNameInUse("vnfName");
+ assertFalse(nameInUse);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java
index 2bdcf30a4c..5772cab995 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java
@@ -21,7 +21,10 @@
package org.onap.so.client.orchestration;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
@@ -39,8 +42,11 @@ import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
+import org.onap.so.client.aai.AAIObjectPlurals;
import org.onap.so.client.aai.AAIResourcesClient;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
@@ -146,4 +152,22 @@ public class AAIVolumeGroupResourcesTest extends TestDataSetup {
assertEquals("testVolumeHeatStackId", volumeGroup.getHeatStackId());
}
+
+ @Test
+ public void checkNameInUseTrueTest() {
+ AAIResourceUri volumeGroupUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VOLUME_GROUP)
+ .queryParam("volume-group-name", "testVolumeGroupName1");
+ doReturn(true).when(MOCK_aaiResourcesClient).exists(eq(volumeGroupUri));
+ boolean nameInUse = aaiVolumeGroupResources.checkNameInUse(volumeGroup);
+ assertTrue(nameInUse);
+ }
+
+ @Test
+ public void checkNameInUseFalseTest() {
+ AAIResourceUri volumeGroupUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VOLUME_GROUP)
+ .queryParam("volume-group-name", "testVolumeGroupName1");
+ doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(volumeGroupUri));
+ boolean nameInUse = aaiVolumeGroupResources.checkNameInUse(volumeGroup);
+ assertFalse(nameInUse);
+ }
}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/Format.java b/common/src/main/java/org/onap/so/client/graphinventory/Format.java
index c3cb4b9eaf..078b35aaf4 100644
--- a/common/src/main/java/org/onap/so/client/graphinventory/Format.java
+++ b/common/src/main/java/org/onap/so/client/graphinventory/Format.java
@@ -29,7 +29,8 @@ public enum Format {
CONSOLE("console"),
PATHED("pathed"),
GRAPHSON("graphson"),
- ID("id");
+ ID("id"),
+ COUNT("count");
private final String name;
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryResourcesClient.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryResourcesClient.java
index 2a76dab107..c7cdb2ff58 100644
--- a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryResourcesClient.java
+++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryResourcesClient.java
@@ -32,9 +32,7 @@ import org.onap.so.client.RestClient;
import org.onap.so.client.RestProperties;
import org.onap.so.client.graphinventory.entities.GraphInventoryEdgeLabel;
import org.onap.so.client.graphinventory.entities.GraphInventoryResultWrapper;
-import org.onap.so.client.graphinventory.entities.uri.Depth;
import org.onap.so.client.graphinventory.entities.uri.GraphInventoryResourceUri;
-import org.onap.so.client.graphinventory.entities.uri.GraphInventoryUri;
public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInventoryResourceUri, EdgeLabel extends GraphInventoryEdgeLabel, Wrapper extends GraphInventoryResultWrapper, TransactionalClient, SingleTransactionClient> {
@@ -74,7 +72,9 @@ public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInven
* @return
*/
public boolean exists(Uri uri) {
- GraphInventoryUri forceMinimal = this.addParams(Optional.of(Depth.ZERO), true, uri);
+ GraphInventoryResourceUri forceMinimal = uri.clone();
+ forceMinimal.format(Format.COUNT);
+ forceMinimal.limit(1);
try {
RestClient giRC = client.createClient(forceMinimal);
@@ -314,18 +314,6 @@ public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInven
*/
public abstract SingleTransactionClient beginSingleTransaction();
- private GraphInventoryUri addParams(Optional<Depth> depth, boolean nodesOnly, GraphInventoryUri uri) {
- GraphInventoryUri clone = uri.clone();
- if (depth.isPresent()) {
- clone.depth(depth.get());
- }
- if (nodesOnly) {
- clone.nodesOnly(nodesOnly);
- }
-
- return clone;
- }
-
public <T extends RestProperties> T getRestProperties() {
return client.getRestProperties();
}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryUri.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryUri.java
index d6d3e5eaa2..6b48ad44ef 100644
--- a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryUri.java
+++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryUri.java
@@ -22,7 +22,6 @@ package org.onap.so.client.graphinventory.entities.uri;
import java.net.URI;
import java.util.Map;
-import org.onap.so.client.graphinventory.entities.uri.Depth;
import org.onap.so.client.graphinventory.GraphInventoryObjectType;
public interface GraphInventoryUri {