aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src/main
diff options
context:
space:
mode:
authorEric Multanen <eric.w.multanen@intel.com>2019-03-12 21:13:23 -0700
committerEric Multanen <eric.w.multanen@intel.com>2019-03-19 23:30:10 -0700
commit9a409f9ea4c3cc5f73d5756dba833889040e7dda (patch)
tree0301b224ceab2f99aa8567656ce37b4286eb997e /adapters/mso-adapter-utils/src/main
parent9cd51d70010f2e8154c26326a4457bf00bbd10aa (diff)
Add cloudOwner to VNF adapter call
The BPMN layer has the CloudRegion which includes the CloudOwner attribute, but this is not passed to the VNF adapter layer. Calls to the Multicloud infrastructure workload need the CloudOwner as well. This patch adds CloudOwner to the VNF adapter API. While the intended usage is primarily for the multicloud adapter, it touches a log of other files - though those do not make use of it at this point. Change-Id: I88028096fbd84fc3fe5d53786c70b3c8806bb711 Issue-ID: SO-1447 Signed-off-by: Eric Multanen <eric.w.multanen@intel.com>
Diffstat (limited to 'adapters/mso-adapter-utils/src/main')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/beans/VnfRollback.java25
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java53
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java11
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java57
4 files changed, 94 insertions, 52 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/beans/VnfRollback.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/beans/VnfRollback.java
index bb8aa92281..8da4df28b1 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/beans/VnfRollback.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/beans/VnfRollback.java
@@ -7,9 +7,9 @@
* 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.
@@ -34,6 +34,7 @@ public class VnfRollback {
private String vnfId;
private String tenantId;
private String cloudSiteId;
+ private String cloudOwner;
private boolean tenantCreated = false;
private boolean vnfCreated = false;
private MsoRequest msoRequest;
@@ -51,10 +52,11 @@ public class VnfRollback {
/**
* For backwards compatibility... orchestration mode defaults to HEAT
- *
+ *
* @param vnfId
* @param tenantId
* @param cloudSiteId
+ * @param cloudOwner
* @param tenantCreated
* @param vnfCreated
* @param msoRequest
@@ -63,7 +65,7 @@ public class VnfRollback {
* @param requestType
* @param modelCustomizationUuid
*/
- public VnfRollback(String vnfId, String tenantId, String cloudSiteId,
+ public VnfRollback(String vnfId, String tenantId, String cloudOwner, String cloudSiteId,
boolean tenantCreated, boolean vnfCreated,
MsoRequest msoRequest,
String volumeGroupName, String volumeGroupId, String requestType, String modelCustomizationUuid) {
@@ -71,6 +73,7 @@ public class VnfRollback {
this.vnfId = vnfId;
this.tenantId = tenantId;
this.cloudSiteId = cloudSiteId;
+ this.cloudOwner = cloudOwner;
this.tenantCreated = tenantCreated;
this.vnfCreated = vnfCreated;
this.msoRequest = msoRequest;
@@ -82,10 +85,11 @@ public class VnfRollback {
/**
* For backwards compatibility... orchestration mode defaults to HEAT
- *
+ *
* @param vnfId
* @param tenantId
* @param cloudSiteId
+ * @param cloudOwner
* @param tenantCreated
* @param vnfCreated
* @param msoRequest
@@ -94,7 +98,7 @@ public class VnfRollback {
* @param requestType
* @param modelCustomizationUuid
*/
- public VnfRollback(String vnfId, String tenantId, String cloudSiteId,
+ public VnfRollback(String vnfId, String tenantId, String cloudOwner, String cloudSiteId,
boolean tenantCreated, boolean vnfCreated,
MsoRequest msoRequest, String volumeGroupName, String volumeGroupId,
String requestType, String modelCustomizationUuid, String orchestrationMode) {
@@ -102,6 +106,7 @@ public class VnfRollback {
this.vnfId = vnfId;
this.tenantId = tenantId;
this.cloudSiteId = cloudSiteId;
+ this.cloudOwner = cloudOwner;
this.tenantCreated = tenantCreated;
this.vnfCreated = vnfCreated;
this.msoRequest = msoRequest;
@@ -131,6 +136,12 @@ public class VnfRollback {
public void setCloudSiteId(String cloudId) {
this.cloudSiteId = cloudId;
}
+ public String getCloudOwner() {
+ return cloudOwner;
+ }
+ public void setCloudOwner(String cloudOwner) {
+ this.cloudOwner = cloudOwner;
+ }
public boolean getTenantCreated() {
return tenantCreated;
}
@@ -207,7 +218,7 @@ public class VnfRollback {
}
@Override
public String toString() {
- return "VnfRollback: cloud=" + cloudSiteId + ", tenant=" + tenantId +
+ return "VnfRollback: cloud=" + cloudSiteId + ", cloudOwner=" + cloudOwner + ", tenant=" + tenantId +
", vnf=" + vnfId + ", tenantCreated=" + tenantCreated +
", vnfCreated=" + vnfCreated + ", requestType = " + requestType
+ ", modelCustomizationUuid=" + this.modelCustomizationUuid
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 60088fc612..b6c98ad996 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
@@ -114,10 +114,10 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
@Autowired
private MsoTenantUtilsFactory tenantUtilsFactory;
-
+
@Autowired
private KeystoneV3Authentication keystoneV3Authentication;
-
+
private static final Logger logger = LoggerFactory.getLogger(MsoHeatUtils.class);
// Properties names and variables (with default values)
@@ -135,6 +135,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
* this method does not include environment, files, or heatFiles
*/
public StackInfo createStack (String cloudSiteId,
+ String cloudOwner,
String tenantId,
String stackName,
String heatTemplate,
@@ -143,6 +144,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
int timeoutMinutes) throws MsoException {
// Just call the new method with the environment & files variable set to null
return this.createStack (cloudSiteId,
+ cloudOwner,
tenantId,
stackName,
heatTemplate,
@@ -157,6 +159,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
// This method has environment, but not files or heatFiles
public StackInfo createStack (String cloudSiteId,
+ String cloudOwner,
String tenantId,
String stackName,
String heatTemplate,
@@ -166,6 +169,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
String environment) throws MsoException {
// Just call the new method with the files/heatFiles variables set to null
return this.createStack (cloudSiteId,
+ cloudOwner,
tenantId,
stackName,
heatTemplate,
@@ -180,6 +184,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
// This method has environment and files, but not heatFiles.
public StackInfo createStack (String cloudSiteId,
+ String cloudOwner,
String tenantId,
String stackName,
String heatTemplate,
@@ -189,6 +194,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
String environment,
Map <String, Object> files) throws MsoException {
return this.createStack (cloudSiteId,
+ cloudOwner,
tenantId,
stackName,
heatTemplate,
@@ -203,6 +209,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
// This method has environment, files, heatfiles
public StackInfo createStack (String cloudSiteId,
+ String cloudOwner,
String tenantId,
String stackName,
String heatTemplate,
@@ -213,6 +220,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
Map <String, Object> files,
Map <String, Object> heatFiles) throws MsoException {
return this.createStack (cloudSiteId,
+ cloudOwner,
tenantId,
stackName,
heatTemplate,
@@ -251,6 +259,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
* stack. We must combine them before we add them to the stack if they're both non-null.
*
* @param cloudSiteId The cloud (may be a region) in which to create the stack.
+ * @param cloudOwner the cloud owner of the cloud site in which to create the stack
* @param tenantId The Openstack ID of the tenant in which to create the Stack
* @param stackName The name of the stack to create
* @param heatTemplate The Heat template
@@ -267,6 +276,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
@SuppressWarnings("unchecked")
public StackInfo createStack (String cloudSiteId,
+ String cloudOwner,
String tenantId,
String stackName,
String heatTemplate,
@@ -309,7 +319,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
request.header ("X-Auth-Key", CryptoUtils.decryptCloudConfigPassword(cloudIdentity.getMsoPass ()));
heatStack = executeAndRecordOpenstackRequest (request);
} catch (OpenStackResponseException e) {
- if (e.getStatus () == 409) {
+ if (e.getStatus () == 409) {
MsoStackAlreadyExists me = new MsoStackAlreadyExists (stackName, tenantId, cloudSiteId);
me.addContext (CREATE_STACK);
throw me;
@@ -317,9 +327,9 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
logger.debug("ERROR STATUS = {},\n{}\n{}", e.getStatus(), e.getMessage(), e.getLocalizedMessage());
throw heatExceptionToMsoException (e, CREATE_STACK);
}
- } catch (OpenStackConnectException e) {
+ } catch (OpenStackConnectException e) {
throw heatExceptionToMsoException (e, CREATE_STACK);
- } catch (RuntimeException e) {
+ } catch (RuntimeException e) {
throw runtimeExceptionToMsoException (e, CREATE_STACK);
}
@@ -327,7 +337,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
// Otherwise, simple query by name returns a 302 redirect.
// NOTE: This is specific to the v1 Orchestration API.
String canonicalName = stackName + "/" + heatStack.getId ();
-
+
if (pollForCompletion) {
heatStack = pollStackForCompletion(cloudSiteId, tenantId, stackName, timeoutMinutes, backout, heatClient,
heatStack, canonicalName);
@@ -360,7 +370,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
logger.debug("an error occurred trying to print out the current outputs of the stack", e);
}
- if ("CREATE_IN_PROGRESS".equals (heatStack.getStackStatus ())) {
+ if ("CREATE_IN_PROGRESS".equals (heatStack.getStackStatus ())) {
if (pollTimeout <= 0) {
logger.error("{} Cloud site: {} Tenant: {} Stack: {} Stack status: {} {} Create stack timeout",
MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, stackName,
@@ -544,11 +554,12 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
*
* @param tenantId The Openstack ID of the tenant in which to query
* @param cloudSiteId The cloud identifier (may be a region) in which to query
+ * @param cloudOwner the cloud owner of the cloud site in which to query
* @param stackName The name of the stack to query (may be simple or canonical)
* @return A StackInfo object
* @throws MsoOpenstackException Thrown if the Openstack API call returns an exception.
*/
- public StackInfo queryStack (String cloudSiteId, String tenantId, String stackName) throws MsoException {
+ public StackInfo queryStack (String cloudSiteId, String cloudOwner, String tenantId, String stackName) throws MsoException {
logger.debug ("Query HEAT stack: {} in tenant {}", stackName, tenantId);
// Obtain the cloud site information where we will create the stack
@@ -602,6 +613,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
* all or partially deleted, so the resulting stack must be considered invalid.
*
* @param tenantId The Openstack ID of the tenant in which to perform the delete
+ * @param cloudOwner the cloud owner of the cloud site in which to delete the stack
* @param cloudSiteId The cloud identifier (may be a region) from which to delete the stack.
* @param stackName The name/id of the stack to delete. May be simple or canonical
* @param pollForCompletion Indicator that polling should be handled in Java vs. in the client
@@ -610,6 +622,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
* @throws MsoCloudSiteNotFound
*/
public StackInfo deleteStack (String tenantId,
+ String cloudOwner,
String cloudSiteId,
String stackName,
boolean pollForCompletion) throws MsoException {
@@ -886,14 +899,14 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
if (ServerType.KEYSTONE.equals(cloudIdentity.getIdentityServerType())) {
Keystone keystoneTenantClient = new Keystone (keystoneUrl);
Access access = null;
-
+
Authentication credentials = authenticationMethodFactory.getAuthenticationFor(cloudIdentity);
-
+
OpenStackRequest <Access> request = keystoneTenantClient.tokens ()
.authenticate (credentials).withTenantId (tenantId);
-
+
access = executeAndRecordOpenstackRequest (request);
-
+
try {
// Isolate trying to printout the region IDs
try {
@@ -998,10 +1011,10 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
}
- public Map<String, Object> queryStackForOutputs(String cloudSiteId,
+ public Map<String, Object> queryStackForOutputs(String cloudSiteId, String cloudOwner,
String tenantId, String stackName) throws MsoException {
logger.debug("MsoHeatUtils.queryStackForOutputs)");
- StackInfo heatStack = this.queryStack(cloudSiteId, tenantId, stackName);
+ StackInfo heatStack = this.queryStack(cloudSiteId, cloudOwner, tenantId, stackName);
if (heatStack == null || heatStack.getStatus() == HeatStatus.NOTFOUND) {
return null;
}
@@ -1180,7 +1193,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
sb.append("[END]");
return sb;
}
-
+
public void copyBaseOutputsToInputs(Map<String, Object> inputs,
Map<String, Object> otherStackOutputs, List<String> paramNames, Map<String, String> aliases) {
@@ -1509,6 +1522,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
throws VduException
{
String cloudSiteId = cloudInfo.getCloudSiteId();
+ String cloudOwner = cloudInfo.getCloudOwner();
String tenantId = cloudInfo.getTenantId();
// Translate the VDU ModelInformation structure to that which is needed for
@@ -1534,6 +1548,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
try {
StackInfo stackInfo = createStack (cloudSiteId,
+ cloudOwner,
tenantId,
instanceName,
heatTemplate,
@@ -1562,11 +1577,12 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
throws VduException
{
String cloudSiteId = cloudInfo.getCloudSiteId();
+ String cloudOwner = cloudInfo.getCloudOwner();
String tenantId = cloudInfo.getTenantId();
try {
// Query the Cloudify Deployment object and populate a VduInstance
- StackInfo stackInfo = queryStack (cloudSiteId, tenantId, instanceId);
+ StackInfo stackInfo = queryStack (cloudSiteId, cloudOwner, tenantId, instanceId);
return stackInfoToVduInstance(stackInfo);
}
@@ -1584,11 +1600,12 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
throws VduException
{
String cloudSiteId = cloudInfo.getCloudSiteId();
+ String cloudOwner = cloudInfo.getCloudOwner();
String tenantId = cloudInfo.getTenantId();
try {
// Delete the Heat stack
- StackInfo stackInfo = deleteStack (tenantId, cloudSiteId, instanceId, true);
+ StackInfo stackInfo = deleteStack (tenantId, cloudOwner, cloudSiteId, instanceId, true);
// Populate a VduInstance based on the deleted Cloudify Deployment object
VduInstance vduInstance = stackInfoToVduInstance(stackInfo);
@@ -1686,7 +1703,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
return vduStatus;
}
-
+
public Resources queryStackResources(String cloudSiteId, String tenantId, String stackName) throws MsoException {
CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId)
.orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId));
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 d93ce9e1e1..c378be7d4b 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
@@ -10,9 +10,9 @@
* 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.
@@ -68,6 +68,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
*/
public StackInfo updateStack (String cloudSiteId,
+ String cloudOwner,
String tenantId,
String stackName,
String heatTemplate,
@@ -77,6 +78,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
// Keeping this method to allow compatibility with no environment or files variable sent. In this case,
// simply return the new method with the environment variable set to null.
return this.updateStack (cloudSiteId,
+ cloudOwner,
tenantId,
stackName,
heatTemplate,
@@ -89,6 +91,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
}
public StackInfo updateStack (String cloudSiteId,
+ String cloudOwner,
String tenantId,
String stackName,
String heatTemplate,
@@ -99,6 +102,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
// Keeping this method to allow compatibility with no environment variable sent. In this case,
// simply return the new method with the files variable set to null.
return this.updateStack (cloudSiteId,
+ cloudOwner,
tenantId,
stackName,
heatTemplate,
@@ -111,6 +115,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
}
public StackInfo updateStack (String cloudSiteId,
+ String cloudOwner,
String tenantId,
String stackName,
String heatTemplate,
@@ -120,6 +125,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
String environment,
Map <String, Object> files) throws MsoException {
return this.updateStack (cloudSiteId,
+ cloudOwner,
tenantId,
stackName,
heatTemplate,
@@ -165,6 +171,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
*/
public StackInfo updateStack (String cloudSiteId,
+ String cloudOwner,
String tenantId,
String stackName,
String heatTemplate,
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 a939f79cf9..01120d51a3 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
@@ -112,7 +112,8 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
* The nested templates and get_file entries both end up being added to the "files" on the
* stack. We must combine them before we add them to the stack if they're both non-null.
*
- * @param cloudSiteId The cloud (may be a region) in which to create the stack.
+ * @param cloudSiteId The cloud (may be a region) in which to create the stack
+ * @param cloudOwner the cloud owner of the cloud site in which to create the stack
* @param tenantId The Openstack ID of the tenant in which to create the Stack
* @param stackName The name of the stack to create
* @param heatTemplate The Heat template
@@ -130,6 +131,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
@SuppressWarnings("unchecked")
@Override
public StackInfo createStack (String cloudSiteId,
+ String cloudOwner,
String tenantId,
String stackName,
String heatTemplate,
@@ -190,7 +192,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
logger.debug(String.format("Multicloud Request is: %s", multicloudRequest.toString()));
}
- String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, null);
+ String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, cloudOwner, null);
RestClient multicloudClient = getMulticloudClient(multicloudEndpoint);
if (multicloudClient == null) {
@@ -213,7 +215,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
if (logger.isDebugEnabled()) {
logger.debug("Multicloud Create Response Body: {}", multicloudResponseBody);
}
- return getStackStatus(cloudSiteId, tenantId, canonicalName, pollForCompletion, timeoutMinutes, backout);
+ return getStackStatus(cloudSiteId, cloudOwner, tenantId, canonicalName, pollForCompletion, timeoutMinutes, backout);
}
StringBuilder stackErrorStatusReason = new StringBuilder(response.getStatusInfo().getReasonPhrase());
if (null != multicloudResponseBody) {
@@ -225,10 +227,10 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
}
@Override
- public Map<String, Object> queryStackForOutputs(String cloudSiteId,
+ public Map<String, Object> queryStackForOutputs(String cloudSiteId, String cloudOwner,
String tenantId, String stackName) throws MsoException {
logger.debug("MsoHeatUtils.queryStackForOutputs)");
- StackInfo heatStack = this.queryStack(cloudSiteId, tenantId, stackName);
+ StackInfo heatStack = this.queryStack(cloudSiteId, cloudOwner, tenantId, stackName);
if (heatStack == null || heatStack.getStatus() == HeatStatus.NOTFOUND) {
return null;
}
@@ -242,12 +244,13 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
*
* @param tenantId The Openstack ID of the tenant in which to query
* @param cloudSiteId The cloud identifier (may be a region) in which to query
+ * @param cloudOwner cloud owner of the cloud site in which to query
* @param stackId The ID of the stack to query
* @return A StackInfo object
* @throws MsoOpenstackException Thrown if the Openstack API call returns an exception.
*/
@Override
- public StackInfo queryStack (String cloudSiteId, String tenantId, String instanceId) throws MsoException {
+ public StackInfo queryStack (String cloudSiteId, String cloudOwner, String tenantId, String instanceId) throws MsoException {
if (logger.isDebugEnabled()) {
logger.debug (String.format("Query multicloud HEAT stack: %s in tenant %s", instanceId, tenantId));
}
@@ -265,7 +268,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
StackInfo returnInfo = new StackInfo();
returnInfo.setName(stackName);
- String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, stackId);
+ String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, cloudOwner, stackId);
RestClient multicloudClient = getMulticloudClient(multicloudEndpoint);
if (multicloudClient != null) {
@@ -295,7 +298,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
return returnInfo;
}
- public StackInfo deleteStack (String cloudSiteId, String tenantId, String instanceId) throws MsoException {
+ public StackInfo deleteStack (String cloudSiteId, String cloudOwner, String tenantId, String instanceId) throws MsoException {
if (logger.isDebugEnabled()) {
logger.debug (String.format("Delete multicloud HEAT stack: %s in tenant %s", instanceId, tenantId));
}
@@ -314,7 +317,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
returnInfo.setName(stackName);
Response response = null;
- String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, stackId);
+ String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, cloudOwner, stackId);
RestClient multicloudClient = getMulticloudClient(multicloudEndpoint);
if (multicloudClient != null) {
@@ -327,7 +330,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
returnInfo.setStatus(HeatStatus.NOTFOUND);
returnInfo.setStatusMessage(response.getStatusInfo().getReasonPhrase());
} else if (response.getStatus() == Response.Status.NO_CONTENT.getStatusCode()) {
- return getStackStatus(cloudSiteId, tenantId, instanceId);
+ return getStackStatus(cloudSiteId, cloudOwner, tenantId, instanceId);
} else {
returnInfo.setStatus(HeatStatus.FAILED);
returnInfo.setStatusMessage(response.getStatusInfo().getReasonPhrase());
@@ -355,11 +358,11 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
return HeatStatus.UNKNOWN;
}
- private StackInfo getStackStatus(String cloudSiteId, String tenantId, String instanceId) throws MsoException {
- return getStackStatus(cloudSiteId, tenantId, instanceId, false, 0, false);
+ private StackInfo getStackStatus(String cloudSiteId, String cloudOwner, String tenantId, String instanceId) throws MsoException {
+ return getStackStatus(cloudSiteId, cloudOwner, tenantId, instanceId, false, 0, false);
}
- private StackInfo getStackStatus(String cloudSiteId, String tenantId, String instanceId, boolean pollForCompletion, int timeoutMinutes, boolean backout) throws MsoException {
+ private StackInfo getStackStatus(String cloudSiteId, String cloudOwner, String tenantId, String instanceId, boolean pollForCompletion, int timeoutMinutes, boolean backout) throws MsoException {
StackInfo stackInfo = new StackInfo();
// If client has requested a final response, poll for stack completion
@@ -379,7 +382,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
while (true) {
try {
- stackInfo = queryStack(cloudSiteId, tenantId, instanceId);
+ stackInfo = queryStack(cloudSiteId, cloudOwner, tenantId, instanceId);
logger.debug (stackInfo.getStatus() + " (" + instanceId + ")");
if (HeatStatus.BUILDING.equals(stackInfo.getStatus())) {
@@ -388,7 +391,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
if (pollTimeout <= 0) {
// Note that this should not occur, since there is a timeout specified
// in the Openstack (multicloud?) call.
- logger.error(String.format("%s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudSiteId, tenantId, instanceId, stackInfo.getStatus(), "", "", ErrorCode.AvailabilityError.getValue(), "Create stack timeout"));
+ logger.error(String.format("%s %s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudOwner, cloudSiteId, tenantId, instanceId, stackInfo.getStatus(), "", "", ErrorCode.AvailabilityError.getValue(), "Create stack timeout"));
createTimedOut = true;
break;
}
@@ -410,17 +413,17 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
} else {
try {
logger.debug("Create Stack error - unable to query for stack status - attempting to delete stack: " + instanceId + " - This will likely fail and/or we won't be able to query to see if delete worked");
- StackInfo deleteInfo = deleteStack(cloudSiteId, tenantId, instanceId);
+ StackInfo deleteInfo = deleteStack(cloudSiteId, cloudOwner, tenantId, instanceId);
// this may be a waste of time - if we just got an exception trying to query the stack - we'll just
// get another one, n'est-ce pas?
boolean deleted = false;
while (!deleted) {
try {
- StackInfo queryInfo = queryStack(cloudSiteId, tenantId, instanceId);
+ StackInfo queryInfo = queryStack(cloudSiteId, cloudOwner, tenantId, instanceId);
logger.debug("Deleting " + instanceId + ", status: " + queryInfo.getStatus());
if (HeatStatus.DELETING.equals(queryInfo.getStatus())) {
if (deletePollTimeout <= 0) {
- logger.error(String.format("%s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudSiteId, tenantId, instanceId,
+ logger.error(String.format("%s %s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudOwner, cloudSiteId, tenantId, instanceId,
queryInfo.getStatus(), "", "", ErrorCode.AvailabilityError.getValue(),
"Rollback: DELETE stack timeout"));
break;
@@ -466,15 +469,15 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
try {
logger.debug("Create Stack errored - attempting to DELETE stack: " + instanceId);
logger.debug("deletePollInterval=" + deletePollInterval + ", deletePollTimeout=" + deletePollTimeout);
- StackInfo deleteInfo = deleteStack(cloudSiteId, tenantId, instanceId);
+ StackInfo deleteInfo = deleteStack(cloudSiteId, cloudOwner, tenantId, instanceId);
boolean deleted = false;
while (!deleted) {
try {
- StackInfo queryInfo = queryStack(cloudSiteId, tenantId, instanceId);
+ StackInfo queryInfo = queryStack(cloudSiteId, cloudOwner, tenantId, instanceId);
logger.debug("Deleting " + instanceId + ", status: " + queryInfo.getStatus());
if (HeatStatus.DELETING.equals(queryInfo.getStatus())) {
if (deletePollTimeout <= 0) {
- logger.error(String.format("%s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudSiteId, tenantId, instanceId,
+ logger.error(String.format("%s %s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudOwner, cloudSiteId, tenantId, instanceId,
queryInfo.getStatus(), "", "", ErrorCode.AvailabilityError.getValue(),
"Rollback: DELETE stack timeout"));
break;
@@ -520,7 +523,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
}
} else {
// Get initial status, since it will have been null after the create.
- stackInfo = queryStack(cloudSiteId, tenantId, instanceId);
+ stackInfo = queryStack(cloudSiteId, cloudOwner, tenantId, instanceId);
logger.debug("Multicloud stack query status is: " + stackInfo.getStatus());
}
return stackInfo;
@@ -580,7 +583,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
return null;
}
- private String getMulticloudEndpoint(String cloudSiteId, String workloadId) throws MsoCloudSiteNotFound {
+ private String getMulticloudEndpoint(String cloudSiteId, String cloudOwner, String workloadId) throws MsoCloudSiteNotFound {
CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId));
String endpoint = cloudSite.getIdentityService().getIdentityUrl();
@@ -645,6 +648,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
throws VduException
{
String cloudSiteId = cloudInfo.getCloudSiteId();
+ String cloudOwner = cloudInfo.getCloudOwner();
String tenantId = cloudInfo.getTenantId();
// Translate the VDU ModelInformation structure to that which is needed for
@@ -670,6 +674,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
try {
StackInfo stackInfo = createStack (cloudSiteId,
+ cloudOwner,
tenantId,
instanceName,
heatTemplate,
@@ -697,11 +702,12 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
throws VduException
{
String cloudSiteId = cloudInfo.getCloudSiteId();
+ String cloudOwner = cloudInfo.getCloudOwner();
String tenantId = cloudInfo.getTenantId();
try {
// Query the Cloudify Deployment object and populate a VduInstance
- StackInfo stackInfo = queryStack (cloudSiteId, tenantId, instanceId);
+ StackInfo stackInfo = queryStack (cloudSiteId, cloudOwner, tenantId, instanceId);
return stackInfoToVduInstance(stackInfo);
}
@@ -719,11 +725,12 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
throws VduException
{
String cloudSiteId = cloudInfo.getCloudSiteId();
+ String cloudOwner = cloudInfo.getCloudOwner();
String tenantId = cloudInfo.getTenantId();
try {
// Delete the Multicloud stack
- StackInfo stackInfo = deleteStack (cloudSiteId, tenantId, instanceId);
+ StackInfo stackInfo = deleteStack (cloudSiteId, cloudOwner, tenantId, instanceId);
// Populate a VduInstance based on the deleted Cloudify Deployment object
VduInstance vduInstance = stackInfoToVduInstance(stackInfo);