Make snapshot and backup name optional

Cinder does not require snapshot and backup name. These arguments are
optional.

Change-Id: I05d59efc9642205a25684bf0b77758328296d959
This commit is contained in:
Ivan Kolodyazhny 2016-03-17 18:35:41 +02:00
parent e49c3f6682
commit 311e775c81
7 changed files with 52 additions and 4 deletions

View File

@ -77,6 +77,30 @@ class TestBackupCreate(TestBackup):
self.assertEqual(columns, volume_fakes.BACKUP_columns)
self.assertEqual(data, volume_fakes.BACKUP_data)
def test_backup_create_without_name(self):
arglist = [
volume_fakes.volume_id,
"--description", volume_fakes.backup_description,
"--container", volume_fakes.backup_name
]
verifylist = [
("volume", volume_fakes.volume_id),
("description", volume_fakes.backup_description),
("container", volume_fakes.backup_name)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.backups_mock.create.assert_called_with(
volume_fakes.volume_id,
container=volume_fakes.backup_name,
name=None,
description=volume_fakes.backup_description
)
self.assertEqual(columns, volume_fakes.BACKUP_columns)
self.assertEqual(data, volume_fakes.BACKUP_data)
class TestBackupDelete(TestBackup):

View File

@ -75,6 +75,30 @@ class TestSnapshotCreate(TestSnapshot):
self.assertEqual(columns, volume_fakes.SNAPSHOT_columns)
self.assertEqual(data, volume_fakes.SNAPSHOT_data)
def test_snapshot_create_without_name(self):
arglist = [
volume_fakes.volume_id,
"--description", volume_fakes.snapshot_description,
"--force"
]
verifylist = [
("volume", volume_fakes.volume_id),
("description", volume_fakes.snapshot_description),
("force", True)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.snapshots_mock.create.assert_called_with(
volume_fakes.volume_id,
force=True,
name=None,
description=volume_fakes.snapshot_description
)
self.assertEqual(columns, volume_fakes.SNAPSHOT_columns)
self.assertEqual(data, volume_fakes.SNAPSHOT_data)
class TestSnapshotDelete(TestSnapshot):

View File

@ -41,7 +41,6 @@ class CreateBackup(command.ShowOne):
parser.add_argument(
'--name',
metavar='<name>',
required=False,
help='Name of the backup',
)
parser.add_argument(

View File

@ -36,7 +36,6 @@ class CreateSnapshot(command.ShowOne):
parser.add_argument(
'--name',
metavar='<name>',
required=True,
help='Name of the snapshot',
)
parser.add_argument(

View File

@ -35,7 +35,6 @@ class CreateBackup(command.ShowOne):
parser.add_argument(
"--name",
metavar="<name>",
required=True,
help="Name of the backup"
)
parser.add_argument(

View File

@ -36,7 +36,6 @@ class CreateSnapshot(command.ShowOne):
parser.add_argument(
"--name",
metavar="<name>",
required=True,
help="Name of the snapshot"
)
parser.add_argument(

View File

@ -0,0 +1,4 @@
---
fixes:
- Make ``--name`` optional in ``volume snapshot create`` and
``volume backup create`` commands.