From commits-return-96071-archive-asf-public=cust-asf.ponee.io@cloudstack.apache.org Fri Dec 20 10:50:39 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 8FC9518064C for ; Fri, 20 Dec 2019 11:50:39 +0100 (CET) Received: (qmail 41976 invoked by uid 500); 20 Dec 2019 10:50:38 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 41966 invoked by uid 99); 20 Dec 2019 10:50:38 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Dec 2019 10:50:38 +0000 From: GitBox To: commits@cloudstack.apache.org Subject: [GitHub] [cloudstack] DaanHoogland commented on a change in pull request #3510: [WIP DO NOT MERGE] Allow additional config to vms Message-ID: <157683903874.26836.7002761829788321524.gitbox@gitbox.apache.org> References: In-Reply-To: Date: Fri, 20 Dec 2019 10:50:38 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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