use of org.onap.so.adapters.vdu.VduException in project so by onap.
the class MsoHeatUtils method queryVdu.
/**
* VduPlugin interface for query function.
*/
@Override
public VduInstance queryVdu(CloudInfo cloudInfo, String instanceId) 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, cloudOwner, tenantId, instanceId);
return stackInfoToVduInstance(stackInfo);
} catch (Exception e) {
throw new VduException("MsoHeatUtile (queryVdu): queryStack Exception ", e);
}
}
use of org.onap.so.adapters.vdu.VduException in project so by onap.
the class MsoMulticloudUtils method instantiateVdu.
/**
* VduPlugin interface for instantiate function.
*
* Translate the VduPlugin parameters to the corresponding 'createStack' parameters, and then invoke the existing
* function.
*/
@Override
public VduInstance instantiateVdu(CloudInfo cloudInfo, String instanceName, Map<String, Object> inputs, VduModelInfo vduModel, boolean rollbackOnFailure) 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
// creating the Heat stack. Loop through the artifacts, looking specifically
// for MAIN_TEMPLATE and ENVIRONMENT. Any other artifact will
// be attached as a FILE.
String heatTemplate = null;
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());
} else if (vduArtifact.getType() == ArtifactType.NESTED_TEMPLATE) {
nestedTemplates.put(vduArtifact.getName(), new String(vduArtifact.getContent()));
} else if (vduArtifact.getType() == ArtifactType.ENVIRONMENT) {
heatEnvironment = new String(vduArtifact.getContent());
}
}
try {
StackInfo stackInfo = createStack(cloudSiteId, cloudOwner, tenantId, instanceName, vduModel, heatTemplate, // poll
inputs, // poll
true, // completion
vduModel.getTimeoutMinutes(), heatEnvironment, nestedTemplates, files, rollbackOnFailure, false);
// Populate a vduInstance from the StackInfo
return stackInfoToVduInstance(stackInfo);
} catch (Exception e) {
throw new VduException("MsoMulticloudUtils (instantiateVDU): createStack Exception", e);
}
}
use of org.onap.so.adapters.vdu.VduException in project so by onap.
the class MsoMulticloudUtils method deleteVdu.
/**
* VduPlugin interface for delete function.
*/
@Override
public VduInstance deleteVdu(CloudInfo cloudInfo, String instanceId, int timeoutMinutes) throws VduException {
String cloudSiteId = cloudInfo.getCloudSiteId();
String cloudOwner = cloudInfo.getCloudOwner();
String tenantId = cloudInfo.getTenantId();
try {
// Delete the Multicloud stack
StackInfo stackInfo = deleteStack(cloudSiteId, cloudOwner, tenantId, instanceId);
// Populate a VduInstance based on the deleted Cloudify Deployment object
VduInstance vduInstance = stackInfoToVduInstance(stackInfo);
// Override return state to DELETED (MulticloudUtils sets to NOTFOUND)
vduInstance.getStatus().setState(VduStateType.DELETED);
return vduInstance;
} catch (Exception e) {
throw new VduException("Delete VDU Exception", e);
}
}
use of org.onap.so.adapters.vdu.VduException in project so by onap.
the class MsoMulticloudUtils method queryVdu.
/**
* VduPlugin interface for query function.
*/
@Override
public VduInstance queryVdu(CloudInfo cloudInfo, String instanceId) 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, cloudOwner, tenantId, instanceId);
return stackInfoToVduInstance(stackInfo);
} catch (Exception e) {
throw new VduException("MsoMulticloudUtils (queryVdu): queryStack Exception ", e);
}
}
use of org.onap.so.adapters.vdu.VduException in project so by onap.
the class MsoVnfPluginAdapterImpl method queryVnf.
/**
* This is the "Query VNF" web service implementation.
*
* This really should be QueryVfModule, but nobody ever changed it.
*
* The method returns an indicator that the VNF exists, along with its status and outputs. The input "vnfName" will
* also be reflected back as its ID.
*
* @param cloudSiteId CLLI code of the cloud site in which to query
* @param tenantId Openstack tenant identifier
* @param vnfNameOrId VNF Name or ID to query
* @param msoRequest Request tracking information for logs
* @param vnfExists Flag reporting the result of the query
* @param vnfId Holder for output VNF ID
* @param outputs Holder for Map of outputs from the deployed VF Module (assigned IPs, etc)
*/
public void queryVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfNameOrId, MsoRequest msoRequest, Holder<Boolean> vnfExists, Holder<String> vnfId, Holder<VnfStatus> status, Holder<Map<String, String>> outputs) throws VnfException {
logger.debug("Querying VNF " + vnfNameOrId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId);
// Will capture execution time for metrics
long startTime = System.currentTimeMillis();
long subStartTime = System.currentTimeMillis();
VduInstance vduInstance = null;
CloudInfo cloudInfo = new CloudInfo(cloudSiteId, cloudOwner, tenantId, null);
VduPlugin vduPlugin = getVduPlugin(cloudSiteId, cloudOwner);
try {
vduInstance = vduPlugin.queryVdu(cloudInfo, vnfNameOrId);
} catch (VduException e) {
// Failed to query the VDU due to a plugin exception.
// Convert to a generic VnfException
e.addContext("QueryVNF");
String error = "Query VNF (VDU): " + vnfNameOrId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + ": " + e;
logger.error("{} {} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), vnfNameOrId, cloudOwner, cloudSiteId, tenantId, "VDU", "QueryVNF", ErrorCode.DataError.getValue(), "Exception - queryVDU", e);
logger.debug(error);
throw new VnfException(e);
}
if (vduInstance != null && vduInstance.getStatus().getState() != VduStateType.NOTFOUND) {
vnfExists.value = Boolean.TRUE;
status.value = vduStatusToVnfStatus(vduInstance);
vnfId.value = vduInstance.getVduInstanceId();
outputs.value = copyStringOutputs(vduInstance.getOutputs());
logger.debug("VNF {} found, ID = {}", vnfNameOrId, vnfId.value);
} else {
vnfExists.value = Boolean.FALSE;
status.value = VnfStatus.NOTFOUND;
vnfId.value = null;
// Return as an empty map
outputs.value = new HashMap<String, String>();
logger.debug("VNF {} not found", vnfNameOrId);
}
return;
}
Aggregations