listen to 'compute.instance.rebuild.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: I793131dd8f24f1ac5f5a6a070bb4fe7980c8dfb2 Implements:blueprint listen-all-necessary-notifications
This commit is contained in:
@@ -158,6 +158,7 @@ class NovaClusterDataModelCollector(base.BaseClusterDataModelCollector):
|
||||
nova.LegacyInstanceDeletedEnd(self),
|
||||
nova.LegacyLiveMigratedEnd(self),
|
||||
nova.LegacyInstanceResizeConfirmEnd(self),
|
||||
nova.LegacyInstanceRebuildEnd(self),
|
||||
]
|
||||
|
||||
def get_audit_scope_handler(self, audit_scope):
|
||||
|
||||
@@ -497,3 +497,30 @@ class LegacyInstanceResizeConfirmEnd(UnversionedNotificationEndpoint):
|
||||
instance = self.get_or_create_instance(instance_uuid, node_uuid)
|
||||
|
||||
self.legacy_update_instance(instance, payload)
|
||||
|
||||
|
||||
class LegacyInstanceRebuildEnd(UnversionedNotificationEndpoint):
|
||||
|
||||
@property
|
||||
def filter_rule(self):
|
||||
"""Nova compute.instance.rebuild.end filter"""
|
||||
return filtering.NotificationFilter(
|
||||
publisher_id=self.publisher_id_regex,
|
||||
event_type='compute.instance.rebuild.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,59 @@
|
||||
{
|
||||
"event_type": "compute.instance.rebuild.end",
|
||||
"payload": {
|
||||
"state_description": "",
|
||||
"availability_zone": "nova",
|
||||
"terminated_at": "",
|
||||
"ephemeral_gb": 0,
|
||||
"instance_type_id": 5,
|
||||
"deleted_at": "",
|
||||
"fixed_ips": [
|
||||
{
|
||||
"version": 4,
|
||||
"vif_mac": "fa:16:3e:78:e1:a0",
|
||||
"floating_ips": [],
|
||||
"label": "test-net",
|
||||
"meta": {},
|
||||
"address": "192.168.200.16",
|
||||
"type": "fixed"
|
||||
}
|
||||
],
|
||||
"instance_id": "73b09e16-35b7-4922-804e-e8f5d9b740fc",
|
||||
"display_name": "INSTANCE_0",
|
||||
"reservation_id": "r-jmbnz8nc",
|
||||
"hostname": "INSTANCE_1",
|
||||
"state": "active",
|
||||
"progress": "",
|
||||
"launched_at": "2017-09-13T06:10:42.751392",
|
||||
"metadata": {},
|
||||
"node": "Node_1",
|
||||
"ramdisk_id": "",
|
||||
"access_ip_v6": null,
|
||||
"disk_gb": 20,
|
||||
"access_ip_v4": null,
|
||||
"kernel_id": "",
|
||||
"image_name": "",
|
||||
"host": "Node_1",
|
||||
"user_id": "0c1add55e6d149108deedee780fdb540",
|
||||
"image_ref_url": "http://10.21.1.16: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": "m1.small",
|
||||
"vcpus": 1,
|
||||
"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": "2"
|
||||
},
|
||||
"priority": "INFO",
|
||||
"publisher_id": "compute.Node_1"
|
||||
}
|
||||
@@ -545,3 +545,27 @@ class TestLegacyNovaNotifications(NotificationTestCase):
|
||||
node = compute_model.get_node_by_instance_uuid(instance0_uuid)
|
||||
self.assertEqual('Node_1', node.uuid)
|
||||
self.assertEqual(element.InstanceState.ACTIVE.value, instance0.state)
|
||||
|
||||
def test_legacy_instance_rebuild_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-rebuild-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)
|
||||
|
||||
Reference in New Issue
Block a user