Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove snapshot does not work #3

Open
zch-bit opened this issue Jan 26, 2016 · 2 comments
Open

Remove snapshot does not work #3

zch-bit opened this issue Jan 26, 2016 · 2 comments

Comments

@zch-bit
Copy link

zch-bit commented Jan 26, 2016

in the example of create_and_remove_snapshot, the code for removing the snapshot does not work, for the code should go deep into the ChildShnapshotTree to see if the name equals the ChildSnapshot.

@erancx
Copy link

erancx commented May 8, 2016

In order to get a ChildSnapshot, I suggest you try something like:

def list_snapshot(vm, vm_name):
    import collections
    try:
        snapshots = vm.snapshot.rootSnapshotList
    except AttributeError as e:
        mylogger.error("No snapshots found for {0}".format(vm_name))
        sys.exit(1)
    d = collections.deque(snapshots)
    all_snapshots = []
    while d:
        snapshot = d.pop()
        all_snapshots.append(snapshot)
        d.extend(reversed(snapshot.childSnapshotList))
    return all_snapshots

Now you can every child too, for example:

all_snapshots = list_snapshot(vm, args.vm_name)
for snapshot in all_snapshots:
    print snapshot.name, snapshot.createTime

@erancx
Copy link

erancx commented May 8, 2016

Or better, in order to get first child first, last child last, use snapshot.childSnapshotList[::-1]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants