Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 05C9E200C29 for ; Tue, 28 Feb 2017 10:03:21 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 03E74160B7C; Tue, 28 Feb 2017 09:03:21 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4B0FF160B6A for ; Tue, 28 Feb 2017 10:03:20 +0100 (CET) Received: (qmail 37911 invoked by uid 500); 28 Feb 2017 09:03:19 -0000 Mailing-List: contact dev-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 dev@cloudstack.apache.org Received: (qmail 37900 invoked by uid 99); 28 Feb 2017 09:03:19 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Feb 2017 09:03:19 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id DD701DFE1E; Tue, 28 Feb 2017 09:03:18 +0000 (UTC) From: rhtyd To: dev@cloudstack.apache.org Reply-To: dev@cloudstack.apache.org References: In-Reply-To: Subject: [GitHub] cloudstack pull request #1302: CLOUDSTACK-9104: VM naming convention in case... Content-Type: text/plain Message-Id: <20170228090318.DD701DFE1E@git1-us-west.apache.org> Date: Tue, 28 Feb 2017 09:03:18 +0000 (UTC) archived-at: Tue, 28 Feb 2017 09:03:21 -0000 Github user rhtyd commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1302#discussion_r103405341 --- Diff: plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java --- @@ -2226,17 +2227,33 @@ int getReservedCpuMHZ(VirtualMachineTO vmSpec) { return new String[] {datastoreDiskPath}; } - // Pair - private Pair composeVmNames(VirtualMachineTO vmSpec) { - String vmInternalCSName = vmSpec.getName(); - String vmNameOnVcenter = vmSpec.getName(); - if (_instanceNameFlag && vmSpec.getHostName() != null) { - vmNameOnVcenter = vmSpec.getHostName(); + /** + * This method generates VM name for Vcenter and Cloudstack( when Hypervisor is VMware). + * It generates VM name according to _instanceNameFlag setting. + * + * @param VirtualMachineTO + * vmSpec + * @return Pair. A pair which contain 'internal CS name' and + * 'vCenter display name'(vCenter knows VM by this name). + **/ + protected Pair composeVmNames(VirtualMachineTO vmSpec) { + + String vmInternalCSName = ""; + String vmNameOnVcenter = ""; + if(vmSpec != null) + { + vmInternalCSName = vmNameOnVcenter = vmSpec.getName(); + if (_instanceNameFlag == true && vmSpec.getType() == VirtualMachine.Type.User) { + String[] tokens = vmInternalCSName.split("-"); + if(tokens.length<3) throw new InvalidParameterValueException("Invalid vmInternalCSName format: "+vmInternalCSName+" expected format : *-*-* (e.g -> i-x-y)"); // vmInternalCSName has format i-x-y- + vmNameOnVcenter = String.format("%s-%s-%s-%s", tokens[0], tokens[1], tokens[2], vmSpec.getHostName()); + } + } return new Pair(vmInternalCSName, vmNameOnVcenter); } - protected void configNestedHVSupport(VirtualMachineMO vmMo, VirtualMachineTO vmSpec, VirtualMachineConfigSpec vmConfigSpec) throws Exception { + protected static void configNestedHVSupport(VirtualMachineMO vmMo, VirtualMachineTO vmSpec, VirtualMachineConfigSpec vmConfigSpec) throws Exception { --- End diff -- Please explain why `static` was added, thanks. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---