
As part of the STX-Openstack upversion to CARACAL, the python- cinderclient is being upversioned to version 9.5.0-1 [1], which is the latest supported on CARACAL [2]. The commit hash of the used repo is: 3b2e2c028bd6b650dce64976f8b48409e2fa85b2 All patches were updated in order to make the package buildable in the new version. [1] https://salsa.debian.org/openstack-team/clients/python-cinderclient/-/tree/debian/9.5.0-1?ref_type=tags [2] https://releases.openstack.org/caracal/index.html#caracal-python-cinderclient Story: 2011303 Task: 51470 Test Plan: PASS: Build the python-cinderclient package PASS: Build the stx-openstackclients image PASS: Tested custom image in a running stx-openstack Change-Id: Ifec8b4714a7d45c1cf8dab332d1e76778b276db1 Signed-off-by: Joao Fracarolli <joao.vicentinifracarolli@windriver.com>
196 lines
9.0 KiB
Diff
196 lines
9.0 KiB
Diff
From 1bc2ecf87f45a0c2737cd05a5681a1f1b1e1f015 Mon Sep 17 00:00:00 2001
|
|
From: Luan Nunes Utimura <LuanNunes.Utimura@windriver.com>
|
|
Date: Mon, 6 Mar 2023 09:25:12 -0300
|
|
Subject: [PATCH] Add location parameter for volume backup creation
|
|
This change adds the `location` parameter in python-cinderclient's
|
|
`volume backup create` command to allow the optional specification of
|
|
volume backup locations.
|
|
This change also updates the unit tests accordingly.
|
|
Signed-off-by: Luan Nunes Utimura <LuanNunes.Utimura@windriver.com>
|
|
---
|
|
cinderclient/tests/unit/v3/test_shell.py | 20 ++++++++++++++-
|
|
cinderclient/v3/shell.py | 9 +++++++
|
|
cinderclient/v3/volume_backups.py | 32 +++++++++++++++---------
|
|
3 files changed, 48 insertions(+), 13 deletions(-)
|
|
|
|
diff --git a/cinderclient/tests/unit/v3/test_shell.py b/cinderclient/tests/unit/v3/test_shell.py
|
|
index ee71620..9acc192 100644
|
|
--- a/cinderclient/tests/unit/v3/test_shell.py
|
|
+++ b/cinderclient/tests/unit/v3/test_shell.py
|
|
@@ -1443,7 +1443,23 @@ class ShellTest(utils.TestCase):
|
|
'incremental': False,
|
|
'force': False,
|
|
'snapshot_id': None,
|
|
- }}
|
|
+ 'location': None, }}
|
|
+ self.assert_called('POST', '/backups', body=expected)
|
|
+
|
|
+ def test_backup_with_location(self):
|
|
+ self.run_command('--os-volume-api-version 3.42 backup-create '
|
|
+ '--name 1234 '
|
|
+ '--location nfs://10.10.10.10:/exports/backups 1234')
|
|
+ expected = {
|
|
+ 'backup': {
|
|
+ 'volume_id': 1234,
|
|
+ 'container': None,
|
|
+ 'name': '1234',
|
|
+ 'description': None,
|
|
+ 'incremental': False,
|
|
+ 'force': False,
|
|
+ 'snapshot_id': None,
|
|
+ 'location': 'nfs://10.10.10.10:/exports/backups', }}
|
|
self.assert_called('POST', '/backups', body=expected)
|
|
|
|
def test_backup_with_metadata(self):
|
|
@@ -1456,6 +1472,7 @@ class ShellTest(utils.TestCase):
|
|
'incremental': False,
|
|
'force': False,
|
|
'snapshot_id': None,
|
|
+ 'location': None,
|
|
'metadata': {'foo': 'bar'}, }}
|
|
self.assert_called('POST', '/backups', body=expected)
|
|
|
|
@@ -1469,6 +1486,7 @@ class ShellTest(utils.TestCase):
|
|
'incremental': False,
|
|
'force': False,
|
|
'snapshot_id': None,
|
|
+ 'location': None,
|
|
'availability_zone': 'AZ2'}}
|
|
self.assert_called('POST', '/backups', body=expected)
|
|
|
|
diff --git a/cinderclient/v3/shell.py b/cinderclient/v3/shell.py
|
|
index 2542530..331318c 100644
|
|
--- a/cinderclient/v3/shell.py
|
|
+++ b/cinderclient/v3/shell.py
|
|
@@ -371,6 +371,10 @@ RESET_STATE_RESOURCES = {'volume': utils.find_volume,
|
|
help="Filters results by a migration status. Default=None. "
|
|
"Admin only. "
|
|
"%s" % FILTER_DEPRECATED)
|
|
+@utils.arg('--location',
|
|
+ metavar='<location>',
|
|
+ default=None,
|
|
+ help='Backup location. Default=None')
|
|
@utils.arg('--metadata',
|
|
nargs='*',
|
|
metavar='<key=value>',
|
|
@@ -2678,6 +2682,10 @@ def do_service_get_log(cs, args):
|
|
metavar='<snapshot-id>',
|
|
default=None,
|
|
help='ID of snapshot to backup. Default=None.')
|
|
+@utils.arg('--location',
|
|
+ metavar='<location>',
|
|
+ default=None,
|
|
+ help='Backup location. Default=None')
|
|
@utils.arg('--metadata',
|
|
nargs='*',
|
|
metavar='<key=value>',
|
|
@@ -2712,6 +2720,7 @@ def do_backup_create(cs, args):
|
|
args.incremental,
|
|
args.force,
|
|
args.snapshot_id,
|
|
+ location=args.location,
|
|
**kwargs)
|
|
info = {"volume_id": volume.id}
|
|
info.update(backup._info)
|
|
diff --git a/cinderclient/v3/volume_backups.py b/cinderclient/v3/volume_backups.py
|
|
index 61069c8..a72caa3 100644
|
|
--- a/cinderclient/v3/volume_backups.py
|
|
+++ b/cinderclient/v3/volume_backups.py
|
|
@@ -61,7 +61,7 @@ class VolumeBackupManager(base.ManagerWithFind):
|
|
def create(self, volume_id, container=None,
|
|
name=None, description=None,
|
|
incremental=False, force=False,
|
|
- snapshot_id=None):
|
|
+ snapshot_id=None, location=None):
|
|
"""Creates a volume backup.
|
|
|
|
:param volume_id: The ID of the volume to backup.
|
|
@@ -73,17 +73,19 @@ class VolumeBackupManager(base.ManagerWithFind):
|
|
:param snapshot_id: The ID of the snapshot to backup. This should
|
|
be a snapshot of the src volume, when specified,
|
|
the new backup will be based on the snapshot.
|
|
+ :param location: The backup location.
|
|
:rtype: :class:`VolumeBackup`
|
|
"""
|
|
return self._create_backup(volume_id, container, name, description,
|
|
- incremental, force, snapshot_id)
|
|
+ incremental, force, snapshot_id,
|
|
+ location=location)
|
|
|
|
@api_versions.wraps("3.43")
|
|
def create(self, volume_id, container=None, # noqa: F811
|
|
name=None, description=None,
|
|
incremental=False, force=False,
|
|
- snapshot_id=None,
|
|
- metadata=None):
|
|
+ snapshot_id=None, metadata=None,
|
|
+ location=None):
|
|
"""Creates a volume backup.
|
|
|
|
:param volume_id: The ID of the volume to backup.
|
|
@@ -92,28 +94,32 @@ class VolumeBackupManager(base.ManagerWithFind):
|
|
:param description: The description of the backup.
|
|
:param incremental: Incremental backup.
|
|
:param force: If True, allows an in-use volume to be backed up.
|
|
- :param metadata: Key Value pairs
|
|
:param snapshot_id: The ID of the snapshot to backup. This should
|
|
be a snapshot of the src volume, when specified,
|
|
the new backup will be based on the snapshot.
|
|
+ :param metadata: Key Value pairs
|
|
+ :param location: The backup location
|
|
:rtype: :class:`VolumeBackup`
|
|
"""
|
|
# pylint: disable=function-redefined
|
|
return self._create_backup(volume_id, container, name, description,
|
|
- incremental, force, snapshot_id, metadata)
|
|
+ incremental, force, snapshot_id, metadata,
|
|
+ location=location)
|
|
|
|
@api_versions.wraps("3.51")
|
|
def create(self, volume_id, container=None, name=None, # noqa: F811
|
|
description=None, incremental=False, force=False,
|
|
- snapshot_id=None, metadata=None, availability_zone=None):
|
|
+ snapshot_id=None, metadata=None, availability_zone=None,
|
|
+ location=None):
|
|
return self._create_backup(volume_id, container, name, description,
|
|
incremental, force, snapshot_id, metadata,
|
|
- availability_zone)
|
|
+ availability_zone, location=location)
|
|
|
|
def _create_backup(self, volume_id, container=None, name=None,
|
|
description=None, incremental=False, force=False,
|
|
- snapshot_id=None, metadata=None,
|
|
- availability_zone=None):
|
|
+ snapshot_id=None, metadata=None, availability_zone=None,
|
|
+ location=None):
|
|
+
|
|
"""Creates a volume backup.
|
|
|
|
:param volume_id: The ID of the volume to backup.
|
|
@@ -122,10 +128,11 @@ class VolumeBackupManager(base.ManagerWithFind):
|
|
:param description: The description of the backup.
|
|
:param incremental: Incremental backup.
|
|
:param force: If True, allows an in-use volume to be backed up.
|
|
- :param metadata: Key Value pairs
|
|
:param snapshot_id: The ID of the snapshot to backup. This should
|
|
be a snapshot of the src volume, when specified,
|
|
the new backup will be based on the snapshot.
|
|
+ :param location: The backup location.
|
|
+ :param metadata: Key Value pairs
|
|
:param availability_zone: The AZ where we want the backup stored.
|
|
:rtype: :class:`VolumeBackup`
|
|
"""
|
|
@@ -136,7 +143,8 @@ class VolumeBackupManager(base.ManagerWithFind):
|
|
'description': description,
|
|
'incremental': incremental,
|
|
'force': force,
|
|
- 'snapshot_id': snapshot_id, }}
|
|
+ 'snapshot_id': snapshot_id,
|
|
+ 'location': location, }}
|
|
if metadata:
|
|
body['backup']['metadata'] = metadata
|
|
if availability_zone:
|
|
--
|
|
2.34.1
|
|
|