listen to 'compute.instance.resize.confirm.end' event
In one integrated cloud env, there would be many solutions, which would make the compute resource strongly relocated. Watcher should listen to all the notifications which represent the compute resource changes, to update compute CDM. If not, the compute CDM will be stale, Watcher couldn't work steadily and harmoniously. Change-Id: I57173f0cce0717aa36c5ff758d972d38013e3ef8 Implements:blueprint listen-all-necessary-notifications
This commit is contained in:
parent
e9c420467e
commit
901c598dd7
@ -53,6 +53,7 @@ class NovaClusterDataModelCollector(base.BaseClusterDataModelCollector):
|
||||
nova.LegacyInstanceUpdated(self),
|
||||
nova.LegacyInstanceDeletedEnd(self),
|
||||
nova.LegacyLiveMigratedEnd(self),
|
||||
nova.LegacyInstanceResizeConfirmEnd(self),
|
||||
]
|
||||
|
||||
def execute(self):
|
||||
|
@ -466,3 +466,30 @@ class LegacyLiveMigratedEnd(UnversionedNotificationEndpoint):
|
||||
instance = self.get_or_create_instance(instance_uuid, node_uuid)
|
||||
|
||||
self.legacy_update_instance(instance, payload)
|
||||
|
||||
|
||||
class LegacyInstanceResizeConfirmEnd(UnversionedNotificationEndpoint):
|
||||
|
||||
@property
|
||||
def filter_rule(self):
|
||||
"""Nova compute.instance.resize.confirm.end filter"""
|
||||
return filtering.NotificationFilter(
|
||||
publisher_id=self.publisher_id_regex,
|
||||
event_type='compute.instance.resize.confirm.end',
|
||||
)
|
||||
|
||||
def info(self, ctxt, publisher_id, event_type, payload, metadata):
|
||||
ctxt.request_id = metadata['message_id']
|
||||
ctxt.project_domain = event_type
|
||||
LOG.info("Event '%(event)s' received from %(publisher)s "
|
||||
"with metadata %(metadata)s" %
|
||||
dict(event=event_type,
|
||||
publisher=publisher_id,
|
||||
metadata=metadata))
|
||||
LOG.debug(payload)
|
||||
|
||||
instance_uuid = payload['instance_id']
|
||||
node_uuid = payload.get('node')
|
||||
instance = self.get_or_create_instance(instance_uuid, node_uuid)
|
||||
|
||||
self.legacy_update_instance(instance, payload)
|
||||
|
@ -0,0 +1,58 @@
|
||||
{
|
||||
"event_type": "compute.instance.resize.confirm.end",
|
||||
"payload": {
|
||||
"state_description": "",
|
||||
"availability_zone": "nova",
|
||||
"terminated_at": "",
|
||||
"ephemeral_gb": 0,
|
||||
"instance_type_id": 15,
|
||||
"deleted_at": "",
|
||||
"fixed_ips": [
|
||||
{
|
||||
"version": 4,
|
||||
"vif_mac": "fa:16:3e:cb:26:a3",
|
||||
"floating_ips": [],
|
||||
"label": "test-net",
|
||||
"meta": {},
|
||||
"address": "192.168.200.14",
|
||||
"type": "fixed"
|
||||
}
|
||||
],
|
||||
"instance_id": "73b09e16-35b7-4922-804e-e8f5d9b740fc",
|
||||
"display_name": "INSTANCE_0",
|
||||
"reservation_id": "r-jmbnz8nc",
|
||||
"hostname": "INSTANCE_0",
|
||||
"state": "active",
|
||||
"progress": "",
|
||||
"launched_at": "2017-09-13T06:26:01.559215",
|
||||
"metadata": {},
|
||||
"node": "Node_1",
|
||||
"ramdisk_id": "",
|
||||
"access_ip_v6": null,
|
||||
"disk_gb": 20,
|
||||
"access_ip_v4": null,
|
||||
"kernel_id": "",
|
||||
"host": "Node_1",
|
||||
"user_id": "0c1add55e6d149108deedee780fdb540",
|
||||
"image_ref_url": "http://10.21.1.14:9292/images/886eae2b-b41f-4340-acd1-a1b926671b0a",
|
||||
"cell_name": "",
|
||||
"root_gb": 20,
|
||||
"tenant_id": "b18faa9487864b20b61386438b7ae2ce",
|
||||
"created_at": "2017-09-11 09:48:05+00:00",
|
||||
"memory_mb": 2048,
|
||||
"instance_type": "U2M2D20",
|
||||
"vcpus": 2,
|
||||
"image_meta": {
|
||||
"min_disk": "20",
|
||||
"container_format": "bare",
|
||||
"min_ram": "0",
|
||||
"disk_format": "raw",
|
||||
"base_image_ref": "886eae2b-b41f-4340-acd1-a1b926671b0a"
|
||||
},
|
||||
"architecture": null,
|
||||
"os_type": null,
|
||||
"instance_flavor_id": "5a0665e0-d2ec-4e4b-85f9-cc0ce4ab052b"
|
||||
},
|
||||
"priority": "INFO",
|
||||
"publisher_id": "compute.Node_1"
|
||||
}
|
@ -521,3 +521,27 @@ class TestLegacyNovaNotifications(NotificationTestCase):
|
||||
self.assertRaises(
|
||||
exception.InstanceNotFound,
|
||||
compute_model.get_instance_by_uuid, instance0_uuid)
|
||||
|
||||
def test_legacy_instance_resize_confirm_end(self):
|
||||
compute_model = self.fake_cdmc.generate_scenario_3_with_2_nodes()
|
||||
self.fake_cdmc.cluster_data_model = compute_model
|
||||
handler = novanotification.LegacyLiveMigratedEnd(self.fake_cdmc)
|
||||
|
||||
instance0_uuid = '73b09e16-35b7-4922-804e-e8f5d9b740fc'
|
||||
instance0 = compute_model.get_instance_by_uuid(instance0_uuid)
|
||||
|
||||
node = compute_model.get_node_by_instance_uuid(instance0_uuid)
|
||||
self.assertEqual('Node_0', node.uuid)
|
||||
|
||||
message = self.load_message(
|
||||
'scenario3_legacy_instance-resize-confirm-end.json')
|
||||
handler.info(
|
||||
ctxt=self.context,
|
||||
publisher_id=message['publisher_id'],
|
||||
event_type=message['event_type'],
|
||||
payload=message['payload'],
|
||||
metadata=self.FAKE_METADATA,
|
||||
)
|
||||
node = compute_model.get_node_by_instance_uuid(instance0_uuid)
|
||||
self.assertEqual('Node_1', node.uuid)
|
||||
self.assertEqual(element.InstanceState.ACTIVE.value, instance0.state)
|
||||
|
Loading…
x
Reference in New Issue
Block a user