rename internal vitrage properties

1. vitrage_sync_mode to vitrage_action_type
2. vitrage_sync_type to vitrage_entity_type

Change-Id: Icd60d8f6f6c5658449028bcec9688f61b8da7c62
This commit is contained in:
Alexey Weyl 2016-11-27 10:23:19 +02:00
parent de1a397423
commit aac14c51a2
61 changed files with 219 additions and 214 deletions

View File

@ -71,9 +71,9 @@ and must implement the following methods:
+----------------------+------------------------------------+--------------------------------+--------------------------------+ +----------------------+------------------------------------+--------------------------------+--------------------------------+
| Name | Input | Output | Comments | | Name | Input | Output | Comments |
+======================+====================================+================================+================================+ +======================+====================================+================================+================================+
| get_all | sync mode | entities | for snapshot mechanism | | get_all | action type | entities | for snapshot mechanism |
+----------------------+------------------------------------+--------------------------------+--------------------------------+ +----------------------+------------------------------------+--------------------------------+--------------------------------+
| get_changes | sync mode | entities | for update pulling mechanism | | get_changes | action type | entities | for update pulling mechanism |
+----------------------+------------------------------------+--------------------------------+--------------------------------+ +----------------------+------------------------------------+--------------------------------+--------------------------------+
| get_event_types | | event types | for update pushing mechanism | | get_event_types | | event types | for update pushing mechanism |
+----------------------+------------------------------------+--------------------------------+--------------------------------+ +----------------------+------------------------------------+--------------------------------+--------------------------------+

View File

@ -64,7 +64,7 @@ class EdgeLabel(object):
if not label.startswith(('_', 'labels'))] if not label.startswith(('_', 'labels'))]
class SyncMode(object): class ActionType(object):
SNAPSHOT = 'snapshot' SNAPSHOT = 'snapshot'
INIT_SNAPSHOT = 'init_snapshot' INIT_SNAPSHOT = 'init_snapshot'
UPDATE = 'update' UPDATE = 'update'
@ -88,8 +88,8 @@ class EntityCategory(object):
class DatasourceProperties(object): class DatasourceProperties(object):
SYNC_TYPE = 'vitrage_sync_type' ENTITY_TYPE = 'vitrage_entity_type'
SYNC_MODE = 'vitrage_sync_mode' ACTION_TYPE = 'vitrage_action_type'
SAMPLE_DATE = 'vitrage_sample_date' SAMPLE_DATE = 'vitrage_sample_date'
EVENT_TYPE = 'vitrage_event_type' EVENT_TYPE = 'vitrage_event_type'

View File

@ -26,8 +26,8 @@ class AlarmDriverBase(DriverBase):
super(DriverBase, self).__init__() super(DriverBase, self).__init__()
self.cache = dict() self.cache = dict()
def _sync_type(self): def _entity_type(self):
"""Return the type of the plugin """ """Return the type of the datasource """
pass pass
def _alarm_key(self, alarm): def _alarm_key(self, alarm):
@ -71,15 +71,15 @@ class AlarmDriverBase(DriverBase):
""" """
pass pass
def get_all(self, sync_mode): def get_all(self, action_type):
return self.make_pickleable(self._get_all_alarms(), return self.make_pickleable(self._get_all_alarms(),
self._sync_type(), self._entity_type(),
sync_mode) action_type)
def get_changes(self, sync_mode): def get_changes(self, action_type):
return self.make_pickleable(self._get_changed_alarms(), return self.make_pickleable(self._get_changed_alarms(),
self._sync_type(), self._entity_type(),
sync_mode) action_type)
def _get_all_alarms(self): def _get_all_alarms(self):
alarms = self._get_alarms() alarms = self._get_alarms()

View File

@ -14,10 +14,10 @@
from oslo_log import log as logging from oslo_log import log as logging
from vitrage.common.constants import ActionType
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.common.constants import EventAction from vitrage.common.constants import EventAction
from vitrage.common.constants import SyncMode
from vitrage.common.exception import VitrageTransformerError from vitrage.common.exception import VitrageTransformerError
from vitrage.datasources.alarm_properties import AlarmProperties as AlarmProps from vitrage.datasources.alarm_properties import AlarmProperties as AlarmProps
from vitrage.datasources import transformer_base as tbase from vitrage.datasources import transformer_base as tbase
@ -44,15 +44,16 @@ class AlarmTransformerBase(tbase.TransformerBase):
entity_event[DSProps.EVENT_TYPE] == EventAction.DELETE_ENTITY: entity_event[DSProps.EVENT_TYPE] == EventAction.DELETE_ENTITY:
return entity_event[DSProps.EVENT_TYPE] return entity_event[DSProps.EVENT_TYPE]
sync_mode = entity_event[DSProps.SYNC_MODE] action_type = entity_event[DSProps.ACTION_TYPE]
if sync_mode in (SyncMode.UPDATE, SyncMode.SNAPSHOT): if action_type in (ActionType.UPDATE, ActionType.SNAPSHOT):
return EventAction.DELETE_ENTITY if self._ok_status(entity_event) \ return EventAction.DELETE_ENTITY if self._ok_status(entity_event) \
else EventAction.UPDATE_ENTITY else EventAction.UPDATE_ENTITY
if SyncMode.INIT_SNAPSHOT == sync_mode: if ActionType.INIT_SNAPSHOT == action_type:
return EventAction.CREATE_ENTITY return EventAction.CREATE_ENTITY
raise VitrageTransformerError('Invalid sync mode: (%s)' % sync_mode) raise VitrageTransformerError('Invalid action type: (%s)'
% action_type)
def _key_values(self, *args): def _key_values(self, *args):
return (EntityCategory.ALARM,) + args return (EntityCategory.ALARM,) + args

View File

@ -35,7 +35,7 @@ class AodhDriver(AlarmDriverBase):
self._client = os_clients.ceilometer_client(self.conf) self._client = os_clients.ceilometer_client(self.conf)
return self._client return self._client
def _sync_type(self): def _entity_type(self):
return AODH_DATASOURCE return AODH_DATASOURCE
def _alarm_key(self, alarm): def _alarm_key(self, alarm):

View File

@ -68,7 +68,7 @@ class AodhTransformer(AlarmTransformerBase):
self._create_entity_key(entity_event), self._create_entity_key(entity_event),
entity_id=entity_event[AodhProps.ALARM_ID], entity_id=entity_event[AodhProps.ALARM_ID],
entity_category=EntityCategory.ALARM, entity_category=EntityCategory.ALARM,
entity_type=entity_event[DSProps.SYNC_TYPE], entity_type=entity_event[DSProps.ENTITY_TYPE],
entity_state=self._get_alarm_state(entity_event), entity_state=self._get_alarm_state(entity_event),
sample_timestamp=sample_timestamp, sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp, update_timestamp=update_timestamp,
@ -122,9 +122,9 @@ class AodhTransformer(AlarmTransformerBase):
if _is_vitrage_alarm(entity_event): if _is_vitrage_alarm(entity_event):
return entity_event.get(AodhProps.VITRAGE_ID) return entity_event.get(AodhProps.VITRAGE_ID)
sync_type = entity_event[DSProps.SYNC_TYPE] entity_type = entity_event[DSProps.ENTITY_TYPE]
alarm_id = entity_event[AodhProps.ALARM_ID] alarm_id = entity_event[AodhProps.ALARM_ID]
return tbase.build_key(self._key_values(sync_type, alarm_id)) return tbase.build_key(self._key_values(entity_type, alarm_id))
@staticmethod @staticmethod
def _timestamp(entity_event): def _timestamp(entity_event):

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from vitrage.common.constants import ActionType
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import SyncMode
from vitrage.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE from vitrage.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE
from vitrage.datasources.driver_base import DriverBase from vitrage.datasources.driver_base import DriverBase
from vitrage import os_clients from vitrage import os_clients
@ -36,12 +36,12 @@ class CinderVolumeDriver(DriverBase):
def extract_events(volumes): def extract_events(volumes):
return [volume.__dict__ for volume in volumes] return [volume.__dict__ for volume in volumes]
def get_all(self, sync_mode): def get_all(self, action_type):
return self.make_pickleable( return self.make_pickleable(
self.extract_events(self.client.volumes.list( self.extract_events(self.client.volumes.list(
search_opts={'all_tenants': 1})), search_opts={'all_tenants': 1})),
CINDER_VOLUME_DATASOURCE, CINDER_VOLUME_DATASOURCE,
sync_mode, action_type,
'manager') 'manager')
@staticmethod @staticmethod
@ -50,7 +50,7 @@ class CinderVolumeDriver(DriverBase):
return CinderVolumeDriver.make_pickleable([event], return CinderVolumeDriver.make_pickleable([event],
CINDER_VOLUME_DATASOURCE, CINDER_VOLUME_DATASOURCE,
SyncMode.UPDATE)[0] ActionType.UPDATE)[0]
@staticmethod @staticmethod
def get_event_types(): def get_event_types():

View File

