mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
parent
de00c181f8
commit
4975300591
1 changed files with 29 additions and 15 deletions
|
@ -3703,38 +3703,52 @@ def delete_keypair(kwargs=None, call=None):
|
|||
|
||||
def create_snapshot(kwargs=None, call=None, wait_to_finish=False):
|
||||
'''
|
||||
Create a snapshot
|
||||
Create a snapshot.
|
||||
|
||||
volume_id
|
||||
The ID of the Volume from which to create a snapshot.
|
||||
|
||||
description
|
||||
The optional description of the snapshot.
|
||||
|
||||
CLI Exampe:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt-cloud -f create_snapshot my-ec2-config volume_id=vol-351d8826
|
||||
salt-cloud -f create_snapshot my-ec2-config volume_id=vol-351d8826 \\
|
||||
description="My Snapshot Description"
|
||||
'''
|
||||
if call != 'function':
|
||||
log.error(
|
||||
raise SaltCloudSystemExit(
|
||||
'The create_snapshot function must be called with -f '
|
||||
'or --function.'
|
||||
)
|
||||
return False
|
||||
|
||||
if 'volume_id' not in kwargs:
|
||||
log.error('A volume_id must be specified to create a snapshot.')
|
||||
return False
|
||||
if kwargs is None:
|
||||
kwargs = {}
|
||||
|
||||
if 'description' not in kwargs:
|
||||
kwargs['description'] = ''
|
||||
volume_id = kwargs.get('volume_id', None)
|
||||
description = kwargs.get('description', '')
|
||||
|
||||
params = {'Action': 'CreateSnapshot'}
|
||||
if volume_id is None:
|
||||
raise SaltCloudSystemExit(
|
||||
'A volume_id must be specified to create a snapshot.'
|
||||
)
|
||||
|
||||
if 'volume_id' in kwargs:
|
||||
params['VolumeId'] = kwargs['volume_id']
|
||||
|
||||
if 'description' in kwargs:
|
||||
params['Description'] = kwargs['description']
|
||||
params = {'Action': 'CreateSnapshot',
|
||||
'VolumeId': volume_id,
|
||||
'Description': description}
|
||||
|
||||
log.debug(params)
|
||||
|
||||
data = aws.query(params,
|
||||
return_url=True,
|
||||
return_root=True,
|
||||
location=get_location(),
|
||||
provider=get_provider(),
|
||||
opts=__opts__,
|
||||
sigver='4')
|
||||
sigver='4')[0]
|
||||
|
||||
r_data = {}
|
||||
for d in data:
|
||||
|
|
Loading…
Add table
Reference in a new issue