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
Use vApp.updateInternalState() to flush the cache.
Christophe.
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.
Thanks that works and in fact I used
vm.updateInternalState();
and it instantly refreshed!
thanks
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.
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.