Browse Source

Merge "Use Share Instance ID in 'name' property"

tags/1.0.0.0b3^0
Jenkins 3 years ago
parent
commit
1faf8ea70f
2 changed files with 13 additions and 2 deletions
  1. 6
    2
      manila/db/sqlalchemy/models.py
  2. 7
    0
      manila/tests/db/sqlalchemy/test_api.py

+ 6
- 2
manila/db/sqlalchemy/models.py View File

@@ -267,8 +267,8 @@ class Share(BASE, ManilaBase):
267 267
 class ShareInstance(BASE, ManilaBase):
268 268
     __tablename__ = 'share_instances'
269 269
 
270
-    _extra_keys = ['export_location', 'availability_zone']
271
-    _proxified_properties = ('name', 'user_id', 'project_id', 'size',
270
+    _extra_keys = ['name', 'export_location', 'availability_zone']
271
+    _proxified_properties = ('user_id', 'project_id', 'size',
272 272
                              'display_name', 'display_description',
273 273
                              'snapshot_id', 'share_proto', 'share_type_id',
274 274
                              'is_public')
@@ -277,6 +277,10 @@ class ShareInstance(BASE, ManilaBase):
277 277
         for share_property in self._proxified_properties:
278 278
             setattr(self, share_property, share[share_property])
279 279
 
280
+    @property
281
+    def name(self):
282
+        return CONF.share_name_template % self.id
283
+
280 284
     @property
281 285
     def export_location(self):
282 286
         if len(self.export_locations) > 0:

+ 7
- 0
manila/tests/db/sqlalchemy/test_api.py View File

@@ -186,6 +186,13 @@ class ShareDatabaseAPITestCase(test.TestCase):
186 186
         self.assertRaises(exception.NotFound, db_api.share_get,
187 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 196
     @ddt.data('host')
190 197
     def test_share_get_all_sort_by_share_instance_fields(self, sort_key):
191 198
         shares = [db_utils.create_share(**{sort_key: n, 'size': 1})

Loading…
Cancel
Save