@ -17,9 +17,9 @@ import six
from oslo_log import log from oslo_log import log
from vitrage.common.constants import ActionType
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import EventAction from vitrage.common.constants import EventAction
from vitrage.common.constants import SyncMode
from vitrage.common import datetime_utils from vitrage.common import datetime_utils
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@ -32,54 +32,54 @@ class DriverBase(object):
pass pass
@abc.abstractmethod @abc.abstractmethod
def get_all(self, sync_mode): def get_all(self, action_type):
pass pass
def callback_on_fault(self, exception): def callback_on_fault(self, exception):
LOG.exception('Exception: {0}'.format(exception)) LOG.exception('Exception: {0}'.format(exception))
@staticmethod @staticmethod
def _get_end_message(sync_type): def _get_end_message(entity_type):
end_message = { end_message = {
DSProps.SYNC_TYPE: sync_type, DSProps.ENTITY_TYPE: entity_type,
DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT, DSProps.ACTION_TYPE: ActionType.INIT_SNAPSHOT,
DSProps.EVENT_TYPE: EventAction.END_MESSAGE DSProps.EVENT_TYPE: EventAction.END_MESSAGE
} }
return end_message return end_message
def get_changes(self, sync_mode): def get_changes(self, action_type):
pass pass
@classmethod @classmethod
def make_pickleable(cls, entities, sync_type, sync_mode, *args): def make_pickleable(cls, entities, entity_type, action_type, *args):
pickleable_entities = [] pickleable_entities = []
for entity in entities: for entity in entities:
for field in args: for field in args:
entity.pop(field, None) entity.pop(field, None)
cls._add_sync_type(entity, sync_type) cls._add_entity_type(entity, entity_type)
cls._add_sync_mode(entity, sync_mode) cls._add_action_type(entity, action_type)
cls._add_sampling_time(entity) cls._add_sampling_time(entity)
pickleable_entities.append(entity) pickleable_entities.append(entity)
if sync_mode == SyncMode.INIT_SNAPSHOT: if action_type == ActionType.INIT_SNAPSHOT:
pickleable_entities.append(cls._get_end_message(sync_type)) pickleable_entities.append(cls._get_end_message(entity_type))
return pickleable_entities return pickleable_entities
@staticmethod @staticmethod
def _add_sync_type(entity, sync_type): def _add_entity_type(entity, entity_type):
if DSProps.SYNC_TYPE not in entity: if DSProps.ENTITY_TYPE not in entity:
entity[DSProps.SYNC_TYPE] = sync_type entity[DSProps.ENTITY_TYPE] = entity_type
@staticmethod @staticmethod
def _add_sampling_time(entity): def _add_sampling_time(entity):
entity[DSProps.SAMPLE_DATE] = str(datetime_utils.utcnow()) entity[DSProps.SAMPLE_DATE] = str(datetime_utils.utcnow())
@staticmethod @staticmethod
def _add_sync_mode(entity, sync_mode): def _add_action_type(entity, action_type):
entity[DSProps.SYNC_MODE] = sync_mode entity[DSProps.ACTION_TYPE] = action_type
@staticmethod @staticmethod
@abc.abstractmethod @abc.abstractmethod

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from vitrage.common.constants import ActionType
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import SyncMode
from vitrage.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE from vitrage.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE
from vitrage.datasources.driver_base import DriverBase from vitrage.datasources.driver_base import DriverBase
from vitrage.datasources.heat.stack import HEAT_STACK_DATASOURCE from vitrage.datasources.heat.stack import HEAT_STACK_DATASOURCE
@ -75,7 +75,7 @@ class HeatStackDriver(DriverBase):
return HeatStackDriver.make_pickleable([event], return HeatStackDriver.make_pickleable([event],
HEAT_STACK_DATASOURCE, HEAT_STACK_DATASOURCE,
SyncMode.UPDATE)[0] ActionType.UPDATE)[0]
def _filter_resource_types(self): def _filter_resource_types(self):
types = self.conf.datasources.types types = self.conf.datasources.types
@ -102,11 +102,11 @@ class HeatStackDriver(DriverBase):
HeatStackDriver.RESOURCE_TYPE_CONVERSION] HeatStackDriver.RESOURCE_TYPE_CONVERSION]
return stack return stack
def get_all(self, sync_mode): def get_all(self, action_type):
stacks = HeatStackDriver.client().stacks.list(global_tenant=True) stacks = HeatStackDriver.client().stacks.list(global_tenant=True)
stacks_list = self._make_stacks_list(stacks) stacks_list = self._make_stacks_list(stacks)
stacks_with_resources = self._append_stacks_resources(stacks_list) stacks_with_resources = self._append_stacks_resources(stacks_list)
return self.make_pickleable(stacks_with_resources, return self.make_pickleable(stacks_with_resources,
HEAT_STACK_DATASOURCE, HEAT_STACK_DATASOURCE,
sync_mode, action_type,
'manager') 'manager')

View File

@ -25,6 +25,7 @@ from vitrage.datasources.nagios.parser import NagiosParser
from vitrage.datasources.nagios.properties import NagiosProperties\ from vitrage.datasources.nagios.properties import NagiosProperties\
as NagiosProps as NagiosProps
from vitrage.datasources.nagios.properties import NagiosTestStatus from vitrage.datasources.nagios.properties import NagiosTestStatus
# noinspection PyProtectedMember # noinspection PyProtectedMember
from vitrage.i18n import _LE from vitrage.i18n import _LE
# noinspection PyProtectedMember # noinspection PyProtectedMember
@ -41,7 +42,7 @@ class NagiosDriver(AlarmDriverBase):
self.conf = conf self.conf = conf
self.config = NagiosConfig(conf) self.config = NagiosConfig(conf)
def _sync_type(self): def _entity_type(self):
return NAGIOS_DATASOURCE return NAGIOS_DATASOURCE
def _alarm_key(self, alarm): def _alarm_key(self, alarm):
@ -83,7 +84,7 @@ class NagiosDriver(AlarmDriverBase):
for alarm in alarms: for alarm in alarms:
# based on nagios configuration file, convert nagios host name # based on nagios configuration file, convert nagios host name
# to vitrage resource type and name # to vitrage resource type and name
alarm[DSProps.SYNC_TYPE] = NagiosProps.NAGIOS alarm[DSProps.ENTITY_TYPE] = NagiosProps.NAGIOS
nagios_host = alarm[NagiosProps.RESOURCE_NAME] nagios_host = alarm[NagiosProps.RESOURCE_NAME]
vitrage_resource = self.config.get_vitrage_resource(nagios_host) vitrage_resource = self.config.get_vitrage_resource(nagios_host)

View File

