Search in sources :

Example 1 with VduException

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);
    }
}
Also used : StackInfo(org.onap.so.openstack.beans.StackInfo) VduException(org.onap.so.adapters.vdu.VduException) OpenStackConnectException(com.woorea.openstack.base.client.OpenStackConnectException) OpenStackResponseException(com.woorea.openstack.base.client.OpenStackResponseException) MsoException(org.onap.so.openstack.exceptions.MsoException) MsoOpenstackException(org.onap.so.openstack.exceptions.MsoOpenstackException) IOException(java.io.IOException) HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) VduException(org.onap.so.adapters.vdu.VduException)

Example 2 with VduException

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);
    }
}
Also used : HashMap(java.util.HashMap) StackInfo(org.onap.so.openstack.beans.StackInfo) VduArtifact(org.onap.so.adapters.vdu.VduArtifact) 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 VduException

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);
    }
}
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 4 with VduException

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);
    }
}
Also used : 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 5 with VduException

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;
}
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)

Aggregations

VduException (org.onap.so.adapters.vdu.VduException)10 MsoException (org.onap.so.openstack.exceptions.MsoException)7 VduInstance (org.onap.so.adapters.vdu.VduInstance)6 StackInfo (org.onap.so.openstack.beans.StackInfo)6 MsoOpenstackException (org.onap.so.openstack.exceptions.MsoOpenstackException)6 CloudInfo (org.onap.so.adapters.vdu.CloudInfo)4 VduPlugin (org.onap.so.adapters.vdu.VduPlugin)4 VnfException (org.onap.so.adapters.vnf.exceptions.VnfException)4 OpenStackConnectException (com.woorea.openstack.base.client.OpenStackConnectException)3 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)3 IOException (java.io.IOException)3 MalformedURLException (java.net.MalformedURLException)3 HashMap (java.util.HashMap)3 UriBuilderException (javax.ws.rs.core.UriBuilderException)3 MsoAdapterException (org.onap.so.openstack.exceptions.MsoAdapterException)3 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)3 VduArtifact (org.onap.so.adapters.vdu.VduArtifact)2 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 ArrayList (java.util.ArrayList)1 VduModelInfo (org.onap.so.adapters.vdu.VduModelInfo)1