[GitHub] cloudstack pull request #1302: CLOUDSTACK-9104: VM naming convention in case...
Github user rhtyd commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1302#discussion_r103404351 --- 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) { + --- End diff -- - Why is the method attribute changed from private to protected? - If vmspec is null, this method should throw an exception, to avoid a situation where empty vmnames are returned. Discuss? --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] cloudstack pull request #1302: CLOUDSTACK-9104: VM naming convention in case...
Github user rhtyd commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1302#discussion_r103404645 --- 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) { --- End diff -- If _instanceNameFlag is boolean, so there is no need of an explicit `== true`. --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] cloudstack pull request #1302: CLOUDSTACK-9104: VM naming convention in case...
Github user rhtyd commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1302#discussion_r103405279 --- 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()); --- End diff -- The token length comparison may break backward compatibility for existing VMs that may not conform to this scheme. Also, assuming the token length is 3 the line can be written as: `vmNameOnVcenter = String.format("%s-%s", vmInternalCSName, vmSpec.getHostName());` As per previous code, `vmNameOnVcenter = vmSpec.getHostName()`, which will introduce backward compatibility issues for older 4.3 environments. Is there any code that handles for such old VMs. If a 4.3 user decides to upgrade to 4.10+, their VMs might not start the next time someone restarts. Please comment on how the change addresses backward compatibility issue. --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] cloudstack pull request #1302: CLOUDSTACK-9104: VM naming convention in case...
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 infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] cloudstack pull request #1302: CLOUDSTACK-9104: VM naming convention in case...
Github user priyankparihar commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1302#discussion_r103423690 --- 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()); --- End diff -- @sateesh-chodapuneedi what is your opinion ? --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] cloudstack pull request #1302: CLOUDSTACK-9104: VM naming convention in case...
Github user priyankparihar commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1302#discussion_r103427150 --- 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) { + --- End diff -- >Why is the method attribute changed from private to protected? Otherwise Unit testing will be difficult. >If vmspec is null, this method should throw an exception, to avoid a situation where empty vmnames are returned. In CS vmspec can not be null. But still code will be modified according your suggestion. --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] cloudstack pull request #1302: CLOUDSTACK-9104: VM naming convention in case...
Github user priyankparihar commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1302#discussion_r103427642 --- 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) { --- End diff -- @rhtyd Good point. Code will be modified. --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] cloudstack pull request #1302: CLOUDSTACK-9104: VM naming convention in case...
Github user priyankparihar commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1302#discussion_r103880795 --- 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()); --- End diff -- >As per previous code, vmNameOnVcenter = vmSpec.getHostName(), which will introduce backward compatibility issues for older 4.3 environments. Is there any code that handles for such old VMs. Yes, vm.instancename.flag will handle backward compatibility issue. Case (vm.instancename.flag = True): User can create the VM with same name form different account. Case (vm.instancename.flag = False): User can not create the VM with same name form different account. Note - But in both the cases, VM with same name are not allowed on a particular network. And only for the User VM's name format will be like "I--" if "vm.instancename.flag = True". It will not cause any impact on other VM names( like Router VM). --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] cloudstack pull request #1302: CLOUDSTACK-9104: VM naming convention in case...
Github user priyankparihar commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1302#discussion_r103892827 --- 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 -- Removed. --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. ---