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;
}
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);
}
}
}
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;
}
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;
}
Aggregations