Github user bhaisaab commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1165#discussion_r47469773
  
    --- Diff: 
plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
 ---
    @@ -1889,11 +1889,20 @@ int getReservedCpuMHZ(VirtualMachineTO vmSpec) {
     
         // Pair<internal CS name, vCenter display name>
         private Pair<String, String> composeVmNames(VirtualMachineTO vmSpec) {
    -        String vmInternalCSName = vmSpec.getName();
    -        String vmNameOnVcenter = vmSpec.getName();
    -        if (_instanceNameFlag && vmSpec.getHostName() != null) {
    -            vmNameOnVcenter = vmSpec.getHostName();
    +
    +        String vmInternalCSName = null;
    +        String vmNameOnVcenter  = null;
    +        if(vmSpec != null)
    +        {
    +            vmInternalCSName = vmNameOnVcenter = vmSpec.getName();
    +            if (_instanceNameFlag == true) {
    +                String[] tokens = vmInternalCSName.split("-");
    +                assert (tokens.length >= 3); // vmInternalCSName has 
format i-x-y-<instance.name>
    +                vmNameOnVcenter = String.format("%s-%s-%s-%s", tokens[0], 
tokens[1], tokens[2], vmSpec.getHostName());
    --- End diff --
    
    @priyankparihar alright, even if we go with this change. If 
vmSpec.getHostName() was null then we've a problem with the vm name (if 
_instanceNameFlag, i.e. the global setting was true).
    
    Once you put a null check, it should be good to go.


---
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.
---

Reply via email to