* 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.
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.onap.so.adapters.vdu.VduStateType;
import org.onap.so.adapters.vdu.VduStatus;
import org.onap.so.cloud.CloudConfig;
+import org.onap.so.cloud.authentication.AuthenticationMethodFactory;
+import org.onap.so.cloud.authentication.KeystoneAuthHolder;
+import org.onap.so.cloud.authentication.KeystoneV3Authentication;
+import org.onap.so.cloud.authentication.ServiceEndpointNotFoundException;
import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.db.catalog.beans.CloudSite;
-import org.onap.so.cloud.authentication.AuthenticationMethodFactory;
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.logger.MessageEnum;
-import org.onap.so.logger.MsoAlarmLogger;
+
import org.onap.so.logger.MsoLogger;
import org.onap.so.openstack.beans.HeatCacheEntry;
import org.onap.so.openstack.beans.HeatStatus;
private static final String DELETE_STACK = "DeleteStack";
- private static final String HEAT_ERROR = "HeatError";
+ protected static final String HEAT_ERROR = "HeatError";
- private static final String CREATE_STACK = "CreateStack";
+ protected static final String CREATE_STACK = "CreateStack";
// Cache Heat Clients statically. Since there is just one MSO user, there is no
// benefit to re-authentication on every request (or across different flows). The
// Fetch cloud configuration each time (may be cached in CloudConfig class)
@Autowired
protected CloudConfig cloudConfig;
-
+
@Autowired
private Environment environment;
@Autowired
private AuthenticationMethodFactory authenticationMethodFactory;
-
+
@Autowired
private MsoTenantUtilsFactory tenantUtilsFactory;
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, MsoHeatUtils.class);
+ @Autowired
+ private KeystoneV3Authentication keystoneV3Authentication;
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, MsoHeatUtils.class);
+
// Properties names and variables (with default values)
- protected String createPollIntervalProp = "ecomp.mso.adapters.po.pollInterval";
- private String deletePollIntervalProp = "ecomp.mso.adapters.po.pollInterval";
- private String deletePollTimeoutProp = "ecomp.mso.adapters.po.pollTimeout";
+ protected String createPollIntervalProp = "onap.so.adapters.po.pollInterval";
+ private String deletePollIntervalProp = "onap.so.adapters.po.pollInterval";
+ private String deletePollTimeoutProp = "onap.so.adapters.po.pollTimeout";
protected static final String createPollIntervalDefault = "15";
private static final String deletePollIntervalDefault = "15";
-
+
private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
/**
Map <String, Object> files,
Map <String, Object> heatFiles,
boolean backout) throws MsoException {
- // Create local variables checking to see if we have an environment, nested, get_files
- // Could later add some checks to see if it's valid.
- boolean haveEnvtVariable = true;
- if (environment == null || "".equalsIgnoreCase (environment.trim ())) {
- haveEnvtVariable = false;
- LOGGER.debug ("createStack called with no environment variable");
- } else {
- LOGGER.debug ("createStack called with an environment variable: " + environment);
- }
- boolean haveFiles = true;
- if (files == null || files.isEmpty ()) {
- haveFiles = false;
- LOGGER.debug ("createStack called with no files / child template ids");
- } else {
- LOGGER.debug ("createStack called with " + files.size () + " files / child template ids");
+ // Take out the multicloud inputs, if present.
+ for (String key : MsoMulticloudUtils.MULTICLOUD_INPUTS) {
+ if (stackInputs.containsKey(key)) {
+ stackInputs.remove(key);
+ if (stackInputs.isEmpty()) {
+ break;
+ }
+ }
}
- boolean haveHeatFiles = true;
- if (heatFiles == null || heatFiles.isEmpty ()) {
- haveHeatFiles = false;
- LOGGER.debug ("createStack called with no heatFiles");
- } else {
- LOGGER.debug ("createStack called with " + heatFiles.size () + " heatFiles");
- }
+ CreateStackParam stack = createStackParam(stackName, heatTemplate, stackInputs, timeoutMinutes, environment, files, heatFiles);
// Obtain the cloud site information where we will create the stack
CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId).orElseThrow(
// This could throw MsoTenantNotFound or MsoOpenstackException (both propagated)
Heat heatClient = getHeatClient (cloudSite, tenantId);
if (heatClient != null) {
- LOGGER.debug("Found: " + heatClient.toString());
+ LOGGER.debug("Found: " + heatClient.toString());
}
LOGGER.debug ("Ready to Create Stack (" + heatTemplate + ") with input params: " + stackInputs);
- //force entire stackInput object to generic Map<String, Object> for openstack compatibility
- ObjectMapper mapper = new ObjectMapper();
- Map<String, Object> normalized = new HashMap<>();
- try {
- normalized = mapper.readValue(mapper.writeValueAsString(stackInputs), new TypeReference<HashMap<String,Object>>() {});
- } catch (IOException e1) {
- LOGGER.debug("could not map json", e1);
- }
-
- // Build up the stack to create
- // Disable auto-rollback, because error reason is lost. Always rollback in the code.
- CreateStackParam stack = new CreateStackParam ();
- stack.setStackName (stackName);
- stack.setTimeoutMinutes (timeoutMinutes);
- stack.setParameters (normalized);
- stack.setTemplate (heatTemplate);
- stack.setDisableRollback (true);
- // TJM New for PO Adapter - add envt variable
- if (haveEnvtVariable) {
- LOGGER.debug ("Found an environment variable - value: " + environment);
- stack.setEnvironment (environment);
- }
- // Now handle nested templates or get_files - have to combine if we have both
- // as they're both treated as "files:" on the stack.
- if (haveFiles && haveHeatFiles) {
- // Let's do this here - not in the bean
- LOGGER.debug ("Found files AND heatFiles - combine and add!");
- Map <String, Object> combinedFiles = new HashMap <> ();
- for (Entry<String, Object> entry : files.entrySet()) {
- combinedFiles.put(entry.getKey(), entry.getValue());
- }
- for (Entry<String, Object> entry : heatFiles.entrySet()) {
- combinedFiles.put(entry.getKey(), entry.getValue());
- }
- stack.setFiles (combinedFiles);
- } else {
- // Handle if we only have one or neither:
- if (haveFiles) {
- LOGGER.debug ("Found files - adding to stack");
- stack.setFiles (files);
- }
- if (haveHeatFiles) {
- LOGGER.debug ("Found heatFiles - adding to stack");
- // the setFiles was modified to handle adding the entries
- stack.setFiles (heatFiles);
- }
- }
-
- // 1802 - attempt to add better formatted printout of request to openstack
- try {
- Map<String, Object> inputs = new HashMap<>();
- for (Entry<String, ?> entry : stackInputs.entrySet()) {
- if (entry.getValue() != null) {
- inputs.put(entry.getKey(), entry.getValue());
- }
- }
- LOGGER.debug(this.printStackRequest(tenantId, heatFiles, files, environment, inputs, stackName, heatTemplate, timeoutMinutes, backout, cloudSiteId));
- } catch (Exception e) {
- // that's okay - this is a nice-to-have
- LOGGER.debug("(had an issue printing nicely formatted request to debuglog) " + e.getMessage());
- }
-
Stack heatStack = null;
try {
// Execute the actual Openstack command to create the Heat stack
throw me;
} else {
// Convert the OpenStackResponseException to an MsoOpenstackException
- LOGGER.debug("ERROR STATUS = " + e.getStatus() + ",\n" + e.getMessage() + "\n" + e.getLocalizedMessage());
+ LOGGER.debug("ERROR STATUS = " + e.getStatus() + ",\n" + e.getMessage() + "\n" + e.getLocalizedMessage());
throw heatExceptionToMsoException (e, CREATE_STACK);
}
} catch (OpenStackConnectException e) {
// 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.s
-
- int createPollInterval = Integer.parseInt(this.environment.getProperty(createPollIntervalProp, createPollIntervalDefault));
+
+ int createPollInterval = Integer.parseInt(this.environment.getProperty(createPollIntervalProp, createPollIntervalDefault));
int pollTimeout = (timeoutMinutes * 60) + createPollInterval;
// New 1610 - poll on delete if we rollback - use same values for now
int deletePollInterval = createPollInterval;
}
// MsoOpenstackException me = new MsoOpenstackException(0, "", stackErrorStatusReason.toString());
// me.addContext(CREATE_STACK);
- // alarmLogger.sendAlarm(HEAT_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage());
+
// throw me;
} catch (Exception e2) {
// shouldn't happen - but handle
}
MsoOpenstackException me = new MsoOpenstackException(0, "", stackErrorStatusReason.toString());
me.addContext(CREATE_STACK);
- alarmLogger.sendAlarm(HEAT_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage());
+
throw me;
}
else {
LOGGER.debug ("Heat Client is NULL" );
}
-
+
executeAndRecordOpenstackRequest (request);
} catch (OpenStackResponseException e) {
if (e.getStatus () == 404) {
if (pollForCompletion) {
// Set a timeout on polling
-
+
int pollInterval = Integer.parseInt(this.environment.getProperty(deletePollIntervalProp, "" + deletePollIntervalDefault));
int pollTimeout = Integer.parseInt(this.environment.getProperty(deletePollTimeoutProp, "" + deletePollIntervalDefault));
me.addContext (DELETE_STACK);
// Alarm this condition, stack deletion failed
- alarmLogger.sendAlarm (HEAT_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage ());
+
throw me;
}
me.addContext (DELETE_STACK);
// Alarm this condition, stack deletion failed
- alarmLogger.sendAlarm (HEAT_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage ());
+
throw me;
}
// Remove any extraneous parameters (don't throw an error)
Map <String, Object> updatedParams = new HashMap <> ();
List <String> extraParams = new ArrayList <> ();
-
+
for (Entry<String, Object> entry : inputParams.entrySet()) {
if (!paramList.contains(entry.getKey())) {
// This is not a valid parameter for this template
*/
public Heat getHeatClient (CloudSite cloudSite, String tenantId) throws MsoException {
String cloudId = cloudSite.getId();
-
+ // For DCP/LCP, the region should be the cloudId.
+ String region = cloudSite.getRegionId ();
+
// Check first in the cache of previously authorized clients
String cacheKey = cloudId + ":" + tenantId;
if (heatClientCache.containsKey (cacheKey)) {
MsoTenantUtils tenantUtils = tenantUtilsFactory.getTenantUtilsByServerType(cloudIdentity.getIdentityServerType());
String keystoneUrl = tenantUtils.getKeystoneUrl(cloudId, cloudIdentity);
LOGGER.debug("keystoneUrl=" + keystoneUrl);
- Keystone keystoneTenantClient = new Keystone (keystoneUrl);
- Access access = null;
- try {
- Authentication credentials = authenticationMethodFactory.getAuthenticationFor(cloudIdentity);
-
- OpenStackRequest <Access> request = keystoneTenantClient.tokens ()
- .authenticate (credentials).withTenantId (tenantId);
-
- access = executeAndRecordOpenstackRequest (request);
- } catch (OpenStackResponseException e) {
+ String heatUrl = null;
+ String tokenId = null;
+ Calendar expiration = null;
+ try {
+ 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 {
+ LOGGER.debug("access=" + access.toString());
+ for (Access.Service service : access.getServiceCatalog()) {
+ List<Access.Service.Endpoint> endpoints = service.getEndpoints();
+ for (Access.Service.Endpoint endpoint : endpoints) {
+ LOGGER.debug("AIC returned region=" + endpoint.getRegion());
+ }
+ }
+ } catch (Exception e) {
+ LOGGER.debug("Encountered an error trying to printout Access object returned from AIC. " + e.getMessage());
+ }
+ heatUrl = KeystoneUtils.findEndpointURL (access.getServiceCatalog (), "orchestration", region, "public");
+ LOGGER.debug("heatUrl=" + heatUrl + ", region=" + region);
+ } catch (RuntimeException e) {
+ // This comes back for not found (probably an incorrect region ID)
+ String error = "AIC did not match an orchestration service for: region=" + region + ",cloud=" + cloudIdentity.getIdentityUrl();
+ 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)
+ String error = "cloud did not match an orchestration service for: region=" + region + ",cloud=" + cloudIdentity.getIdentityUrl();
+ throw new MsoAdapterException (error, e);
+ }
+ }
+ } catch (OpenStackResponseException e) {
if (e.getStatus () == 401) {
// Authentication error.
String error = "Authentication Failure: tenant=" + tenantId + ",cloud=" + cloudIdentity.getId ();
- alarmLogger.sendAlarm ("MsoAuthenticationError", MsoAlarmLogger.CRITICAL, error);
+
throw new MsoAdapterException (error);
} else {
throw keystoneErrorToMsoException (e, TOKEN_AUTH);
throw runtimeExceptionToMsoException (e, TOKEN_AUTH);
}
- // For DCP/LCP, the region should be the cloudId.
- String region = cloudSite.getRegionId ();
- String heatUrl = null;
- try {
- // Isolate trying to printout the region IDs
- try {
- LOGGER.debug("access=" + access.toString());
- for (Access.Service service : access.getServiceCatalog()) {
- List<Access.Service.Endpoint> endpoints = service.getEndpoints();
- for (Access.Service.Endpoint endpoint : endpoints) {
- LOGGER.debug("AIC returned region=" + endpoint.getRegion());
- }
- }
- } catch (Exception e) {
- LOGGER.debug("Encountered an error trying to printout Access object returned from AIC. " + e.getMessage());
- }
- heatUrl = KeystoneUtils.findEndpointURL (access.getServiceCatalog (), "orchestration", region, "public");
- LOGGER.debug("heatUrl=" + heatUrl + ", region=" + region);
- } catch (RuntimeException e) {
- // This comes back for not found (probably an incorrect region ID)
- String error = "AIC did not match an orchestration service for: region=" + region + ",cloud=" + cloudIdentity.getIdentityUrl();
- alarmLogger.sendAlarm ("MsoConfigurationError", MsoAlarmLogger.CRITICAL, error);
- throw new MsoAdapterException (error, e);
- }
-
Heat heatClient = new Heat (heatUrl);
- heatClient.token (access.getToken ().getId ());
+ heatClient.token (tokenId);
heatClientCache.put (cacheKey,
new HeatCacheEntry (heatUrl,
- access.getToken ().getId (),
- access.getToken ().getExpires ()));
+ tokenId,
+ expiration));
LOGGER.debug ("Caching HEAT Client for " + cacheKey);
return heatClient;
*/
protected Stack queryHeatStack (Heat heatClient, String stackName) throws MsoException {
if (stackName == null) {
- return null;
+ return null;
}
try {
OpenStackRequest <Stack> request = heatClient.getStacks ().byName (stackName);
}
- private StringBuilder getOutputsAsStringBuilder(Stack heatStack) {
+ protected StringBuilder getOutputsAsStringBuilder(Stack heatStack) {
// This should only be used as a utility to print out the stack outputs
// to the log
StringBuilder sb = new StringBuilder("");
} catch (Exception e) {
LOGGER.debug("Exception :",e);
sb.append("(a LinkedHashMap value that would not convert nicely)");
- }
+ }
} else if (obj instanceof Integer) {
String str = "";
try {
sb.append("[END]");
return sb;
}
-
-
+
+
public void copyBaseOutputsToInputs(Map<String, Object> inputs,
Map<String, Object> otherStackOutputs, List<String> paramNames, Map<String, String> aliases) {
if (inputs == null || otherStackOutputs == null)
}
return;
}
-
+
public List<String> convertCdlToArrayList(String cdl) {
String cdl2 = cdl.trim();
String cdl3;
}
return new ArrayList<>(Arrays.asList(cdl3.split(",")));
}
-
+
/**
* New with 1707 - this method will convert all the String *values* of the inputs
* to their "actual" object type (based on the param type: in the db - which comes from the template):
HashMap<String, Object> newInputs = new HashMap<>();
HashMap<String, HeatTemplateParam> params = new HashMap<>();
HashMap<String, HeatTemplateParam> paramAliases = new HashMap<>();
-
+
if (inputs == null) {
LOGGER.debug("convertInputMap - inputs is null - nothing to do here");
return new HashMap<>();
}
-
+
LOGGER.debug("convertInputMap in MsoHeatUtils called, with " + inputs.size() + " inputs, and template " + template.getArtifactUuid());
try {
LOGGER.debug(template.toString());
} catch (Exception e) {
LOGGER.debug("Exception occurred in convertInputMap:" + e.getMessage(), e);
}
-
+
for (HeatTemplateParam htp : template.getParameters()) {
LOGGER.debug("Adding " + htp.getParamName());
params.put(htp.getParamName(), htp);
if ("string".equalsIgnoreCase(type)) {
// Easiest!
String str = inputs.get(key);
- if (alias)
+ if (alias)
newInputs.put(realName, str);
- else
+ else
newInputs.put(key, str);
} else if ("number".equalsIgnoreCase(type)) {
String integerString = inputs.get(key);
}
return newInputs;
}
-
- /*
- * This helpful method added for Valet
+
+ /*
+ * This helpful method added for Valet
*/
public String getCloudSiteKeystoneUrl(String cloudSiteId) throws MsoCloudSiteNotFound {
String keystone_url = null;
}
return keystone_url;
}
-
+
/*
- * Create a string suitable for being dumped to a debug log that creates a
+ * Create a string suitable for being dumped to a debug log that creates a
* pseudo-JSON request dumping what's being sent to Openstack API in the create or update request
*/
-
- private String printStackRequest(String tenantId,
+
+ private String printStackRequest(String tenantId,
Map<String, Object> heatFiles,
Map<String, Object> nestedTemplates,
String environment,
- Map<String, Object> inputs,
+ Map<String, Object> inputs,
String vfModuleName,
String template,
int timeoutMinutes,
sb.append("{\n");
sb.append(" \"stack_name\": \"" + vfModuleName + "\",\n");
sb.append(" \"disable_rollback\": " + backout + ",\n");
- sb.append(" \"timeout_mins\": " + timeoutMinutes + ",\n");
+ sb.append(" \"timeout_mins\": " + timeoutMinutes + ",\n");
sb.append(" \"template\": {\n");
sb.append(template);
sb.append(" },\n");
sb.append(" \"environment\": {\n");
- if (environment == null)
+ if (environment == null)
sb.append("<none>");
- else
+ else
sb.append(environment);
sb.append(" },\n");
sb.append(" \"files\": {\n");
}
}
sb.append("\n }\n}\n");
-
+
return sb.toString();
}
-
+
/*******************************************************************************
- *
+ *
* Methods (and associated utilities) to implement the VduPlugin interface
- *
+ *
*******************************************************************************/
-
+
/**
* VduPlugin interface for instantiate function.
- *
+ *
* Translate the VduPlugin parameters to the corresponding 'createStack' parameters,
* and then invoke the existing function.
*/
{
String cloudSiteId = cloudInfo.getCloudSiteId();
String tenantId = cloudInfo.getTenantId();
-
+
// Translate the VDU ModelInformation structure to that which is needed for
// creating the Heat stack. Loop through the artifacts, looking specifically
// for MAIN_TEMPLATE and ENVIRONMENT. Any other artifact will
Map<String,Object> nestedTemplates = new HashMap<>();
Map<String,Object> files = new HashMap<>();
String heatEnvironment = null;
-
+
for (VduArtifact vduArtifact: vduModel.getArtifacts()) {
if (vduArtifact.getType() == ArtifactType.MAIN_TEMPLATE) {
heatTemplate = new String(vduArtifact.getContent());
heatEnvironment = new String(vduArtifact.getContent());
}
}
-
+
try {
StackInfo stackInfo = createStack (cloudSiteId,
tenantId,
nestedTemplates,
files,
rollbackOnFailure);
-
+
// Populate a vduInstance from the StackInfo
return stackInfoToVduInstance(stackInfo);
}
throw new VduException ("MsoHeatUtils (instantiateVDU): createStack Exception", e);
}
}
-
-
+
+
/**
* VduPlugin interface for query function.
*/
{
String cloudSiteId = cloudInfo.getCloudSiteId();
String tenantId = cloudInfo.getTenantId();
-
+
try {
// Query the Cloudify Deployment object and populate a VduInstance
StackInfo stackInfo = queryStack (cloudSiteId, tenantId, instanceId);
-
+
return stackInfoToVduInstance(stackInfo);
}
catch (Exception e) {
throw new VduException ("MsoHeatUtile (queryVdu): queryStack Exception ", e);
}
}
-
-
+
+
/**
* VduPlugin interface for delete function.
*/
{
String cloudSiteId = cloudInfo.getCloudSiteId();
String tenantId = cloudInfo.getTenantId();
-
+
try {
// Delete the Heat stack
StackInfo stackInfo = deleteStack (tenantId, cloudSiteId, instanceId, true);
-
+
// Populate a VduInstance based on the deleted Cloudify Deployment object
VduInstance vduInstance = stackInfoToVduInstance(stackInfo);
-
+
// Override return state to DELETED (HeatUtils sets to NOTFOUND)
vduInstance.getStatus().setState(VduStateType.DELETED);
-
+
return vduInstance;
}
catch (Exception e) {
throw new VduException ("Delete VDU Exception", e);
}
}
-
-
+
+
/**
* VduPlugin interface for update function.
- *
+ *
* Update is currently not supported in the MsoHeatUtils implementation of VduPlugin.
* Just return a VduException.
- *
+ *
*/
@Override
public VduInstance updateVdu (
{
throw new VduException ("MsoHeatUtils: updateVdu interface not supported");
}
-
-
+
+
/*
* Convert the local DeploymentInfo object (Cloudify-specific) to a generic VduInstance object
*/
- private VduInstance stackInfoToVduInstance (StackInfo stackInfo)
+ protected VduInstance stackInfoToVduInstance (StackInfo stackInfo)
{
VduInstance vduInstance = new VduInstance();
-
+
// The full canonical name as the instance UUID
vduInstance.setVduInstanceId(stackInfo.getCanonicalName());
vduInstance.setVduInstanceName(stackInfo.getName());
-
+
// Copy inputs and outputs
vduInstance.setInputs(stackInfo.getParameters());
vduInstance.setOutputs(stackInfo.getOutputs());
-
+
// Translate the status elements
vduInstance.setStatus(stackStatusToVduStatus (stackInfo));
-
+
return vduInstance;
}
-
+
private VduStatus stackStatusToVduStatus (StackInfo stackInfo)
{
VduStatus vduStatus = new VduStatus();
-
+
// Map the status fields to more generic VduStatus.
// There are lots of HeatStatus values, so this is a bit long...
HeatStatus heatStatus = stackInfo.getStatus();
String statusMessage = stackInfo.getStatusMessage();
-
+
if (heatStatus == HeatStatus.INIT || heatStatus == HeatStatus.BUILDING) {
vduStatus.setState(VduStateType.INSTANTIATING);
vduStatus.setLastAction((new PluginAction ("create", "in_progress", statusMessage)));
} else {
vduStatus.setState(VduStateType.UNKNOWN);
}
-
+
return vduStatus;
}
-
- private void sleep(long time) {
+
+ protected void sleep(long time) {
try {
Thread.sleep(time);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
-
+
}