use of com.cloud.agent.api.to.deployasis.OVFConfigurationTO in project cloudstack by apache.
the class OVFHelper method getDeploymentOptionsFromDocumentTree.
private List<OVFConfigurationTO> getDeploymentOptionsFromDocumentTree(Document doc) {
List<OVFConfigurationTO> options = new ArrayList<>();
if (doc == null) {
return options;
}
NodeList deploymentOptionSection = ovfParser.getElementsFromOVFDocument(doc, "DeploymentOptionSection");
if (deploymentOptionSection.getLength() == 0) {
return options;
}
Node hardwareSectionNode = deploymentOptionSection.item(0);
NodeList childNodes = hardwareSectionNode.getChildNodes();
int index = 0;
for (int i = 0; i < childNodes.getLength(); i++) {
Node node = childNodes.item(i);
if (node != null && (node.getNodeName().equals("Configuration") || node.getNodeName().equals("ovf:Configuration"))) {
Element configuration = (Element) node;
String configurationId = ovfParser.getNodeAttribute(configuration, "id");
String description = ovfParser.getChildNodeValue(configuration, "Description");
String label = ovfParser.getChildNodeValue(configuration, "Label");
OVFConfigurationTO option = new OVFConfigurationTO(configurationId, label, description, index);
options.add(option);
index++;
}
}
return options;
}
use of com.cloud.agent.api.to.deployasis.OVFConfigurationTO in project cloudstack by apache.
the class OVFHelper method getVirtualHardwareSectionFromDocument.
/**
* Retrieve the virtual hardware section and its deployment options as configurations
*/
public OVFVirtualHardwareSectionTO getVirtualHardwareSectionFromDocument(Document doc) {
List<OVFConfigurationTO> configurations = getDeploymentOptionsFromDocumentTree(doc);
List<OVFVirtualHardwareItemTO> items = getVirtualHardwareItemsFromDocumentTree(doc);
if (CollectionUtils.isNotEmpty(configurations)) {
for (OVFConfigurationTO configuration : configurations) {
List<OVFVirtualHardwareItemTO> confItems = items.stream().filter(x -> StringUtils.isNotBlank(x.getConfigurationIds()) && hardwareItemContainsConfiguration(x, configuration.getId())).collect(Collectors.toList());
configuration.setHardwareItems(confItems);
}
}
List<OVFVirtualHardwareItemTO> commonItems = null;
if (CollectionUtils.isNotEmpty(items)) {
commonItems = items.stream().filter(x -> StringUtils.isBlank(x.getConfigurationIds())).collect(Collectors.toList());
}
String minimumHardwareVersion = getMinimumHardwareVersionFromDocumentTree(doc);
return new OVFVirtualHardwareSectionTO(configurations, commonItems, minimumHardwareVersion);
}
use of com.cloud.agent.api.to.deployasis.OVFConfigurationTO 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;
}
Aggregations