128 lines
4.7 KiB
Diff
128 lines
4.7 KiB
Diff
From c2c7f074270c687dde542d061518ee9aeefbc4ba Mon Sep 17 00:00:00 2001
|
|
From: Luan Nunes Utimura <LuanNunes.Utimura@windriver.com>
|
|
Date: Mon, 6 Mar 2023 09:52:22 -0300
|
|
Subject: [PATCH] Add location parameter for volume backup creation
|
|
|
|
This change adds the `location` parameter in python-openstackclient'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>
|
|
[ Fixed backup creation with --location flag ]
|
|
Signed-off-by: Lucas de Ataides <lucas.deataidesbarreto@windriver.com>
|
|
---
|
|
openstackclient/tests/unit/volume/v2/fakes.py | 1 +
|
|
.../tests/unit/volume/v2/test_volume_backup.py | 8 ++++++++
|
|
openstackclient/volume/v2/volume_backup.py | 6 ++++++
|
|
3 files changed, 15 insertions(+)
|
|
|
|
diff --git a/openstackclient/tests/unit/volume/v2/fakes.py b/openstackclient/tests/unit/volume/v2/fakes.py
|
|
index a3ef142f..2e320863 100644
|
|
--- a/openstackclient/tests/unit/volume/v2/fakes.py
|
|
+++ b/openstackclient/tests/unit/volume/v2/fakes.py
|
|
@@ -553,6 +553,7 @@ def create_one_backup(attrs=None):
|
|
"size": random.randint(1, 20),
|
|
"status": "error",
|
|
"availability_zone": 'zone' + uuid.uuid4().hex,
|
|
+ "location": 'location-' + uuid.uuid4().hex,
|
|
}
|
|
|
|
# Overwrite default attributes.
|
|
diff --git a/openstackclient/tests/unit/volume/v2/test_volume_backup.py b/openstackclient/tests/unit/volume/v2/test_volume_backup.py
|
|
index 7d00b8bf..6c22f3b6 100644
|
|
--- a/openstackclient/tests/unit/volume/v2/test_volume_backup.py
|
|
+++ b/openstackclient/tests/unit/volume/v2/test_volume_backup.py
|
|
@@ -50,6 +50,7 @@ class TestBackupCreate(TestBackup):
|
|
'container',
|
|
'description',
|
|
'id',
|
|
+ 'location',
|
|
'name',
|
|
'object_count',
|
|
'size',
|
|
@@ -62,6 +63,7 @@ class TestBackupCreate(TestBackup):
|
|
new_backup.container,
|
|
new_backup.description,
|
|
new_backup.id,
|
|
+ new_backup.location,
|
|
new_backup.name,
|
|
new_backup.object_count,
|
|
new_backup.size,
|
|
@@ -88,6 +90,7 @@ class TestBackupCreate(TestBackup):
|
|
"--force",
|
|
"--incremental",
|
|
"--snapshot", self.new_backup.snapshot_id,
|
|
+ "--location", self.new_backup.location,
|
|
self.new_backup.volume_id,
|
|
]
|
|
verifylist = [
|
|
@@ -97,6 +100,7 @@ class TestBackupCreate(TestBackup):
|
|
("force", True),
|
|
("incremental", True),
|
|
("snapshot", self.new_backup.snapshot_id),
|
|
+ ("location", self.new_backup.location),
|
|
("volume", self.new_backup.volume_id),
|
|
]
|
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
@@ -111,6 +115,7 @@ class TestBackupCreate(TestBackup):
|
|
force=True,
|
|
incremental=True,
|
|
snapshot_id=self.new_backup.snapshot_id,
|
|
+ location=self.new_backup.location,
|
|
)
|
|
self.assertEqual(self.columns, columns)
|
|
self.assertEqual(self.data, data)
|
|
@@ -139,6 +144,7 @@ class TestBackupCreate(TestBackup):
|
|
description=None,
|
|
force=False,
|
|
incremental=False,
|
|
+ location=None,
|
|
metadata={"foo": "bar", "wow": "much-cool"},
|
|
)
|
|
self.assertEqual(self.columns, columns)
|
|
@@ -852,6 +858,7 @@ class TestBackupShow(TestBackup):
|
|
'container',
|
|
'description',
|
|
'id',
|
|
+ 'location',
|
|
'name',
|
|
'object_count',
|
|
'size',
|
|
@@ -864,6 +871,7 @@ class TestBackupShow(TestBackup):
|
|
backup.container,
|
|
backup.description,
|
|
backup.id,
|
|
+ backup.location,
|
|
backup.name,
|
|
backup.object_count,
|
|
backup.size,
|
|
diff --git a/openstackclient/volume/v2/volume_backup.py b/openstackclient/volume/v2/volume_backup.py
|
|
index d96b28e9..eac6167d 100644
|
|
--- a/openstackclient/volume/v2/volume_backup.py
|
|
+++ b/openstackclient/volume/v2/volume_backup.py
|
|
@@ -88,6 +88,11 @@ class CreateVolumeBackup(command.ShowOne):
|
|
metavar="<snapshot>",
|
|
help=_("Snapshot to backup (name or ID)")
|
|
)
|
|
+ parser.add_argument(
|
|
+ "--location",
|
|
+ metavar="<location>",
|
|
+ help=_("Optional backup location")
|
|
+ )
|
|
parser.add_argument(
|
|
'--force',
|
|
action='store_true',
|
|
@@ -168,6 +173,7 @@ class CreateVolumeBackup(command.ShowOne):
|
|
description=parsed_args.description,
|
|
force=parsed_args.force,
|
|
incremental=parsed_args.incremental,
|
|
+ location=parsed_args.location,
|
|
**kwargs,
|
|
)
|
|
backup._info.pop("links", None)
|
|
--
|
|
2.25.1
|
|
|