Snapshotter show outputs ALL snapshots
This commit is contained in:
parent
6c10e08980
commit
db5218f7c0
@ -91,19 +91,27 @@ def show():
|
|||||||
vms = get_vagrant_vms()
|
vms = get_vagrant_vms()
|
||||||
for vm in vms:
|
for vm in vms:
|
||||||
msg = "[{vm}] {snap}"
|
msg = "[{vm}] {snap}"
|
||||||
kwargs = {
|
click.echo(click.style(vm, fg='green'))
|
||||||
'vm': click.style(vm, fg='green'),
|
|
||||||
'snap': '',
|
|
||||||
}
|
|
||||||
try:
|
try:
|
||||||
snap = vboxmanage(['snapshot', vm, 'list'], output_dict=True)
|
snap = vboxmanage(['snapshot', vm, 'list'], output_dict=True)
|
||||||
kwargs['snap'] = '{SnapshotName} (UUID: {SnapshotUUID})'.format(**snap)
|
snap_num = (len(snap.keys()) / 3) - 1
|
||||||
except CalledProcessError:
|
if snap_num < 1:
|
||||||
kwargs['snap'] = click.style(
|
click.echo(click.style(
|
||||||
'This machine does not have any snapshots',
|
'This machine does not have any snapshots',
|
||||||
fg='red'
|
fg='red'
|
||||||
)
|
))
|
||||||
click.echo(msg.format(**kwargs))
|
else:
|
||||||
|
s = {}
|
||||||
|
for key, value in snap.items():
|
||||||
|
if not key.startswith('SnapshotName'):
|
||||||
|
continue
|
||||||
|
uuid_key = key.replace("SnapshotName", "SnapshotUUID")
|
||||||
|
click.echo('\t{name} (UUID {uuid})'.format(name=value, uuid=snap[uuid_key]))
|
||||||
|
except CalledProcessError:
|
||||||
|
click.echo(click.style(
|
||||||
|
'This machine does not have any snapshots',
|
||||||
|
fg='red'
|
||||||
|
))
|
||||||
click.echo('-' * 10)
|
click.echo('-' * 10)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user