Search in sources :

Example 1 with OVFEulaSectionTO

use of com.cloud.agent.api.to.deployasis.OVFEulaSectionTO in project cloudstack by apache.

the class DeployAsIsHelperImpl method persistTemplateOVFInformation.

private void persistTemplateOVFInformation(long templateId, OVFInformationTO ovfInformationTO) {
    List<OVFPropertyTO> ovfProperties = ovfInformationTO.getProperties();
    List<OVFNetworkTO> networkRequirements = ovfInformationTO.getNetworks();
    OVFVirtualHardwareSectionTO ovfHardwareSection = ovfInformationTO.getHardwareSection();
    List<OVFEulaSectionTO> eulaSections = ovfInformationTO.getEulaSections();
    Pair<String, String> guestOsInfo = ovfInformationTO.getGuestOsInfo();
    if (CollectionUtils.isNotEmpty(ovfProperties)) {
        persistTemplateDeployAsIsInformationTOList(templateId, ovfProperties);
    }
    if (CollectionUtils.isNotEmpty(networkRequirements)) {
        persistTemplateDeployAsIsInformationTOList(templateId, networkRequirements);
    }
    if (CollectionUtils.isNotEmpty(eulaSections)) {
        persistTemplateDeployAsIsInformationTOList(templateId, eulaSections);
    }
    String minimumHardwareVersion = null;
    if (ovfHardwareSection != null) {
        if (CollectionUtils.isNotEmpty(ovfHardwareSection.getConfigurations())) {
            persistTemplateDeployAsIsInformationTOList(templateId, ovfHardwareSection.getConfigurations());
        }
        if (CollectionUtils.isNotEmpty(ovfHardwareSection.getCommonHardwareItems())) {
            persistTemplateDeployAsIsInformationTOList(templateId, ovfHardwareSection.getCommonHardwareItems());
        }
        minimumHardwareVersion = ovfHardwareSection.getMinimiumHardwareVersion();
    }
    if (guestOsInfo != null) {
        String osType = guestOsInfo.first();
        String osDescription = guestOsInfo.second();
        LOGGER.info("Guest OS information retrieved from the template: " + osType + " - " + osDescription);
        handleGuestOsFromOVFDescriptor(templateId, osType, osDescription, minimumHardwareVersion);
    }
}
Also used : OVFEulaSectionTO(com.cloud.agent.api.to.deployasis.OVFEulaSectionTO) OVFPropertyTO(com.cloud.agent.api.to.deployasis.OVFPropertyTO) OVFNetworkTO(com.cloud.agent.api.to.deployasis.OVFNetworkTO) OVFVirtualHardwareSectionTO(com.cloud.agent.api.to.deployasis.OVFVirtualHardwareSectionTO)

Example 2 with OVFEulaSectionTO

use of com.cloud.agent.api.to.deployasis.OVFEulaSectionTO in project cloudstack by apache.

the class OVFHelper method getEulaSectionsFromDocument.

public List<OVFEulaSectionTO> getEulaSectionsFromDocument(Document doc) {
    List<OVFEulaSectionTO> eulas = new LinkedList<>();
    if (doc == null) {
        return eulas;
    }
    NodeList eulaSections = ovfParser.getElementsFromOVFDocument(doc, "EulaSection");
    int eulaIndex = 0;
    if (eulaSections.getLength() > 0) {
        for (int index = 0; index < eulaSections.getLength(); index++) {
            Node eulaNode = eulaSections.item(index);
            NodeList eulaChildNodes = eulaNode.getChildNodes();
            String eulaInfo = null;
            String eulaLicense = null;
            for (int i = 0; i < eulaChildNodes.getLength(); i++) {
                Node eulaItem = eulaChildNodes.item(i);
                if (eulaItem.getNodeName().equalsIgnoreCase("Info")) {
                    eulaInfo = eulaItem.getTextContent();
                } else if (eulaItem.getNodeName().equalsIgnoreCase("License")) {
                    eulaLicense = eulaItem.getTextContent();
                }
            }
            byte[] compressedLicense = new byte[0];
            try {
                compressedLicense = compressOVFEula(eulaLicense);
            } catch (IOException e) {
                s_logger.error("Could not compress the license for info " + eulaInfo);
                continue;
            }
            OVFEulaSectionTO eula = new OVFEulaSectionTO(eulaInfo, compressedLicense, eulaIndex);
            eulas.add(eula);
            eulaIndex++;
        }
    }
    return eulas;
}
Also used : OVFEulaSectionTO(com.cloud.agent.api.to.deployasis.OVFEulaSectionTO) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) IOException(java.io.IOException) LinkedList(java.util.LinkedList)

Example 3 with OVFEulaSectionTO

use of com.cloud.agent.api.to.deployasis.OVFEulaSectionTO in project cloudstack by apache.

the class OVAProcessor method createOvfInformationTO.

