VMware Cloud Community
Naineyess
Enthusiast
Enthusiast
Jump to solution

Snapshot creator ?

Hi,

I am creating a report for snapshots by using vCO 5.5, I want to fetch snapshot creators name in the report, and I want to export the report in CSV format.

Please help me.

Thanks !!

0 Kudos
1 Solution

Accepted Solutions
Naineyess
Enthusiast
Enthusiast
Jump to solution

Thanks !!

I used the same script but getting error as "TypeError: Cannot read property "name" from undefined (Workflow:snapshot creator / Scriptable task (item1)#6)"

please check and verify and let me know if I am doing something wrong.

View solution in original post

0 Kudos
3 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

You can fetch snapshot creator names from the corresponding events.

The sample code below enumerates all snapshot-related events for a given virtual machine ('vm' parameter) and prints who took the snapshot and when:

var spec = new VcEventFilterSpec();

spec.entity = new VcEventFilterSpecByEntity();

spec.entity.entity = vm;

spec.entity.recursion = VcEventFilterSpecRecursionOption.self;

var events = vm.sdkConnection.eventManager.queryEvents(spec);

for each (var ev in events) {

  if (ev.info.name == "CreateSnapshot_Task") {

    System.log("Snapshot created by: " + ev.userName + " on: " + ev.createdTime);

  }

}

0 Kudos
Naineyess
Enthusiast
Enthusiast
Jump to solution

Thanks !!

I used the same script but getting error as "TypeError: Cannot read property "name" from undefined (Workflow:snapshot creator / Scriptable task (item1)#6)"

please check and verify and let me know if I am doing something wrong.

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Hmm, this error means that in expression

     if (ev.info.name == "CreateSnapshot_Task")

the value of ev.info is not evaluated.


I'm not sure why and when this is happening. Could you log the 'ev' object and it's properties (use API Explorer to check what are the property names for the object whose type should be visible when you log the ev object)? Perhaps some property (other than 'info') will have a value identifying the event as 'create snapshot' event.

Another possible explanation for ev.info being undefined is the famous issue with inventory service. Could you try to disable it by putting the following line in the file vmo.properties

com.vmware.o11n.vim.useInventoryService=false

and then restarting vCO service

0 Kudos