Browse Source

Add CRUD notification objects for volume connector and volume target

This patch adds CRUD notification objects for volume connector and
volume target. Emission will be implemented in API changes for
volume connector and volume target.

Change-Id: Ib13428702f109c20d014ea1870b3c5982db3df0f
Partial-Bug: 1526231
tags/9.0.0
Hironori Shiina 2 years ago
parent
commit
4db3123e60

+ 42
- 0
ironic/objects/volume_connector.py View File

@@ -20,6 +20,7 @@ from ironic.common import exception
20 20
 from ironic.db import api as db_api
21 21
 from ironic.objects import base
22 22
 from ironic.objects import fields as object_fields
23
+from ironic.objects import notification
23 24
 
24 25
 
25 26
 @base.IronicObjectRegistry.register
@@ -240,3 +241,44 @@ class VolumeConnector(base.IronicObject,
240 241
         current = self.get_by_uuid(self._context, uuid=self.uuid)
241 242
         self.obj_refresh(current)
242 243
         self.obj_reset_changes()
244
+
245
+
246
+@base.IronicObjectRegistry.register
247
+class VolumeConnectorCRUDNotification(notification.NotificationBase):
248
+    """Notification emitted at CRUD of a volume connector."""
249
+    # Version 1.0: Initial version
250
+    VERSION = '1.0'
251
+
252
+    fields = {
253
+        'payload': object_fields.ObjectField('VolumeConnectorCRUDPayload')
254
+    }
255
+
256
+
257
+@base.IronicObjectRegistry.register
258
+class VolumeConnectorCRUDPayload(notification.NotificationPayloadBase):
259
+    """Payload schema for CRUD of a volume connector."""
260
+    # Version 1.0: Initial version
261
+    VERSION = '1.0'
262
+
263
+    SCHEMA = {
264
+        'extra': ('connector', 'extra'),
265
+        'type': ('connector', 'type'),
266
+        'connector_id': ('connector', 'connector_id'),
267
+        'created_at': ('connector', 'created_at'),
268
+        'updated_at': ('connector', 'updated_at'),
269
+        'uuid': ('connector', 'uuid'),
270
+    }
271
+
272
+    fields = {
273
+        'extra': object_fields.FlexibleDictField(nullable=True),
274
+        'type': object_fields.StringField(nullable=True),
275
+        'connector_id': object_fields.StringField(nullable=True),
276
+        'node_uuid': object_fields.UUIDField(),
277
+        'created_at': object_fields.DateTimeField(nullable=True),
278
+        'updated_at': object_fields.DateTimeField(nullable=True),
279
+        'uuid': object_fields.UUIDField(),
280
+    }
281
+
282
+    def __init__(self, connector, node_uuid):
283
+        super(VolumeConnectorCRUDPayload, self).__init__(node_uuid=node_uuid)
284
+        self.populate_schema(connector=connector)

+ 45
- 0
ironic/objects/volume_target.py View File

@@ -20,6 +20,7 @@ from ironic.common import exception
20 20
 from ironic.db import api as db_api
21 21
 from ironic.objects import base
22 22
 from ironic.objects import fields as object_fields
23
+from ironic.objects import notification
23 24
 
24 25
 
25 26
 @base.IronicObjectRegistry.register
@@ -263,3 +264,47 @@ class VolumeTarget(base.IronicObject,
263 264
         current = self.get_by_uuid(self._context, uuid=self.uuid)
264 265
         self.obj_refresh(current)
265 266
         self.obj_reset_changes()
267
+
268
+
269
+@base.IronicObjectRegistry.register
270
+class VolumeTargetCRUDNotification(notification.NotificationBase):
271
+    """Notification emitted at CRUD of a volume target."""
272
+    # Version 1.0: Initial version
273
+    VERSION = '1.0'
274
+
275
+    fields = {
276
+        'payload': object_fields.ObjectField('VolumeTargetCRUDPayload')
277
+    }
278
+
279
+
280
+@base.IronicObjectRegistry.register
281
+class VolumeTargetCRUDPayload(notification.NotificationPayloadBase):
282
+    # Version 1.0: Initial Version
283
+    VERSION = '1.0'
284
+
285
+    SCHEMA = {
286
+        'boot_index': ('target', 'boot_index'),
287
+        'extra': ('target', 'extra'),
288
+        'properties': ('target', 'properties'),
289
+        'volume_id': ('target', 'volume_id'),
290
+        'volume_type': ('target', 'volume_type'),
291
+        'created_at': ('target', 'created_at'),
292
+        'updated_at': ('target', 'updated_at'),
293
+        'uuid': ('target', 'uuid'),
294
+    }
295
+
296
+    fields = {
297
+        'boot_index': object_fields.IntegerField(nullable=True),
298
+        'extra': object_fields.FlexibleDictField(nullable=True),
299
+        'node_uuid': object_fields.UUIDField(),
300
+        'properties': object_fields.FlexibleDictField(nullable=True),
301
+        'volume_id': object_fields.StringField(nullable=True),
302
+        'volume_type': object_fields.StringField(nullable=True),
303
+        'created_at': object_fields.DateTimeField(nullable=True),
304
+        'updated_at': object_fields.DateTimeField(nullable=True),
305
+        'uuid': object_fields.UUIDField(),
306
+    }
307
+
308
+    def __init__(self, target, node_uuid):
309
+        super(VolumeTargetCRUDPayload, self).__init__(node_uuid=node_uuid)
310
+        self.populate_schema(target=target)

+ 4
- 0
ironic/tests/unit/objects/test_objects.py View File

@@ -654,6 +654,10 @@ expected_object_fingerprints = {
654 654
     'NodeConsoleNotification': '1.0-59acc533c11d306f149846f922739c15',
655 655
     'PortgroupCRUDNotification': '1.0-59acc533c11d306f149846f922739c15',
656 656
     'PortgroupCRUDPayload': '1.0-b73c1fecf0cef3aa56bbe3c7e2275018',
657
+    'VolumeConnectorCRUDNotification': '1.0-59acc533c11d306f149846f922739c15',
658
+    'VolumeConnectorCRUDPayload': '1.0-5e8dbb41e05b6149d8f7bfd4daff9339',
659
+    'VolumeTargetCRUDNotification': '1.0-59acc533c11d306f149846f922739c15',
660
+    'VolumeTargetCRUDPayload': '1.0-30dcc4735512c104a3a36a2ae1e2aeb2',
657 661
 }
658 662
 
659 663
 

+ 7
- 1
ironic/tests/unit/objects/test_volume_connector.py View File

@@ -21,9 +21,11 @@ from ironic.common import exception
21 21
 from ironic import objects
22 22
 from ironic.tests.unit.db import base as db_base
23 23
 from ironic.tests.unit.db import utils as db_utils
24
+from ironic.tests.unit.objects import utils as obj_utils
24 25
 
25 26
 
26
-class TestVolumeConnectorObject(db_base.DbTestCase):
27
+class TestVolumeConnectorObject(db_base.DbTestCase,
28
+                                obj_utils.SchemasTestMixIn):
27 29
 
28 30
     def setUp(self):
29 31
         super(TestVolumeConnectorObject, self).setUp()
@@ -193,3 +195,7 @@ class TestVolumeConnectorObject(db_base.DbTestCase):
193 195
         vc_copy.name = 'aaff'
194 196
         # Ensure this passes and an exception is not generated
195 197
         vc_copy.save()
198
+
199
+    def test_payload_schemas(self):
200
+        self._check_payload_schemas(objects.volume_connector,
201
+                                    objects.VolumeConnector.fields)

+ 6
- 1
ironic/tests/unit/objects/test_volume_target.py View File

@@ -21,9 +21,10 @@ from ironic.common import exception
21 21
 from ironic import objects
22 22
 from ironic.tests.unit.db import base as db_base
23 23
 from ironic.tests.unit.db import utils as db_utils
24
+from ironic.tests.unit.objects import utils as obj_utils
24 25
 
25 26
 
26
-class TestVolumeTargetObject(db_base.DbTestCase):
27
+class TestVolumeTargetObject(db_base.DbTestCase, obj_utils.SchemasTestMixIn):
27 28
 
28 29
     def setUp(self):
29 30
         super(TestVolumeTargetObject, self).setUp()
@@ -204,3 +205,7 @@ class TestVolumeTargetObject(db_base.DbTestCase):
204 205
         vt_copy.name = 'aaff'
205 206
         # Ensure this passes and an exception is not generated
206 207
         vt_copy.save()
208
+
209
+    def test_payload_schemas(self):
210
+        self._check_payload_schemas(objects.volume_target,
211
+                                    objects.VolumeTarget.fields)

Loading…
Cancel
Save