@ -63,7 +63,7 @@ class NagiosTransformer(AlarmTransformerBase):
return graph_utils.create_vertex( return graph_utils.create_vertex(
self._create_entity_key(entity_event), self._create_entity_key(entity_event),
entity_category=EntityCategory.ALARM, entity_category=EntityCategory.ALARM,
entity_type=entity_event[DSProps.SYNC_TYPE], entity_type=entity_event[DSProps.ENTITY_TYPE],
entity_state=self._get_alarm_state(entity_event), entity_state=self._get_alarm_state(entity_event),
sample_timestamp=sample_timestamp, sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp, update_timestamp=update_timestamp,
@ -124,10 +124,10 @@ class NagiosTransformer(AlarmTransformerBase):
def _create_entity_key(self, entity_event): def _create_entity_key(self, entity_event):
sync_type = entity_event[DSProps.SYNC_TYPE] entity_type = entity_event[DSProps.ENTITY_TYPE]
alarm_name = entity_event[NagiosProperties.SERVICE] alarm_name = entity_event[NagiosProperties.SERVICE]
resource_name = entity_event[NagiosProperties.RESOURCE_NAME] resource_name = entity_event[NagiosProperties.RESOURCE_NAME]
return tbase.build_key(self._key_values(sync_type, return tbase.build_key(self._key_values(entity_type,
resource_name, resource_name,
alarm_name)) alarm_name))

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from vitrage.common.constants import ActionType
from vitrage.common.constants import DatasourceProperties as DSProps 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.base import NeutronBase
from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE
@ -33,10 +33,10 @@ class NetworkDriver(NeutronBase):
return NetworkDriver.make_pickleable([event], return NetworkDriver.make_pickleable([event],
NEUTRON_NETWORK_DATASOURCE, NEUTRON_NETWORK_DATASOURCE,
SyncMode.UPDATE)[0] ActionType.UPDATE)[0]
def get_all(self, sync_mode): def get_all(self, action_type):
return self.make_pickleable( return self.make_pickleable(
self.client.list_networks()['networks'], self.client.list_networks()['networks'],
NEUTRON_NETWORK_DATASOURCE, NEUTRON_NETWORK_DATASOURCE,
sync_mode) action_type)

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from vitrage.common.constants import ActionType
from vitrage.common.constants import DatasourceProperties as DSProps 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.base import NeutronBase
from vitrage.datasources.neutron.port import NEUTRON_PORT_DATASOURCE from vitrage.datasources.neutron.port import NEUTRON_PORT_DATASOURCE
@ -32,10 +32,10 @@ class PortDriver(NeutronBase):
event[DSProps.EVENT_TYPE] = event_type event[DSProps.EVENT_TYPE] = event_type
return PortDriver.make_pickleable([event], NEUTRON_PORT_DATASOURCE, return PortDriver.make_pickleable([event], NEUTRON_PORT_DATASOURCE,
SyncMode.UPDATE)[0] ActionType.UPDATE)[0]
def get_all(self, sync_mode): def get_all(self, action_type):
return self.make_pickleable( return self.make_pickleable(
self.client.list_ports()['ports'], self.client.list_ports()['ports'],
NEUTRON_PORT_DATASOURCE, NEUTRON_PORT_DATASOURCE,
sync_mode) action_type)

View File

@ -27,9 +27,9 @@ class HostDriver(NovaDriverBase):
compute_hosts.append(host_dict) compute_hosts.append(host_dict)
return compute_hosts return compute_hosts
def get_all(self, sync_mode): def get_all(self, action_type):
return self.make_pickleable( return self.make_pickleable(
self.filter_none_compute_hosts(self.client.hosts.list()), self.filter_none_compute_hosts(self.client.hosts.list()),
NOVA_HOST_DATASOURCE, NOVA_HOST_DATASOURCE,
sync_mode, action_type,
'manager') 'manager')

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from vitrage.common.constants import ActionType
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import SyncMode
from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE
from vitrage.datasources.nova.nova_driver_base import NovaDriverBase from vitrage.datasources.nova.nova_driver_base import NovaDriverBase
@ -24,12 +24,12 @@ class InstanceDriver(NovaDriverBase):
def extract_events(instances): def extract_events(instances):
return [instance.__dict__ for instance in instances] return [instance.__dict__ for instance in instances]
def get_all(self, sync_mode): def get_all(self, action_type):
return self.make_pickleable( return self.make_pickleable(
self.extract_events(self.client.servers.list( self.extract_events(self.client.servers.list(
search_opts={'all_tenants': 1})), search_opts={'all_tenants': 1})),
NOVA_INSTANCE_DATASOURCE, NOVA_INSTANCE_DATASOURCE,
sync_mode, action_type,
'manager', 'manager',
'OS-EXT-SRV-ATTR:user_data', 'OS-EXT-SRV-ATTR:user_data',
'_info') '_info')
@ -40,7 +40,7 @@ class InstanceDriver(NovaDriverBase):
return InstanceDriver.make_pickleable([event], return InstanceDriver.make_pickleable([event],
NOVA_INSTANCE_DATASOURCE, NOVA_INSTANCE_DATASOURCE,
SyncMode.UPDATE)[0] ActionType.UPDATE)[0]
@staticmethod @staticmethod
def get_event_types(): def get_event_types():

View File

@ -67,7 +67,7 @@ class InstanceTransformer(ResourceTransformerBase):
sample_timestamp = entity_event[DSProps.SAMPLE_DATE] sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
# TODO(Alexey): need to check here that only the UPDATE sync_mode will # TODO(Alexey): need to check that only the UPDATE action_type will
# update the UPDATE_TIMESTAMP property # update the UPDATE_TIMESTAMP property
update_timestamp = self._format_update_timestamp( update_timestamp = self._format_update_timestamp(
extract_field_value(entity_event, DSProps.SAMPLE_DATE), extract_field_value(entity_event, DSProps.SAMPLE_DATE),

View File

@ -10,8 +10,8 @@
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from vitrage.datasources.nova.nova_driver_base import NovaDriverBase from vitrage.datasources.nova.nova_driver_base import NovaDriverBase
from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE
@ -27,9 +27,9 @@ class ZoneDriver(NovaDriverBase):
zones_res.append(zone_dict) zones_res.append(zone_dict)
return zones_res return zones_res
def get_all(self, sync_mode): def get_all(self, action_type):
return self.make_pickleable(self.filter_internal_zone( return self.make_pickleable(self.filter_internal_zone(
self.client.availability_zones.list()), self.client.availability_zones.list()),
NOVA_ZONE_DATASOURCE, NOVA_ZONE_DATASOURCE,
sync_mode, action_type,
'manager') 'manager')

View File

@ -14,7 +14,7 @@
from oslo_log import log from oslo_log import log
from oslo_service import service as os_service from oslo_service import service as os_service
from vitrage.common.constants import SyncMode from vitrage.common.constants import ActionType
from vitrage.datasources.rescheduler import ReScheduler from vitrage.datasources.rescheduler import ReScheduler
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@ -48,7 +48,8 @@ class SnapshotsService(DatasourceService):
for ds_driver in self.registered_datasources.values(): for ds_driver in self.registered_datasources.values():
snap_scheduler.schedule( snap_scheduler.schedule(
func=self.entities_to_queue(ds_driver, SyncMode.INIT_SNAPSHOT), func=self.entities_to_queue(ds_driver,
ActionType.INIT_SNAPSHOT),
standard_interval=standard_interval, standard_interval=standard_interval,
fault_interval=fault_interval, fault_interval=fault_interval,
times=1, times=1,
@ -56,7 +57,7 @@ class SnapshotsService(DatasourceService):
fault_callback=ds_driver.callback_on_fault) fault_callback=ds_driver.callback_on_fault)
snap_scheduler.schedule( snap_scheduler.schedule(
func=self.entities_to_queue(ds_driver, SyncMode.SNAPSHOT), func=self.entities_to_queue(ds_driver, ActionType.SNAPSHOT),
initial_delay=standard_interval, initial_delay=standard_interval,
standard_interval=standard_interval, standard_interval=standard_interval,
fault_interval=fault_interval, fault_interval=fault_interval,
@ -66,9 +67,9 @@ class SnapshotsService(DatasourceService):
LOG.info('Vitrage datasources Snapshot Service - Started!') LOG.info('Vitrage datasources Snapshot Service - Started!')
def entities_to_queue(self, driver, sync_mode): def entities_to_queue(self, driver, action_type):
def _entities_to_queue(): def _entities_to_queue():
for entity in driver.get_all(sync_mode): for entity in driver.get_all(action_type):
self.send_to_queue(entity) self.send_to_queue(entity)
return _entities_to_queue return _entities_to_queue
@ -115,7 +116,7 @@ class ChangesService(DatasourceService):
LOG.debug("start get changes") LOG.debug("start get changes")
for datasource in self.registered_datasources: for datasource in self.registered_datasources:
try: try:
for entity in datasource.get_changes(SyncMode.UPDATE): for entity in datasource.get_changes(ActionType.UPDATE):
self.send_to_queue(entity) self.send_to_queue(entity)
except Exception as e: except Exception as e:
LOG.error("Get changes Failed - %s", e.message) LOG.error("Get changes Failed - %s", e.message)

View File

@ -31,16 +31,16 @@ class StaticDriver(DriverBase):
def enrich_event(event, event_type): def enrich_event(event, event_type):
pass pass
def get_all(self, sync_mode): def get_all(self, action_type):
"""Query all entities and send events to the vitrage events queue""" """Query all entities and send events to the vitrage events queue"""
return self.make_pickleable(self._get_all_entities(), return self.make_pickleable(self._get_all_entities(),
STATIC_DATASOURCE, STATIC_DATASOURCE,
sync_mode) action_type)
def get_changes(self, sync_mode): def get_changes(self, action_type):
return self.make_pickleable(self._get_changes_entities(), return self.make_pickleable(self._get_changes_entities(),
STATIC_DATASOURCE, STATIC_DATASOURCE,
sync_mode) action_type)
def _get_all_entities(self): def _get_all_entities(self):
"""Internal method to get all entities""" """Internal method to get all entities"""

View File

@ -46,15 +46,15 @@ class StaticTransformer(ResourceTransformerBase):
def _create_entity_key(self, entity_event): def _create_entity_key(self, entity_event):
entity_id = entity_event[VProps.ID] entity_id = entity_event[VProps.ID]
sync_type = entity_event[VProps.TYPE] entity_type = entity_event[VProps.TYPE]
key_fields = self._key_values(sync_type, entity_id) key_fields = self._key_values(entity_type, entity_id)
return transformer_base.build_key(key_fields) return transformer_base.build_key(key_fields)
def get_type(self): def get_type(self):
return STATIC_DATASOURCE return STATIC_DATASOURCE
def _create_vertex(self, entity_event): def _create_vertex(self, entity_event):
sync_type = entity_event[VProps.TYPE] entity_type = entity_event[VProps.TYPE]
entity_id = entity_event[VProps.ID] entity_id = entity_event[VProps.ID]
sample_timestamp = entity_event[DSProps.SAMPLE_DATE] sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
update_timestamp = self._format_update_timestamp( update_timestamp = self._format_update_timestamp(
@ -67,7 +67,7 @@ class StaticTransformer(ResourceTransformerBase):
entity_key, entity_key,
entity_id=entity_id, entity_id=entity_id,
entity_category=EntityCategory.RESOURCE, entity_category=EntityCategory.RESOURCE,
entity_type=sync_type, entity_type=entity_type,
sample_timestamp=sample_timestamp, sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp, update_timestamp=update_timestamp,
entity_state=state) entity_state=state)

View File

@ -38,15 +38,15 @@ class StaticPhysicalDriver(DriverBase):
self.cfg = conf self.cfg = conf
self.cache = {} self.cache = {}
def get_all(self, sync_mode): def get_all(self, action_type):
return self.make_pickleable(self._get_all_entities(), return self.make_pickleable(self._get_all_entities(),
STATIC_PHYSICAL_DATASOURCE, STATIC_PHYSICAL_DATASOURCE,
sync_mode) action_type)
def get_changes(self, sync_mode): def get_changes(self, action_type):
return self.make_pickleable(self._get_changes_entities(), return self.make_pickleable(self._get_changes_entities(),
STATIC_PHYSICAL_DATASOURCE, STATIC_PHYSICAL_DATASOURCE,
sync_mode) action_type)
def _get_all_entities(self): def _get_all_entities(self):
static_entities = [] static_entities = []

View File

@ -52,7 +52,7 @@ class StaticPhysicalTransformer(ResourceTransformerBase):
def _create_vertex(self, entity_event): def _create_vertex(self, entity_event):
sync_type = entity_event[VProps.TYPE] entity_type = entity_event[VProps.TYPE]
entity_id = entity_event[VProps.ID] entity_id = entity_event[VProps.ID]
sample_timestamp = entity_event[DSProps.SAMPLE_DATE] sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
update_timestamp = self._format_update_timestamp( update_timestamp = self._format_update_timestamp(
@ -66,7 +66,7 @@ class StaticPhysicalTransformer(ResourceTransformerBase):
entity_key, entity_key,
entity_id=entity_id, entity_id=entity_id,
entity_category=EntityCategory.RESOURCE, entity_category=EntityCategory.RESOURCE,
entity_type=sync_type, entity_type=entity_type,
sample_timestamp=sample_timestamp, sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp, update_timestamp=update_timestamp,
entity_state=state, entity_state=state,
@ -126,8 +126,8 @@ class StaticPhysicalTransformer(ResourceTransformerBase):
def _create_entity_key(self, entity_event): def _create_entity_key(self, entity_event):
entity_id = entity_event[VProps.ID] entity_id = entity_event[VProps.ID]
sync_type = entity_event[VProps.TYPE] entity_type = entity_event[VProps.TYPE]
key_fields = self._key_values(sync_type, entity_id) key_fields = self._key_values(entity_type, entity_id)
return transformer_base.build_key(key_fields) return transformer_base.build_key(key_fields)
@staticmethod @staticmethod

View File

@ -21,9 +21,9 @@ import six
from vitrage.common import datetime_utils from vitrage.common import datetime_utils
import vitrage.common.constants as cons import vitrage.common.constants as cons
from vitrage.common.constants import ActionType
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import EventAction from vitrage.common.constants import EventAction
from vitrage.common.constants import SyncMode
from vitrage.common.constants import UpdateMethod from vitrage.common.constants import UpdateMethod
from vitrage.common.exception import VitrageTransformerError from vitrage.common.exception import VitrageTransformerError
from vitrage.common import utils from vitrage.common import utils
@ -87,7 +87,7 @@ def convert_timestamp_format(current_timestamp_format, timestamp):
def is_update_event(event): def is_update_event(event):
return event[DSProps.SYNC_MODE] == SyncMode.UPDATE return event[DSProps.ACTION_TYPE] == ActionType.UPDATE
@six.add_metaclass(abc.ABCMeta) @six.add_metaclass(abc.ABCMeta)
@ -212,21 +212,21 @@ class TransformerBase(object):
:rtype: str :rtype: str
""" """
sync_mode = entity_event[DSProps.SYNC_MODE] action_type = entity_event[DSProps.ACTION_TYPE]
if SyncMode.UPDATE == sync_mode: if ActionType.UPDATE == action_type:
return self.UPDATE_EVENT_TYPES.get( return self.UPDATE_EVENT_TYPES.get(
entity_event.get(DSProps.EVENT_TYPE, None), entity_event.get(DSProps.EVENT_TYPE, None),
EventAction.UPDATE_ENTITY) EventAction.UPDATE_ENTITY)
if SyncMode.SNAPSHOT == sync_mode: if ActionType.SNAPSHOT == action_type:
return EventAction.UPDATE_ENTITY return EventAction.UPDATE_ENTITY
if SyncMode.INIT_SNAPSHOT == sync_mode: if ActionType.INIT_SNAPSHOT == action_type:
return EventAction.CREATE_ENTITY return EventAction.CREATE_ENTITY
raise VitrageTransformerError( raise VitrageTransformerError(
'Invalid sync mode: (%s)' % sync_mode) 'Invalid action type: (%s)' % action_type)
def _key_values(self, *args): def _key_values(self, *args):
"""A list of key fields """A list of key fields
@ -240,16 +240,16 @@ class TransformerBase(object):
@staticmethod @staticmethod
def _create_end_vertex(entity_event): def _create_end_vertex(entity_event):
sync_type = entity_event[DSProps.SYNC_TYPE] entity_type = entity_event[DSProps.ENTITY_TYPE]
return graph_utils.create_vertex( return graph_utils.create_vertex(
'END_MESSAGE:' + sync_type, 'END_MESSAGE:' + entity_type,
entity_type=sync_type) entity_type=entity_type)
@staticmethod @staticmethod
def _is_end_message(entity_event): def _is_end_message(entity_event):
sync_mode = entity_event[DSProps.SYNC_MODE] action_type = entity_event[DSProps.ACTION_TYPE]
is_snapshot_event = sync_mode == SyncMode.INIT_SNAPSHOT is_snapshot_event = action_type == ActionType.INIT_SNAPSHOT
event_type = entity_event.get(DSProps.EVENT_TYPE, None) event_type = entity_event.get(DSProps.EVENT_TYPE, None)
return is_snapshot_event and event_type == EventAction.END_MESSAGE return is_snapshot_event and event_type == EventAction.END_MESSAGE

View File

@ -17,8 +17,8 @@ from collections import namedtuple
from oslo_log import log from oslo_log import log
from oslo_utils import importutils as utils from oslo_utils import importutils as utils
from vitrage.common.constants import ActionType
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import SyncMode
from vitrage.common import file_utils from vitrage.common import file_utils
from vitrage.datasources.alarm_driver_base import AlarmDriverBase from vitrage.datasources.alarm_driver_base import AlarmDriverBase
from vitrage.datasources.zabbix.properties import ZabbixProperties as ZProps from vitrage.datasources.zabbix.properties import ZabbixProperties as ZProps
@ -63,7 +63,7 @@ class ZabbixDriver(AlarmDriverBase):
LOG.exception('pyzabbix.ZabbixAPI %s', e) LOG.exception('pyzabbix.ZabbixAPI %s', e)
self._client = None self._client = None
def _sync_type(self): def _entity_type(self):
return ZABBIX_DATASOURCE return ZABBIX_DATASOURCE
def _alarm_key(self, alarm): def _alarm_key(self, alarm):
@ -183,7 +183,7 @@ class ZabbixDriver(AlarmDriverBase):
event[ZProps.RESOURCE_TYPE] = v_resource[ZProps.RESOURCE_TYPE] event[ZProps.RESOURCE_TYPE] = v_resource[ZProps.RESOURCE_TYPE]
return ZabbixDriver.make_pickleable([event], ZABBIX_DATASOURCE, return ZabbixDriver.make_pickleable([event], ZABBIX_DATASOURCE,
SyncMode.UPDATE)[0] ActionType.UPDATE)[0]
@staticmethod @staticmethod
def get_event_types(): def get_event_types():

View File

@ -78,7 +78,7 @@ class ZabbixTransformer(AlarmTransformerBase):
return graph_utils.create_vertex( return graph_utils.create_vertex(
self._create_entity_key(entity_event), self._create_entity_key(entity_event),
entity_category=EntityCategory.ALARM, entity_category=EntityCategory.ALARM,
entity_type=entity_event[DSProps.SYNC_TYPE], entity_type=entity_event[DSProps.ENTITY_TYPE],
entity_state=entity_state, entity_state=entity_state,
sample_timestamp=sample_timestamp, sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp, update_timestamp=update_timestamp,
@ -138,10 +138,10 @@ class ZabbixTransformer(AlarmTransformerBase):
def _create_entity_key(self, entity_event): def _create_entity_key(self, entity_event):
sync_type = entity_event[DSProps.SYNC_TYPE] entity_type = entity_event[DSProps.ENTITY_TYPE]
alarm_id = entity_event[ZProps.TRIGGER_ID] alarm_id = entity_event[ZProps.TRIGGER_ID]
resource_name = entity_event[ZProps.RESOURCE_NAME] resource_name = entity_event[ZProps.RESOURCE_NAME]
return tbase.build_key(self._key_values(sync_type, return tbase.build_key(self._key_values(entity_type,
resource_name, resource_name,
alarm_id)) alarm_id))

View File

@ -17,10 +17,10 @@ import time
from oslo_log import log from oslo_log import log
from vitrage.common.constants import ActionType
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.common.constants import EventAction from vitrage.common.constants import EventAction
from vitrage.common.constants import SyncMode
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.common.datetime_utils import utcnow from vitrage.common.datetime_utils import utcnow
from vitrage.datasources.consistency import CONSISTENCY_DATASOURCE from vitrage.datasources.consistency import CONSISTENCY_DATASOURCE
@ -152,8 +152,8 @@ class ConsistencyEnforcer(object):
def _push_events_to_queue(self, vertices, action): def _push_events_to_queue(self, vertices, action):
for vertex in vertices: for vertex in vertices:
event = { event = {
DSProps.SYNC_TYPE: CONSISTENCY_DATASOURCE, DSProps.ENTITY_TYPE: CONSISTENCY_DATASOURCE,
DSProps.SYNC_MODE: SyncMode.UPDATE, DSProps.ACTION_TYPE: ActionType.UPDATE,
DSProps.SAMPLE_DATE: str(utcnow()), DSProps.SAMPLE_DATE: str(utcnow()),
DSProps.EVENT_TYPE: action, DSProps.EVENT_TYPE: action,
VProps.VITRAGE_ID: vertex[VProps.VITRAGE_ID] VProps.VITRAGE_ID: vertex[VProps.VITRAGE_ID]

View File

@ -67,21 +67,21 @@ class TransformerManager(object):
return transformer return transformer
def transform(self, entity_event): def transform(self, entity_event):
sync_type = self.get_sync_type(entity_event) entity_type = self.get_entity_type(entity_event)
return self.get_transformer(sync_type).transform(entity_event) return self.get_transformer(entity_type).transform(entity_event)
def get_enrich_query(self, entity_event): def get_enrich_query(self, entity_event):
sync_type = self.get_sync_type(entity_event) entity_type = self.get_entity_type(entity_event)
return self.get_transformer(sync_type).get_enrich_query(entity_event) return self.get_transformer(entity_type).get_enrich_query(entity_event)
def extract_key(self, entity_event): def extract_key(self, entity_event):
sync_type = self.get_sync_type(entity_event) entity_type = self.get_entity_type(entity_event)
return self.get_transformer(sync_type)._create_entity_key() return self.get_transformer(entity_type)._create_entity_key()
@staticmethod @staticmethod
def get_sync_type(entity_event): def get_entity_type(entity_event):
try: try:
return entity_event[DSProps.SYNC_TYPE] return entity_event[DSProps.ENTITY_TYPE]
except KeyError: except KeyError:
raise VitrageTransformerError( raise VitrageTransformerError(
'Entity Event must contains sync_type field.') 'Entity Event must contains entity_type field.')

View File

@ -16,8 +16,8 @@ import copy
from oslo_utils import importutils from oslo_utils import importutils
from vitrage.common.constants import ActionType as AType
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import SyncMode
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.common import datetime_utils from vitrage.common import datetime_utils
from vitrage.evaluator.actions.base import ActionMode from vitrage.evaluator.actions.base import ActionMode
@ -103,8 +103,8 @@ class ActionExecutor(object):
@staticmethod @staticmethod
def _add_default_properties(event): def _add_default_properties(event):
event[DSProps.SYNC_MODE] = SyncMode.UPDATE event[DSProps.ACTION_TYPE] = AType.UPDATE
event[DSProps.SYNC_TYPE] = VITRAGE_TYPE event[DSProps.ENTITY_TYPE] = VITRAGE_TYPE
event[VProps.UPDATE_TIMESTAMP] = str(datetime_utils.utcnow(False)) event[VProps.UPDATE_TIMESTAMP] = str(datetime_utils.utcnow(False))
event[VProps.SAMPLE_TIMESTAMP] = str(datetime_utils.utcnow()) event[VProps.SAMPLE_TIMESTAMP] = str(datetime_utils.utcnow())

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from vitrage.common.constants import ActionType
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import SyncMode
from vitrage.entity_graph.initialization_status import InitializationStatus from vitrage.entity_graph.initialization_status import InitializationStatus
from vitrage.entity_graph.processor import processor as proc from vitrage.entity_graph.processor import processor as proc
from vitrage.tests.mocks import mock_driver from vitrage.tests.mocks import mock_driver
@ -38,15 +38,15 @@ class TestFunctionalBase(TestEntityGraphUnitBase):
self.NUM_ZONES, self.NUM_ZONES,
self.NUM_HOSTS, self.NUM_HOSTS,
snapshot_events=self.NUM_ZONES, snapshot_events=self.NUM_ZONES,
snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) snap_vals={DSProps.ACTION_TYPE: ActionType.INIT_SNAPSHOT})
gen_list += mock_driver.simple_host_generators( gen_list += mock_driver.simple_host_generators(
self.NUM_ZONES, self.NUM_ZONES,
self.NUM_HOSTS, self.NUM_HOSTS,
self.NUM_HOSTS, self.NUM_HOSTS,
snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) snap_vals={DSProps.ACTION_TYPE: ActionType.INIT_SNAPSHOT})
gen_list += mock_driver.simple_instance_generators( gen_list += mock_driver.simple_instance_generators(
self.NUM_HOSTS, self.NUM_HOSTS,
self.NUM_INSTANCES, self.NUM_INSTANCES,
self.NUM_INSTANCES, self.NUM_INSTANCES,
snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) snap_vals={DSProps.ACTION_TYPE: ActionType.INIT_SNAPSHOT})
return mock_driver.generate_sequential_events_list(gen_list) return mock_driver.generate_sequential_events_list(gen_list)

View File

@ -67,7 +67,7 @@ class TestStaticPhysical(TestDataSourcesBase):
snapshot_events=1) snapshot_events=1)
static_events = mock_driver.generate_random_events_list(spec_list) static_events = mock_driver.generate_random_events_list(spec_list)
static_physical_event = static_events[0] static_physical_event = static_events[0]
static_physical_event[DSProps.SYNC_TYPE] = SWITCH static_physical_event[DSProps.ENTITY_TYPE] = SWITCH
static_physical_event['relationships'][0]['name'] = \ static_physical_event['relationships'][0]['name'] = \
self._find_entity_id_by_type(processor.entity_graph, self._find_entity_id_by_type(processor.entity_graph,
NOVA_HOST_DATASOURCE) NOVA_HOST_DATASOURCE)

View File

@ -14,8 +14,8 @@
from oslo_config import cfg from oslo_config import cfg
from vitrage.common.constants import ActionType
from vitrage.common.constants import EventAction from vitrage.common.constants import EventAction
from vitrage.common.constants import SyncMode
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.nova.instance.transformer import InstanceTransformer from vitrage.datasources.nova.instance.transformer import InstanceTransformer
from vitrage.entity_graph.initialization_status import InitializationStatus from vitrage.entity_graph.initialization_status import InitializationStatus
@ -40,7 +40,7 @@ class TestDatasourceInfoMapperFunctional(TestFunctionalBase):
# setup # setup
processor = proc.Processor(self.conf, InitializationStatus()) processor = proc.Processor(self.conf, InitializationStatus())
event = self._create_event(spec_type='INSTANCE_SPEC', event = self._create_event(spec_type='INSTANCE_SPEC',
sync_mode=SyncMode.INIT_SNAPSHOT) action_type=ActionType.INIT_SNAPSHOT)
# action # action
processor.process_event(event) processor.process_event(event)
@ -57,7 +57,7 @@ class TestDatasourceInfoMapperFunctional(TestFunctionalBase):
# setup # setup
vertex, neighbors, processor = self._create_entity( vertex, neighbors, processor = self._create_entity(
spec_type='INSTANCE_SPEC', spec_type='INSTANCE_SPEC',
sync_mode=SyncMode.INIT_SNAPSHOT) action_type=ActionType.INIT_SNAPSHOT)
self.assertEqual(2, processor.entity_graph.num_vertices()) self.assertEqual(2, processor.entity_graph.num_vertices())
neighbors[0].vertex[VProps.STATE] = 'available' neighbors[0].vertex[VProps.STATE] = 'available'

View File

@ -259,8 +259,8 @@ class TestActionExecutor(TestFunctionalBase):
'service': 'Check_MK', 'service': 'Check_MK',
'status': 'CRITICAL', 'status': 'CRITICAL',
'status_info': 'test test test', 'status_info': 'test test test',
'vitrage_sync_mode': 'snapshot', 'vitrage_action_type': 'snapshot',
'vitrage_sync_type': 'nagios', 'vitrage_entity_type': 'nagios',
'vitrage_sample_date': '2016-02-07 15:26:04'} 'vitrage_sample_date': '2016-02-07 15:26:04'}
@staticmethod @staticmethod
@ -268,10 +268,10 @@ class TestActionExecutor(TestFunctionalBase):
return {'target': target_vertex.vertex_id, return {'target': target_vertex.vertex_id,
'update_timestamp': '2016-03-17 11:33:32.443002', 'update_timestamp': '2016-03-17 11:33:32.443002',
'vitrage_sync_mode': 'update', 'vitrage_action_type': 'update',
'alarm_name': alarm_name, 'alarm_name': alarm_name,
'state': 'Active', 'state': 'Active',
'type': 'add_vertex', 'type': 'add_vertex',
'vitrage_sync_type': 'vitrage', 'vitrage_entity_type': 'vitrage',
'severity': 'CRITICAL', 'severity': 'CRITICAL',
'sample_timestamp': '2016-03-17 11:33:32.443002+00:00'} 'sample_timestamp': '2016-03-17 11:33:32.443002+00:00'}

View File

@ -29,7 +29,7 @@ from vitrage.tests.mocks import utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
_TARGET_HOST = 'host-2' _TARGET_HOST = 'host-2'
_NAGIOS_TEST_INFO = {'resource_name': _TARGET_HOST, 'sync_mode': 'snapshot'} _NAGIOS_TEST_INFO = {'resource_name': _TARGET_HOST, 'action_type': 'snapshot'}
class TestScenarioEvaluator(TestFunctionalBase): class TestScenarioEvaluator(TestFunctionalBase):

View File

@ -350,7 +350,7 @@ def simple_switch_generators(switch_num, host_num,
) )
if update_events: if update_events:
update_vals = {} if not update_vals else update_vals update_vals = {} if not update_vals else update_vals
update_vals['sync_mode'] = 'update' update_vals['action_type'] = 'update'
test_entity_spec_list.append( test_entity_spec_list.append(
{tg.DYNAMIC_INFO_FKEY: tg.DRIVER_SWITCH_SNAPSHOT_D, {tg.DYNAMIC_INFO_FKEY: tg.DRIVER_SWITCH_SNAPSHOT_D,
tg.STATIC_INFO_FKEY: None, tg.STATIC_INFO_FKEY: None,

View File

@ -1,7 +1,7 @@
{ {
"vitrage_sample_date": "2015-12-01T12:46:41Z", "vitrage_sample_date": "2015-12-01T12:46:41Z",
"vitrage_sync_type": "consistency", "vitrage_entity_type": "consistency",
"vitrage_sync_mode": "update", "vitrage_action_type": "update",
"vitrage_event_type": "delete_entity", "vitrage_event_type": "delete_entity",
"vitrage_id": "[0-9]{5}" "vitrage_id": "[0-9]{5}"
} }

View File

@ -7,8 +7,8 @@
"_loaded": "True", "_loaded": "True",
"host_name": "compute-0-0.local", "host_name": "compute-0-0.local",
"service": "compute", "service": "compute",
"vitrage_sync_type": "nova.host", "vitrage_entity_type": "nova.host",
"zone": "zone0", "zone": "zone0",
"vitrage_sync_mode": "init_snapshot", "vitrage_action_type": "init_snapshot",
"vitrage_sample_date": "2015-12-01T12:46:41Z" "vitrage_sample_date": "2015-12-01T12:46:41Z"
} }

View File

@ -1,7 +1,7 @@
{ {
"OS-EXT-STS:task_state": null, "OS-EXT-STS:task_state": null,
"vitrage_sync_mode": "snapshot", "vitrage_action_type": "snapshot",
"vitrage_sync_type": "nova.instance", "vitrage_entity_type": "nova.instance",
"vitrage_sample_date": "2015-12-01T12:46:41Z", "vitrage_sample_date": "2015-12-01T12:46:41Z",
"addresses": { "addresses": {
"public": [ "public": [

View File

@ -1,5 +1,5 @@
{ {
"vitrage_sync_mode": "update", "vitrage_action_type": "update",
"vitrage_sample_date": "2015-12-01T12:46:41Z", "vitrage_sample_date": "2015-12-01T12:46:41Z",
"publisher_id": "compute.emalin-devstack", "publisher_id": "compute.emalin-devstack",
"vitrage_event_type": "compute.instance.pause.end|compute.instance.delete.end|compute.instance.create.start", "vitrage_event_type": "compute.instance.pause.end|compute.instance.delete.end|compute.instance.create.start",

View File

@ -1,5 +1,5 @@
{ {
"vitrage_sync_type": "nagios", "vitrage_entity_type": "nagios",
"resource_type": "nova.host", "resource_type": "nova.host",
"resource_name": "compute-[1-9]", "resource_name": "compute-[1-9]",
"service": "CPU utilization", "service": "CPU utilization",
@ -9,5 +9,5 @@
"vitrage_sample_date": "2015-12-01T12:46:41Z", "vitrage_sample_date": "2015-12-01T12:46:41Z",
"attempt": "1/1", "attempt": "1/1",
"status_info": "OK - user: 0\\.6%, system: 0\\.3%, wait: 0\\.4%", "status_info": "OK - user: 0\\.6%, system: 0\\.3%, wait: 0\\.4%",
"vitrage_sync_mode": "snapshot" "vitrage_action_type": "snapshot"
} }

View File

@ -4,11 +4,11 @@
"creation_time": "2016-08-25T13:03:36", "creation_time": "2016-08-25T13:03:36",
"stack_owner": "admin", "stack_owner": "admin",
"project": "a077142e250543be90f6fce8f623d45d", "project": "a077142e250543be90f6fce8f623d45d",
"vitrage_sync_mode": "init_snapshot", "vitrage_action_type": "init_snapshot",
"id": "f22416fb-b33c-4e24-822e-0174421f5ece", "id": "f22416fb-b33c-4e24-822e-0174421f5ece",
"stack_status": "CREATE_COMPLETE", "stack_status": "CREATE_COMPLETE",
"vitrage_sample_date": "2016-08-2515:12:28.281460+00:00", "vitrage_sample_date": "2016-08-2515:12:28.281460+00:00",
"vitrage_sync_type": "heat.stack", "vitrage_entity_type": "heat.stack",
"resources": [{ "resources": [{
"resource_name": "cinder_volume_1", "resource_name": "cinder_volume_1",
"logical_resource_id": "cinder_volume_1", "logical_resource_id": "cinder_volume_1",

View File

@ -4,12 +4,12 @@
"stack_name": "newstack", "stack_name": "newstack",
"tenant_id": "a077142e250543be90f6fce8f623d45d", "tenant_id": "a077142e250543be90f6fce8f623d45d",
"stack_identity": "d2df0a2a-765c-44ef-b117-32d599bc9c3b", "stack_identity": "d2df0a2a-765c-44ef-b117-32d599bc9c3b",
"vitrage_sync_mode": "update", "vitrage_action_type": "update",
"create_at": "2016-08-25T15:23:02", "create_at": "2016-08-25T15:23:02",
"state": "CREATE_COMPLETE", "state": "CREATE_COMPLETE",
"vitrage_event_type": "orchestration.stack.create.end", "vitrage_event_type": "orchestration.stack.create.end",
"vitrage_sample_date": "2016-08-2515:23:23.150274+00:00", "vitrage_sample_date": "2016-08-2515:23:23.150274+00:00",
"vitrage_sync_type": "heat.stack", "vitrage_entity_type": "heat.stack",
"user_identity": "3515b9535e5d4c9e82cb166324ca29dd", "user_identity": "3515b9535e5d4c9e82cb166324ca29dd",
"resources": [{ "resources": [{
"resource_name": "cinder_volume_1", "resource_name": "cinder_volume_1",

View File

@ -10,7 +10,7 @@
"id": "[1-9]{5}", "id": "[1-9]{5}",
"vitrage_sample_date": "2015-12-01T12:46:41Z", "vitrage_sample_date": "2015-12-01T12:46:41Z",
"type": "switch", "type": "switch",
"vitrage_sync_mode": "snapshot", "vitrage_action_type": "snapshot",
"state": "available", "state": "available",
"vitrage_event_type": "entity_update" "vitrage_event_type": "entity_update"
} }

View File

@ -4,8 +4,8 @@
"created_at": "2015-12-01T12:46:41Z", "created_at": "2015-12-01T12:46:41Z",
"status": "In-use", "status": "In-use",
"id": "12345", "id": "12345",
"vitrage_sync_type": "cinder.volume", "vitrage_entity_type": "cinder.volume",
"vitrage_sync_mode": "snapshot", "vitrage_action_type": "snapshot",
"vitrage_sample_date": "2015-12-01T12:46:41Z", "vitrage_sample_date": "2015-12-01T12:46:41Z",
"volume_type": "lvmdriver-1", "volume_type": "lvmdriver-1",
"size": "1559" "size": "1559"

View File

@ -4,8 +4,8 @@
"updated_at": "2015-12-01T12:46:41Z", "updated_at": "2015-12-01T12:46:41Z",
"status": "In-use", "status": "In-use",
"volume_id": "12345", "volume_id": "12345",
"vitrage_sync_type": "cinder.volume", "vitrage_entity_type": "cinder.volume",
"vitrage_sync_mode": "update", "vitrage_action_type": "update",
"vitrage_event_type": "volume.create.start", "vitrage_event_type": "volume.create.start",
"vitrage_sample_date": "2015-12-01T12:46:41Z", "vitrage_sample_date": "2015-12-01T12:46:41Z",
"volume_type": "SCSIID", "volume_type": "SCSIID",

View File

@ -1,5 +1,5 @@
{ {
"vitrage_sync_type": "zabbix", "vitrage_entity_type": "zabbix",
"resource_type": "nova.host", "resource_type": "nova.host",
"resource_name": "compute-[1-9]", "resource_name": "compute-[1-9]",
"zabbix_resource_name": "computer-[1-9]", "zabbix_resource_name": "computer-[1-9]",
@ -12,6 +12,6 @@
"vitrage_sample_date": "2015-12-01T12:46:41Z", "vitrage_sample_date": "2015-12-01T12:46:41Z",
"value": "1", "value": "1",
"priority": "1", "priority": "1",
"vitrage_sync_mode": "snapshot", "vitrage_action_type": "snapshot",
"rawtext": "CPU utilization" "rawtext": "CPU utilization"
} }

View File

@ -9,8 +9,8 @@
"_loaded": "True", "_loaded": "True",
"hosts": {}, "hosts": {},
"vitrage_sample_date": "2015-12-01T12:46:41Z", "vitrage_sample_date": "2015-12-01T12:46:41Z",
"vitrage_sync_type": "nova.zone", "vitrage_entity_type": "nova.zone",
"vitrage_sync_mode": "snapshot", "vitrage_action_type": "snapshot",
"zoneName": "zone0", "zoneName": "zone0",
"zoneState": { "zoneState": {
"available": "True" "available": "True"

View File

@ -1,5 +1,5 @@
{ {
"vitrage_sync_mode": "init_snapshot", "vitrage_action_type": "init_snapshot",
"id": "host[0-3]", "id": "host[0-3]",
"name": "host[0-3]", "name": "host[0-3]",
"zone_id": "zone[0-1]", "zone_id": "zone[0-1]",

View File

@ -1,5 +1,5 @@
{ {
"vitrage_sync_mode": "init_snapshot", "vitrage_action_type": "init_snapshot",
"image": "cirros-[a-z]+", "image": "cirros-[a-z]+",
"status": "ACTIVE", "status": "ACTIVE",
"tenant_id": "[0-9a-f]{32}", "tenant_id": "[0-9a-f]{32}",
@ -9,7 +9,7 @@
"id": "vm[0-1][0-9]", "id": "vm[0-1][0-9]",
"name": "vm[0-9]{3}", "name": "vm[0-9]{3}",
"vitrage_event_type": "update", "vitrage_event_type": "update",
"vitrage_sync_type": "nova.instance", "vitrage_entity_type": "nova.instance",
"vitrage_sample_date": "2015-12-01T12:46:41Z" "vitrage_sample_date": "2015-12-01T12:46:41Z"
} }

View File

@ -1,5 +1,5 @@
{ {
"vitrage_sync_mode": "init_snapshot", "vitrage_action_type": "init_snapshot",
"id": "zone[0-1]", "id": "zone[0-1]",
"name": "zone[0-1]", "name": "zone[0-1]",
"vitrage_event_type": "update", "vitrage_event_type": "update",

View File

@ -162,7 +162,7 @@ class TestCinderVolumeTransformer(base.BaseTest):
is_update_event = tbase.is_update_event(event) is_update_event = tbase.is_update_event(event)
self.assertEqual(EntityCategory.RESOURCE, vertex[VProps.CATEGORY]) self.assertEqual(EntityCategory.RESOURCE, vertex[VProps.CATEGORY])
self.assertEqual(event[DSProps.SYNC_TYPE], vertex[VProps.TYPE]) self.assertEqual(event[DSProps.ENTITY_TYPE], vertex[VProps.TYPE])
id_field_path = 'volume_id' if is_update_event else 'id' id_field_path = 'volume_id' if is_update_event else 'id'
self.assertEqual( self.assertEqual(

View File

@ -163,7 +163,7 @@ class TestHeatStackTransformer(base.BaseTest):
is_update_event = tbase.is_update_event(event) is_update_event = tbase.is_update_event(event)
self.assertEqual(EntityCategory.RESOURCE, vertex[VProps.CATEGORY]) self.assertEqual(EntityCategory.RESOURCE, vertex[VProps.CATEGORY])
self.assertEqual(event[DSProps.SYNC_TYPE], vertex[VProps.TYPE]) self.assertEqual(event[DSProps.ENTITY_TYPE], vertex[VProps.TYPE])
id_field_path = 'stack_identity' if is_update_event else 'id' id_field_path = 'stack_identity' if is_update_event else 'id'
self.assertEqual( self.assertEqual(

View File

@ -15,11 +15,11 @@
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from vitrage.common.constants import ActionType
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import EdgeLabel from vitrage.common.constants import EdgeLabel
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.common.constants import EventAction from vitrage.common.constants import EventAction
from vitrage.common.constants import SyncMode
from vitrage.common.constants import UpdateMethod from vitrage.common.constants import UpdateMethod
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.alarm_properties import AlarmProperties as AlarmProps from vitrage.datasources.alarm_properties import AlarmProperties as AlarmProps
@ -72,7 +72,7 @@ class NagiosTransformerTest(base.BaseTest):
TransformerBase.KEY_SEPARATOR) TransformerBase.KEY_SEPARATOR)
self.assertEqual(EntityCategory.ALARM, observed_key_fields[0]) self.assertEqual(EntityCategory.ALARM, observed_key_fields[0])
self.assertEqual(event[DSProps.SYNC_TYPE], observed_key_fields[1]) self.assertEqual(event[DSProps.ENTITY_TYPE], observed_key_fields[1])
self.assertEqual(event[NagiosProperties.RESOURCE_NAME], self.assertEqual(event[NagiosProperties.RESOURCE_NAME],
observed_key_fields[2]) observed_key_fields[2])
self.assertEqual(event[NagiosProperties.SERVICE], self.assertEqual(event[NagiosProperties.SERVICE],
@ -103,8 +103,8 @@ class NagiosTransformerTest(base.BaseTest):
self._validate_action(alarm, wrapper) self._validate_action(alarm, wrapper)
def _validate_action(self, alarm, wrapper): def _validate_action(self, alarm, wrapper):
sync_mode = alarm[DSProps.SYNC_MODE] action_type = alarm[DSProps.ACTION_TYPE]
if sync_mode in (SyncMode.SNAPSHOT, SyncMode.UPDATE): if action_type in (ActionType.SNAPSHOT, ActionType.UPDATE):
if alarm[NagiosProperties.STATUS] == 'OK': if alarm[NagiosProperties.STATUS] == 'OK':
self.assertEqual(EventAction.DELETE_ENTITY, wrapper.action) self.assertEqual(EventAction.DELETE_ENTITY, wrapper.action)
else: else:
@ -115,7 +115,7 @@ class NagiosTransformerTest(base.BaseTest):
def _validate_vertex(self, vertex, event): def _validate_vertex(self, vertex, event):
self.assertEqual(EntityCategory.ALARM, vertex[VProps.CATEGORY]) self.assertEqual(EntityCategory.ALARM, vertex[VProps.CATEGORY])
self.assertEqual(event[DSProps.SYNC_TYPE], vertex[VProps.TYPE]) self.assertEqual(event[DSProps.ENTITY_TYPE], vertex[VProps.TYPE])
self.assertEqual(event[NagiosProperties.SERVICE], vertex[VProps.NAME]) self.assertEqual(event[NagiosProperties.SERVICE], vertex[VProps.NAME])
event_type = event.get(DSProps.EVENT_TYPE, None) event_type = event.get(DSProps.EVENT_TYPE, None)

View File

@ -17,11 +17,11 @@ import datetime
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from vitrage.common.constants import ActionType
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import EdgeLabel from vitrage.common.constants import EdgeLabel
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.common.constants import EventAction from vitrage.common.constants import EventAction
from vitrage.common.constants import SyncMode
from vitrage.common.constants import UpdateMethod from vitrage.common.constants import UpdateMethod
from vitrage.common.constants import VertexProperties from vitrage.common.constants import VertexProperties
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
@ -133,7 +133,7 @@ class NovaHostTransformerTest(base.BaseTest):
self.assertEqual(1, len(neighbors)) self.assertEqual(1, len(neighbors))
self._validate_zone_neighbor(neighbors[0], event) self._validate_zone_neighbor(neighbors[0], event)
if SyncMode.SNAPSHOT == event[DSProps.SYNC_MODE]: if ActionType.SNAPSHOT == event[DSProps.ACTION_TYPE]:
self.assertEqual(EventAction.UPDATE_ENTITY, wrapper.action) self.assertEqual(EventAction.UPDATE_ENTITY, wrapper.action)
else: else:
self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action) self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action)
@ -200,7 +200,7 @@ class NovaHostTransformerTest(base.BaseTest):
zone_num=1, zone_num=1,
host_num=1, host_num=1,
snapshot_events=1, snapshot_events=1,
snap_vals={DSProps.SYNC_MODE: SyncMode.SNAPSHOT}) snap_vals={DSProps.ACTION_TYPE: ActionType.SNAPSHOT})
hosts_events = mock_sync.generate_random_events_list(spec_list) hosts_events = mock_sync.generate_random_events_list(spec_list)
host_transformer = self.transformers[NOVA_HOST_DATASOURCE] host_transformer = self.transformers[NOVA_HOST_DATASOURCE]
@ -216,7 +216,7 @@ class NovaHostTransformerTest(base.BaseTest):
zone_num=1, zone_num=1,
host_num=1, host_num=1,
snapshot_events=1, snapshot_events=1,
snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) snap_vals={DSProps.ACTION_TYPE: ActionType.INIT_SNAPSHOT})
hosts_events = mock_sync.generate_random_events_list(spec_list) hosts_events = mock_sync.generate_random_events_list(spec_list)
host_transformer = self.transformers[NOVA_HOST_DATASOURCE] host_transformer = self.transformers[NOVA_HOST_DATASOURCE]

View File

@ -17,11 +17,11 @@ import datetime
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from vitrage.common.constants import ActionType
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import EdgeLabel from vitrage.common.constants import EdgeLabel
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.common.constants import EventAction from vitrage.common.constants import EventAction
from vitrage.common.constants import SyncMode
from vitrage.common.constants import UpdateMethod from vitrage.common.constants import UpdateMethod
from vitrage.common.constants import VertexProperties from vitrage.common.constants import VertexProperties
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
@ -118,10 +118,10 @@ class NovaInstanceTransformerTest(base.BaseTest):
host_neighbor = wrapper.neighbors[0] host_neighbor = wrapper.neighbors[0]
self._validate_host_neighbor(host_neighbor, event) self._validate_host_neighbor(host_neighbor, event)
sync_mode = event[DSProps.SYNC_MODE] action_type = event[DSProps.ACTION_TYPE]
if sync_mode == SyncMode.INIT_SNAPSHOT: if action_type == ActionType.INIT_SNAPSHOT:
self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action) self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action)
elif sync_mode == SyncMode.SNAPSHOT: elif action_type == ActionType.SNAPSHOT:
self.assertEqual(EventAction.UPDATE_ENTITY, wrapper.action) self.assertEqual(EventAction.UPDATE_ENTITY, wrapper.action)
def test_update_event_transform(self): def test_update_event_transform(self):

View File

@ -152,7 +152,7 @@ class NovaZoneTransformerTest(base.BaseTest):
self._validate_host_neighbor(neighbor, self._validate_host_neighbor(neighbor,
zone_vertex_id, zone_vertex_id,
hosts, hosts,
event[DSProps.SYNC_MODE]) event[DSProps.ACTION_TYPE])
self.assertEqual(1, self.assertEqual(1,
cluster_neighbors_counter, cluster_neighbors_counter,
@ -162,7 +162,7 @@ class NovaZoneTransformerTest(base.BaseTest):
host_neighbor, host_neighbor,
zone_vertex_id, zone_vertex_id,
hosts, hosts,
sync_mode): action_type):
host_vertex = host_neighbor.vertex host_vertex = host_neighbor.vertex
host_vertex_id = host_vertex.get(VertexProperties.ID) host_vertex_id = host_vertex.get(VertexProperties.ID)

View File

@ -15,8 +15,8 @@
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from vitrage.common.constants import ActionType
from vitrage.common.constants import EventAction from vitrage.common.constants import EventAction
from vitrage.common.constants import SyncMode
from vitrage.datasources.static import driver from vitrage.datasources.static import driver
from vitrage.datasources.static import STATIC_DATASOURCE from vitrage.datasources.static import STATIC_DATASOURCE
from vitrage.tests import base from vitrage.tests import base
@ -70,7 +70,7 @@ class TestStaticDriver(base.BaseTest):
def test_get_all(self): def test_get_all(self):
# Action # Action
static_entities = self.static_driver.get_all(SyncMode.UPDATE) static_entities = self.static_driver.get_all(ActionType.UPDATE)
# Test assertions # Test assertions
self.assertEqual(0, len(static_entities)) self.assertEqual(0, len(static_entities))
@ -78,7 +78,7 @@ class TestStaticDriver(base.BaseTest):
# noinspection PyAttributeOutsideInit # noinspection PyAttributeOutsideInit
def test_get_changes(self): def test_get_changes(self):
# Setup # Setup
entities = self.static_driver.get_all(SyncMode.UPDATE) entities = self.static_driver.get_all(ActionType.UPDATE)
self.assertEqual(0, len(entities)) self.assertEqual(0, len(entities))
self.conf = cfg.ConfigOpts() self.conf = cfg.ConfigOpts()

View File

@ -17,9 +17,9 @@ import os
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from vitrage.common.constants import ActionType
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import EventAction from vitrage.common.constants import EventAction
from vitrage.common.constants import SyncMode
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.common import file_utils from vitrage.common import file_utils
from vitrage.datasources.static_physical import driver from vitrage.datasources.static_physical import driver
@ -92,7 +92,8 @@ class TestStaticPhysicalDriver(base.BaseTest):
def test_get_all(self): def test_get_all(self):
# Action # Action
static_entities = self.static_physical_driver.get_all(SyncMode.UPDATE) static_entities = \
self.static_physical_driver.get_all(ActionType.UPDATE)
# Test assertions # Test assertions
self.assertEqual(5, len(static_entities)) self.assertEqual(5, len(static_entities))
@ -100,7 +101,7 @@ class TestStaticPhysicalDriver(base.BaseTest):
# noinspection PyAttributeOutsideInit # noinspection PyAttributeOutsideInit
def test_get_changes(self): def test_get_changes(self):
# Setup # Setup
entities = self.static_physical_driver.get_all(SyncMode.UPDATE) entities = self.static_physical_driver.get_all(ActionType.UPDATE)
self.assertEqual(5, len(entities)) self.assertEqual(5, len(entities))
self.conf = cfg.ConfigOpts() self.conf = cfg.ConfigOpts()

View File

@ -15,11 +15,11 @@
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from vitrage.common.constants import ActionType
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import EdgeLabel from vitrage.common.constants import EdgeLabel
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.common.constants import EventAction from vitrage.common.constants import EventAction
from vitrage.common.constants import SyncMode
from vitrage.common.constants import UpdateMethod from vitrage.common.constants import UpdateMethod
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.common.datetime_utils import format_unix_timestamp from vitrage.common.datetime_utils import format_unix_timestamp
@ -77,7 +77,7 @@ class ZabbixTransformerTest(base.BaseTest):
TransformerBase.KEY_SEPARATOR) TransformerBase.KEY_SEPARATOR)
self.assertEqual(EntityCategory.ALARM, observed_key_fields[0]) self.assertEqual(EntityCategory.ALARM, observed_key_fields[0])
self.assertEqual(event[DSProps.SYNC_TYPE], observed_key_fields[1]) self.assertEqual(event[DSProps.ENTITY_TYPE], observed_key_fields[1])
self.assertEqual(event[ZabbixProps.RESOURCE_NAME], self.assertEqual(event[ZabbixProps.RESOURCE_NAME],
observed_key_fields[2]) observed_key_fields[2])
self.assertEqual(event[ZabbixProps.TRIGGER_ID], self.assertEqual(event[ZabbixProps.TRIGGER_ID],
@ -109,8 +109,8 @@ class ZabbixTransformerTest(base.BaseTest):
self._validate_action(alarm, wrapper) self._validate_action(alarm, wrapper)
def _validate_action(self, alarm, wrapper): def _validate_action(self, alarm, wrapper):
sync_mode = alarm[DSProps.SYNC_MODE] action_type = alarm[DSProps.ACTION_TYPE]
if sync_mode in (SyncMode.SNAPSHOT, SyncMode.UPDATE): if action_type in (ActionType.SNAPSHOT, ActionType.UPDATE):
if alarm[ZabbixProps.VALUE] == ZabbixTriggerValue.OK: if alarm[ZabbixProps.VALUE] == ZabbixTriggerValue.OK:
self.assertEqual(EventAction.DELETE_ENTITY, wrapper.action) self.assertEqual(EventAction.DELETE_ENTITY, wrapper.action)
else: else:
@ -121,7 +121,7 @@ class ZabbixTransformerTest(base.BaseTest):
def _validate_vertex(self, vertex, event): def _validate_vertex(self, vertex, event):
self.assertEqual(EntityCategory.ALARM, vertex[VProps.CATEGORY]) self.assertEqual(EntityCategory.ALARM, vertex[VProps.CATEGORY])
self.assertEqual(event[DSProps.SYNC_TYPE], vertex[VProps.TYPE]) self.assertEqual(event[DSProps.ENTITY_TYPE], vertex[VProps.TYPE])
self.assertEqual(event[ZabbixProps.DESCRIPTION], self.assertEqual(event[ZabbixProps.DESCRIPTION],
vertex[VProps.NAME]) vertex[VProps.NAME])

View File

@ -14,9 +14,9 @@
from oslo_config import cfg from oslo_config import cfg
from vitrage.common.constants import ActionType
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.common.constants import SyncMode
from vitrage.datasources.nagios import NAGIOS_DATASOURCE from vitrage.datasources.nagios import NAGIOS_DATASOURCE
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE
@ -80,24 +80,24 @@ class TestEntityGraphUnitBase(base.BaseTest):
self.NUM_ZONES, self.NUM_ZONES,
self.NUM_HOSTS, self.NUM_HOSTS,
snapshot_events=self.NUM_ZONES, snapshot_events=self.NUM_ZONES,
snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) snap_vals={DSProps.ACTION_TYPE: ActionType.INIT_SNAPSHOT})
gen_list += mock_sync.simple_host_generators( gen_list += mock_sync.simple_host_generators(
self.NUM_ZONES, self.NUM_ZONES,
self.NUM_HOSTS, self.NUM_HOSTS,
self.NUM_HOSTS, self.NUM_HOSTS,
snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) snap_vals={DSProps.ACTION_TYPE: ActionType.INIT_SNAPSHOT})
gen_list += mock_sync.simple_instance_generators( gen_list += mock_sync.simple_instance_generators(
self.NUM_HOSTS, self.NUM_HOSTS,
self.NUM_INSTANCES, self.NUM_INSTANCES,
self.NUM_INSTANCES, self.NUM_INSTANCES,
snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) snap_vals={DSProps.ACTION_TYPE: ActionType.INIT_SNAPSHOT})
return mock_sync.generate_sequential_events_list(gen_list) return mock_sync.generate_sequential_events_list(gen_list)
def _create_entity(self, processor=None, spec_type=None, sync_mode=None, def _create_entity(self, processor=None, spec_type=None, action_type=None,
event_type=None, properties=None): event_type=None, properties=None):
# create instance event with host neighbor # create instance event with host neighbor
event = self._create_event(spec_type=spec_type, event = self._create_event(spec_type=spec_type,
sync_mode=sync_mode, action_type=action_type,
event_type=event_type, event_type=event_type,
properties=properties) properties=properties)
@ -112,7 +112,7 @@ class TestEntityGraphUnitBase(base.BaseTest):
return vertex, neighbors, processor return vertex, neighbors, processor
@staticmethod @staticmethod
def _create_event(spec_type=None, sync_mode=None, def _create_event(spec_type=None, action_type=None,
event_type=None, properties=None): event_type=None, properties=None):
# generate event # generate event
spec_list = mock_sync.simple_instance_generators(1, 1, 1) spec_list = mock_sync.simple_instance_generators(1, 1, 1)
@ -120,8 +120,8 @@ class TestEntityGraphUnitBase(base.BaseTest):
spec_list) spec_list)
# update properties # update properties
if sync_mode is not None: if action_type is not None:
events_list[0][DSProps.SYNC_MODE] = sync_mode events_list[0][DSProps.ACTION_TYPE] = action_type
if event_type is not None: if event_type is not None:
events_list[0][DSProps.EVENT_TYPE] = event_type events_list[0][DSProps.EVENT_TYPE] = event_type

View File

@ -14,9 +14,9 @@
from oslo_config import cfg from oslo_config import cfg
from vitrage.common.constants import ActionType
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import EventAction from vitrage.common.constants import EventAction
from vitrage.common.constants import SyncMode
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.common.datetime_utils import utcnow from vitrage.common.datetime_utils import utcnow
from vitrage.datasources.transformer_base import Neighbor from vitrage.datasources.transformer_base import Neighbor
@ -51,13 +51,13 @@ class TestProcessor(TestEntityGraphUnitBase):
# check create instance event # check create instance event
processor = proc.Processor(self.conf, InitializationStatus()) processor = proc.Processor(self.conf, InitializationStatus())
event = self._create_event(spec_type=self.INSTANCE_SPEC, event = self._create_event(spec_type=self.INSTANCE_SPEC,
sync_mode=SyncMode.INIT_SNAPSHOT) action_type=ActionType.INIT_SNAPSHOT)
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,
self.NUM_EDGES_AFTER_CREATION) self.NUM_EDGES_AFTER_CREATION)
# check update instance even # check update instance even
event[DSProps.SYNC_MODE] = SyncMode.UPDATE event[DSProps.ACTION_TYPE] = ActionType.UPDATE
event[DSProps.EVENT_TYPE] = 'compute.instance.volume.attach' event[DSProps.EVENT_TYPE] = 'compute.instance.volume.attach'
event['hostname'] = 'new_host' event['hostname'] = 'new_host'
event['instance_id'] = event['id'] event['instance_id'] = event['id']
@ -68,7 +68,7 @@ class TestProcessor(TestEntityGraphUnitBase):
self.NUM_EDGES_AFTER_CREATION) self.NUM_EDGES_AFTER_CREATION)
# check delete instance event # check delete instance event
event[DSProps.SYNC_MODE] = SyncMode.UPDATE event[DSProps.ACTION_TYPE] = ActionType.UPDATE
event[DSProps.EVENT_TYPE] = 'compute.instance.delete.end' event[DSProps.EVENT_TYPE] = 'compute.instance.delete.end'
processor.process_event(event) processor.process_event(event)
self._check_graph(processor, self.NUM_VERTICES_AFTER_DELETION, self._check_graph(processor, self.NUM_VERTICES_AFTER_DELETION,
@ -133,10 +133,10 @@ class TestProcessor(TestEntityGraphUnitBase):
# setup # setup
vertex1, neighbors1, processor = self._create_entity( vertex1, neighbors1, processor = self._create_entity(
spec_type=self.INSTANCE_SPEC, spec_type=self.INSTANCE_SPEC,
sync_mode=SyncMode.INIT_SNAPSHOT) action_type=ActionType.INIT_SNAPSHOT)
vertex2, neighbors2, processor = self._create_entity( vertex2, neighbors2, processor = self._create_entity(
spec_type=self.INSTANCE_SPEC, spec_type=self.INSTANCE_SPEC,
sync_mode=SyncMode.INIT_SNAPSHOT, action_type=ActionType.INIT_SNAPSHOT,
processor=processor) processor=processor)
self.assertEqual(2, processor.entity_graph.num_edges()) self.assertEqual(2, processor.entity_graph.num_edges())
@ -155,10 +155,10 @@ class TestProcessor(TestEntityGraphUnitBase):
# setup # setup
vertex1, neighbors1, processor = self._create_entity( vertex1, neighbors1, processor = self._create_entity(
spec_type=self.INSTANCE_SPEC, spec_type=self.INSTANCE_SPEC,
sync_mode=SyncMode.INIT_SNAPSHOT) action_type=ActionType.INIT_SNAPSHOT)
vertex2, neighbors2, processor = self._create_entity( vertex2, neighbors2, processor = self._create_entity(
spec_type=self.INSTANCE_SPEC, spec_type=self.INSTANCE_SPEC,
sync_mode=SyncMode.INIT_SNAPSHOT, action_type=ActionType.INIT_SNAPSHOT,
processor=processor) processor=processor)
self.assertEqual(2, processor.entity_graph.num_edges()) self.assertEqual(2, processor.entity_graph.num_edges())
@ -179,7 +179,7 @@ class TestProcessor(TestEntityGraphUnitBase):
# setup # setup
vertex, neighbors, processor = self._create_entity( vertex, neighbors, processor = self._create_entity(
spec_type=self.INSTANCE_SPEC, spec_type=self.INSTANCE_SPEC,
sync_mode=SyncMode.INIT_SNAPSHOT) action_type=ActionType.INIT_SNAPSHOT)
self.assertEqual(1, processor.entity_graph.num_edges()) self.assertEqual(1, processor.entity_graph.num_edges())
vertex[VProps.IS_DELETED] = True vertex[VProps.IS_DELETED] = True
processor.entity_graph.update_vertex(vertex) processor.entity_graph.update_vertex(vertex)
@ -302,7 +302,7 @@ class TestProcessor(TestEntityGraphUnitBase):
# create instance event with host neighbor # create instance event with host neighbor
(vertex, neighbors, processor) = self._create_entity( (vertex, neighbors, processor) = self._create_entity(
spec_type=self.INSTANCE_SPEC, spec_type=self.INSTANCE_SPEC,
sync_mode=SyncMode.INIT_SNAPSHOT, action_type=ActionType.INIT_SNAPSHOT,
properties=kwargs, properties=kwargs,
processor=processor) processor=processor)

View File

@ -45,9 +45,10 @@ class BaseMock(testtools.TestCase):
@staticmethod @staticmethod
def _create_mock_events(): def _create_mock_events():
gen_list = mock_sync.simple_zone_generators( gen_list = mock_sync.simple_zone_generators(
2, 4, snapshot_events=2, snap_vals={'sync_mode': 'init_snapshot'}) 2, 4, snapshot_events=2,
snap_vals={'action_type': 'init_snapshot'})
gen_list += mock_sync.simple_host_generators( gen_list += mock_sync.simple_host_generators(
2, 4, 4, snap_vals={'sync_mode': 'init_snapshot'}) 2, 4, 4, snap_vals={'action_type': 'init_snapshot'})
gen_list += mock_sync.simple_instance_generators( gen_list += mock_sync.simple_instance_generators(
4, 15, 15, snap_vals={'sync_mode': 'init_snapshot'}) 4, 15, 15, snap_vals={'action_type': 'init_snapshot'})
return mock_sync.generate_sequential_events_list(gen_list) return mock_sync.generate_sequential_events_list(gen_list)