Return appropriate data on share create
With the introduction of share instances in the Liberty release, some attributes of the share model were moved to the share_instance model. The create API has since been returning merely the share data which makes for a bad user experience with some attributes being set to null. Fix this issue by retrieving the share from the database after the instance has been created; so that the status field reflects the pre-scheduler acceptable status of 'creating'. Note: Back porting this fix needs commit7319e0fe6f
to be back ported as well to fix the share_metadata unit tests since they use this API as well. Depends-On: Ia584e3e6bd02f937df7630a1d09d49c888f77c8f Change-Id: I63955e1a60e7ced3ad126829521cd43e0b914c17 Closes-Bug: #1534161 (cherry picked from commit2e65c5cf35
)
This commit is contained in:
parent
5e4d589c54
commit
e17ce1cd2c
|
@ -252,6 +252,9 @@ class API(base.Base):
|
|||
consistency_group=consistency_group,
|
||||
cgsnapshot_member=cgsnapshot_member)
|
||||
|
||||
# Retrieve the share with instance details
|
||||
share = self.db.share_get(context, share['id'])
|
||||
|
||||
return share
|
||||
|
||||
def create_instance(self, context, share, share_network_id=None,
|
||||
|
|
|
@ -583,6 +583,9 @@ class ShareAPITestCase(test.TestCase):
|
|||
availability_zone=az
|
||||
)
|
||||
|
||||
share['status'] = constants.STATUS_CREATING
|
||||
share['host'] = None
|
||||
|
||||
self.assertSubDictMatch(share_data,
|
||||
db_api.share_create.call_args[0][1])
|
||||
|
||||
|
@ -607,6 +610,9 @@ class ShareAPITestCase(test.TestCase):
|
|||
share_data['display_description'],
|
||||
availability_zone=az)
|
||||
|
||||
share['status'] = constants.STATUS_CREATING
|
||||
share['host'] = None
|
||||
|
||||
self.assertSubDictMatch(share_data,
|
||||
db_api.share_create.call_args[0][1])
|
||||
|
||||
|
|
|
@ -56,6 +56,10 @@ class SharesNFSTest(base.BaseSharesTest):
|
|||
"actual": share.keys()})
|
||||
self.assertFalse(share['is_public'])
|
||||
|
||||
# The 'status' of the share returned by the create API must be
|
||||
# the default value - 'creating'.
|
||||
self.assertEqual('creating', share['status'])
|
||||
|
||||
# delete share
|
||||
self.shares_client.delete_share(share['id'])
|
||||
self.shares_client.wait_for_resource_deletion(share_id=share['id'])
|
||||
|
@ -107,6 +111,10 @@ class SharesNFSTest(base.BaseSharesTest):
|
|||
s2 = self.create_share(
|
||||
self.protocol, snapshot_id=snap["id"], cleanup_in_class=False)
|
||||
|
||||
# The 'status' of the share returned by the create API must be
|
||||
# the default value - 'creating'.
|
||||
self.assertEqual('creating', s2['status'])
|
||||
|
||||
# verify share, created from snapshot
|
||||
get = self.shares_client.get_share(s2["id"])
|
||||
msg = "Expected snapshot_id %s as "\
|
||||
|
@ -133,6 +141,10 @@ class SharesNFSTest(base.BaseSharesTest):
|
|||
child = self.create_share(
|
||||
self.protocol, snapshot_id=snap["id"], cleanup_in_class=False)
|
||||
|
||||
# The 'status' of the share returned by the create API must be
|
||||
# the default value - 'creating'.
|
||||
self.assertEqual('creating', child['status'])
|
||||
|
||||
# verify share, created from snapshot
|
||||
get = self.shares_client.get_share(child["id"])
|
||||
keys = {
|
||||
|
|
Loading…
Reference in New Issue