Search in sources :

Example 1 with VduInstance

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;
}
Also used : VduInstance(org.onap.so.adapters.vdu.VduInstance)

Example 2 with 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);
    }
}
Also used : VduInstance(org.onap.so.adapters.vdu.VduInstance) StackInfo(org.onap.so.openstack.beans.StackInfo) MsoAdapterException(org.onap.so.openstack.exceptions.MsoAdapterException) VduException(org.onap.so.adapters.vdu.VduException) MsoOpenstackException(org.onap.so.openstack.exceptions.MsoOpenstackException) MalformedURLException(java.net.MalformedURLException) UriBuilderException(javax.ws.rs.core.UriBuilderException) MsoException(org.onap.so.openstack.exceptions.MsoException) VduException(org.onap.so.adapters.vdu.VduException)

Example 3 with VduInstance

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));
}
Also used : CloudInfo(org.onap.so.adapters.vdu.CloudInfo) VduInstance(org.onap.so.adapters.vdu.VduInstance) VduStatus(org.onap.so.adapters.vdu.VduStatus) PluginAction(org.onap.so.adapters.vdu.PluginAction) Test(org.junit.Test) BaseTest(org.onap.so.BaseTest)

Example 4 with VduInstance

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;
}
Also used : VduPlugin(org.onap.so.adapters.vdu.VduPlugin) CloudInfo(org.onap.so.adapters.vdu.CloudInfo) VnfException(org.onap.so.adapters.vnf.exceptions.VnfException) VduInstance(org.onap.so.adapters.vdu.VduInstance) VduException(org.onap.so.adapters.vdu.VduException)

Example 5 with VduInstance

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;
}
Also used : VduInstance(org.onap.so.adapters.vdu.VduInstance)

Aggregations

VduInstance (org.onap.so.adapters.vdu.VduInstance)12 CloudInfo (org.onap.so.adapters.vdu.CloudInfo)8 VduException (org.onap.so.adapters.vdu.VduException)6 Test (org.junit.Test)4 BaseTest (org.onap.so.BaseTest)4 VduPlugin (org.onap.so.adapters.vdu.VduPlugin)4 VnfException (org.onap.so.adapters.vnf.exceptions.VnfException)4 VduStatus (org.onap.so.adapters.vdu.VduStatus)3 MsoException (org.onap.so.openstack.exceptions.MsoException)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 PluginAction (org.onap.so.adapters.vdu.PluginAction)2 VduModelInfo (org.onap.so.adapters.vdu.VduModelInfo)2 StackInfo (org.onap.so.openstack.beans.StackInfo)2 MsoOpenstackException (org.onap.so.openstack.exceptions.MsoOpenstackException)2 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 OpenStackConnectException (com.woorea.openstack.base.client.OpenStackConnectException)1 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1