diff options
| author | whoami-rajat <rajatdhasmana@gmail.com> | 2022-11-22 19:25:39 +0530 |
|---|---|---|
| committer | whoami-rajat <rajatdhasmana@gmail.com> | 2022-11-23 14:20:06 +0530 |
| commit | 4710cbeca6638cc78880f2c4fc22d74aa7bb7c41 (patch) | |
| tree | 5b7b4fa2d2758202a5c4f4824ed9e7c0dde3c059 /openstackclient/volume | |
| parent | 96162c24eaba5ba70a6d8f61da815d2d6ffea7ed (diff) | |
| download | python-openstackclient-4710cbeca6638cc78880f2c4fc22d74aa7bb7c41.tar.gz | |
Add test for creating volume from source
This patch adds a test to create a new volume from source.
We also include code changes to pass the right size i.e. either
size passed by the user via --size argument or the source volume
size. This case is already handled at the API layer[1] but it
helps being consistent with passing the right size value as in case
of creating a volume from snapshot or backup.
[1] https://github.com/openstack/cinder/blob/7c1a5ce7b11964da4537fd6a7d157ede646b9e94/cinder/api/v3/volumes.py#L381-L382
Change-Id: Idc71636dad6bb678fe24f19b0836d2e9bd92d7d2
Diffstat (limited to 'openstackclient/volume')
| -rw-r--r-- | openstackclient/volume/v2/volume.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/openstackclient/volume/v2/volume.py b/openstackclient/volume/v2/volume.py index ffcbd573..7905e097 100644 --- a/openstackclient/volume/v2/volume.py +++ b/openstackclient/volume/v2/volume.py @@ -183,6 +183,11 @@ class CreateVolume(command.ShowOne): def take_action(self, parsed_args): _check_size_arg(parsed_args) + # size is validated in the above call to + # _check_size_arg where we check that size + # should be passed if we are not creating a + # volume from snapshot, backup or source volume + size = parsed_args.size volume_client = self.app.client_manager.volume image_client = self.app.client_manager.image @@ -195,9 +200,11 @@ class CreateVolume(command.ShowOne): source_volume = None if parsed_args.source: - source_volume = utils.find_resource( + source_volume_obj = utils.find_resource( volume_client.volumes, - parsed_args.source).id + parsed_args.source) + source_volume = source_volume_obj.id + size = max(size or 0, source_volume_obj.size) consistency_group = None if parsed_args.consistency_group: @@ -210,8 +217,6 @@ class CreateVolume(command.ShowOne): image = image_client.find_image(parsed_args.image, ignore_missing=False).id - size = parsed_args.size - snapshot = None if parsed_args.snapshot: snapshot_obj = utils.find_resource( |
