add update events to neutron datasource
Change-Id: I9baa0851de943f021e0f3f4fcdf02d28032886e2
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
# under the License.
|
||||
|
||||
from collections import defaultdict
|
||||
import json
|
||||
|
||||
from oslo_log import log
|
||||
import oslo_messaging
|
||||
@@ -105,7 +106,7 @@ class NotificationsEndpoint(object):
|
||||
|
||||
def info(self, ctxt, publisher_id, event_type, payload, metadata):
|
||||
|
||||
LOG.debug('EVENT RECEIVED: %s' % str(payload))
|
||||
LOG.debug('EVENT RECEIVED: %s' % json.dumps(payload))
|
||||
|
||||
# TODO(Alexey): improve skipped implementation because we need to skip
|
||||
# event depending on the drivers and not for all drivers
|
||||
|
||||
@@ -27,4 +27,8 @@ OPTS = [
|
||||
'NetworkDriver',
|
||||
help='Neutron network driver class path',
|
||||
required=True),
|
||||
cfg.StrOpt('notification_topic',
|
||||
default='vitrage_notifications',
|
||||
help='Neutron network configured notifications topic for '
|
||||
'Vitrage'),
|
||||
]
|
||||
|
||||
@@ -12,27 +12,30 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from vitrage.common.constants import DatasourceProperties as DSProps
|
||||
from vitrage.common.constants import SyncMode
|
||||
from vitrage.datasources.neutron.base import NeutronBase
|
||||
from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE
|
||||
|
||||
|
||||
# noinspection PyAbstractClass
|
||||
class NetworkDriver(NeutronBase):
|
||||
|
||||
@staticmethod
|
||||
def get_skipped_event_types():
|
||||
return []
|
||||
|
||||
@staticmethod
|
||||
def get_topic(conf):
|
||||
pass
|
||||
return conf[NEUTRON_NETWORK_DATASOURCE].notification_topic
|
||||
|
||||
@staticmethod
|
||||
def get_event_types(conf):
|
||||
return []
|
||||
return ['network.']
|
||||
|
||||
@staticmethod
|
||||
def enrich_event(event, event_type):
|
||||
pass
|
||||
event[DSProps.EVENT_TYPE] = event_type
|
||||
|
||||
return NetworkDriver.make_pickleable([event],
|
||||
NEUTRON_NETWORK_DATASOURCE,
|
||||
SyncMode.UPDATE)[0]
|
||||
|
||||
def get_all(self, sync_mode):
|
||||
return self.make_pickleable(
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
from vitrage.common.constants import DatasourceProperties as DSProps
|
||||
from vitrage.common.constants import EntityCategory
|
||||
from vitrage.common.constants import EventAction
|
||||
from vitrage.common.constants import VertexProperties as VProps
|
||||
from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE
|
||||
from vitrage.datasources.resource_transformer_base import \
|
||||
@@ -25,7 +26,10 @@ import vitrage.graph.utils as graph_utils
|
||||
|
||||
class NetworkTransformer(ResourceTransformerBase):
|
||||
|
||||
UPDATE_EVENT_TYPES = {}
|
||||
# Event types which need to refer them differently
|
||||
UPDATE_EVENT_TYPES = {
|
||||
'network.delete.end': EventAction.DELETE_ENTITY,
|
||||
}
|
||||
|
||||
def __init__(self, transformers):
|
||||
super(NetworkTransformer, self).__init__(transformers)
|
||||
|
||||
@@ -26,4 +26,7 @@ OPTS = [
|
||||
default='vitrage.datasources.neutron.port.driver.PortDriver',
|
||||
help='Neutron port driver class path',
|
||||
required=True),
|
||||
cfg.StrOpt('notification_topic',
|
||||
default='vitrage_notifications',
|
||||
help='Neutron port configured notifications topic for Vitrage'),
|
||||
]
|
||||
|
||||
@@ -12,27 +12,29 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from vitrage.common.constants import DatasourceProperties as DSProps
|
||||
from vitrage.common.constants import SyncMode
|
||||
from vitrage.datasources.neutron.base import NeutronBase
|
||||
from vitrage.datasources.neutron.port import NEUTRON_PORT_DATASOURCE
|
||||
|
||||
|
||||
# noinspection PyAbstractClass
|
||||
class PortDriver(NeutronBase):
|
||||
|
||||
@staticmethod
|
||||
def get_skipped_event_types():
|
||||
return []
|
||||
|
||||
@staticmethod
|
||||
def get_topic(conf):
|
||||
pass
|
||||
return conf[NEUTRON_PORT_DATASOURCE].notification_topic
|
||||
|
||||
@staticmethod
|
||||
def get_event_types(conf):
|
||||
return []
|
||||
return ['port.']
|
||||
|
||||
@staticmethod
|
||||
def enrich_event(event, event_type):
|
||||
pass
|
||||
event[DSProps.EVENT_TYPE] = event_type
|
||||
|
||||
return PortDriver.make_pickleable([event], NEUTRON_PORT_DATASOURCE,
|
||||
SyncMode.UPDATE)[0]
|
||||
|
||||
def get_all(self, sync_mode):
|
||||
return self.make_pickleable(
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from vitrage.datasources.resource_transformer_base import \
|
||||
ResourceTransformerBase
|
||||
|
||||
@@ -19,6 +20,7 @@ from oslo_log import log as logging
|
||||
from vitrage.common.constants import DatasourceProperties as DSProps
|
||||
from vitrage.common.constants import EdgeLabels
|
||||
from vitrage.common.constants import EntityCategory
|
||||
from vitrage.common.constants import EventAction
|
||||
from vitrage.common.constants import VertexProperties as VProps
|
||||
from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE
|
||||
from vitrage.datasources.neutron.port import NEUTRON_PORT_DATASOURCE
|
||||
@@ -33,6 +35,12 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PortTransformer(ResourceTransformerBase):
|
||||
|
||||
# Event types which need to refer them differently
|
||||
UPDATE_EVENT_TYPES = {
|
||||
'port.delete.end': EventAction.DELETE_ENTITY,
|
||||
}
|
||||
|
||||
def __init__(self, transformers):
|
||||
super(PortTransformer, self).__init__(transformers)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user