VMware Cloud Community
AyoubSouihel
Contributor
Contributor
Jump to solution

vm power state when Snapshot taken

Hi community ,

i am searching for a way to know what is the power state of the VM when a snapshot taken .

vcenter 6.5

thanks in advance

Tags (2)
Reply
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi, and welcome to the community.

Take a look at the scripting action com.vmware.library.vc.vm.snapshot/getAllSnapshotsOfVM. It enumerates all snapshots of a VM. The state of the VM when a particular snapshot was taken is stored in the snapshot tree object, so you can easily fetch it from the variable state.

Something like the following should print all snapshot names for the given VM referenced by the variable vm, together with the state of the VM when each snapshot was taken (the difference from the original scripting action code is only line 11 being added)

var snapshots = new Array();

if(vm.snapshot){

  var snapshotTrees = vm.snapshot.rootSnapshotList;

  for (i in snapshotTrees){

    getSnapshotsOfVM(snapshotTrees[i]);

  }

}

return snapshots;

function getSnapshotsOfVM(tree) {

  System.log("Snapshot name: " + tree.name + "   VM state: " + tree.state);

  snapshots.push(tree.snapshot);

  var trees = tree.childSnapshotList;

  if (trees != null) {

    for (index in trees) {

      if (trees[index] != null)

        getSnapshotsOfVM(trees[index]);

    }

  }

}

View solution in original post

4 Replies
dekoshal
Hot Shot
Hot Shot
Jump to solution

I think i misunderstood the question. Please follow the suggestion given below by Ilian Iliev.

You can not have two active task on a VM at any given point of time.

While taking the snapshot either the VM is up or down.

Nevermind if the VM is down. You can tail on the vmware.log  located in the virtual machine working directory while take snapshot task is in progress.

Change in power state will be shown in the logs. Power state change might happen because of  BSOD or kernel panic etc.

If you found this or any other answer helpful, please consider the use of the Correct or Helpful to award points.

Best Regards,

Deepak Koshal

CNE|CLA|CWMA|VCP4|VCP5|CCAH

iiliev
VMware Employee
VMware Employee
Jump to solution

Hi, and welcome to the community.

Take a look at the scripting action com.vmware.library.vc.vm.snapshot/getAllSnapshotsOfVM. It enumerates all snapshots of a VM. The state of the VM when a particular snapshot was taken is stored in the snapshot tree object, so you can easily fetch it from the variable state.

Something like the following should print all snapshot names for the given VM referenced by the variable vm, together with the state of the VM when each snapshot was taken (the difference from the original scripting action code is only line 11 being added)

var snapshots = new Array();

if(vm.snapshot){

  var snapshotTrees = vm.snapshot.rootSnapshotList;

  for (i in snapshotTrees){

    getSnapshotsOfVM(snapshotTrees[i]);

  }

}

return snapshots;

function getSnapshotsOfVM(tree) {

  System.log("Snapshot name: " + tree.name + "   VM state: " + tree.state);

  snapshots.push(tree.snapshot);

  var trees = tree.childSnapshotList;

  if (trees != null) {

    for (index in trees) {

      if (trees[index] != null)

        getSnapshotsOfVM(trees[index]);

    }

  }

}

AyoubSouihel
Contributor
Contributor
Jump to solution

thank you so much .

also you can use  get-snapsho command .

AyoubSouihel
Contributor
Contributor
Jump to solution

hi ;

We found another easy way to get the information , this time it is from RV tools

Go to vSnapshot ,  column State

State The power state of the virtual machine when this snapshot was taken.

You can found out more from RV tools document page 40

http://robware.net/download/RVTools.pdf

Reply
0 Kudos