VMware {code} Community
ashvitech
Contributor
Contributor

WaitForUpdateEx with vSphere 5.5 host is not working as expected. (Returns VM properties though it is not modified/updated on vSphere)?

I am using vSphere WS SDK 5.5 with vSphere 5.5 (VMware ESXi 5.5.0 build-1331820).   The WaitForUpdateEx  method returns immediately though there is no change in specified properties.  The same logic or code works with ESXi 5.0 and 5.1 hosts.

The below is the sample code. It is "GetUpdates" sample code which I modified to get updates for any VM for hostname change. In this case, I expect "waitForUpdatesEx" should return me hostname change in first version, and later if it updated/modified. But the waitfordateEx returns the same hostname as modified property in few seconds (2-5 sec) without considering the wait timeout (300secs).

I am not sure whats going with vSphere 5.5 host, as the same code and logics works fine against vSphere 5.1 ESX host, and I get update only if it changed or otherwise no updates.

I did see release notes for WS SDK 5.5, not found any change in this API call/behavior. Please let me know if anyone has solution on this or happened to see the same problem.

// Updated  GetUpdates sample

public void getUpdates() throws RuntimeFaultFaultMsg, IOException, InvalidCollectorVersionFaultMsg, InvalidPropertyFaultMsg {  
    
        String[][] typeInfo = {new String[]{"VirtualMachine", "guest.hostName"}};
        List<PropertySpec> pSpecs = buildPropertySpecArray(typeInfo);
        List<ObjectSpec> oSpecs = new ArrayList<ObjectSpec>();
        ObjectSpec os = new ObjectSpec();
        os.setObj(rootRef);
        os.setSkip(Boolean.TRUE);
        os.getSelectSet().addAll(Arrays.asList(buildFullTraversal()));
        oSpecs.add(os);
        PropertyFilterSpec propertyFilterSpec = new PropertyFilterSpec();
        propertyFilterSpec.getPropSet().addAll(pSpecs);
        propertyFilterSpec.getObjectSet().addAll(oSpecs);
        ManagedObjectReference propFilter =
                vimPort.createFilter(propCollectorRef, propertyFilterSpec, false);

        BufferedReader console =
                new BufferedReader(new InputStreamReader(System.in));

        String version = "";
        long count = 0;
        do {
            WaitOptions opts = new WaitOptions();
            opts.setMaxWaitSeconds(300);
            UpdateSet update = vimPort.waitForUpdatesEx(propCollectorRef, version, opts);
            System.out.println("Current Time In Seconds----> " + System.currentTimeMillis()/1000);
            System.out.println("Data Version----> " + version);
            if (update != null && update.getFilterSet() != null) {
                handleUpdate(update);
                version = update.getVersion();
            } else {
                System.out.println("No update is present!");
            }
            System.out.println("");
            System.out.println("****************");
            System.out.println("");
            //System.out.println("Press <Enter> to check for updates");
            //System.out.println("Enter 'exit' <Enter> to exit the program");           
            //String line = console.readLine();
            //if (line != null && line.trim().equalsIgnoreCase("exit")) {
              //  break;
            //}
            // just to exit the loop after
            count++;
            if (count > 1000) {
             break;
            }
        } while (true);
        vimPort.destroyPropertyFilter(propFilter);
    }

Output against vSphere 5.5 host:

[There are 6 VMs on host, 3 are powered off. It return all 3 VM hostnames correctly in first version and null for others as expected, but again in next version it returns one of the VM hostname change thought it is not changed or no operation on the vm in this time]

-- VMware samples in Java --
Current Time In Seconds----> 1384885325
Data Version---->
Virtual Machine updates:
New Data:
  Property Name: guest.hostName,  Value :null
New Data:
  Property Name: guest.hostName,  Value :template
New Data:
  Property Name: guest.hostName,  Value :null
New Data:
  Property Name: guest.hostName,  Value :null
New Data:
  Property Name: guest.hostName,  Value :PCOIP-GP2
New Data:
  Property Name: guest.hostName,  Value :Win8EntBase51

****************

Current Time In Seconds----> 1384885333
Data Version----> 1
Virtual Machine updates:
Changed Data:
  Property Name: guest.hostName,  Value :PCOIP-GP2

****************

Current Time In Seconds----> 1384885333
Data Version----> 2
Virtual Machine updates:
Changed Data:
  Property Name: guest.hostName,  Value :PCOIP-GP2

****************

Current Time In Seconds----> 1384885335
Data Version----> 3
Virtual Machine updates:
Changed Data:
  Property Name: guest.hostName,  Value :template

****************

Current Time In Seconds----> 1384885335
Data Version----> 4
Virtual Machine updates:
Changed Data:
  Property Name: guest.hostName,  Value :template

****************

Current Time In Seconds----> 1384885336
Data Version----> 5
Virtual Machine updates:
Changed Data:
  Property Name: guest.hostName,  Value :Win8EntBase51

****************

Current Time In Seconds----> 1384885349
Data Version----> 6
Virtual Machine updates:
Changed Data:
  Property Name: guest.hostName,  Value :Win8EntBase51

****************

Current Time In Seconds----> 1384885363
Data Version----> 7
Virtual Machine updates:
Changed Data:
  Property Name: guest.hostName,  Value :PCOIP-GP2

****************

Current Time In Seconds----> 1384885363
Data Version----> 8
Virtual Machine updates:
Changed Data:
  Property Name: guest.hostName,  Value :PCOIP-GP2

****************

Tags (1)
0 Kudos
0 Replies