summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-09-01 19:37:41 +0000
committerGerrit Code Review <review@openstack.org>2015-09-01 19:37:41 +0000
commit1faf8ea70fc8ff08db833657bf45a4ff0fd0c432 (patch)
treeaa52aad62f0d4bf75271233266454f45b391aee0
parent401f1cfdef9004e5b2c23991e8b8f3182ef07f34 (diff)
parentb5ac930aabfeff69f9a669f6dd774851db53df99 (diff)
Merge "Use Share Instance ID in 'name' property"1.0.0.0b3
-rw-r--r--manila/db/sqlalchemy/models.py8
-rw-r--r--manila/tests/db/sqlalchemy/test_api.py7
2 files changed, 13 insertions, 2 deletions
diff --git a/manila/db/sqlalchemy/models.py b/manila/db/sqlalchemy/models.py
index 96ebb5b..bd041fc 100644
--- a/manila/db/sqlalchemy/models.py
+++ b/manila/db/sqlalchemy/models.py
@@ -267,8 +267,8 @@ class Share(BASE, ManilaBase):
267class ShareInstance(BASE, ManilaBase): 267class ShareInstance(BASE, ManilaBase):
268 __tablename__ = 'share_instances' 268 __tablename__ = 'share_instances'
269 269
270 _extra_keys = ['export_location', 'availability_zone'] 270 _extra_keys = ['name', 'export_location', 'availability_zone']
271 _proxified_properties = ('name', 'user_id', 'project_id', 'size', 271 _proxified_properties = ('user_id', 'project_id', 'size',
272 'display_name', 'display_description', 272 'display_name', 'display_description',
273 'snapshot_id', 'share_proto', 'share_type_id', 273 'snapshot_id', 'share_proto', 'share_type_id',
274 'is_public') 274 'is_public')
@@ -278,6 +278,10 @@ class ShareInstance(BASE, ManilaBase):
278 setattr(self, share_property, share[share_property]) 278 setattr(self, share_property, share[share_property])
279 279
280 @property 280 @property
281 def name(self):
282 return CONF.share_name_template % self.id
283
284 @property
281 def export_location(self): 285 def export_location(self):
282 if len(self.export_locations) > 0: 286 if len(self.export_locations) > 0:
283 return self.export_locations[0]['path'] 287 return self.export_locations[0]['path']
diff --git a/manila/tests/db/sqlalchemy/test_api.py b/manila/tests/db/sqlalchemy/test_api.py
index 59736a6..832b985 100644
--- a/manila/tests/db/sqlalchemy/test_api.py
+++ b/manila/tests/db/sqlalchemy/test_api.py
@@ -186,6 +186,13 @@ class ShareDatabaseAPITestCase(test.TestCase):
186 self.assertRaises(exception.NotFound, db_api.share_get, 186 self.assertRaises(exception.NotFound, db_api.share_get,
187 self.ctxt, share['id']) 187 self.ctxt, share['id'])
188 188
189 def test_share_instance_get(self):
190 share = db_utils.create_share()
191
192 instance = db_api.share_instance_get(self.ctxt, share.instance['id'])
193
194 self.assertEqual('share-%s' % instance['id'], instance['name'])
195
189 @ddt.data('host') 196 @ddt.data('host')
190 def test_share_get_all_sort_by_share_instance_fields(self, sort_key): 197 def test_share_get_all_sort_by_share_instance_fields(self, sort_key):
191 shares = [db_utils.create_share(**{sort_key: n, 'size': 1}) 198 shares = [db_utils.create_share(**{sort_key: n, 'size': 1})