Fixes create share from snapshot in OSC
This patch set adds the capability of creating a share from snapshot in the openstack client. This bug was fixed for the GHC2020 OSD by the $author, Maari Tamm, Sol K, Priya, Zuleinis and Hieu. Change-Id: If32d55d52cd0c04a10fd0f1b2ac19fad843cecf6 Closes-Bug: #1888327
This commit is contained in:
parent
3cc12ce444
commit
07898faca6
@ -206,11 +206,12 @@ class CreateShare(command.ShowOne):
|
||||
if parsed_args.snapshot_id:
|
||||
snapshot = apiutils.find_resource(share_client.share_snapshots,
|
||||
parsed_args.snapshot_id)
|
||||
snapshot_id = snapshot.id
|
||||
size = max(size or 0, snapshot.size)
|
||||
|
||||
body = {
|
||||
'share_proto': parsed_args.share_proto,
|
||||
'size': parsed_args.size,
|
||||
'size': size,
|
||||
'snapshot_id': snapshot_id,
|
||||
'name': parsed_args.name,
|
||||
'description': parsed_args.description,
|
||||
|
@ -41,6 +41,9 @@ class TestShare(manila_fakes.TestShare):
|
||||
self.users_mock = self.app.client_manager.identity.users
|
||||
self.users_mock.reset_mock()
|
||||
|
||||
self.snapshots_mock = self.app.client_manager.share.share_snapshots
|
||||
self.snapshots_mock.reset_mock()
|
||||
|
||||
def setup_shares_mock(self, count):
|
||||
shares = manila_fakes.FakeShare.create_shares(count=count)
|
||||
|
||||
@ -61,6 +64,9 @@ class TestShareCreate(TestShare):
|
||||
self.shares_mock.create.return_value = self.new_share
|
||||
|
||||
self.shares_mock.get.return_value = self.new_share
|
||||
self.share_snapshot = (
|
||||
manila_fakes.FakeShareSnapshot.create_one_snapshot())
|
||||
self.snapshots_mock.get.return_value = self.share_snapshot
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = osc_shares.CreateShare(self.app, None)
|
||||
@ -146,9 +152,41 @@ class TestShareCreate(TestShare):
|
||||
self.assertCountEqual(self.columns, columns)
|
||||
self.assertCountEqual(self.datalist, data)
|
||||
|
||||
# TODO(vkmc) Add test with snapshot when
|
||||
# we implement snapshot support in OSC
|
||||
# def test_share_create_with_snapshot(self):
|
||||
def test_share_create_with_snapshot(self):
|
||||
"""Verifies create share from snapshot."""
|
||||
|
||||
arglist = [
|
||||
self.new_share.share_proto,
|
||||
str(self.new_share.size),
|
||||
'--snapshot-id', self.share_snapshot.id
|
||||
|
||||
]
|
||||
verifylist = [
|
||||
('share_proto', self.new_share.share_proto),
|
||||
('size', self.new_share.size),
|
||||
('snapshot_id', self.share_snapshot.id)
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.shares_mock.create.assert_called_with(
|
||||
availability_zone=None,
|
||||
description=None,
|
||||
is_public=False,
|
||||
metadata={},
|
||||
name=None,
|
||||
share_group_id=None,
|
||||
share_network=None,
|
||||
share_proto=self.new_share.share_proto,
|
||||
share_type=None,
|
||||
size=self.new_share.size,
|
||||
snapshot_id=self.share_snapshot.id
|
||||
)
|
||||
|
||||
self.assertCountEqual(self.columns, columns)
|
||||
self.assertCountEqual(self.datalist, data)
|
||||
|
||||
def test_share_create_wait(self):
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user