Merge "Updated delete_volume_snapshots and create_volume_snapshot"
This commit is contained in:
commit
4a9fc478e0
|
@ -751,7 +751,7 @@ def delete_volume_snapshots(snapshots=None, force=False, check_first=True,
|
||||||
|
|
||||||
args_ = '{}{}'.format('--force ' if force else '',
|
args_ = '{}{}'.format('--force ' if force else '',
|
||||||
' '.join(snapshots_to_del))
|
' '.join(snapshots_to_del))
|
||||||
code, output = cli.openstack('snapshot delete', args_, ssh_client=con_ssh,
|
code, output = cli.openstack('volume snapshot delete', args_, ssh_client=con_ssh,
|
||||||
fail_ok=fail_ok, auth_info=auth_info)
|
fail_ok=fail_ok, auth_info=auth_info)
|
||||||
|
|
||||||
if code == 1:
|
if code == 1:
|
||||||
|
@ -1254,7 +1254,7 @@ def is_volumes_pool_sufficient(min_size=40):
|
||||||
|
|
||||||
def create_volume_snapshot(name, volume=None, description=None, force=False,
|
def create_volume_snapshot(name, volume=None, description=None, force=False,
|
||||||
properties=None, remote_sources=None,
|
properties=None, remote_sources=None,
|
||||||
fail_ok=False, con_ssh=None, auth_info=None):
|
fail_ok=False, con_ssh=None, auth_info=None, cleanup=None):
|
||||||
"""
|
"""
|
||||||
Create snapshot for an existing volume
|
Create snapshot for an existing volume
|
||||||
Args:
|
Args:
|
||||||
|
@ -1267,10 +1267,16 @@ def create_volume_snapshot(name, volume=None, description=None, force=False,
|
||||||
fail_ok (bool):
|
fail_ok (bool):
|
||||||
con_ssh:
|
con_ssh:
|
||||||
auth_info:
|
auth_info:
|
||||||
|
cleanup:
|
||||||
|
|
||||||
Returns (tuple):
|
Returns (tuple):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
valid_cleanups = ('module', 'session', 'function', 'class', None)
|
||||||
|
if cleanup not in valid_cleanups:
|
||||||
|
raise ValueError(
|
||||||
|
"Invalid scope provided. Choose from: {}".format(valid_cleanups))
|
||||||
|
|
||||||
arg_dict = {
|
arg_dict = {
|
||||||
'volume': volume,
|
'volume': volume,
|
||||||
'description': description,
|
'description': description,
|
||||||
|
@ -1287,11 +1293,14 @@ def create_volume_snapshot(name, volume=None, description=None, force=False,
|
||||||
code, output = cli.openstack('volume snapshot create', arg_str,
|
code, output = cli.openstack('volume snapshot create', arg_str,
|
||||||
ssh_client=con_ssh, fail_ok=fail_ok,
|
ssh_client=con_ssh, fail_ok=fail_ok,
|
||||||
auth_info=auth_info)
|
auth_info=auth_info)
|
||||||
if code > 0:
|
|
||||||
return 1, output
|
|
||||||
|
|
||||||
table_ = table_parser.table(output)
|
table_ = table_parser.table(output)
|
||||||
snap_shot_id = table_parser.get_value_two_col_table(table_, 'id')
|
snap_shot_id = table_parser.get_value_two_col_table(table_, 'id')
|
||||||
|
if cleanup and snap_shot_id:
|
||||||
|
ResourceCleanup.add('vol_snapshot', snap_shot_id, scope=cleanup)
|
||||||
|
|
||||||
|
if code > 0:
|
||||||
|
return 1, output
|
||||||
|
|
||||||
LOG.info(
|
LOG.info(
|
||||||
"Volume snapshot {} created for volume {}. Wait for it to become "
|
"Volume snapshot {} created for volume {}. Wait for it to become "
|
||||||
|
|
Loading…
Reference in New Issue