summaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-adapter-utils')
-rw-r--r--adapters/mso-adapter-utils/pom.xml5
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java4
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java16
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyWorkflowException.java4
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java4
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java90
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java18
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java14
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java6
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java6
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoYamlEditorWithEnvt.java9
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java2
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java2
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java2
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java2
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java2
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java2
17 files changed, 110 insertions, 78 deletions
diff --git a/adapters/mso-adapter-utils/pom.xml b/adapters/mso-adapter-utils/pom.xml
index 7918072323..aa9a1cea9e 100644
--- a/adapters/mso-adapter-utils/pom.xml
+++ b/adapters/mso-adapter-utils/pom.xml
@@ -147,5 +147,10 @@
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.so</groupId>
+ <artifactId>mso-requests-db</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</project>
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java
index f717144562..35c928c3b5 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java
@@ -72,9 +72,7 @@ public class KeystoneV3Authentication {
OpenStackRequest<Token> v3Request = keystoneTenantClient.tokens().authenticate(v3Credentials);
- KeystoneAuthHolder holder = makeRequest(v3Request, type, region);
-
- return holder;
+ return makeRequest(v3Request, type, region);
}
protected KeystoneAuthHolder makeRequest(OpenStackRequest<Token> v3Request, String type, String region) {
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java
index 02ace5665d..072bf404e7 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java
@@ -72,22 +72,22 @@ public final class DeploymentInfoBuilder {
this.errorMessage = execution.getError();
// Compute the status based on the last workflow
- if (lastAction.equals("install")) {
- if (actionStatus.equals("terminated")) {
+ if (("install").equals(lastAction)) {
+ if (("terminated").equals(actionStatus)) {
this.deploymentStatus = DeploymentStatus.INSTALLED;
- } else if (actionStatus.equals("failed")) {
+ } else if (("failed").equals(actionStatus)) {
this.deploymentStatus = DeploymentStatus.FAILED;
- } else if (actionStatus.equals("started") || actionStatus.equals("pending")) {
+ } else if (("started").equals(actionStatus) || ("pending").equals(actionStatus)) {
this.deploymentStatus = DeploymentStatus.INSTALLING;
} else {
this.deploymentStatus = DeploymentStatus.UNKNOWN;
}
- } else if (lastAction.equals("uninstall")) {
- if (actionStatus.equals("terminated")) {
+ } else if (("uninstall").equals(lastAction)) {
+ if (("terminated").equals(actionStatus)) {
this.deploymentStatus = DeploymentStatus.CREATED;
- } else if (actionStatus.equals("failed")) {
+ } else if (("failed").equals(actionStatus)) {
this.deploymentStatus = DeploymentStatus.FAILED;
- } else if (actionStatus.equals("started") || actionStatus.equals("pending")) {
+ } else if (("started").equals(actionStatus) || ("pending").equals(actionStatus)) {
this.deploymentStatus = DeploymentStatus.UNINSTALLING;
} else {
this.deploymentStatus = DeploymentStatus.UNKNOWN;
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyWorkflowException.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyWorkflowException.java
index 5c2348dffa..2251575671 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyWorkflowException.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/exceptions/MsoCloudifyWorkflowException.java
@@ -38,8 +38,8 @@ public class MsoCloudifyWorkflowException extends MsoCloudifyException {
super(0, "Workflow Exception",
"Workflow " + workflowId + " failed on deployment " + deploymentId + ": " + message);
this.workflowStatus = workflowStatus;
- if (workflowStatus.equals("pending") || workflowStatus.equals("started") || workflowStatus.equals("cancelling")
- || workflowStatus.equals("force_cancelling")) {
+ if (("pending").equals(workflowStatus) || ("started").equals(workflowStatus)
+ || ("cancelling").equals(workflowStatus) || ("force_cancelling").equals(workflowStatus)) {
workflowStillRunning = true;
}
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java
index a21db78cee..723bed17f7 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java
@@ -70,7 +70,7 @@ public class MsoHeatEnvironmentEntry {
logger.debug("Exception:", e);
this.valid = false;
this.errorString = e.getMessage();
- // e.printStackTrace();
+
}
}
@@ -173,7 +173,7 @@ public class MsoHeatEnvironmentEntry {
// Basically give back the envt - but exclude the params that aren't in the HeatTemplate
StringBuilder sb = new StringBuilder();
- ArrayList<String> paramNameList = new ArrayList<String>(params.size());
+ ArrayList<String> paramNameList = new ArrayList<>(params.size());
for (HeatTemplateParam htp : params) {
paramNameList.add(htp.getParamName());
}
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 b54301509f..8093f045eb 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
@@ -23,6 +23,7 @@
package org.onap.so.openstack.utils;
+import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.woorea.openstack.base.client.OpenStackConnectException;
@@ -47,6 +48,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.adapters.vdu.CloudInfo;
import org.onap.so.adapters.vdu.PluginAction;
import org.onap.so.adapters.vdu.VduArtifact;
@@ -67,6 +69,9 @@ import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.db.catalog.beans.HeatTemplate;
import org.onap.so.db.catalog.beans.HeatTemplateParam;
import org.onap.so.db.catalog.beans.ServerType;
+import org.onap.so.db.request.beans.CloudApiRequests;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.logger.ErrorCode;
import org.onap.so.logger.MessageEnum;
import org.onap.so.openstack.beans.HeatStatus;
@@ -82,6 +87,7 @@ import org.onap.so.openstack.mappers.StackInfoMapper;
import org.onap.so.utils.CryptoUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.core.env.Environment;
@@ -100,6 +106,10 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
protected static final String HEAT_ERROR = "HeatError";
protected static final String CREATE_STACK = "CreateStack";
+ public static final String FOUND = "Found: {}";
+ public static final String EXCEPTION_ROLLING_BACK_STACK =
+ "{} Create Stack: Nested exception rolling back stack: {} ";
+ public static final String IN_PROGRESS = "in_progress";
// Fetch cloud configuration each time (may be cached in CloudConfig class)
@Autowired
@@ -117,6 +127,9 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
@Autowired
private KeystoneV3Authentication keystoneV3Authentication;
+ @Autowired
+ RequestsDbClient requestDBClient;
+
private static final Logger logger = LoggerFactory.getLogger(MsoHeatUtils.class);
// Properties names and variables (with default values)
@@ -124,8 +137,8 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
private String deletePollIntervalProp = "org.onap.so.adapters.po.pollInterval";
private String deletePollTimeoutProp = "org.onap.so.adapters.po.pollTimeout";
- protected static final String createPollIntervalDefault = "15";
- private static final String deletePollIntervalDefault = "15";
+ protected static final String CREATE_POLL_INTERVAL_DEFAULT = "15";
+ private static final String DELETE_POLL_INTERVAL_DEFAULT = "15";
private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
@@ -226,17 +239,18 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
// Obtain the cloud site information where we will create the stack
CloudSite cloudSite =
cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId));
- logger.debug("Found: {}", cloudSite);
+ logger.debug(FOUND, cloudSite);
// Get a Heat client. They are cached between calls (keyed by tenantId:cloudId)
// This could throw MsoTenantNotFound or MsoOpenstackException (both propagated)
Heat heatClient = getHeatClient(cloudSite, tenantId);
- logger.debug("Found: {}", heatClient);
+ logger.debug(FOUND, heatClient);
logger.debug("Ready to Create Stack ({}) with input params: {}", heatTemplate, stackInputs);
Stack heatStack = null;
try {
OpenStackRequest<Stack> request = heatClient.getStacks().create(stack);
+ saveStackRequest(request, MDC.get(ONAPLogConstants.MDCs.REQUEST_ID), stackName);
CloudIdentity cloudIdentity = cloudSite.getIdentityService();
request.header("X-Auth-User", cloudIdentity.getMsoId());
request.header("X-Auth-Key", CryptoUtils.decryptCloudConfigPassword(cloudIdentity.getMsoPass()));
@@ -272,11 +286,27 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
return new StackInfoMapper(heatStack).map();
}
+ private void saveStackRequest(OpenStackRequest<Stack> request, String requestId, String stackName) {
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ InfraActiveRequests foundRequest = requestDBClient.getInfraActiveRequestbyRequestId(requestId);
+ String stackRequest = mapper.writeValueAsString(request.entity());
+ CloudApiRequests cloudReq = new CloudApiRequests();
+ cloudReq.setCloudIdentifier(stackName);
+ cloudReq.setRequestBody(stackRequest);
+ cloudReq.setRequestId(requestId);
+ foundRequest.getCloudApiRequests().add(cloudReq);
+ requestDBClient.updateInfraActiveRequests(foundRequest);
+ } catch (Exception e) {
+ logger.error("Error updating in flight request with Openstack Create Request", e);
+ }
+ }
+
private Stack pollStackForCompletion(String cloudSiteId, String tenantId, String stackName, int timeoutMinutes,
boolean backout, Heat heatClient, Stack heatStack, String canonicalName)
throws MsoException, MsoOpenstackException {
int createPollInterval =
- Integer.parseInt(this.environment.getProperty(createPollIntervalProp, createPollIntervalDefault));
+ Integer.parseInt(this.environment.getProperty(createPollIntervalProp, CREATE_POLL_INTERVAL_DEFAULT));
int pollTimeout = (timeoutMinutes * 60) + createPollInterval;
int deletePollInterval = createPollInterval;
int deletePollTimeout = pollTimeout;
@@ -361,15 +391,14 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
} catch (Exception e3) {
// Just log this one. We will report the original exception.
- logger.error("{} Create Stack: Nested exception rolling back stack: {} ",
- MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue(),
- e3);
+ logger.error(EXCEPTION_ROLLING_BACK_STACK, MessageEnum.RA_CREATE_STACK_ERR,
+ ErrorCode.BusinessProcesssError.getValue(), e3);
}
}
} catch (Exception e2) {
// Just log this one. We will report the original exception.
- logger.error("{} Create Stack: Nested exception rolling back stack: {} ",
- MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue(), e2);
+ logger.error(EXCEPTION_ROLLING_BACK_STACK, MessageEnum.RA_CREATE_STACK_ERR,
+ ErrorCode.BusinessProcesssError.getValue(), e2);
}
}
@@ -465,8 +494,8 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
}
} catch (Exception e2) {
// shouldn't happen - but handle
- logger.error("{} Create Stack: Nested exception rolling back stack: {} ",
- MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue(), e2);
+ logger.error(EXCEPTION_ROLLING_BACK_STACK, MessageEnum.RA_CREATE_STACK_ERR,
+ ErrorCode.BusinessProcesssError.getValue(), e2);
}
}
MsoOpenstackException me = new MsoOpenstackException(0, "", stackErrorStatusReason.toString());
@@ -494,14 +523,14 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
// Obtain the cloud site information where we will create the stack
CloudSite cloudSite =
cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId));
- logger.debug("Found: {}", cloudSite.toString());
+ logger.debug(FOUND, cloudSite.toString());
// Get a Heat client. They are cached between calls (keyed by tenantId:cloudId)
Heat heatClient = null;
try {
heatClient = getHeatClient(cloudSite, tenantId);
if (heatClient != null) {
- logger.debug("Found: {}", heatClient.toString());
+ logger.debug(FOUND, heatClient.toString());
}
} catch (MsoTenantNotFound e) {
// Tenant doesn't exist, so stack doesn't either
@@ -553,14 +582,14 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
// Obtain the cloud site information where we will create the stack
CloudSite cloudSite =
cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId));
- logger.debug("Found: {}", cloudSite.toString());
+ logger.debug(FOUND, cloudSite.toString());
// Get a Heat client. They are cached between calls (keyed by tenantId:cloudId)
Heat heatClient = null;
try {
heatClient = getHeatClient(cloudSite, tenantId);
if (heatClient != null) {
- logger.debug("Found: {}", heatClient.toString());
+ logger.debug(FOUND, heatClient.toString());
}
} catch (MsoTenantNotFound e) {
// Tenant doesn't exist, so stack doesn't either
@@ -621,9 +650,9 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
// Set a timeout on polling
int pollInterval = Integer
- .parseInt(this.environment.getProperty(deletePollIntervalProp, "" + deletePollIntervalDefault));
+ .parseInt(this.environment.getProperty(deletePollIntervalProp, "" + DELETE_POLL_INTERVAL_DEFAULT));
int pollTimeout = Integer
- .parseInt(this.environment.getProperty(deletePollTimeoutProp, "" + deletePollIntervalDefault));
+ .parseInt(this.environment.getProperty(deletePollTimeoutProp, "" + DELETE_POLL_INTERVAL_DEFAULT));
// When querying by canonical name, Openstack returns DELETE_COMPLETE status
// instead of "404" (which would result from query by stack name).
@@ -805,14 +834,14 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
// Obtain an MSO token for the tenant
CloudIdentity cloudIdentity = cloudSite.getIdentityService();
- logger.debug("Found: {}", cloudIdentity.toString());
+ logger.debug(FOUND, cloudIdentity.toString());
MsoTenantUtils tenantUtils =
tenantUtilsFactory.getTenantUtilsByServerType(cloudIdentity.getIdentityServerType());
String keystoneUrl = tenantUtils.getKeystoneUrl(cloudId, cloudIdentity);
logger.debug("keystoneUrl={}", keystoneUrl);
String heatUrl = null;
String tokenId = null;
- Calendar expiration = null;
+
try {
if (ServerType.KEYSTONE.equals(cloudIdentity.getIdentityServerType())) {
Keystone keystoneTenantClient = new Keystone(keystoneUrl);
@@ -849,12 +878,12 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
throw new MsoAdapterException(error, e);
}
tokenId = access.getToken().getId();
- expiration = access.getToken().getExpires();
+
} else if (ServerType.KEYSTONE_V3.equals(cloudIdentity.getIdentityServerType())) {
try {
KeystoneAuthHolder holder = keystoneV3Authentication.getToken(cloudSite, tenantId, "orchestration");
tokenId = holder.getId();
- expiration = holder.getexpiration();
+
heatUrl = holder.getServiceUrl();
} catch (ServiceEndpointNotFoundException e) {
// This comes back for not found (probably an incorrect region ID)
@@ -1027,8 +1056,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
private String convertNode(final JsonNode node) {
try {
final Object obj = JSON_MAPPER.treeToValue(node, Object.class);
- final String json = JSON_MAPPER.writeValueAsString(obj);
- return json;
+ return JSON_MAPPER.writeValueAsString(obj);
} catch (Exception e) {
logger.debug("Error converting json to string {} ", e.getMessage(), e);
}
@@ -1321,19 +1349,19 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
* This helpful method added for Valet
*/
public String getCloudSiteKeystoneUrl(String cloudSiteId) throws MsoCloudSiteNotFound {
- String keystone_url = null;
+ String keystoneUrl = null;
try {
CloudSite cloudSite =
cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId));
CloudIdentity cloudIdentity = cloudSite.getIdentityService();
- keystone_url = cloudIdentity.getIdentityUrl();
+ keystoneUrl = cloudIdentity.getIdentityUrl();
} catch (Exception e) {
throw new MsoCloudSiteNotFound(cloudSiteId);
}
- if (keystone_url == null || keystone_url.isEmpty()) {
+ if (keystoneUrl == null || keystoneUrl.isEmpty()) {
throw new MsoCloudSiteNotFound(cloudSiteId);
}
- return keystone_url;
+ return keystoneUrl;
}
/*
@@ -1550,7 +1578,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
if (heatStatus == HeatStatus.INIT || heatStatus == HeatStatus.BUILDING) {
vduStatus.setState(VduStateType.INSTANTIATING);
- vduStatus.setLastAction((new PluginAction("create", "in_progress", statusMessage)));
+ vduStatus.setLastAction((new PluginAction("create", IN_PROGRESS, statusMessage)));
} else if (heatStatus == HeatStatus.NOTFOUND) {
vduStatus.setState(VduStateType.NOTFOUND);
} else if (heatStatus == HeatStatus.CREATED) {
@@ -1561,10 +1589,10 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
vduStatus.setLastAction((new PluginAction("update", "complete", statusMessage)));
} else if (heatStatus == HeatStatus.UPDATING) {
vduStatus.setState(VduStateType.UPDATING);
- vduStatus.setLastAction((new PluginAction("update", "in_progress", statusMessage)));
+ vduStatus.setLastAction((new PluginAction("update", IN_PROGRESS, statusMessage)));
} else if (heatStatus == HeatStatus.DELETING) {
vduStatus.setState(VduStateType.DELETING);
- vduStatus.setLastAction((new PluginAction("delete", "in_progress", statusMessage)));
+ vduStatus.setLastAction((new PluginAction("delete", IN_PROGRESS, statusMessage)));
} else if (heatStatus == HeatStatus.FAILED) {
vduStatus.setState(VduStateType.FAILED);
vduStatus.setErrorMessage(stackInfo.getStatusMessage());
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java
index 1bf780f6d3..a2e386adea 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java
@@ -60,6 +60,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
private static final Logger logger = LoggerFactory.getLogger(MsoHeatUtilsWithUpdate.class);
private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
+ public static final String EXCEPTION = "Exception :";
@Autowired
private Environment environment;
@@ -221,8 +222,8 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
// Set a time limit on overall polling.
// Use the resource (template) timeout for Openstack (expressed in minutes)
// and add one poll interval to give Openstack a chance to fail on its own.
- int createPollInterval =
- Integer.parseInt(this.environment.getProperty(createPollIntervalProp, createPollIntervalDefault));
+ int createPollInterval = Integer
+ .parseInt(this.environment.getProperty(createPollIntervalProp, CREATE_POLL_INTERVAL_DEFAULT));
int pollTimeout = (timeoutMinutes * 60) + createPollInterval;
boolean loopAgain = true;
@@ -335,7 +336,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
String str = JSON_MAPPER.writeValueAsString(obj);
sb.append(str).append(" (a java.util.LinkedHashMap)");
} catch (Exception e) {
- logger.debug("Exception :", e);
+ logger.debug(EXCEPTION, e);
sb.append("(a LinkedHashMap value that would not convert nicely)");
}
} else if (obj instanceof Integer) {
@@ -343,7 +344,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
try {
str = obj.toString() + " (an Integer)\n";
} catch (Exception e) {
- logger.debug("Exception :", e);
+ logger.debug(EXCEPTION, e);
str = "(an Integer unable to call .toString() on)";
}
sb.append(str);
@@ -352,7 +353,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
try {
str = obj.toString() + " (an ArrayList)";
} catch (Exception e) {
- logger.debug("Exception :", e);
+ logger.debug(EXCEPTION, e);
str = "(an ArrayList unable to call .toString() on?)";
}
sb.append(str);
@@ -361,7 +362,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
try {
str = obj.toString() + " (a Boolean)";
} catch (Exception e) {
- logger.debug("Exception :", e);
+ logger.debug(EXCEPTION, e);
str = "(an Boolean unable to call .toString() on?)";
}
sb.append(str);
@@ -370,7 +371,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
try {
str = obj.toString() + " (unknown Object type)";
} catch (Exception e) {
- logger.debug("Exception :", e);
+ logger.debug(EXCEPTION, e);
str = "(a value unable to call .toString() on?)";
}
sb.append(str);
@@ -384,8 +385,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
private String convertNodeWithUpdate(final JsonNode node) {
try {
final Object obj = JSON_MAPPER.treeToValue(node, Object.class);
- final String json = JSON_MAPPER.writeValueAsString(obj);
- return json;
+ return JSON_MAPPER.writeValueAsString(obj);
} catch (Exception e) {
logger.debug("Error converting json to string {} ", e.getMessage(), e);
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java
index cfc8c23c5f..ab93a6c4c6 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java
@@ -58,6 +58,7 @@ import org.springframework.stereotype.Component;
@Component
public class MsoKeystoneUtils extends MsoTenantUtils {
+ public static final String DELETE_TENANT = "Delete Tenant";
private static Logger logger = LoggerFactory.getLogger(MsoKeystoneUtils.class);
@Autowired
@@ -207,7 +208,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
return null;
}
- Map<String, String> metadata = new HashMap<String, String>();
+ Map<String, String> metadata = new HashMap<>();
if (cloudSite.getIdentityService().getTenantMetadata()) {
OpenStackRequest<Metadata> request = keystoneAdminClient.tenants().showMetadata(tenant.getId());
Metadata tenantMetadata = executeAndRecordOpenstackRequest(request);
@@ -252,7 +253,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
return null;
}
- Map<String, String> metadata = new HashMap<String, String>();
+ Map<String, String> metadata = new HashMap<>();
if (cloudSite.getIdentityService().getTenantMetadata()) {
OpenStackRequest<Metadata> request = keystoneAdminClient.tenants().showMetadata(tenant.getId());
Metadata tenantMetadata = executeAndRecordOpenstackRequest(request);
@@ -304,10 +305,10 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
logger.debug("Deleted Tenant {} ({})", tenant.getId(), tenant.getName());
} catch (OpenStackBaseException e) {
// Convert Keystone OpenStackResponseException to MsoOpenstackException
- throw keystoneErrorToMsoException(e, "Delete Tenant");
+ throw keystoneErrorToMsoException(e, DELETE_TENANT);
} catch (RuntimeException e) {
// Catch-all
- throw runtimeExceptionToMsoException(e, "DeleteTenant");
+ throw runtimeExceptionToMsoException(e, DELETE_TENANT);
}
return true;
@@ -354,10 +355,10 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
} catch (OpenStackBaseException e) {
// Note: It doesn't seem to matter if tenant doesn't exist, no exception is thrown.
// Convert Keystone OpenStackResponseException to MsoOpenstackException
- throw keystoneErrorToMsoException(e, "DeleteTenant");
+ throw keystoneErrorToMsoException(e, DELETE_TENANT);
} catch (RuntimeException e) {
// Catch-all
- throw runtimeExceptionToMsoException(e, "DeleteTenant");
+ throw runtimeExceptionToMsoException(e, DELETE_TENANT);
}
return true;
@@ -379,7 +380,6 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
public Keystone getKeystoneAdminClient(CloudSite cloudSite) throws MsoException {
CloudIdentity cloudIdentity = cloudSite.getIdentityService();
- String cloudId = cloudIdentity.getId();
String adminTenantName = cloudIdentity.getAdminTenant();
String region = cloudSite.getRegionId();
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
index e16bf90d4d..dc5ff0dcca 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
@@ -467,7 +467,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
}
int updatePollInterval =
- Integer.parseInt(this.environment.getProperty(createPollIntervalProp, createPollIntervalDefault));
+ Integer.parseInt(this.environment.getProperty(createPollIntervalProp, CREATE_POLL_INTERVAL_DEFAULT));
int pollTimeout = (timeoutMinutes * 60) + updatePollInterval;
boolean updateTimedOut = false;
logger.debug("updatePollInterval=" + updatePollInterval + ", pollTimeout=" + pollTimeout);
@@ -535,8 +535,8 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
// Use the resource (template) timeout for Openstack (expressed in minutes)
// and add one poll interval to give Openstack a chance to fail on its own.s
- int createPollInterval =
- Integer.parseInt(this.environment.getProperty(createPollIntervalProp, createPollIntervalDefault));
+ int createPollInterval = Integer
+ .parseInt(this.environment.getProperty(createPollIntervalProp, CREATE_POLL_INTERVAL_DEFAULT));
int pollTimeout = (timeoutMinutes * 60) + createPollInterval;
// New 1610 - poll on delete if we rollback - use same values for now
int deletePollInterval = createPollInterval;
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 78db27f65e..6f08afc55f 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
@@ -373,7 +373,7 @@ public class MsoNeutronUtils extends MsoCommonUtils {
final String keystoneUrl = tenantUtils.getKeystoneUrl(cloudId, cloudIdentity);
String neutronUrl = null;
String tokenId = null;
- Calendar expiration = null;
+
try {
if (ServerType.KEYSTONE.equals(cloudIdentity.getIdentityServerType())) {
Keystone keystoneTenantClient = new Keystone(keystoneUrl);
@@ -396,12 +396,12 @@ public class MsoNeutronUtils extends MsoCommonUtils {
throw new MsoAdapterException(error, e);
}
tokenId = access.getToken().getId();
- expiration = access.getToken().getExpires();
+
} else if (ServerType.KEYSTONE_V3.equals(cloudIdentity.getIdentityServerType())) {
try {
KeystoneAuthHolder holder = keystoneV3Authentication.getToken(cloudSite, tenantId, "network");
tokenId = holder.getId();
- expiration = holder.getexpiration();
+
neutronUrl = holder.getServiceUrl();
if (!neutronUrl.endsWith("/")) {
neutronUrl += "/v2.0/";
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoYamlEditorWithEnvt.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoYamlEditorWithEnvt.java
index 0541a8f51b..9ee8a09ea6 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoYamlEditorWithEnvt.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoYamlEditorWithEnvt.java
@@ -40,6 +40,7 @@ import org.yaml.snakeyaml.Yaml;
public class MsoYamlEditorWithEnvt {
private static final Logger logger = LoggerFactory.getLogger(MsoYamlEditorWithEnvt.class);
+ public static final String EXCEPTION = "Exception:";
private Map<String, Object> yml;
private Yaml yaml = new Yaml();
@@ -68,7 +69,7 @@ public class MsoYamlEditorWithEnvt {
try {
resourceMap = (Map<String, Object>) yml.get("parameters");
} catch (Exception e) {
- logger.debug("Exception:", e);
+ logger.debug(EXCEPTION, e);
return paramSet;
}
if (resourceMap == null) {
@@ -89,7 +90,7 @@ public class MsoYamlEditorWithEnvt {
try {
value = JSON_MAPPER.writeValueAsString(obj);
} catch (Exception e) {
- logger.debug("Exception:", e);
+ logger.debug(EXCEPTION, e);
value = "_BAD_JSON_MAPPING";
}
} else {
@@ -118,7 +119,7 @@ public class MsoYamlEditorWithEnvt {
}
return resourceList;
} catch (Exception e) {
- logger.debug("Exception:", e);
+ logger.debug(EXCEPTION, e);
}
return null;
}
@@ -137,7 +138,7 @@ public class MsoYamlEditorWithEnvt {
try {
value = resourceEntry.get("default");
} catch (ClassCastException cce) {
- logger.debug("Exception:", cce);
+ logger.debug(EXCEPTION, cce);
// This exception only - the value is an integer. For what we're doing
// here - we don't care - so set value to something - and it will
// get marked as not being required - which is correct.
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java
index a4cdba22a1..16671bbe50 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java
@@ -31,7 +31,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({"id", "links"})
public class MulticloudCreateHeatResponse implements Serializable {
- private final static long serialVersionUID = -5215028275577848311L;
+ private static final long serialVersionUID = -5215028275577848311L;
@JsonProperty("id")
private String id;
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java
index e8a5b1480e..1f55aa92a2 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java
@@ -31,7 +31,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({"href", "rel"})
public class MulticloudCreateLinkResponse implements Serializable {
- private final static long serialVersionUID = -5215028275577848311L;
+ private static final long serialVersionUID = -5215028275577848311L;
@JsonProperty("href")
private String href;
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java
index bb15e58c88..fc08201bcb 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java
@@ -30,7 +30,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({"template_type", "workload_id", "template_response"})
public class MulticloudCreateResponse implements Serializable {
- private final static long serialVersionUID = -5215028275577848311L;
+ private static final long serialVersionUID = -5215028275577848311L;
@JsonProperty("template_type")
private String templateType;
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java
index 67cb73539d..67d1cbff4e 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java
@@ -30,7 +30,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({"stack"})
public class MulticloudCreateStackResponse implements Serializable {
- private final static long serialVersionUID = -5215028275577848311L;
+ private static final long serialVersionUID = -5215028275577848311L;
@JsonProperty("stack")
private MulticloudCreateHeatResponse stack;
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java
index a22937aea3..ad37b39f30 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java
@@ -31,7 +31,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({"template_type", "workload_id", "workload_status", "workload_status_reason"})
public class MulticloudQueryResponse implements Serializable {
- private final static long serialVersionUID = -5215028275577848311L;
+ private static final long serialVersionUID = -5215028275577848311L;
@JsonProperty("template_type")
private String templateType;
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java
index b733552a2b..95dd48caa6 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java
@@ -33,7 +33,7 @@ import org.apache.commons.lang.builder.ToStringBuilder;
"vf-module-model-customization-id", "oof_directives", "sdnc_directives", "user_directives", "template_type",
"template_data"})
public class MulticloudRequest implements Serializable {
- private final static long serialVersionUID = -5215028275577848311L;
+ private static final long serialVersionUID = -5215028275577848311L;
@JsonProperty("generic-vnf-id")
private String genericVnfId;