Noam
Noam

Reputation: 3145

How to get vm creation time from the machine's properties

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

Answers (2)

Rishi Anand
Rishi Anand

Reputation: 300

It is hard to get creation time of virtual machine using vijava api. However you can get other below informations from VirtualMachineConfigInfo.

  1. changeVersion : The changeVersion is a unique identifier for a given version of the configuration. Each change to the configuration updates this value. This is typically implemented as an ever increasing count or a time-stamp. However, a client should always treat this as an opaque string.
  2. 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

Michael Rice
Michael Rice

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

Related Questions