Return-Path: X-Original-To: apmail-cloudstack-dev-archive@www.apache.org Delivered-To: apmail-cloudstack-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9AE9619252 for ; Thu, 21 Apr 2016 11:08:09 +0000 (UTC) Received: (qmail 11468 invoked by uid 500); 21 Apr 2016 11:08:09 -0000 Delivered-To: apmail-cloudstack-dev-archive@cloudstack.apache.org Received: (qmail 11410 invoked by uid 500); 21 Apr 2016 11:08:09 -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 11399 invoked by uid 99); 21 Apr 2016 11:08:08 -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; Thu, 21 Apr 2016 11:08:08 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D0718DFC70; Thu, 21 Apr 2016 11:08:08 +0000 (UTC) From: jburwell To: dev@cloudstack.apache.org Reply-To: dev@cloudstack.apache.org References: In-Reply-To: Subject: [GitHub] cloudstack pull request: CLOUDSTACK-9104: VM naming convention in ... Content-Type: text/plain Message-Id: <20160421110808.D0718DFC70@git1-us-west.apache.org> Date: Thu, 21 Apr 2016 11:08:08 +0000 (UTC) Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1302#discussion_r60562805 --- Diff: plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java --- @@ -2030,12 +2030,29 @@ 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). + **/ + private Pair composeVmNatmes(VirtualMachineTO vmSpec) { + + String vmInternalCSName = null; + String vmNameOnVcenter = null; + if(vmSpec != null) + { + vmInternalCSName = vmNameOnVcenter = vmSpec.getName(); + if (_instanceNameFlag == true && vmSpec.getType()==VirtualMachine.Type.User) { + String[] tokens = vmInternalCSName.split("-"); + assert (tokens.length >= 3); // vmInternalCSName has format i-x-y- --- End diff -- Guava's ``Preconditions.checkState`` is terse way to implement such checks. --- 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. ---