UofS
Enthusiast
Enthusiast

Does Server.findAllForType("vCloud:VM") cache responses?

I have this function in a custom action and when the workflow workflow is executed I extract the MAC address from the returned VM:


var vms = Server.findAllForType("vCloud:VM");
for each (var vm in vms) {
    System.log(" findAllForType comparing: " + href + " = " + vm['href'] );
    if ( href ==  vm['href'] ) {
        System.log(" findAllForType found: " + href );
        return vm;
    }
}

and in my main code I do:


var vm = System.getModule("ca.usask.sds.vCloud").getVcdVmByHref(entityVm.href);

var networkConnectionSection = vm.getNetworkConnectionSection();
var networkConnections = networkConnectionSection.networkConnection.enumerate();
for each (var networkConnection in networkConnections) {
    System.log('Int IP: ' + networkConnection.IpAddress);
    System.log('   MAC: ' + networkConnection.MACAddress);
}

I  am finding that the data for the VM is not changing even though I KNOW the MAC address has changed and many times since runnning this.

Is this data cached somehow as I noticed it is sometimes slow to execute, but other time it takes longer.

I was hoping for up to date reliable data when querying the  system.  Any doing something wrong?  or can this cache re forced to clear?

Dion

0 Kudos
5 Replies
cdecanini_
VMware Employee
VMware Employee

Use vApp.updateInternalState() to flush the cache.

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos
cdecanini_
VMware Employee
VMware Employee

BTW I hope you do not have too many VMs because if you need to get all of them and update their state then vCO will effectively http GET all of them.

Unfortunately the query service that helps making this kind of operations a lot faster does not provide a way to get the Mac Addresses. YOu have ot get the network connection section through the API.

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos
UofS
Enthusiast
Enthusiast

Thanks that works and in fact I used

vm.updateInternalState();

and it instantly refreshed!

thanks

0 Kudos
cdecanini_
VMware Employee
VMware Employee

The vCD plug-in caches the objects for 30 min. In the vCD 1.5 this value cannot be changed. You will see that the workflows in the library use updateInternalState each time there is a CRUD operation on an object. If there is a change done somewhere else (vCD UI, vCD API) and that you must have updated information then you can call the method before reading the object properties.

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos
cdecanini_
VMware Employee
VMware Employee

Yep if I recall well updating the VM will cause the full vApp to be http-get since the VM is only a sub section of the vApp. So if you have several VMs per vApp you may want to do it once for the full vApp instead of having the full vApp being reloaded as many times as the number of children VMs.

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos