use of org.onap.so.adapters.vdu.VduInstance in project so by onap.
the class MsoHeatUtils method stackInfoToVduInstance.
/*
* Convert the local DeploymentInfo object (Cloudify-specific) to a generic VduInstance object
*/
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;
}
use of org.onap.so.adapters.vdu.VduInstance 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.VduInstance in project so by onap.
the class MsoHeatUtilsITTest method queryVduTest.
@Test
public void queryVduTest() throws Exception {
VduInstance expected = new VduInstance();
expected.setVduInstanceId("name/da886914-efb2-4917-b335-c8381528d90b");
expected.setVduInstanceName("name");
VduStatus status = new VduStatus();
status.setState(VduStateType.INSTANTIATED);
status.setLastAction((new PluginAction("create", "complete", null)));
expected.setStatus(status);
CloudInfo cloudInfo = new CloudInfo();
cloudInfo.setCloudSiteId("mtn13");
cloudInfo.setTenantId("tenantId");
String instanceId = "instanceId";
StubOpenStack.mockOpenStackResponseAccess(wireMockServer, wireMockPort);
StubOpenStack.mockOpenStackPostStack_200(wireMockServer, "OpenstackResponse_Stack_Created.json");
wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/instanceId")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("OpenstackResponse_StackId.json").withStatus(HttpStatus.SC_OK)));
VduInstance actual = heatUtils.queryVdu(cloudInfo, instanceId);
assertThat(actual, sameBeanAs(expected));
}
use of org.onap.so.adapters.vdu.VduInstance 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;
}
use of org.onap.so.adapters.vdu.VduInstance in project so by onap.
the class MsoMulticloudUtils method stackInfoToVduInstance.
/*
* Convert the local DeploymentInfo object (Cloudify-specific) to a generic VduInstance object
*/
@Override
protected VduInstance stackInfoToVduInstance(StackInfo stackInfo) {
VduInstance vduInstance = new VduInstance();
if (logger.isDebugEnabled()) {
logger.debug(String.format("StackInfo to convert: %s", stackInfo.getParameters().toString()));
}
// 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;
}
Aggregations