[GitHub] DaanHoogland commented on a change in pull request #1302: CLOUDSTACK-9104: VM naming convention in case vmware is used
DaanHoogland commented on a change in pull request #1302: CLOUDSTACK-9104: VM naming convention in case vmware is used URL: https://github.com/apache/cloudstack/pull/1302#discussion_r113908318 ## File path: server/src/com/cloud/vm/UserVmManagerImpl.java ## @@ -3383,12 +3383,6 @@ protected UserVm createVirtualMachine(DataCenter zone, ServiceOffering serviceOf hostName = generateHostName(uuidName); } } -// If global config vm.instancename.flag is set to true, then CS will set guest VM's name as it appears on the hypervisor, to its hostname. -// In case of VMware since VM name must be unique within a DC, check if VM with the same hostname already exists in the zone. Review comment: are those not allowed (in different domains/accounts)? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] DaanHoogland commented on a change in pull request #1302: CLOUDSTACK-9104: VM naming convention in case vmware is used
DaanHoogland commented on a change in pull request #1302: CLOUDSTACK-9104: VM naming convention in case vmware is used URL: https://github.com/apache/cloudstack/pull/1302#discussion_r113907617 ## File path: plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/resource/VmwareResourceTest.java ## @@ -404,4 +410,46 @@ public void testConfigNestedHVSupportFlagFalse() throws Exception{ verify(vmMo, never()).getRunningHost(); } +@Test +public void testComposeVmNames() throws Exception{ Review comment: i agree, let's test as little as possible per test This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] DaanHoogland commented on a change in pull request #1302: CLOUDSTACK-9104: VM naming convention in case vmware is used
DaanHoogland commented on a change in pull request #1302: CLOUDSTACK-9104: VM naming convention in case vmware is used URL: https://github.com/apache/cloudstack/pull/1302#discussion_r113907545 ## File path: plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java ## @@ -2226,13 +2227,30 @@ int getReservedCpuMHZ(VirtualMachineTO vmSpec) { return new String[] {datastoreDiskPath}; } -// Pair -private PaircomposeVmNames(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) throws CloudRuntimeException { + +String vmInternalCSName = ""; +String vmNameOnVcenter = ""; +if(vmSpec == null) { +throw new CloudRuntimeException("vmSpec is null"); } + +vmInternalCSName = vmNameOnVcenter = vmSpec.getName(); +if (_instanceNameFlag && 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()); Review comment: @rhtyd I don't mind "null" in a name as long as the name is not null or duplicate. (see your comment further on) This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services