Search in sources :

Example 6 with OVFPropertyTO

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

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

the class UserVmManagerImpl method persistVMDeployAsIsProperties.

/**
 * take the properties and set them on the vm.
 * consider should we be complete, and make sure all default values are copied as well if known?
 * I.E. iterate over the template details as well to copy any that are not defined yet.
 */
private void persistVMDeployAsIsProperties(UserVmVO vm, Map<String, String> userVmOVFPropertiesMap) {
    if (MapUtils.isNotEmpty(userVmOVFPropertiesMap)) {
        for (String key : userVmOVFPropertiesMap.keySet()) {
            String detailKey = key;
            String value = userVmOVFPropertiesMap.get(key);
            // Sanitize boolean values to expected format and encrypt passwords
            if (StringUtils.isNotBlank(value)) {
                if (value.equalsIgnoreCase("True")) {
                    value = "True";
                } else if (value.equalsIgnoreCase("False")) {
                    value = "False";
                } else {
                    OVFPropertyTO propertyTO = templateDeployAsIsDetailsDao.findPropertyByTemplateAndKey(vm.getTemplateId(), key);
                    if (propertyTO != null && propertyTO.isPassword()) {
                        value = DBEncryptionUtil.encrypt(value);
                    }
                }
            } else if (value == null) {
                value = "";
            }
            if (s_logger.isTraceEnabled()) {
                s_logger.trace(String.format("setting property '%s' as '%s' with value '%s'", key, detailKey, value));
            }
            UserVmDeployAsIsDetailVO detail = new UserVmDeployAsIsDetailVO(vm.getId(), detailKey, value);
            userVmDeployAsIsDetailsDao.persist(detail);
        }
    }
}
Also used : UserVmDeployAsIsDetailVO(com.cloud.deployasis.UserVmDeployAsIsDetailVO) OVFPropertyTO(com.cloud.agent.api.to.deployasis.OVFPropertyTO)

Example 8 with OVFPropertyTO

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

the class VmwareResource method getOVFMap.

private Map<String, Pair<String, Boolean>> getOVFMap(List<OVFPropertyTO> props) {
    Map<String, Pair<String, Boolean>> map = new HashMap<>();
    for (OVFPropertyTO prop : props) {
        String value = getPropertyValue(prop);
        Pair<String, Boolean> pair = new Pair<>(value, prop.isPassword());
        map.put(prop.getKey(), pair);
    }
    return map;
}
Also used : HashMap(java.util.HashMap) OVFPropertyTO(com.cloud.agent.api.to.deployasis.OVFPropertyTO) Pair(com.cloud.utils.Pair)

Example 9 with OVFPropertyTO

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

the class DeployAsIsHelperImpl method getVirtualMachineDeployAsIsProperties.

@Override
public Map<String, String> getVirtualMachineDeployAsIsProperties(VirtualMachineProfile vm) {
    Map<String, String> map = new HashMap<>();
    List<UserVmDeployAsIsDetailVO> details = userVmDeployAsIsDetailsDao.listDetails(vm.getId());
    if (CollectionUtils.isNotEmpty(details)) {
        for (UserVmDeployAsIsDetailVO detail : details) {
            OVFPropertyTO property = templateDeployAsIsDetailsDao.findPropertyByTemplateAndKey(vm.getTemplateId(), detail.getName());
            String value = property.isPassword() ? DBEncryptionUtil.decrypt(detail.getValue()) : detail.getValue();
            map.put(detail.getName(), value);
        }
    }
    return map;
}
Also used : UserVmDeployAsIsDetailVO(com.cloud.deployasis.UserVmDeployAsIsDetailVO) HashMap(java.util.HashMap) OVFPropertyTO(com.cloud.agent.api.to.deployasis.OVFPropertyTO)

Aggregations

OVFPropertyTO (com.cloud.agent.api.to.deployasis.OVFPropertyTO)9 OVFNetworkTO (com.cloud.agent.api.to.deployasis.OVFNetworkTO)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 UserVmDeployAsIsDetailVO (com.cloud.deployasis.UserVmDeployAsIsDetailVO)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)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 Pair (com.cloud.utils.Pair)1 Test (org.junit.Test)1 Element (org.w3c.dom.Element)1 Node (org.w3c.dom.Node)1 NodeList (org.w3c.dom.NodeList)1