private OVFInformationTO createOvfInformationTO(OVFHelper ovfHelper, Document doc, String ovfFilePath) throws InternalErrorException {
    OVFInformationTO ovfInformationTO = new OVFInformationTO();
    List<DatadiskTO> disks = ovfHelper.getOVFVolumeInfoFromFile(ovfFilePath, doc, null);
    if (CollectionUtils.isNotEmpty(disks)) {
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace(String.format("Found %d disks in template %s", disks.size(), ovfFilePath));
        }
        ovfInformationTO.setDisks(disks);
    }
    List<OVFNetworkTO> nets = ovfHelper.getNetPrerequisitesFromDocument(doc);
    if (CollectionUtils.isNotEmpty(nets)) {
        LOGGER.info("Found " + nets.size() + " prerequisite networks");
        ovfInformationTO.setNetworks(nets);
    } else if (LOGGER.isTraceEnabled()) {
        LOGGER.trace(String.format("no net prerequisites found in template %s", ovfFilePath));
    }
    List<OVFPropertyTO> ovfProperties = ovfHelper.getConfigurableOVFPropertiesFromDocument(doc);
    if (CollectionUtils.isNotEmpty(ovfProperties)) {
        LOGGER.info("Found " + ovfProperties.size() + " configurable OVF properties");
        ovfInformationTO.setProperties(ovfProperties);
    } else if (LOGGER.isTraceEnabled()) {
        LOGGER.trace(String.format("no ovf properties found in template %s", ovfFilePath));
    }
    OVFVirtualHardwareSectionTO hardwareSection = ovfHelper.getVirtualHardwareSectionFromDocument(doc);
    List<OVFConfigurationTO> configurations = hardwareSection.getConfigurations();
    if (CollectionUtils.isNotEmpty(configurations)) {
        LOGGER.info("Found " + configurations.size() + " deployment option configurations");
    }
    List<OVFVirtualHardwareItemTO> hardwareItems = hardwareSection.getCommonHardwareItems();
    if (CollectionUtils.isNotEmpty(hardwareItems)) {
        LOGGER.info("Found " + hardwareItems.size() + " virtual hardware items");
    }
    if (StringUtils.isNotBlank(hardwareSection.getMinimiumHardwareVersion())) {
        LOGGER.info("Found minimum hardware version " + hardwareSection.getMinimiumHardwareVersion());
    }
    ovfInformationTO.setHardwareSection(hardwareSection);
    List<OVFEulaSectionTO> eulaSections = ovfHelper.getEulaSectionsFromDocument(doc);
    if (CollectionUtils.isNotEmpty(eulaSections)) {
        LOGGER.info("Found " + eulaSections.size() + " license agreements");
        ovfInformationTO.setEulaSections(eulaSections);
    }
    Pair<String, String> guestOsPair = ovfHelper.getOperatingSystemInfoFromDocument(doc);
    if (guestOsPair != null) {
        LOGGER.info("Found guest OS information: " + guestOsPair.first() + " - " + guestOsPair.second());
        ovfInformationTO.setGuestOsInfo(guestOsPair);
    }
    return ovfInformationTO;
}
Also used : OVFInformationTO(com.cloud.agent.api.to.OVFInformationTO) OVFConfigurationTO(com.cloud.agent.api.to.deployasis.OVFConfigurationTO) OVFNetworkTO(com.cloud.agent.api.to.deployasis.OVFNetworkTO) OVFPropertyTO(com.cloud.agent.api.to.deployasis.OVFPropertyTO) OVFEulaSectionTO(com.cloud.agent.api.to.deployasis.OVFEulaSectionTO) OVFVirtualHardwareItemTO(com.cloud.agent.api.to.deployasis.OVFVirtualHardwareItemTO) DatadiskTO(com.cloud.agent.api.to.DatadiskTO) OVFVirtualHardwareSectionTO(com.cloud.agent.api.to.deployasis.OVFVirtualHardwareSectionTO)

Example 4 with OVFEulaSectionTO

use of com.cloud.agent.api.to.deployasis.OVFEulaSectionTO in project cloudstack by apache.

the class DeployAsIsHelperImpl method getValueFromInformationTO.

private String getValueFromInformationTO(TemplateDeployAsIsInformationTO informationTO) throws IOException {
    if (informationTO instanceof OVFEulaSectionTO) {
        CompressionUtil compressionUtil = new CompressionUtil();
        byte[] compressedLicense = ((OVFEulaSectionTO) informationTO).getCompressedLicense();
        return compressionUtil.decompressByteArary(compressedLicense);
    }
    return gson.toJson(informationTO);
}
Also used : OVFEulaSectionTO(com.cloud.agent.api.to.deployasis.OVFEulaSectionTO) CompressionUtil(com.cloud.utils.compression.CompressionUtil)

Aggregations

OVFEulaSectionTO (com.cloud.agent.api.to.deployasis.OVFEulaSectionTO)4 OVFNetworkTO (com.cloud.agent.api.to.deployasis.OVFNetworkTO)2 OVFPropertyTO (com.cloud.agent.api.to.deployasis.OVFPropertyTO)2 OVFVirtualHardwareSectionTO (com.cloud.agent.api.to.deployasis.OVFVirtualHardwareSectionTO)2 DatadiskTO (com.cloud.agent.api.to.DatadiskTO)1 OVFInformationTO (com.cloud.agent.api.to.OVFInformationTO)1 OVFConfigurationTO (com.cloud.agent.api.to.deployasis.OVFConfigurationTO)1 OVFVirtualHardwareItemTO (com.cloud.agent.api.to.deployasis.OVFVirtualHardwareItemTO)1 CompressionUtil (com.cloud.utils.compression.CompressionUtil)1 IOException (java.io.IOException)1 LinkedList (java.util.LinkedList)1 Node (org.w3c.dom.Node)1 NodeList (org.w3c.dom.NodeList)1