Reputation: 3145
I'm using vijava (5.1) to fetch data from a vCenter about virtual machines. For that matter I'm using a filter with some properties (for example, guest.hostName, runtime.powerState etc.). I need to get the creation time for these virtual machines and from what I saw, this info is available in the event logs of the vCenter.
Is there a way to get this info part of the virtual machine's properties? I searched this info using the vSphere-Client and I didn't - so I guess the only place is from the event logs - but just to be sure, is that the only way?
Thanks
Upvotes: 0
Views: 1252
Reputation: 300
It is hard to get creation time of virtual machine using vijava api. However you can get other below informations from VirtualMachineConfigInfo.
modified : Last time a virtual machine's configuration was modified.
Folder rootFolder = serviceInstance.getRootFolder();
InventoryNavigator inventoryNavigator = new InventoryNavigator(rootFolder);
vm = (VirtualMachine) inventoryNavigator.searchManagedEntity(VirtualMachine.class.getSimpleName(), vmName);
VirtualMachineConfigInfo vmConfig = vm.getConfig();
System.out.println(vmConfig.getChangeVersion);
image for information in virtualMachineConfigInfo object
Upvotes: 1
Reputation: 8194
Unless you set the creation time as an extra config property then the event log is the only way I know of. If you want to go the extra config route I created a sample that shows how to use them that is part of the pyvmomi-community-samples project.
Upvotes: 0