cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [cloudstack] DaanHoogland commented on a change in pull request #3510: [WIP DO NOT MERGE] Allow additional config to vms
Date Fri, 20 Dec 2019 10:50:38 GMT
DaanHoogland 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_r360320521
 
 

 ##########
 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:
   we are keeping a secret what the issue with the cfg is according to the `ArrayIndexOutOfBoundsException`!
better add make sure we log or nest the exception
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message