Use Nova versioned notifications by default

Changed the behavior of the Nova instance datasource to use by
default the versioned notifications.

Change-Id: Ife5c78c6568939f919174b5072fd70f461de0bd1
Story: 2004052
Task: 28501
This commit is contained in:
Ifat Afek 2018-12-13 16:33:54 +00:00
parent a96bc0642b
commit 832522c292
12 changed files with 56 additions and 12 deletions

View File

@ -25,6 +25,10 @@ Enabling Vitrage in DevStack
notification_topics = notifications,vitrage_notifications notification_topics = notifications,vitrage_notifications
notification_driver=messagingv2 notification_driver=messagingv2
[notifications]
versioned_notifications_topics = versioned_notifications,vitrage_notifications
notification_driver = messagingv2
4. Add this to add notification from neutron to vitrage 4. Add this to add notification from neutron to vitrage
(make sure neutron is enabled in devstack) (make sure neutron is enabled in devstack)

View File

@ -38,6 +38,10 @@ DEVSTACK_LOCAL_CONFIG+="$(cat <<EOF
notification_topics = notifications,vitrage_notifications notification_topics = notifications,vitrage_notifications
notification_driver = messagingv2 notification_driver = messagingv2
[notifications]
versioned_notifications_topics = versioned_notifications,vitrage_notifications
notification_driver = messagingv2
[[post-config|\$NEUTRON_CONF]] [[post-config|\$NEUTRON_CONF]]
[DEFAULT] [DEFAULT]
notification_topics = notifications,vitrage_notifications notification_topics = notifications,vitrage_notifications

View File

@ -32,6 +32,10 @@ DEVSTACK_LOCAL_CONFIG+="$(cat <<EOF
notification_topics = notifications,vitrage_notifications notification_topics = notifications,vitrage_notifications
notification_driver = messagingv2 notification_driver = messagingv2
[notifications]
versioned_notifications_topics = versioned_notifications,vitrage_notifications
notification_driver = messagingv2
[[post-config|\$CINDER_CONF]] [[post-config|\$CINDER_CONF]]
[DEFAULT] [DEFAULT]
notification_topics = notifications,vitrage_notifications notification_topics = notifications,vitrage_notifications

View File

@ -26,6 +26,7 @@ Datasources
static-config static-config
zabbix_vitrage zabbix_vitrage
k8s_datasource k8s_datasource
nova-config
Notifiers Notifiers
--------- ---------

View File

@ -0,0 +1,23 @@
=============================
Nova Datasource Configuration
=============================
By default, Nova datasource listens to Nova versioned notifications. If you
are using Nova legacy notifications, then it should be indicated in Vitrage
configuration as well.
That is, if you have in ``/etc/nova/nova.conf`` or in ``/etc/nova/nova-cpu.conf``:
.. code:: bash
notification_format = unversioned
Then you should set in ``/etc/vitrage/vitrage.conf``:
.. code:: bash
[nova.instance]
use_nova_versioned_notifications = False
In other cases there is no need to set this option.

View File

@ -144,6 +144,10 @@ Neutron, Heat and Aodh) to Vitrage, set the following in their conf files:
notification_driver=messagingv2 notification_driver=messagingv2
[notifications]
versioned_notifications_topics = versioned_notifications,vitrage_notifications
notification_driver = messagingv2
Initialize Vitrage Initialize Vitrage
------------------ ------------------

View File

@ -1,3 +1,5 @@
--- ---
features: features:
- Added support for Nova versioned notifications. - Use Nova versioned notifications instead of the legacy, unversioned ones.
This bahavior is controlled by the ``use_nova_versioned_notifications``
configuration option.

View File

@ -97,9 +97,6 @@ LEGACY_NOTIFICATIONS = {
class InstanceDriver(NovaDriverBase): class InstanceDriver(NovaDriverBase):
def __init__(self, conf):
super(InstanceDriver, self).__init__(conf)
@staticmethod @staticmethod
def extract_events(instances): def extract_events(instances):
events = [instance.__dict__ for instance in instances] events = [instance.__dict__ for instance in instances]

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import abc import abc
from vitrage.datasources.transformer_base import extract_field_value from vitrage.datasources.transformer_base import extract_field_value

View File

@ -30,7 +30,7 @@ OPTS = [
cfg.StrOpt('mistral_version', default='2', help='Mistral version'), cfg.StrOpt('mistral_version', default='2', help='Mistral version'),
cfg.StrOpt('gnocchi_version', default='1', help='Gnocchi version'), cfg.StrOpt('gnocchi_version', default='1', help='Gnocchi version'),
cfg.BoolOpt('use_nova_versioned_notifications', cfg.BoolOpt('use_nova_versioned_notifications',
default=False, default=True,
help='Indicates whether to use Nova versioned notifications.' help='Indicates whether to use Nova versioned notifications.'
'The default is True. If False, the deprecated Nova ' 'The default is True. If False, the deprecated Nova '
'legacy notifications will be used.' 'legacy notifications will be used.'

View File

@ -65,7 +65,7 @@ class TestEntityGraphUnitBase(base.BaseTest):
OS_CLIENTS_OPTS = [ OS_CLIENTS_OPTS = [
cfg.BoolOpt('use_nova_versioned_notifications', cfg.BoolOpt('use_nova_versioned_notifications',
default=False, required=True), default=True, required=True),
] ]
NUM_CLUSTERS = 1 NUM_CLUSTERS = 1

View File

@ -58,13 +58,17 @@ class TestProcessor(TestEntityGraphUnitBase):
self._check_graph(processor, self.NUM_VERTICES_AFTER_CREATION, self._check_graph(processor, self.NUM_VERTICES_AFTER_CREATION,
self.NUM_EDGES_AFTER_CREATION) self.NUM_EDGES_AFTER_CREATION)
# check update instance event # check update instance event (versioned notification format)
event[DSProps.DATASOURCE_ACTION] = DSAction.UPDATE event[DSProps.DATASOURCE_ACTION] = DSAction.UPDATE
event[DSProps.EVENT_TYPE] = 'compute.instance.volume.attach' event[DSProps.EVENT_TYPE] = 'instance.volume_attach.end'
event['hostname'] = 'new_host'
event['instance_id'] = event['id'] nova_object_data = {
event['state'] = event['status'] 'host_name': 'new_host',
event['host'] = event['OS-EXT-SRV-ATTR:host'] 'uuid': event['id'],
'state': event['status'],
'host': event['OS-EXT-SRV-ATTR:host']
}
event['nova_object.data'] = nova_object_data
processor.process_event(event) processor.process_event(event)
self._check_graph(processor, self.NUM_VERTICES_AFTER_CREATION, self._check_graph(processor, self.NUM_VERTICES_AFTER_CREATION,