Add policy field to ServerGroup notification object
In this patch, the ServerGroupPayload is updated to include the new ``policy`` field; the ``policies`` field is deprecated for removal but still put into the notification payload for backward compatibility. Related to blueprint complex-anti-affinity-policies Change-Id: Ie739ee8dec4685cd70e735ff83f7f30bc7e95a57
This commit is contained in:
parent
8fa70e5dfc
commit
c67ab38ea0
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"nova_object.version": "1.0",
|
"nova_object.version": "1.1",
|
||||||
"nova_object.namespace": "nova",
|
"nova_object.namespace": "nova",
|
||||||
"nova_object.name": "ServerGroupPayload",
|
"nova_object.name": "ServerGroupPayload",
|
||||||
"nova_object.data": {
|
"nova_object.data": {
|
||||||
@ -10,6 +10,8 @@
|
|||||||
"policies": [
|
"policies": [
|
||||||
"anti-affinity"
|
"anti-affinity"
|
||||||
],
|
],
|
||||||
|
"policy": "anti-affinity",
|
||||||
|
"rules": {},
|
||||||
"members": [],
|
"members": [],
|
||||||
"hosts": null
|
"hosts": null
|
||||||
}
|
}
|
||||||
|
@ -27,17 +27,24 @@ class ServerGroupPayload(base.NotificationPayloadBase):
|
|||||||
'policies': ('group', 'policies'),
|
'policies': ('group', 'policies'),
|
||||||
'members': ('group', 'members'),
|
'members': ('group', 'members'),
|
||||||
'hosts': ('group', 'hosts'),
|
'hosts': ('group', 'hosts'),
|
||||||
|
'policy': ('group', 'policy'),
|
||||||
|
'rules': ('group', 'rules'),
|
||||||
}
|
}
|
||||||
# Version 1.0: Initial version
|
# Version 1.0: Initial version
|
||||||
VERSION = '1.0'
|
# Version 1.1: Deprecate policies, add policy and add rules
|
||||||
|
VERSION = '1.1'
|
||||||
fields = {
|
fields = {
|
||||||
'uuid': fields.UUIDField(),
|
'uuid': fields.UUIDField(),
|
||||||
'name': fields.StringField(nullable=True),
|
'name': fields.StringField(nullable=True),
|
||||||
'user_id': fields.StringField(nullable=True),
|
'user_id': fields.StringField(nullable=True),
|
||||||
'project_id': fields.StringField(nullable=True),
|
'project_id': fields.StringField(nullable=True),
|
||||||
|
# NOTE(yikun): policies is deprecated and should
|
||||||
|
# be removed on the next major version bump
|
||||||
'policies': fields.ListOfStringsField(nullable=True),
|
'policies': fields.ListOfStringsField(nullable=True),
|
||||||
'members': fields.ListOfStringsField(nullable=True),
|
'members': fields.ListOfStringsField(nullable=True),
|
||||||
'hosts': fields.ListOfStringsField(nullable=True),
|
'hosts': fields.ListOfStringsField(nullable=True),
|
||||||
|
'policy': fields.StringField(nullable=True),
|
||||||
|
'rules': fields.DictOfStringsField(),
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, group):
|
def __init__(self, group):
|
||||||
|
@ -1160,7 +1160,9 @@ class ServerGroupTestCase(test.TestCase):
|
|||||||
user_id=self.user_id,
|
user_id=self.user_id,
|
||||||
project_id=self.project_id,
|
project_id=self.project_id,
|
||||||
name="test-server-group",
|
name="test-server-group",
|
||||||
policies=["anti-affinity"])
|
policy="anti-affinity",
|
||||||
|
policies=["anti-affinity"],
|
||||||
|
rules={"max_server_per_host": 3})
|
||||||
|
|
||||||
def test_notify_about_server_group_action(self):
|
def test_notify_about_server_group_action(self):
|
||||||
compute_utils.notify_about_server_group_action(self.context,
|
compute_utils.notify_about_server_group_action(self.context,
|
||||||
@ -1174,6 +1176,8 @@ class ServerGroupTestCase(test.TestCase):
|
|||||||
'nova_object.data': {
|
'nova_object.data': {
|
||||||
'name': u'test-server-group',
|
'name': u'test-server-group',
|
||||||
'policies': [u'anti-affinity'],
|
'policies': [u'anti-affinity'],
|
||||||
|
'policy': u'anti-affinity',
|
||||||
|
'rules': {"max_server_per_host": "3"},
|
||||||
'project_id': u'fake',
|
'project_id': u'fake',
|
||||||
'user_id': u'fake',
|
'user_id': u'fake',
|
||||||
'uuid': uuids.server_group,
|
'uuid': uuids.server_group,
|
||||||
@ -1182,7 +1186,7 @@ class ServerGroupTestCase(test.TestCase):
|
|||||||
},
|
},
|
||||||
'nova_object.name': 'ServerGroupPayload',
|
'nova_object.name': 'ServerGroupPayload',
|
||||||
'nova_object.namespace': 'nova',
|
'nova_object.namespace': 'nova',
|
||||||
'nova_object.version': '1.0'
|
'nova_object.version': '1.1'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.assertEqual(notification, expected)
|
self.assertEqual(notification, expected)
|
||||||
@ -1204,6 +1208,8 @@ class ServerGroupTestCase(test.TestCase):
|
|||||||
'nova_object.data': {
|
'nova_object.data': {
|
||||||
'name': u'test-server-group',
|
'name': u'test-server-group',
|
||||||
'policies': [u'anti-affinity'],
|
'policies': [u'anti-affinity'],
|
||||||
|
'policy': u'anti-affinity',
|
||||||
|
'rules': {"max_server_per_host": "3"},
|
||||||
'project_id': u'fake',
|
'project_id': u'fake',
|
||||||
'user_id': u'fake',
|
'user_id': u'fake',
|
||||||
'uuid': uuids.server_group,
|
'uuid': uuids.server_group,
|
||||||
@ -1212,7 +1218,7 @@ class ServerGroupTestCase(test.TestCase):
|
|||||||
},
|
},
|
||||||
'nova_object.name': 'ServerGroupPayload',
|
'nova_object.name': 'ServerGroupPayload',
|
||||||
'nova_object.namespace': 'nova',
|
'nova_object.namespace': 'nova',
|
||||||
'nova_object.version': '1.0'
|
'nova_object.version': '1.1'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.assertEqual(notification, expected)
|
self.assertEqual(notification, expected)
|
||||||
|
@ -405,7 +405,7 @@ notification_object_data = {
|
|||||||
'KeypairPayload': '1.0-6daebbbde0e1bf35c1556b1ecd9385c1',
|
'KeypairPayload': '1.0-6daebbbde0e1bf35c1556b1ecd9385c1',
|
||||||
'NotificationPublisher': '2.2-b6ad48126247e10b46b6b0240e52e614',
|
'NotificationPublisher': '2.2-b6ad48126247e10b46b6b0240e52e614',
|
||||||
'ServerGroupNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
|
'ServerGroupNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
|
||||||
'ServerGroupPayload': '1.0-eb4bd1738b4670cfe1b7c30344c143c3',
|
'ServerGroupPayload': '1.1-4ded2997ea1b07038f7af33ef5c45f7f',
|
||||||
'ServiceStatusNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
|
'ServiceStatusNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
|
||||||
'ServiceStatusPayload': '1.1-7b6856bd879db7f3ecbcd0ca9f35f92f',
|
'ServiceStatusPayload': '1.1-7b6856bd879db7f3ecbcd0ca9f35f92f',
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
The new style ``policy`` field has been added to ``ServerGroupPayload``.
|
||||||
|
The ``server_group.create``, ``server_group.delete`` and
|
||||||
|
``server_group.add_member`` versioned notifications will be updated to
|
||||||
|
include the new ``policy`` and ``rules``field. The ``policies`` field is
|
||||||
|
deprecated for removal but still put into the notification payload for
|
||||||
|
backward compatibility.
|
Loading…
Reference in New Issue
Block a user