mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
modules.parallels: rename snapshot to snap_name
This commit is contained in:
parent
93836d9f6b
commit
af62e5ba4b
@ -334,16 +334,16 @@ def snapshot_id_to_name(name, id, runas=None):
|
|||||||
try:
|
try:
|
||||||
data = yaml.safe_load(info)
|
data = yaml.safe_load(info)
|
||||||
if isinstance(data, dict):
|
if isinstance(data, dict):
|
||||||
snapshot = data.get('Name', '')
|
snap_name = data.get('Name', '')
|
||||||
# Do not return None if snapshot name is of type NoneType
|
# Do not return None if snapshot name is of type NoneType
|
||||||
return snapshot if snapshot else ''
|
return snap_name if snap_name else ''
|
||||||
else:
|
else:
|
||||||
return ''
|
return ''
|
||||||
except yaml.YAMLError:
|
except yaml.YAMLError:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def snapshot_name_to_id(name, snapshot, runas=None):
|
def snapshot_name_to_id(name, snap_name, runas=None):
|
||||||
'''
|
'''
|
||||||
Attempt to convert a snapshot name to a snapshot ID. If the name is not
|
Attempt to convert a snapshot name to a snapshot ID. If the name is not
|
||||||
found an empty string is returned. If multiple snapshots share the same
|
found an empty string is returned. If multiple snapshots share the same
|
||||||
@ -353,7 +353,7 @@ def snapshot_name_to_id(name, snapshot, runas=None):
|
|||||||
|
|
||||||
Name/ID of VM whose snapshots are inspected
|
Name/ID of VM whose snapshots are inspected
|
||||||
|
|
||||||
:param str name:
|
:param str snap_name:
|
||||||
|
|
||||||
Name of the snapshot
|
Name of the snapshot
|
||||||
|
|
||||||
@ -375,12 +375,12 @@ def snapshot_name_to_id(name, snapshot, runas=None):
|
|||||||
|
|
||||||
# Try to match the snapshot name to an ID
|
# Try to match the snapshot name to an ID
|
||||||
for id in ids:
|
for id in ids:
|
||||||
if snapshot_id_to_name(name, id, runas=runas) == snapshot:
|
if snapshot_id_to_name(name, id, runas=runas) == snap_name:
|
||||||
return id
|
return id
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def snapshot(name, snapshot=None, desc=None, runas=None):
|
def snapshot(name, snap_name=None, desc=None, runas=None):
|
||||||
'''
|
'''
|
||||||
Create a snapshot
|
Create a snapshot
|
||||||
|
|
||||||
@ -388,7 +388,7 @@ def snapshot(name, snapshot=None, desc=None, runas=None):
|
|||||||
|
|
||||||
Name/ID of VM to take a snapshot of
|
Name/ID of VM to take a snapshot of
|
||||||
|
|
||||||
:param str snapshot:
|
:param str snap_name:
|
||||||
|
|
||||||
Name of snapshot
|
Name of snapshot
|
||||||
|
|
||||||
@ -404,13 +404,13 @@ def snapshot(name, snapshot=None, desc=None, runas=None):
|
|||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
salt '*' parallels.create_snapshot macvm snapshot=macvm-original runas=macdev
|
salt '*' parallels.create_snapshot macvm snap_name=macvm-original runas=macdev
|
||||||
salt '*' parallels.create_snapshot macvm snapshot=macvm-updates desc='clean install with updates' runas=macdev
|
salt '*' parallels.create_snapshot macvm snap_name=macvm-updates desc='clean install with updates' runas=macdev
|
||||||
'''
|
'''
|
||||||
# Construct argument list
|
# Construct argument list
|
||||||
args = [name]
|
args = [name]
|
||||||
if snapshot:
|
if snap_name:
|
||||||
args.extend(['--name', snapshot])
|
args.extend(['--name', snap_name])
|
||||||
if desc:
|
if desc:
|
||||||
args.extend(['--description', desc])
|
args.extend(['--description', desc])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user