Search in sources :

Example 6 with OVFNetworkTO

use of com.cloud.agent.api.to.deployasis.OVFNetworkTO 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 7 with OVFNetworkTO

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

the class TemplateDeployAsIsDetailsDaoImpl method listNetworkRequirementsByTemplateId.

@Override
public List<OVFNetworkTO> listNetworkRequirementsByTemplateId(long templateId) {
    List<TemplateDeployAsIsDetailVO> networkDetails = listDetailsByTemplateIdMatchingPrefix(templateId, DeployAsIsConstants.NETWORK_PREFIX);
    List<OVFNetworkTO> networkPrereqs = new ArrayList<>();
    for (TemplateDeployAsIsDetailVO property : networkDetails) {
        OVFNetworkTO ovfPropertyTO = gson.fromJson(property.getValue(), OVFNetworkTO.class);
        networkPrereqs.add(ovfPropertyTO);
    }
    networkPrereqs.sort(new Comparator<OVFNetworkTO>() {

        @Override
        public int compare(OVFNetworkTO o1, OVFNetworkTO o2) {
            return o1.getInstanceID() - o2.getInstanceID();
        }
    });
    return networkPrereqs;
}
Also used : ArrayList(java.util.ArrayList) TemplateDeployAsIsDetailVO(com.cloud.deployasis.TemplateDeployAsIsDetailVO) OVFNetworkTO(com.cloud.agent.api.to.deployasis.OVFNetworkTO)

Aggregations

OVFNetworkTO (com.cloud.agent.api.to.deployasis.OVFNetworkTO)7 OVFPropertyTO (com.cloud.agent.api.to.deployasis.OVFPropertyTO)3 OVFInformationTO (com.cloud.agent.api.to.OVFInformationTO)2 OVFEulaSectionTO (com.cloud.agent.api.to.deployasis.OVFEulaSectionTO)2 OVFVirtualHardwareSectionTO (com.cloud.agent.api.to.deployasis.OVFVirtualHardwareSectionTO)2 ArrayList (java.util.ArrayList)2 Element (org.w3c.dom.Element)2 Answer (com.cloud.agent.api.Answer)1 DatadiskTO (com.cloud.agent.api.to.DatadiskTO)1 OVFConfigurationTO (com.cloud.agent.api.to.deployasis.OVFConfigurationTO)1 OVFVirtualHardwareItemTO (com.cloud.agent.api.to.deployasis.OVFVirtualHardwareItemTO)1 TemplateDeployAsIsDetailVO (com.cloud.deployasis.TemplateDeployAsIsDetailVO)1 Network (com.cloud.network.Network)1 PhysicalNetwork (com.cloud.network.PhysicalNetwork)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Test (org.junit.Test)1 Node (org.w3c.dom.Node)1 NodeList (org.w3c.dom.NodeList)1 DocumentTraversal (org.w3c.dom.traversal.DocumentTraversal)1