Search in sources :

Example 1 with VduArtifact

use of org.onap.so.adapters.vdu.VduArtifact 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 2 with VduArtifact

use of org.onap.so.adapters.vdu.VduArtifact in project so by onap.

the class VfModuleCustomizationToVduMapper method mapHeatTemplateToVduArtifact.

private VduArtifact mapHeatTemplateToVduArtifact(HeatTemplate heatTemplate, ArtifactType artifactType) {
    VduArtifact vduArtifact = new VduArtifact();
    vduArtifact.setName(heatTemplate.getTemplateName());
    vduArtifact.setContent(heatTemplate.getHeatTemplate().getBytes());
    vduArtifact.setType(artifactType);
    return vduArtifact;
}
Also used : VduArtifact(org.onap.so.adapters.vdu.VduArtifact)

Example 3 with VduArtifact

use of org.onap.so.adapters.vdu.VduArtifact in project so by onap.

the class VfModuleCustomizationToVduMapper method mapEnvironmentFileToVduArtifact.

private VduArtifact mapEnvironmentFileToVduArtifact(HeatEnvironment heatEnv) {
    VduArtifact vduArtifact = new VduArtifact();
    vduArtifact.setName(heatEnv.getName());
    vduArtifact.setContent(heatEnv.getEnvironment().getBytes());
    vduArtifact.setType(ArtifactType.ENVIRONMENT);
    return vduArtifact;
}
Also used : VduArtifact(org.onap.so.adapters.vdu.VduArtifact)

Example 4 with VduArtifact

use of org.onap.so.adapters.vdu.VduArtifact in project so by onap.

the class VfModuleCustomizationToVduMapper method mapCloudTemplates.

private void mapCloudTemplates(HeatTemplate heatTemplate, VduModelInfo vduModel) {
    // TODO: These catalog objects will be refactored to be non-Heat-specific
    List<VduArtifact> vduArtifacts = vduModel.getArtifacts();
    // Main template. Also set the VDU timeout based on the main template.
    vduArtifacts.add(mapHeatTemplateToVduArtifact(heatTemplate, ArtifactType.MAIN_TEMPLATE));
    vduModel.setTimeoutMinutes(heatTemplate.getTimeoutMinutes());
    // Nested templates
    List<HeatTemplate> childTemplates = heatTemplate.getChildTemplates();
    if (childTemplates != null) {
        for (HeatTemplate childTemplate : childTemplates) {
            vduArtifacts.add(mapHeatTemplateToVduArtifact(childTemplate, ArtifactType.NESTED_TEMPLATE));
        }
    }
}
Also used : HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) VduArtifact(org.onap.so.adapters.vdu.VduArtifact)

Example 5 with VduArtifact

use of org.onap.so.adapters.vdu.VduArtifact in project so by onap.

the class VfModuleCustomizationToVduMapper method mapCloudFileToVduArtifact.

private VduArtifact mapCloudFileToVduArtifact(HeatFiles heatFile, ArtifactType artifactType) {
    VduArtifact vduArtifact = new VduArtifact();
    vduArtifact.setName(heatFile.getFileName());
    vduArtifact.setContent(heatFile.getFileBody().getBytes());
    vduArtifact.setType(artifactType);
    return vduArtifact;
}
Also used : VduArtifact(org.onap.so.adapters.vdu.VduArtifact)

Aggregations

VduArtifact (org.onap.so.adapters.vdu.VduArtifact)8 HashMap (java.util.HashMap)3 VduException (org.onap.so.adapters.vdu.VduException)2 StackInfo (org.onap.so.openstack.beans.StackInfo)2 MsoException (org.onap.so.openstack.exceptions.MsoException)2 MsoOpenstackException (org.onap.so.openstack.exceptions.MsoOpenstackException)2 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 ArrayList (java.util.ArrayList)1 UriBuilderException (javax.ws.rs.core.UriBuilderException)1 Test (org.junit.Test)1 BaseTest (org.onap.so.BaseTest)1 CloudInfo (org.onap.so.adapters.vdu.CloudInfo)1 PluginAction (org.onap.so.adapters.vdu.PluginAction)1 VduInstance (org.onap.so.adapters.vdu.VduInstance)1 VduModelInfo (org.onap.so.adapters.vdu.VduModelInfo)1 VduStatus (org.onap.so.adapters.vdu.VduStatus)1 HeatFiles (org.onap.so.db.catalog.beans.HeatFiles)1