anuragaw commented on a change in pull request #3510: [WIP DO NOT MERGE] Allow
additional config to vms
URL: https://github.com/apache/cloudstack/pull/3510#discussion_r360337798
##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -5105,32 +5130,132 @@ public UserVm createVirtualMachine(DeployVMCmd cmd)
throws InsufficientCapacityE
}
/**
- * Persist extra configurations as details for VMware VMs
+ * Persist extra configuration data in the user_vm_details table as
key/value pair
+ * @param decodedUrl String consisting of the extra config data to
appended onto the vmx file for VMware instances
*/
protected void persistExtraConfigVmware(String decodedUrl, UserVm vm) {
- String[] configDataArr = decodedUrl.split("\\r?\\n");
- for (String config: configDataArr) {
- String[] keyValue = config.split("=");
- try {
- userVmDetailsDao.addDetail(vm.getId(), keyValue[0],
keyValue[1], true);
- } catch (ArrayIndexOutOfBoundsException e) {
- throw new CloudRuntimeException("Issue occurred during parsing
of:" + config);
+ boolean isValidConfig = isValidKeyValuePair(decodedUrl);
+ if (isValidConfig) {
+ String[] extraConfigs = decodedUrl.split("\\r?\\n");
+ for (String cfg : extraConfigs) {
+ // Validate cfg against unsupported operations set by admin
here
+ String[] allowedKeyList =
VmwareAdditionalConfigAllowList.value().split(",");
+ boolean validXenOrVmwareConfiguration =
isValidXenOrVmwareConfiguration(cfg, allowedKeyList);
+ String[] paramArray = cfg.split("=");
+ if (validXenOrVmwareConfiguration && paramArray.length == 2) {
+ try {
+ userVmDetailsDao.addDetail(vm.getId(),
paramArray[0].trim(), paramArray[1].trim(), true);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ throw new CloudRuntimeException("Issue occurred during
parsing of:" + cfg);
Review comment:
This was redundant as above if checks length. Cleaned up.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services