diff --git a/watcher/decision_engine/model/notification/nova.py b/watcher/decision_engine/model/notification/nova.py index f73e4c273..3ec755e81 100644 --- a/watcher/decision_engine/model/notification/nova.py +++ b/watcher/decision_engine/model/notification/nova.py @@ -121,7 +121,7 @@ class NovaNotification(base.NotificationEndpoint): if node_data['forced_down'] else element.ServiceState.ONLINE.value) node.status = ( element.ServiceState.DISABLED.value - if node_data['host'] else element.ServiceState.ENABLED.value) + if node_data['disabled'] else element.ServiceState.ENABLED.value) def create_compute_node(self, node_hostname): """Update the compute node by querying the Nova API.""" diff --git a/watcher/tests/decision_engine/model/notification/data/scenario3_service-update.json b/watcher/tests/decision_engine/model/notification/data/scenario3_service-update-disabled.json similarity index 100% rename from watcher/tests/decision_engine/model/notification/data/scenario3_service-update.json rename to watcher/tests/decision_engine/model/notification/data/scenario3_service-update-disabled.json diff --git a/watcher/tests/decision_engine/model/notification/data/scenario3_service-update-enabled.json b/watcher/tests/decision_engine/model/notification/data/scenario3_service-update-enabled.json new file mode 100644 index 000000000..f3e7f2334 --- /dev/null +++ b/watcher/tests/decision_engine/model/notification/data/scenario3_service-update-enabled.json @@ -0,0 +1,21 @@ +{ + "priority": "INFO", + "payload": { + "nova_object.namespace": "nova", + "nova_object.name": "ServiceStatusPayload", + "nova_object.version": "1.0", + "nova_object.data": { + "host": "Node_0", + "disabled": false, + "last_seen_up": "2012-10-29T13:42:05Z", + "binary": "nova-compute", + "topic": "compute", + "disabled_reason": null, + "report_count": 1, + "forced_down": false, + "version": 15 + } + }, + "event_type": "service.update", + "publisher_id": "nova-compute:Node_0" +} diff --git a/watcher/tests/decision_engine/model/notification/test_nova_notifications.py b/watcher/tests/decision_engine/model/notification/test_nova_notifications.py index fae9d9a43..f99c5dca7 100644 --- a/watcher/tests/decision_engine/model/notification/test_nova_notifications.py +++ b/watcher/tests/decision_engine/model/notification/test_nova_notifications.py @@ -127,7 +127,7 @@ class TestNovaNotifications(NotificationTestCase): node0_uuid = 'Node_0' node0 = compute_model.get_node_by_uuid(node0_uuid) - message = self.load_message('scenario3_service-update.json') + message = self.load_message('scenario3_service-update-disabled.json') self.assertEqual('hostname_0', node0.hostname) self.assertEqual(element.ServiceState.ONLINE.value, node0.state) @@ -145,6 +145,20 @@ class TestNovaNotifications(NotificationTestCase): self.assertEqual(element.ServiceState.OFFLINE.value, node0.state) self.assertEqual(element.ServiceState.DISABLED.value, node0.status) + message = self.load_message('scenario3_service-update-enabled.json') + + handler.info( + ctxt=self.context, + publisher_id=message['publisher_id'], + event_type=message['event_type'], + payload=message['payload'], + metadata=self.FAKE_METADATA, + ) + + self.assertEqual('Node_0', node0.hostname) + self.assertEqual(element.ServiceState.ONLINE.value, node0.state) + self.assertEqual(element.ServiceState.ENABLED.value, node0.status) + def test_nova_instance_update(self): compute_model = self.fake_cdmc.generate_scenario_3_with_2_nodes() self.fake_cdmc.cluster_data_model = compute_model