summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java2
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java85
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java43
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.8.1__AddColumnAdminProjectDomainName.sql3
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java26
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java37
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java27
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/PollServiceTest.java16
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/prepare/PrepareSdncUpgradePreCheckPnfBBTest.java88
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java102
-rw-r--r--graph-inventory/aai-client/pom.xml2
-rw-r--r--graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java22
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java35
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java23
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceRepository.java3
15 files changed, 425 insertions, 89 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java
index ab0239057a..c1c7ed5fd6 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java
@@ -100,7 +100,7 @@ public final class AuthenticationMethodFactory {
Project project = new Project();
Project.Domain projectDomain = new Project.Domain();
userDomain.setName(cloudIdentity.getUserDomainName());
- projectDomain.setName(cloudIdentity.getProjectDomainName());
+ projectDomain.setName(cloudIdentity.getAdminProjectDomainName());
user.setName(cloudIdentity.getMsoId());
user.setPassword(CryptoUtils.decryptCloudConfigPassword(cloudIdentity.getMsoPass()));
user.setDomain(userDomain);
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 c4ef3678c3..ba4b30903d 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
@@ -31,9 +31,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import static org.apache.commons.lang3.StringUtils.isBlank;
+import static org.apache.commons.lang3.StringUtils.isNotBlank;
import org.onap.logging.filter.base.ErrorCode;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.adapters.vdu.CloudInfo;
@@ -49,6 +50,11 @@ import org.onap.so.adapters.vdu.VduStatus;
import org.onap.so.cloud.authentication.KeystoneAuthHolder;
import org.onap.so.db.catalog.beans.HeatTemplate;
import org.onap.so.db.catalog.beans.HeatTemplateParam;
+import org.onap.so.db.catalog.beans.NetworkResource;
+import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
+import org.onap.so.db.catalog.beans.VfModule;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.db.request.beans.CloudApiRequests;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.client.RequestsDbClient;
@@ -108,6 +114,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
public static final String EXCEPTION_ROLLING_BACK_STACK =
"{} Create Stack: Nested exception rolling back stack: {} ";
public static final String IN_PROGRESS = "in_progress";
+ private static final int DEFAULT_POLLING_TIMEOUT = 118;
@Autowired
private Environment environment;
@@ -121,6 +128,9 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
@Autowired
RequestsDbClient requestDBClient;
+ @Autowired
+ private CatalogDbClient catalogClient;
+
private static final Logger logger = LoggerFactory.getLogger(MsoHeatUtils.class);
// Properties names and variables (with default values)
@@ -898,11 +908,6 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
if (inputs == null) {
return new HashMap<>();
}
- try {
- Set<HeatTemplateParam> paramSet = template.getParameters();
- } catch (Exception e) {
- logger.debug("Exception occurred in convertInputMap {} :", e.getMessage(), e);
- }
for (HeatTemplateParam htp : template.getParameters()) {
params.put(htp.getParamName(), htp);
@@ -1232,4 +1237,72 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
}
}
+ public int getVfHeatTimeoutValue(String modelCustomizationUuid, boolean isVolumeGroup) {
+ int timeoutMinutes = DEFAULT_POLLING_TIMEOUT;
+ try {
+ VfModuleCustomization vfmc = null;
+ if (modelCustomizationUuid != null) {
+ vfmc = catalogClient.getVfModuleCustomizationByModelCuztomizationUUID(modelCustomizationUuid);
+ if (vfmc != null) {
+ VfModule vf = vfmc.getVfModule();
+ if (vf != null) {
+ HeatTemplate heat = vf.getModuleHeatTemplate();
+ if (isVolumeGroup) {
+ heat = vf.getVolumeHeatTemplate();
+ }
+ if (heat != null && heat.getTimeoutMinutes() != null) {
+ if (heat.getTimeoutMinutes() < DEFAULT_POLLING_TIMEOUT) {
+ timeoutMinutes = heat.getTimeoutMinutes();
+ }
+ }
+ }
+ } else {
+ logger.debug(
+ "Unable to find Vf Module Customization with model customization uuid {}. Using default timeout {}",
+ modelCustomizationUuid, timeoutMinutes);
+ }
+ }
+ } catch (Exception e) {
+ logger.warn("Exception occured while getting heat timeout value. Using default timeout {}", timeoutMinutes,
+ e);
+ }
+ return timeoutMinutes;
+ }
+
+ public int getNetworkHeatTimeoutValue(String modelCustomizationUuid, String networkType) {
+ int timeoutMinutes = DEFAULT_POLLING_TIMEOUT;
+ try {
+ NetworkResource networkResource = null;
+ if (isBlank(modelCustomizationUuid)) {
+ if (isNotBlank(networkType)) {
+ networkResource = catalogClient.getNetworkResourceByModelName(networkType);
+ }
+ } else {
+ NetworkResourceCustomization nrc =
+ catalogClient.getNetworkResourceCustomizationByModelCustomizationUUID(modelCustomizationUuid);
+ if (nrc != null) {
+ networkResource = nrc.getNetworkResource();
+ }
+ }
+
+ if (networkResource != null) {
+ networkResource.getHeatTemplate().getTimeoutMinutes();
+ HeatTemplate heat = networkResource.getHeatTemplate();
+ if (heat != null && heat.getTimeoutMinutes() != null) {
+ if (heat.getTimeoutMinutes() < DEFAULT_POLLING_TIMEOUT) {
+ timeoutMinutes = heat.getTimeoutMinutes();
+ }
+ }
+ } else {
+ logger.debug(
+ "Unable to find Network Resource with model customization uuid {} or network type {}. Using default timeout {}",
+ modelCustomizationUuid, networkType, timeoutMinutes);
+ }
+ } catch (Exception e) {
+ logger.warn("Exception occured while getting heat timeout value. Using default timeout {}", timeoutMinutes,
+ e);
+ }
+ return timeoutMinutes;
+ }
+
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
index 5bd7c29313..f20f6f1448 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
@@ -46,6 +46,12 @@ import org.mockito.Mockito;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.db.catalog.beans.HeatTemplate;
+import org.onap.so.db.catalog.beans.NetworkResource;
+import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
+import org.onap.so.db.catalog.beans.VfModule;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.db.request.beans.CloudApiRequests;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.client.RequestsDbClient;
@@ -103,6 +109,9 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
@Mock
private CreateStack mockCreateStack;
+ @Mock
+ private CatalogDbClient catalogDbClient;
+
private String cloudSiteId = "cloudSiteId";
private String tenantId = "tenantId";
@@ -564,4 +573,38 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
Mockito.verify(heatUtils, times(0)).handleUnknownCreateStackFailure(stack, 120, cloudSiteId, tenantId);
}
+ @Test
+ public void testGetVfHeatTimeoutValue() {
+
+ VfModuleCustomization vfmc = new VfModuleCustomization();
+ VfModule vf = new VfModule();
+ HeatTemplate heat = new HeatTemplate();
+ heat.setTimeoutMinutes(110);
+ vf.setModuleHeatTemplate(heat);
+ vfmc.setVfModule(vf);
+
+ Mockito.when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("uuid")).thenReturn(vfmc);
+
+ int timeout = heatUtils.getVfHeatTimeoutValue("uuid", false);
+ assertEquals(110, timeout);
+ Mockito.verify(catalogDbClient, times(1)).getVfModuleCustomizationByModelCuztomizationUUID("uuid");
+ }
+
+ @Test
+ public void testGetNetworkHeatTimeoutValue() {
+
+ NetworkResourceCustomization mc = new NetworkResourceCustomization();
+ NetworkResource nr = new NetworkResource();
+ HeatTemplate heat = new HeatTemplate();
+ heat.setTimeoutMinutes(110);
+ nr.setHeatTemplate(heat);
+ mc.setNetworkResource(nr);
+
+ Mockito.when(catalogDbClient.getNetworkResourceCustomizationByModelCustomizationUUID("uuid")).thenReturn(mc);
+
+ int timeout = heatUtils.getNetworkHeatTimeoutValue("uuid", "type");
+ assertEquals(110, timeout);
+ Mockito.verify(catalogDbClient, times(1)).getNetworkResourceCustomizationByModelCustomizationUUID("uuid");
+ }
+
}
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.8.1__AddColumnAdminProjectDomainName.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.8.1__AddColumnAdminProjectDomainName.sql
new file mode 100644
index 0000000000..a883466515
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.8.1__AddColumnAdminProjectDomainName.sql
@@ -0,0 +1,3 @@
+use catalogdb;
+
+ALTER TABLE identity_services ADD COLUMN ADMIN_PROJECT_DOMAIN_NAME varchar(255) DEFAULT 'Default'; \ No newline at end of file
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java
index 489585c04b..9123ac9f36 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java
@@ -962,31 +962,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
pollForCompletion = true;
}
- // Retrieve the Network Resource definition
- NetworkResource networkResource = null;
- if (commonUtils.isNullOrEmpty(modelCustomizationUuid)) {
- if (!commonUtils.isNullOrEmpty(networkType)) {
- networkResource = networkResourceRepo.findFirstByModelNameOrderByModelVersionDesc(networkType);
- }
- } else {
- NetworkResourceCustomization nrc =
- networkCustomRepo.findOneByModelCustomizationUUID(modelCustomizationUuid);
- if (nrc != null) {
- networkResource = nrc.getNetworkResource();
- }
- }
-
- int timeoutMinutes = 118;
- if (networkResource != null) {
- logger.debug(LOG_DEBUG_MSG, networkResource.toString());
- networkResource.getHeatTemplate().getTimeoutMinutes();
- HeatTemplate heat = networkResource.getHeatTemplate();
- if (heat != null && heat.getTimeoutMinutes() != null) {
- if (heat.getTimeoutMinutes() < 118) {
- timeoutMinutes = heat.getTimeoutMinutes();
- }
- }
- }
+ int timeoutMinutes = heat.getNetworkHeatTimeoutValue(modelCustomizationUuid, networkType);
try {
StackInfo stack =
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java
index c319fdc23c..ddbda5da62 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java
@@ -90,7 +90,9 @@ public class PollService extends ExternalTaskUtils {
JAXB.unmarshal(new StringReader(xmlRequest), DeleteVfModuleRequest.class);
boolean isMulticloud = vnfAdapterUtils.isMulticloudMode(null, req.getCloudSiteId());
if (!isMulticloud) {
- pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+ int timeoutMinutes = msoHeatUtils.getVfHeatTimeoutValue(req.getModelCustomizationUuid(), false);
+ pollDeleteResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), externalTask,
+ success);
} else {
success.setTrue();
}
@@ -100,7 +102,7 @@ public class PollService extends ExternalTaskUtils {
JAXB.unmarshal(new StringReader(xmlRequest), DeleteVolumeGroupRequest.class);
boolean isMulticloud = vnfAdapterUtils.isMulticloudMode(null, req.getCloudSiteId());
if (!isMulticloud) {
- pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+ pollDeleteResource(118, req.getCloudSiteId(), req.getTenantId(), externalTask, success);
} else {
success.setTrue();
}
@@ -109,7 +111,7 @@ public class PollService extends ExternalTaskUtils {
} else if ("deleteNetworkRequest".equals(requestType.get())) {
logger.debug("Executing External Task Poll Service for Delete Network");
DeleteNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), DeleteNetworkRequest.class);
- pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+ pollDeleteResource(118, req.getCloudSiteId(), req.getTenantId(), externalTask, success);
} else if ("updateNetworkRequest".equals(requestType.get())) {
UpdateNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), UpdateNetworkRequest.class);
pollUpdateResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
@@ -152,9 +154,10 @@ public class PollService extends ExternalTaskUtils {
boolean pollRollbackStatus = externalTask.getVariable("PollRollbackStatus");
if (pollRollbackStatus) {
logger.debug("Executing External Task Poll Service for Rollback Create Volume Group");
- pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+ pollDeleteResource(118, req.getCloudSiteId(), req.getTenantId(), externalTask, success);
} else {
- pollCreateResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+ int timeoutMinutes = msoHeatUtils.getVfHeatTimeoutValue(req.getModelCustomizationUuid(), true);
+ pollCreateResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), externalTask, success);
}
} else {
success.setTrue();
@@ -167,12 +170,13 @@ public class PollService extends ExternalTaskUtils {
boolean isMulticloud = vnfAdapterUtils.isMulticloudMode(null, req.getCloudSiteId());
if (!isMulticloud) {
boolean pollRollbackStatus = externalTask.getVariable("PollRollbackStatus");
+ int timeoutMinutes = msoHeatUtils.getVfHeatTimeoutValue(req.getModelCustomizationUuid(), false);
if (pollRollbackStatus) {
logger.debug("Executing External Task Poll Service for Rollback Create Vf Module");
- pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+ pollDeleteResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), externalTask, success);
} else {
logger.debug("Executing External Task Poll Service for Create Vf Module");
- pollCreateResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+ pollCreateResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), externalTask, success);
}
} else {
success.setTrue();
@@ -183,29 +187,31 @@ public class PollService extends ExternalTaskUtils {
throws MsoException {
CreateNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateNetworkRequest.class);
boolean pollRollbackStatus = externalTask.getVariable("PollRollbackStatus");
+ int timeoutMinutes =
+ msoHeatUtils.getNetworkHeatTimeoutValue(req.getModelCustomizationUuid(), req.getNetworkType());
if (pollRollbackStatus) {
logger.debug("Executing External Task Poll Service for Rollback Create Network");
- pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+ pollDeleteResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), externalTask, success);
} else {
logger.debug("Executing External Task Poll Service for Create Network");
- pollCreateResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+ pollCreateResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), externalTask, success);
}
}
- private void pollCreateResource(String cloudSiteId, String tenantId, ExternalTask externalTask,
+ private void pollCreateResource(int pollingTimeout, String cloudSiteId, String tenantId, ExternalTask externalTask,
MutableBoolean success) throws MsoException {
Stack currentStack = createCurrentStack(externalTask.getVariable("stackId"));
- Stack stack =
- msoHeatUtils.pollStackForStatus(1, currentStack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId, false);
+ Stack stack = msoHeatUtils.pollStackForStatus(pollingTimeout, currentStack, "CREATE_IN_PROGRESS", cloudSiteId,
+ tenantId, false);
msoHeatUtils.postProcessStackCreate(stack, false, 0, false, cloudSiteId, tenantId, null);
success.setTrue();
}
- private void pollDeleteResource(String cloudSiteId, String tenantId, ExternalTask externalTask,
+ private void pollDeleteResource(int pollingTimeout, String cloudSiteId, String tenantId, ExternalTask externalTask,
MutableBoolean success) throws MsoException {
Stack currentStack = createCurrentStack(externalTask.getVariable("stackId"));
- Stack stack =
- msoHeatUtils.pollStackForStatus(1, currentStack, "DELETE_IN_PROGRESS", cloudSiteId, tenantId, true);
+ Stack stack = msoHeatUtils.pollStackForStatus(pollingTimeout, currentStack, "DELETE_IN_PROGRESS", cloudSiteId,
+ tenantId, true);
if (stack != null) { // if stack is null it was not found and no need to do post process
msoHeatUtils.postProcessStackDelete(stack);
}
@@ -245,5 +251,4 @@ public class PollService extends ExternalTaskUtils {
currentStack.setStackName(stackName);
return currentStack;
}
-
}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java
index 26bce5f362..7acf953282 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java
@@ -158,6 +158,7 @@ public class MsoVnfAdapterImpl {
* @param outputs Holder for Map of VNF outputs from heat (assigned IPs, etc)
* @param rollback Holder for returning VnfRollback object
*/
+ @Deprecated
public void createVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfType, String vnfVersion,
String vnfName, String requestType, String volumeGroupHeatStackId, Map<String, Object> inputs,
Boolean failIfExists, Boolean backout, Boolean enableBridge, MsoRequest msoRequest, Holder<String> vnfId,
@@ -212,6 +213,7 @@ public class MsoVnfAdapterImpl {
* @param vnfName VNF Name or Openstack ID
* @param msoRequest Request tracking information for logs
*/
+ @Deprecated
public void deleteVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, MsoRequest msoRequest)
throws VnfException {
@@ -251,6 +253,7 @@ public class MsoVnfAdapterImpl {
* @param vnfName VNF Name or Openstack ID
* @param msoRequest Request tracking information for logs
*/
+ @Deprecated
public void deleteVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, MsoRequest msoRequest,
boolean pollStackStatus) throws VnfException {
@@ -988,29 +991,7 @@ public class MsoVnfAdapterImpl {
// call method which handles the conversion from Map<String,Object> to Map<String,String> for our expected
// Object types
outputs.value = this.convertMapStringObjectToStringString(stackOutputs);
- int timeoutMinutes = 118;
- VfModule vf = null;
- VfModuleCustomization vfmc = null;
- if (modelCustomizationUuid != null) {
- vfmc = vfModuleCustomRepo.findFirstByModelCustomizationUUIDOrderByCreatedDesc(modelCustomizationUuid);
- if (vfmc != null) {
- vf = vfmc.getVfModule();
- }
- if (vf != null) {
- logger.trace("Found vfModuleCust entry {}", vfmc.toString());
- HeatTemplate heat = vf.getModuleHeatTemplate();
- if (heat != null && heat.getTimeoutMinutes() != null) {
- if (heat.getTimeoutMinutes() < 118) {
- timeoutMinutes = heat.getTimeoutMinutes();
- }
- }
-
- } else {
- logger.debug(
- "Unable to find vfModuleCust with modelCustomizationUuid={} . Using default timeout for polling",
- modelCustomizationUuid);
- }
- }
+ int timeoutMinutes = msoHeatUtils.getVfHeatTimeoutValue(modelCustomizationUuid, false);
try {
StackInfo currentStack =
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/PollServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/PollServiceTest.java
index 60826705fd..0214fdd265 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/PollServiceTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/PollServiceTest.java
@@ -52,15 +52,17 @@ public class PollServiceTest {
Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(xmlString);
Mockito.when(mockExternalTask.getVariable("PollRollbackStatus")).thenReturn(false);
Mockito.when(mockExternalTask.getVariable("stackId")).thenReturn("stackId/stack123");
- Mockito.when(msoHeatUtils.pollStackForStatus(eq(1), any(Stack.class), eq("CREATE_IN_PROGRESS"), eq("regionOne"),
- eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(false))).thenReturn(new Stack());
+ Mockito.when(msoHeatUtils.pollStackForStatus(eq(118), any(Stack.class), eq("CREATE_IN_PROGRESS"),
+ eq("regionOne"), eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(false))).thenReturn(new Stack());
+ Mockito.when(msoHeatUtils.getVfHeatTimeoutValue(any(), eq(false))).thenReturn(118);
// Mockito.doNothing().when(msoHeatUtils).postProcessStackCreate(Mockito.any(), Mockito.any(), Mockito.any(),
// Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
pollService.executeExternalTask(mockExternalTask, mockExternalTaskService);
- Mockito.verify(msoHeatUtils).pollStackForStatus(eq(1), any(Stack.class), eq("CREATE_IN_PROGRESS"),
+ Mockito.verify(msoHeatUtils).pollStackForStatus(eq(118), any(Stack.class), eq("CREATE_IN_PROGRESS"),
eq("regionOne"), eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(false));
+ Mockito.verify(msoHeatUtils).getVfHeatTimeoutValue(any(), eq(false));
}
@@ -72,16 +74,16 @@ public class PollServiceTest {
Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(xmlString);
Mockito.when(mockExternalTask.getVariable("PollRollbackStatus")).thenReturn(true);
Mockito.when(mockExternalTask.getVariable("stackId")).thenReturn("stackId/stack123");
- Mockito.when(msoHeatUtils.pollStackForStatus(eq(1), any(), eq("DELETE_IN_PROGRESS"), eq("regionOne"),
+ Mockito.when(msoHeatUtils.pollStackForStatus(eq(118), any(), eq("DELETE_IN_PROGRESS"), eq("regionOne"),
eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(true))).thenReturn(new Stack());
Mockito.doNothing().when(msoHeatUtils).postProcessStackDelete(Mockito.any());
-
+ Mockito.when(msoHeatUtils.getVfHeatTimeoutValue(any(), eq(false))).thenReturn(118);
pollService.executeExternalTask(mockExternalTask, mockExternalTaskService);
- Mockito.verify(msoHeatUtils).pollStackForStatus(eq(1), any(), eq("DELETE_IN_PROGRESS"), eq("regionOne"),
+ Mockito.verify(msoHeatUtils).pollStackForStatus(eq(118), any(), eq("DELETE_IN_PROGRESS"), eq("regionOne"),
eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(true));
-
+ Mockito.verify(msoHeatUtils).getVfHeatTimeoutValue(any(), eq(false));
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/prepare/PrepareSdncUpgradePreCheckPnfBBTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/prepare/PrepareSdncUpgradePreCheckPnfBBTest.java
new file mode 100644
index 0000000000..0ba1e27f5e
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/prepare/PrepareSdncUpgradePreCheckPnfBBTest.java
@@ -0,0 +1,88 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nokia
+ * ================================================================================
+ * 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.bpmn.infrastructure.decisionpoint.impl.buildingblock.controller.sdnc.prepare;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.DelegateExecutionImpl;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+
+public class PrepareSdncUpgradePreCheckPnfBBTest {
+
+ private PrepareSdncUpgradePreCheckPnfBB testedObject;
+
+ @Before
+ public void setup() {
+ testedObject = new PrepareSdncUpgradePreCheckPnfBB();
+ }
+
+ @Test
+ public void understandTrue() {
+ ControllerContext<BuildingBlockExecution> controllerContext =
+ createControllerContext("sdnc", "UpgradePreCheck", "pnf");
+ boolean result = testedObject.understand(controllerContext);
+ assertThat(result).isTrue();
+ }
+
+ @Test
+ public void understandFalse() {
+ ControllerContext<BuildingBlockExecution> controllerContext =
+ createControllerContext("actor1", "action1", "scope1");
+ boolean result = testedObject.understand(controllerContext);
+ assertThat(result).isFalse();
+ }
+
+ @Test
+ public void prepare_jsonWithoutActionPayload() {
+ String payloadWithoutActionArray = "{\"json name\": \"test1\"}";
+ ControllerContext<BuildingBlockExecution> controllerContext =
+ createControllerContext(payloadWithoutActionArray);
+ testedObject.prepare(controllerContext);
+
+ assertThat((String) controllerContext.getExecution().getVariable("payload"))
+ .isEqualTo(payloadWithoutActionArray);
+ }
+
+ private ControllerContext<BuildingBlockExecution> createControllerContext(String actor, String action,
+ String scope) {
+ ControllerContext<BuildingBlockExecution> controllerContext = new ControllerContext<>();
+ controllerContext.setControllerActor(actor);
+ controllerContext.setControllerAction(action);
+ controllerContext.setControllerScope(scope);
+ return controllerContext;
+ }
+
+ private ControllerContext<BuildingBlockExecution> createControllerContext(String payload) {
+ ControllerContext<BuildingBlockExecution> controllerContext = new ControllerContext<>();
+ controllerContext.setExecution(prepareBuildingBlockExecution(payload));
+ return controllerContext;
+ }
+
+ private BuildingBlockExecution prepareBuildingBlockExecution(String payload) {
+ DelegateExecution execution = new DelegateExecutionFake();
+ execution.setVariable("payload", payload);
+ return new DelegateExecutionImpl(execution);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java
new file mode 100644
index 0000000000..35a5bfefd7
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java
@@ -0,0 +1,102 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.workflow.tasks;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.aai.domain.yang.VpnBinding;
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
+import org.onap.aaiclient.client.aai.entities.Relationships;
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAISimpleUri;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
+import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
+
+@RunWith(MockitoJUnitRunner.class)
+public class WorkflowActionExtractResourcesAAITest {
+
+ private static final String CONFIGURATION_ID = "configTestId";
+ private static final String VPN_ID = "vpnTestId";
+
+ @Mock
+ private BBInputSetupUtils bbInputSetupUtils;
+ @InjectMocks
+ private WorkflowActionExtractResourcesAAI testedObject;
+
+ @Test
+ public void extractRelationshipsConfigurationSuccess() {
+ // given
+ Relationships relationships = mock(Relationships.class);
+ when(relationships.getByType(Types.CONFIGURATION)).thenReturn(getConfigurationList());
+ // when
+ Optional<Configuration> resultOpt = testedObject.extractRelationshipsConfiguration(relationships);
+ // then
+ assertThat(resultOpt).isNotEmpty();
+ assertThat(resultOpt.get().getConfigurationId()).isEqualTo(CONFIGURATION_ID);
+ }
+
+ @Test
+ public void extractRelationshipsConfiguration_notFound() {
+ // given
+ Relationships relationships = mock(Relationships.class);
+ when(relationships.getByType(Types.CONFIGURATION)).thenReturn(Collections.emptyList());
+ // when
+ Optional<Configuration> resultOpt = testedObject.extractRelationshipsConfiguration(relationships);
+ // then
+ assertThat(resultOpt).isEmpty();
+ }
+
+ @Test
+ public void extractRelationshipsVpnBindingSuccess() {
+ // given
+ Relationships relationships = mock(Relationships.class);
+ AAIResourceUri aaiResourceUri = mock(AAISimpleUri.class);
+ List<AAIResourceUri> aaiResourceUriList = new ArrayList<>();
+ aaiResourceUriList.add(aaiResourceUri);
+ when(relationships.getRelatedUris(Types.VPN_BINDING)).thenReturn(aaiResourceUriList);
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper("{\"vpn-id\" : \"" + VPN_ID + "\"}");
+ when(bbInputSetupUtils.getAAIResourceDepthOne(aaiResourceUri)).thenReturn(aaiResultWrapper);
+ // when
+ Optional<VpnBinding> resultOpt = testedObject.extractRelationshipsVpnBinding(relationships);
+ // then
+ assertThat(resultOpt).isNotEmpty();
+ assertThat(resultOpt.get().getVpnId()).isEqualTo(VPN_ID);
+ }
+
+ private List<AAIResultWrapper> getConfigurationList() {
+ List<AAIResultWrapper> configurations = new ArrayList<>();
+ AAIResultWrapper aaiResultWrapper =
+ new AAIResultWrapper("{\"configuration-id\" : \"" + CONFIGURATION_ID + "\"}");
+ configurations.add(aaiResultWrapper);
+ return configurations;
+ }
+}
diff --git a/graph-inventory/aai-client/pom.xml b/graph-inventory/aai-client/pom.xml
index d1c9742cea..d532103c40 100644
--- a/graph-inventory/aai-client/pom.xml
+++ b/graph-inventory/aai-client/pom.xml
@@ -93,7 +93,7 @@
<destination>${project.build.directory}/generated-sources</destination>
<destinationClasspath>org.onap.aaiclient.client.generated.fluentbuilders</destinationClasspath>
<builderName>AAIFluentTypeBuilder</builderName>
- <swaggerLocation>${project.build.directory}/swagger/onap/aai_swagger_yaml/aai_swagger_v21.yaml</swaggerLocation>
+ <swaggerLocation>${project.build.directory}/swagger/onap/aai_swagger_yaml/aai_swagger_LATEST.yaml</swaggerLocation>
<singularBuilderClass>org.onap.aaiclient.client.aai.entities.uri.AAIFluentSingleType</singularBuilderClass>
<pluralBuilderClass>org.onap.aaiclient.client.aai.entities.uri.AAIFluentPluralType</pluralBuilderClass>
<topLevelBuilderClass>org.onap.aaiclient.client.aai.entities.uri.AAIFluentTopLevelType</topLevelBuilderClass>
diff --git a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java
index ec09af8a4e..fc42d9ca0d 100644
--- a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java
+++ b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java
@@ -1,6 +1,10 @@
package org.onap.graphinventory.generate;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -26,6 +30,9 @@ public class SwaggerConverter {
}
public Map<String, ObjectType> getDoc(String swaggerLocation) throws JsonProcessingException {
+
+
+ swaggerLocation = processLocation(swaggerLocation);
Swagger swagger = new SwaggerParser().read(swaggerLocation);
Map<String, Path> paths = swagger.getPaths().entrySet().stream()
@@ -168,4 +175,19 @@ public class SwaggerConverter {
return output;
}
+
+ private String processLocation(String swaggerLocation) {
+
+ java.nio.file.Path path = Paths.get(swaggerLocation);
+ try {
+ return Files.list(path.getParent())
+ .filter(it -> it.getFileName().toString()
+ .matches(path.getFileName().toString().replaceFirst("LATEST", "v\\\\\\d+")))
+ .sorted(Comparator.reverseOrder()).map(it -> it.toString()).findFirst().orElseGet(null);
+ } catch (IOException e) {
+ log.error(e);
+ }
+
+ return null;
+ }
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java
index 61b0b11445..63ee35cd9c 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java
@@ -20,13 +20,7 @@
package org.onap.so.db.catalog.beans;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.openpojo.business.annotation.BusinessKey;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
import java.util.Date;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
@@ -36,6 +30,12 @@ import javax.persistence.PrePersist;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.openpojo.business.annotation.BusinessKey;
import uk.co.blackpepper.bowman.annotation.RemoteResource;
/**
@@ -74,6 +74,11 @@ public class CloudIdentity {
@Column(name = "PROJECT_DOMAIN_NAME")
private String projectDomainName;
+ @JsonProperty("admin_project_domain_name ")
+ @BusinessKey
+ @Column(name = "ADMIN_PROJECT_DOMAIN_NAME")
+ private String adminProjectDomainName;
+
@JsonProperty("user_domain_name")
@BusinessKey
@Column(name = "USER_DOMAIN_NAME")
@@ -245,6 +250,14 @@ public class CloudIdentity {
this.projectDomainName = projectDomainName;
}
+ public String getAdminProjectDomainName() {
+ return adminProjectDomainName;
+ }
+
+ public void setAdminProjectDomainName(String adminProjectDomainName) {
+ this.adminProjectDomainName = adminProjectDomainName;
+ }
+
public String getUserDomainName() {
return userDomainName;
}
@@ -267,6 +280,7 @@ public class CloudIdentity {
cloudIdentityCopy.identityServerType = this.identityServerType;
cloudIdentityCopy.identityAuthenticationType = this.identityAuthenticationType;
cloudIdentityCopy.projectDomainName = this.projectDomainName;
+ cloudIdentityCopy.adminProjectDomainName = this.adminProjectDomainName;
cloudIdentityCopy.userDomainName = this.userDomainName;
return cloudIdentityCopy;
@@ -279,7 +293,8 @@ public class CloudIdentity {
.append("projectDomain", getProjectDomainName()).append("userDomain", getUserDomainName())
.append("adminTenant", getAdminTenant()).append("memberRole", getMemberRole())
.append("tenantMetadata", getTenantMetadata()).append("identityServerType", getIdentityServerType())
- .append("identityAuthenticationType", getIdentityAuthenticationType()).toString();
+ .append("identityAuthenticationType", getIdentityAuthenticationType())
+ .append("adminProjectDomainName", getAdminProjectDomainName()).toString();
}
@Override
@@ -299,7 +314,8 @@ public class CloudIdentity {
.append(getMemberRole(), castOther.getMemberRole())
.append(getTenantMetadata(), castOther.getTenantMetadata())
.append(getIdentityServerType(), castOther.getIdentityServerType())
- .append(getIdentityAuthenticationType(), castOther.getIdentityAuthenticationType()).isEquals();
+ .append(getIdentityAuthenticationType(), castOther.getIdentityAuthenticationType())
+ .append(getAdminProjectDomainName(), castOther.getAdminProjectDomainName()).isEquals();
}
@Override
@@ -307,6 +323,7 @@ public class CloudIdentity {
return new HashCodeBuilder(1, 31).append(getId()).append(getIdentityUrl()).append(getMsoId())
.append(getMsoPass()).append(getProjectDomainName()).append(getUserDomainName())
.append(getAdminTenant()).append(getMemberRole()).append(getTenantMetadata())
- .append(getIdentityServerType()).append(getIdentityAuthenticationType()).toHashCode();
+ .append(getIdentityServerType()).append(getIdentityAuthenticationType())
+ .append(getAdminProjectDomainName()).toHashCode();
}
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
index ef90dd6984..91cfb00911 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
@@ -47,6 +47,7 @@ import org.onap.so.db.catalog.beans.HomingInstance;
import org.onap.so.db.catalog.beans.InstanceGroup;
import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
import org.onap.so.db.catalog.beans.NetworkRecipe;
+import org.onap.so.db.catalog.beans.NetworkResource;
import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
import org.onap.so.db.catalog.beans.OrchestrationAction;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
@@ -98,6 +99,7 @@ public class CatalogDbClient {
private static final String RAINY_DAY_HANDLER_MACRO = "/rainy_day_handler_macro";
private static final String NORTHBOUND_REQUEST_REF_LOOKUP = "/northbound_request_ref_lookup";
private static final String NETWORK_RESOURCE_CUSTOMIZATION = "/networkResourceCustomization";
+ private static final String NETWORK_RESOURCE = "/networkResource";
private static final String COLLECTION_RESOURCE_INSTANCE_GROUP_CUSTOMIZATION =
"/collectionResourceInstanceGroupCustomization";
private static final String VNFC_INSTANCE_GROUP_CUSTOMIZATION = "/vnfcInstanceGroupCustomization";
@@ -223,6 +225,7 @@ public class CatalogDbClient {
private String vnfResourceURI;
private String networkCollectionResourceCustomizationURI;
private String networkResourceCustomizationURI;
+ private String networkResourceURI;
private String collectionNetworkResourceCustomizationURI;
private String instanceGroupURI;
private String cloudifyManagerURI;
@@ -375,6 +378,7 @@ public class CatalogDbClient {
networkCollectionResourceCustomizationURI =
endpoint + NETWORK_COLLECTION_RESOURCE_CUSTOMIZATION + URI_SEPARATOR;
networkResourceCustomizationURI = endpoint + NETWORK_RESOURCE_CUSTOMIZATION + URI_SEPARATOR;
+ networkResourceURI = endpoint + NETWORK_RESOURCE + SEARCH;
collectionNetworkResourceCustomizationURI =
endpoint + COLLECTION_NETWORK_RESOURCE_CUSTOMIZATION + URI_SEPARATOR;
instanceGroupURI = endpoint + INSTANCE_GROUP + URI_SEPARATOR;
@@ -607,6 +611,25 @@ public class CatalogDbClient {
return networkResourceCustomization;
}
+ public NetworkResource getNetworkResourceByModelName(String networkType) {
+ if (Strings.isNullOrEmpty(networkType)) {
+ throw new EntityNotFoundException("networkType passed as Null or Empty String");
+ }
+ try {
+ HttpEntity<?> entity = getHttpEntity();
+ return restTemplate.exchange(
+ UriBuilder.fromUri(networkResourceURI + "/findFirstByModelNameOrderByModelVersionDesc")
+ .queryParam("modelName", networkType).build(),
+ HttpMethod.GET, entity, NetworkResource.class).getBody();
+ } catch (HttpClientErrorException e) {
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ throw new EntityNotFoundException("Unable to find NetworkResource By networkType " + networkType);
+ }
+ throw e;
+ }
+ }
+
+
public BuildingBlockDetail getBuildingBlockDetail(String buildingBlockName) {
BuildingBlockDetail buildingBlockDetail =
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceRepository.java
index 42d107c1ff..30f3df7110 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceRepository.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceRepository.java
@@ -23,6 +23,7 @@ package org.onap.so.db.catalog.data.repository;
import org.onap.so.db.catalog.beans.NetworkResource;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.stereotype.Repository;
@@ -38,7 +39,7 @@ public interface NetworkResourceRepository extends JpaRepository<NetworkResource
*/
@Query(value = "SELECT * FROM network_resource WHERE MODEL_NAME = ?1 ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(MODEL_VERSION,'.0.0.0'),'.',4)) DESC LIMIT 1;",
nativeQuery = true)
- NetworkResource findFirstByModelNameOrderByModelVersionDesc(String modelName);
+ NetworkResource findFirstByModelNameOrderByModelVersionDesc(@Param("modelName") String modelName);
NetworkResource findResourceByModelUUID(String modelUUID);