use of com.cloud.deployasis.UserVmDeployAsIsDetailVO 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.deployasis.UserVmDeployAsIsDetailVO 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