change constants names

event_action to graph_action
action_type to datasource_action

Closes-Bug: #1622966

Change-Id: I23cd775f0b3aca477f85ff4851e416e8d042efdc
This commit is contained in:
Alexey Weyl 2016-11-29 12:00:54 +02:00
parent fbfa617246
commit c7f2468981
61 changed files with 294 additions and 275 deletions

View File

@ -64,7 +64,7 @@ class EdgeLabel(object):
if not label.startswith(('_', 'labels'))] if not label.startswith(('_', 'labels'))]
class ActionType(object): class DatasourceAction(object):
SNAPSHOT = 'snapshot' SNAPSHOT = 'snapshot'
INIT_SNAPSHOT = 'init_snapshot' INIT_SNAPSHOT = 'init_snapshot'
UPDATE = 'update' UPDATE = 'update'
@ -89,12 +89,12 @@ class EntityCategory(object):
class DatasourceProperties(object): class DatasourceProperties(object):
ENTITY_TYPE = 'vitrage_entity_type' ENTITY_TYPE = 'vitrage_entity_type'
ACTION_TYPE = 'vitrage_action_type' DATASOURCE_ACTION = 'vitrage_datasource_action'
SAMPLE_DATE = 'vitrage_sample_date' SAMPLE_DATE = 'vitrage_sample_date'
EVENT_TYPE = 'vitrage_event_type' EVENT_TYPE = 'vitrage_event_type'
class EventAction(object): class GraphAction(object):
CREATE_ENTITY = 'create_entity' CREATE_ENTITY = 'create_entity'
DELETE_ENTITY = 'delete_entity' DELETE_ENTITY = 'delete_entity'
UPDATE_ENTITY = 'update_entity' UPDATE_ENTITY = 'update_entity'

View File

@ -14,7 +14,7 @@
from oslo_log import log from oslo_log import log
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 GraphAction
from vitrage.common import datetime_utils from vitrage.common import datetime_utils
from vitrage.datasources.driver_base import DriverBase from vitrage.datasources.driver_base import DriverBase
@ -71,15 +71,15 @@ class AlarmDriverBase(DriverBase):
""" """
pass pass
def get_all(self, action_type): def get_all(self, datasource_action):
return self.make_pickleable(self._get_all_alarms(), return self.make_pickleable(self._get_all_alarms(),
self._entity_type(), self._entity_type(),
action_type) datasource_action)
def get_changes(self, action_type): def get_changes(self, datasource_action):
return self.make_pickleable(self._get_changed_alarms(), return self.make_pickleable(self._get_changed_alarms(),
self._entity_type(), self._entity_type(),
action_type) datasource_action)
def _get_all_alarms(self): def _get_all_alarms(self):
alarms = self._get_alarms() alarms = self._get_alarms()
@ -105,7 +105,7 @@ class AlarmDriverBase(DriverBase):
if filter_(self, alarm, old_alarm): if filter_(self, alarm, old_alarm):
# delete state changed alarm: alarm->OK # delete state changed alarm: alarm->OK
if not self._is_erroneous(alarm): if not self._is_erroneous(alarm):
alarm[DSProps.EVENT_TYPE] = EventAction.DELETE_ENTITY alarm[DSProps.EVENT_TYPE] = GraphAction.DELETE_ENTITY
alarms_to_update.append(alarm) alarms_to_update.append(alarm)
self.cache[alarm_key] = alarm, now self.cache[alarm_key] = alarm, now
@ -115,7 +115,7 @@ class AlarmDriverBase(DriverBase):
for cached_alarm, timestamp in values: for cached_alarm, timestamp in values:
if self._is_erroneous(cached_alarm) and timestamp is not now: if self._is_erroneous(cached_alarm) and timestamp is not now:
LOG.debug('deleting cached_alarm %s', cached_alarm) LOG.debug('deleting cached_alarm %s', cached_alarm)
cached_alarm[DSProps.EVENT_TYPE] = EventAction.DELETE_ENTITY cached_alarm[DSProps.EVENT_TYPE] = GraphAction.DELETE_ENTITY
alarms_to_update.append(cached_alarm) alarms_to_update.append(cached_alarm)
self.cache.pop(self._alarm_key(cached_alarm)) self.cache.pop(self._alarm_key(cached_alarm))

View File

@ -16,7 +16,7 @@ from oslo_log import log as logging
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 GraphAction
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
@ -42,7 +42,7 @@ class AlarmTransformerBase(tbase.TransformerBase):
event_type = entity_event.get(DSProps.EVENT_TYPE, None) event_type = entity_event.get(DSProps.EVENT_TYPE, None)
if event_type is not None: if event_type is not None:
return AlarmProps.INACTIVE_STATE if \ return AlarmProps.INACTIVE_STATE if \
EventAction.DELETE_ENTITY == event_type else \ GraphAction.DELETE_ENTITY == event_type else \
AlarmProps.ACTIVE_STATE AlarmProps.ACTIVE_STATE
else: else:
return AlarmProps.INACTIVE_STATE if \ return AlarmProps.INACTIVE_STATE if \

View File

@ -12,7 +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.
from vitrage.common.constants import ActionType from vitrage.common.constants import DatasourceAction
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
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
@ -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, action_type): def get_all(self, datasource_action):
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,
action_type, datasource_action,
'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,
ActionType.UPDATE)[0] DatasourceAction.UPDATE)[0]
@staticmethod @staticmethod
def get_event_types(): def get_event_types():

View File

@ -17,7 +17,7 @@ from oslo_log import log as logging
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 GraphAction
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE from vitrage.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE
from vitrage.datasources.cinder.volume.properties import \ from vitrage.datasources.cinder.volume.properties import \
@ -37,11 +37,11 @@ LOG = logging.getLogger(__name__)
class CinderVolumeTransformer(ResourceTransformerBase): class CinderVolumeTransformer(ResourceTransformerBase):
# Event types which need to refer them differently # graph actions which need to refer them differently
UPDATE_EVENT_TYPES = { GRAPH_ACTION_MAPPING = {
'volume.delete.end': EventAction.DELETE_ENTITY, 'volume.delete.end': GraphAction.DELETE_ENTITY,
'volume.detach.start': EventAction.DELETE_RELATIONSHIP, 'volume.detach.start': GraphAction.DELETE_RELATIONSHIP,
'volume.attach.end': EventAction.UPDATE_RELATIONSHIP 'volume.attach.end': GraphAction.UPDATE_RELATIONSHIP
} }
def __init__(self, transformers, conf): def __init__(self, transformers, conf):

View File

@ -13,7 +13,7 @@
# under the License. # under the License.
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 GraphAction
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.consistency import CONSISTENCY_DATASOURCE from vitrage.datasources.consistency import CONSISTENCY_DATASOURCE
from vitrage.datasources.resource_transformer_base import \ from vitrage.datasources.resource_transformer_base import \
@ -23,10 +23,10 @@ import vitrage.graph.utils as graph_utils
class ConsistencyTransformer(ResourceTransformerBase): class ConsistencyTransformer(ResourceTransformerBase):
# Event types which need to refer them differently # graph actions which need to refer them differently
UPDATE_EVENT_TYPES = { GRAPH_ACTION_MAPPING = {
EventAction.DELETE_ENTITY: EventAction.DELETE_ENTITY, GraphAction.DELETE_ENTITY: GraphAction.DELETE_ENTITY,
EventAction.REMOVE_DELETED_ENTITY: EventAction.REMOVE_DELETED_ENTITY GraphAction.REMOVE_DELETED_ENTITY: GraphAction.REMOVE_DELETED_ENTITY
} }
def __init__(self, transformers, conf): def __init__(self, transformers, conf):

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 DatasourceAction
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 GraphAction
from vitrage.common import datetime_utils from vitrage.common import datetime_utils
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@ -32,7 +32,7 @@ class DriverBase(object):
pass pass
@abc.abstractmethod @abc.abstractmethod
def get_all(self, action_type): def get_all(self, datasource_action):
pass pass
def callback_on_fault(self, exception): def callback_on_fault(self, exception):
@ -42,16 +42,16 @@ class DriverBase(object):
def _get_end_message(entity_type): def _get_end_message(entity_type):
end_message = { end_message = {
DSProps.ENTITY_TYPE: entity_type, DSProps.ENTITY_TYPE: entity_type,
DSProps.ACTION_TYPE: ActionType.INIT_SNAPSHOT, DSProps.DATASOURCE_ACTION: DatasourceAction.INIT_SNAPSHOT,
DSProps.EVENT_TYPE: EventAction.END_MESSAGE DSProps.EVENT_TYPE: GraphAction.END_MESSAGE
} }
return end_message return end_message
def get_changes(self, action_type): def get_changes(self, datasource_action):
pass pass
@classmethod @classmethod
def make_pickleable(cls, entities, entity_type, action_type, *args): def make_pickleable(cls, entities, entity_type, datasource_action, *args):
pickleable_entities = [] pickleable_entities = []
for entity in entities: for entity in entities:
@ -59,11 +59,11 @@ class DriverBase(object):
entity.pop(field, None) entity.pop(field, None)
cls._add_entity_type(entity, entity_type) cls._add_entity_type(entity, entity_type)
cls._add_action_type(entity, action_type) cls._add_datasource_action(entity, datasource_action)
cls._add_sampling_time(entity) cls._add_sampling_time(entity)
pickleable_entities.append(entity) pickleable_entities.append(entity)
if action_type == ActionType.INIT_SNAPSHOT: if datasource_action == DatasourceAction.INIT_SNAPSHOT:
pickleable_entities.append(cls._get_end_message(entity_type)) pickleable_entities.append(cls._get_end_message(entity_type))
return pickleable_entities return pickleable_entities
@ -78,8 +78,8 @@ class DriverBase(object):
entity[DSProps.SAMPLE_DATE] = str(datetime_utils.utcnow()) entity[DSProps.SAMPLE_DATE] = str(datetime_utils.utcnow())
@staticmethod @staticmethod
def _add_action_type(entity, action_type): def _add_datasource_action(entity, datasource_action):
entity[DSProps.ACTION_TYPE] = action_type entity[DSProps.DATASOURCE_ACTION] = datasource_action
@staticmethod @staticmethod
@abc.abstractmethod @abc.abstractmethod

View File

@ -12,7 +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.
from vitrage.common.constants import ActionType from vitrage.common.constants import DatasourceAction
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
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
@ -75,7 +75,7 @@ class HeatStackDriver(DriverBase):
return HeatStackDriver.make_pickleable([event], return HeatStackDriver.make_pickleable([event],
HEAT_STACK_DATASOURCE, HEAT_STACK_DATASOURCE,
ActionType.UPDATE)[0] DatasourceAction.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, action_type): def get_all(self, datasource_action):
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,
action_type, datasource_action,
'manager') 'manager')

View File

@ -15,7 +15,7 @@
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 GraphAction
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE from vitrage.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE
from vitrage.datasources.heat.stack import HEAT_STACK_DATASOURCE from vitrage.datasources.heat.stack import HEAT_STACK_DATASOURCE
@ -40,9 +40,9 @@ class HeatStackTransformer(ResourceTransformerBase):
'OS::Neutron::Port': NEUTRON_PORT_DATASOURCE 'OS::Neutron::Port': NEUTRON_PORT_DATASOURCE
} }
# Event types which need to refer them differently # graph actions which need to refer them differently
UPDATE_EVENT_TYPES = { GRAPH_ACTION_MAPPING = {
'orchestration.stack.delete.end': EventAction.DELETE_ENTITY, 'orchestration.stack.delete.end': GraphAction.DELETE_ENTITY,
} }
def __init__(self, transformers, conf): def __init__(self, transformers, conf):

View File

@ -12,7 +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.
from vitrage.common.constants import ActionType from vitrage.common.constants import DatasourceAction
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
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,
ActionType.UPDATE)[0] DatasourceAction.UPDATE)[0]
def get_all(self, action_type): def get_all(self, datasource_action):
return self.make_pickleable( return self.make_pickleable(
self.client.list_networks()['networks'], self.client.list_networks()['networks'],
NEUTRON_NETWORK_DATASOURCE, NEUTRON_NETWORK_DATASOURCE,
action_type) datasource_action)

View File

@ -14,7 +14,7 @@
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 GraphAction
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE
from vitrage.datasources.resource_transformer_base import \ from vitrage.datasources.resource_transformer_base import \
@ -33,9 +33,9 @@ class NetworkTransformer(ResourceTransformerBase):
None: ('id',) None: ('id',)
} }
# Event types which need to refer them differently # graph actions which need to refer them differently
UPDATE_EVENT_TYPES = { GRAPH_ACTION_MAPPING = {
'network.delete.end': EventAction.DELETE_ENTITY, 'network.delete.end': GraphAction.DELETE_ENTITY,
} }
def __init__(self, transformers, conf): def __init__(self, transformers, conf):

View File

@ -12,7 +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.
from vitrage.common.constants import ActionType from vitrage.common.constants import DatasourceAction
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
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,
ActionType.UPDATE)[0] DatasourceAction.UPDATE)[0]
def get_all(self, action_type): def get_all(self, datasource_action):
return self.make_pickleable( return self.make_pickleable(
self.client.list_ports()['ports'], self.client.list_ports()['ports'],
NEUTRON_PORT_DATASOURCE, NEUTRON_PORT_DATASOURCE,
action_type) datasource_action)

View File

@ -18,7 +18,7 @@ from vitrage.datasources.resource_transformer_base import \
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 GraphAction
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE
from vitrage.datasources.neutron.port import NEUTRON_PORT_DATASOURCE from vitrage.datasources.neutron.port import NEUTRON_PORT_DATASOURCE
@ -45,9 +45,9 @@ class PortTransformer(ResourceTransformerBase):
None: ('fixed_ips',) None: ('fixed_ips',)
} }
# Event types which need to refer them differently # graph actions which need to refer them differently
UPDATE_EVENT_TYPES = { GRAPH_ACTION_MAPPING = {
'port.delete.end': EventAction.DELETE_ENTITY, 'port.delete.end': GraphAction.DELETE_ENTITY,
} }
def __init__(self, transformers, conf): def __init__(self, transformers, conf):

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, action_type): def get_all(self, datasource_action):
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,
action_type, datasource_action,
'manager') 'manager')

View File

@ -12,7 +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.
from vitrage.common.constants import ActionType from vitrage.common.constants import DatasourceAction
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
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, action_type): def get_all(self, datasource_action):
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,
action_type, datasource_action,
'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,
ActionType.UPDATE)[0] DatasourceAction.UPDATE)[0]
@staticmethod @staticmethod
def get_event_types(): def get_event_types():

View File

@ -17,7 +17,7 @@ from oslo_log import log as logging
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 GraphAction
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
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
@ -34,9 +34,9 @@ LOG = logging.getLogger(__name__)
class InstanceTransformer(ResourceTransformerBase): class InstanceTransformer(ResourceTransformerBase):
# Event types which need to refer them differently # graph actions which need to refer them differently
UPDATE_EVENT_TYPES = { GRAPH_ACTION_MAPPING = {
'compute.instance.delete.end': EventAction.DELETE_ENTITY, 'compute.instance.delete.end': GraphAction.DELETE_ENTITY,
} }
def __init__(self, transformers, conf): def __init__(self, transformers, conf):
@ -67,8 +67,8 @@ class InstanceTransformer(ResourceTransformerBase):
sample_timestamp = entity_event[DSProps.SAMPLE_DATE] sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
# TODO(Alexey): need to check that only the UPDATE action_type will # TODO(Alexey): need to check that only the UPDATE datasource_action
# update the UPDATE_TIMESTAMP property # will 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),
sample_timestamp) sample_timestamp)

View File

@ -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, action_type): def get_all(self, datasource_action):
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,
action_type, datasource_action,
'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 ActionType from vitrage.common.constants import DatasourceAction
from vitrage.datasources.rescheduler import ReScheduler from vitrage.datasources.rescheduler import ReScheduler
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@ -49,7 +49,7 @@ class SnapshotsService(DatasourceService):
snap_scheduler.schedule( snap_scheduler.schedule(
func=self.entities_to_queue(ds_driver, func=self.entities_to_queue(ds_driver,
ActionType.INIT_SNAPSHOT), DatasourceAction.INIT_SNAPSHOT),
standard_interval=standard_interval, standard_interval=standard_interval,
fault_interval=fault_interval, fault_interval=fault_interval,
times=1, times=1,
@ -57,7 +57,8 @@ 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, ActionType.SNAPSHOT), func=self.entities_to_queue(ds_driver,
DatasourceAction.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,
@ -67,9 +68,9 @@ class SnapshotsService(DatasourceService):
LOG.info('Vitrage datasources Snapshot Service - Started!') LOG.info('Vitrage datasources Snapshot Service - Started!')
def entities_to_queue(self, driver, action_type): def entities_to_queue(self, driver, datasource_action):
def _entities_to_queue(): def _entities_to_queue():
for entity in driver.get_all(action_type): for entity in driver.get_all(datasource_action):
self.send_to_queue(entity) self.send_to_queue(entity)
return _entities_to_queue return _entities_to_queue
@ -116,7 +117,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(ActionType.UPDATE): for entity in datasource.get_changes(DatasourceAction.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, action_type): def get_all(self, datasource_action):
"""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,
action_type) datasource_action)
def get_changes(self, action_type): def get_changes(self, datasource_action):
return self.make_pickleable(self._get_changes_entities(), return self.make_pickleable(self._get_changes_entities(),
STATIC_DATASOURCE, STATIC_DATASOURCE,
action_type) datasource_action)
def _get_all_entities(self): def _get_all_entities(self):
"""Internal method to get all entities""" """Internal method to get all entities"""

View File

@ -15,7 +15,7 @@
import copy import copy
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 GraphAction
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.driver_base import DriverBase from vitrage.datasources.driver_base import DriverBase
@ -38,15 +38,15 @@ class StaticPhysicalDriver(DriverBase):
self.cfg = conf self.cfg = conf
self.cache = {} self.cache = {}
def get_all(self, action_type): def get_all(self, datasource_action):
return self.make_pickleable(self._get_all_entities(), return self.make_pickleable(self._get_all_entities(),
STATIC_PHYSICAL_DATASOURCE, STATIC_PHYSICAL_DATASOURCE,
action_type) datasource_action)
def get_changes(self, action_type): def get_changes(self, datasource_action):
return self.make_pickleable(self._get_changes_entities(), return self.make_pickleable(self._get_changes_entities(),
STATIC_PHYSICAL_DATASOURCE, STATIC_PHYSICAL_DATASOURCE,
action_type) datasource_action)
def _get_all_entities(self): def _get_all_entities(self):
static_entities = [] static_entities = []
@ -125,10 +125,10 @@ class StaticPhysicalDriver(DriverBase):
if not new_entities or old_entity not in new_entities: if not new_entities or old_entity not in new_entities:
new_entity = self._find_entity(old_entity, new_entities) new_entity = self._find_entity(old_entity, new_entities)
if not new_entity: if not new_entity:
self._set_event_type(old_entity, EventAction.DELETE_ENTITY) self._set_event_type(old_entity, GraphAction.DELETE_ENTITY)
updates.append(old_entity.copy()) updates.append(old_entity.copy())
else: else:
self._set_event_type(new_entity, EventAction.UPDATE_ENTITY) self._set_event_type(new_entity, GraphAction.UPDATE_ENTITY)
updates.append(new_entity.copy()) updates.append(new_entity.copy())
@staticmethod @staticmethod

View File

@ -16,7 +16,7 @@ from oslo_log import log as logging
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 GraphAction
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
from vitrage.datasources.resource_transformer_base import \ from vitrage.datasources.resource_transformer_base import \
@ -35,9 +35,9 @@ class StaticPhysicalTransformer(ResourceTransformerBase):
RELATION_TYPE = 'relation_type' RELATION_TYPE = 'relation_type'
RELATIONSHIPS_SECTION = 'relationships' RELATIONSHIPS_SECTION = 'relationships'
# Event types which need to refer them differently # graph actions which need to refer them differently
UPDATE_EVENT_TYPES = { GRAPH_ACTION_MAPPING = {
EventAction.DELETE_ENTITY: EventAction.DELETE_ENTITY GraphAction.DELETE_ENTITY: GraphAction.DELETE_ENTITY
} }
def __init__(self, transformers, conf): def __init__(self, transformers, conf):

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 DatasourceAction
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 GraphAction
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.ACTION_TYPE] == ActionType.UPDATE return event[DSProps.DATASOURCE_ACTION] == DatasourceAction.UPDATE
@six.add_metaclass(abc.ABCMeta) @six.add_metaclass(abc.ABCMeta)
@ -96,7 +96,8 @@ class TransformerBase(object):
KEY_SEPARATOR = ':' KEY_SEPARATOR = ':'
QUERY_RESULT = 'graph_query_result' QUERY_RESULT = 'graph_query_result'
UPDATE_EVENT_TYPES = {} # graph actions which need to refer them differently
GRAPH_ACTION_MAPPING = {}
def __init__(self, transformers, conf): def __init__(self, transformers, conf):
self.conf = conf self.conf = conf
@ -119,13 +120,13 @@ class TransformerBase(object):
if not self._is_end_message(entity_event): if not self._is_end_message(entity_event):
entity_vertex = self._create_entity_vertex(entity_event) entity_vertex = self._create_entity_vertex(entity_event)
neighbors = self._create_neighbors(entity_event) neighbors = self._create_neighbors(entity_event)
action = self._extract_event_action(entity_event) action = self._extract_graph_action(entity_event)
return EntityWrapper(entity_vertex, neighbors, action) return EntityWrapper(entity_vertex, neighbors, action)
else: else:
return EntityWrapper(self._create_end_vertex(entity_event), return EntityWrapper(self._create_end_vertex(entity_event),
None, None,
EventAction.END_MESSAGE) GraphAction.END_MESSAGE)
def _create_entity_vertex(self, entity_event): def _create_entity_vertex(self, entity_event):
if is_update_event(entity_event) and \ if is_update_event(entity_event) and \
@ -201,10 +202,10 @@ class TransformerBase(object):
""" """
pass pass
def _extract_event_action(self, entity_event): def _extract_graph_action(self, entity_event):
"""Extract event action. """Extract graph action.
Decides what action (from constants.EventAction) the processor need Decides what action (from constants.GraphAction) the processor need
to perform according to the data received from the event. to perform according to the data received from the event.
:param entity_event: event that returns from the driver :param entity_event: event that returns from the driver
@ -213,24 +214,24 @@ class TransformerBase(object):
""" """
if DSProps.EVENT_TYPE in entity_event and \ if DSProps.EVENT_TYPE in entity_event and \
entity_event[DSProps.EVENT_TYPE] in EventAction.__dict__.values(): entity_event[DSProps.EVENT_TYPE] in GraphAction.__dict__.values():
return entity_event[DSProps.EVENT_TYPE] return entity_event[DSProps.EVENT_TYPE]
action_type = entity_event[DSProps.ACTION_TYPE] datasource_action = entity_event[DSProps.DATASOURCE_ACTION]
if ActionType.UPDATE == action_type: if DatasourceAction.UPDATE == datasource_action:
return self.UPDATE_EVENT_TYPES.get( return self.GRAPH_ACTION_MAPPING.get(
entity_event.get(DSProps.EVENT_TYPE, None), entity_event.get(DSProps.EVENT_TYPE, None),
EventAction.UPDATE_ENTITY) GraphAction.UPDATE_ENTITY)
if ActionType.SNAPSHOT == action_type: if DatasourceAction.SNAPSHOT == datasource_action:
return EventAction.UPDATE_ENTITY return GraphAction.UPDATE_ENTITY
if ActionType.INIT_SNAPSHOT == action_type: if DatasourceAction.INIT_SNAPSHOT == datasource_action:
return EventAction.CREATE_ENTITY return GraphAction.CREATE_ENTITY
raise VitrageTransformerError( raise VitrageTransformerError(
'Invalid action type: (%s)' % action_type) 'Invalid action type: (%s)' % datasource_action)
def _key_values(self, *args): def _key_values(self, *args):
"""A list of key fields """A list of key fields
@ -252,10 +253,10 @@ class TransformerBase(object):
@staticmethod @staticmethod
def _is_end_message(entity_event): def _is_end_message(entity_event):
action_type = entity_event[DSProps.ACTION_TYPE] ds_action = entity_event[DSProps.DATASOURCE_ACTION]
is_snapshot_event = action_type == ActionType.INIT_SNAPSHOT is_snapshot_event = ds_action == DatasourceAction.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 == GraphAction.END_MESSAGE
@staticmethod @staticmethod
def _format_update_timestamp(update_timestamp, sample_timestamp): def _format_update_timestamp(update_timestamp, sample_timestamp):

View File

@ -17,7 +17,7 @@ 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 DatasourceAction
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
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
@ -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,
ActionType.UPDATE)[0] DatasourceAction.UPDATE)[0]
@staticmethod @staticmethod
def get_event_types(): def get_event_types():

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 DatasourceAction
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 GraphAction
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
@ -82,7 +82,7 @@ class ConsistencyEnforcer(object):
LOG.debug('Found %s vertices to be deleted by consistency service' LOG.debug('Found %s vertices to be deleted by consistency service'
': %s', len(old_deleted_entities), old_deleted_entities) ': %s', len(old_deleted_entities), old_deleted_entities)
self._push_events_to_queue(old_deleted_entities, self._push_events_to_queue(old_deleted_entities,
EventAction.REMOVE_DELETED_ENTITY) GraphAction.REMOVE_DELETED_ENTITY)
# mark stale entities as is_deleted=True # mark stale entities as is_deleted=True
stale_entities = self._find_stale_entities() stale_entities = self._find_stale_entities()
@ -90,7 +90,7 @@ class ConsistencyEnforcer(object):
'consistency service: %s', len(stale_entities), 'consistency service: %s', len(stale_entities),
stale_entities) stale_entities)
self._push_events_to_queue(stale_entities, self._push_events_to_queue(stale_entities,
EventAction.DELETE_ENTITY) GraphAction.DELETE_ENTITY)
except Exception as e: except Exception as e:
LOG.exception( LOG.exception(
'Error in deleting vertices from entity_graph: %s', e) 'Error in deleting vertices from entity_graph: %s', e)
@ -147,13 +147,13 @@ class ConsistencyEnforcer(object):
def _mark_old_deduced_alarms_as_deleted(self, timestamp): def _mark_old_deduced_alarms_as_deleted(self, timestamp):
old_deduced_alarms = self._find_old_deduced_alarms(timestamp) old_deduced_alarms = self._find_old_deduced_alarms(timestamp)
self._push_events_to_queue(old_deduced_alarms, self._push_events_to_queue(old_deduced_alarms,
EventAction.DELETE_ENTITY) GraphAction.DELETE_ENTITY)
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.ENTITY_TYPE: CONSISTENCY_DATASOURCE, DSProps.ENTITY_TYPE: CONSISTENCY_DATASOURCE,
DSProps.ACTION_TYPE: ActionType.UPDATE, DSProps.DATASOURCE_ACTION: DatasourceAction.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

@ -15,7 +15,7 @@
from oslo_log import log from oslo_log import log
from vitrage.common.constants import EventAction from vitrage.common.constants import GraphAction
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.transformer_base import TransformerBase from vitrage.datasources.transformer_base import TransformerBase
from vitrage.entity_graph.mappings.datasource_info_mapper import \ from vitrage.entity_graph.mappings.datasource_info_mapper import \
@ -75,7 +75,7 @@ class Processor(processor.ProcessorBase):
LOG.debug('Add entity to entity graph:\n%s', new_vertex) LOG.debug('Add entity to entity graph:\n%s', new_vertex)
self.entity_graph.add_vertex(new_vertex) self.entity_graph.add_vertex(new_vertex)
self._connect_neighbors(neighbors, [], EventAction.CREATE_ENTITY) self._connect_neighbors(neighbors, [], GraphAction.CREATE_ENTITY)
def update_entity(self, updated_vertex, neighbors): def update_entity(self, updated_vertex, neighbors):
"""Updates the vertex in the entity graph """Updates the vertex in the entity graph
@ -206,7 +206,7 @@ class Processor(processor.ProcessorBase):
self._delete_old_connections(vertex, obsolete_edges) self._delete_old_connections(vertex, obsolete_edges)
self._connect_neighbors(neighbors, self._connect_neighbors(neighbors,
valid_edges, valid_edges,
EventAction.UPDATE_ENTITY) GraphAction.UPDATE_ENTITY)
def _connect_neighbors(self, neighbors, valid_edges, action): def _connect_neighbors(self, neighbors, valid_edges, action):
"""Updates the neighbor vertex and adds the connection edges """ """Updates the neighbor vertex and adds the connection edges """
@ -289,28 +289,28 @@ class Processor(processor.ProcessorBase):
def _initialize_events_actions(self): def _initialize_events_actions(self):
self.actions = { self.actions = {
EventAction.CREATE_ENTITY: self.create_entity, GraphAction.CREATE_ENTITY: self.create_entity,
EventAction.UPDATE_ENTITY: self.update_entity, GraphAction.UPDATE_ENTITY: self.update_entity,
EventAction.DELETE_ENTITY: self.delete_entity, GraphAction.DELETE_ENTITY: self.delete_entity,
EventAction.UPDATE_RELATIONSHIP: self.update_relationship, GraphAction.UPDATE_RELATIONSHIP: self.update_relationship,
EventAction.DELETE_RELATIONSHIP: self.delete_relationship, GraphAction.DELETE_RELATIONSHIP: self.delete_relationship,
EventAction.REMOVE_DELETED_ENTITY: self.remove_deleted_entity, GraphAction.REMOVE_DELETED_ENTITY: self.remove_deleted_entity,
# should not be called explicitly # should not be called explicitly
EventAction.END_MESSAGE: self.handle_end_message GraphAction.END_MESSAGE: self.handle_end_message
} }
def _calculate_aggregated_state(self, vertex, action): def _calculate_aggregated_state(self, vertex, action):
LOG.debug("calculate event state") LOG.debug("calculate event state")
try: try:
if action in [EventAction.UPDATE_ENTITY, if action in [GraphAction.UPDATE_ENTITY,
EventAction.DELETE_ENTITY, GraphAction.DELETE_ENTITY,
EventAction.CREATE_ENTITY]: GraphAction.CREATE_ENTITY]:
graph_vertex = self.entity_graph.get_vertex(vertex.vertex_id) graph_vertex = self.entity_graph.get_vertex(vertex.vertex_id)
elif action in [EventAction.END_MESSAGE, elif action in [GraphAction.END_MESSAGE,
EventAction.REMOVE_DELETED_ENTITY, GraphAction.REMOVE_DELETED_ENTITY,
EventAction.UPDATE_RELATIONSHIP, GraphAction.UPDATE_RELATIONSHIP,
EventAction.DELETE_RELATIONSHIP]: GraphAction.DELETE_RELATIONSHIP]:
return None return None
else: else:
LOG.error('unrecognized action: %s for vertex: %s', LOG.error('unrecognized action: %s for vertex: %s',

View File

@ -16,7 +16,7 @@ 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 DatasourceAction as AType
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
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
@ -103,7 +103,7 @@ class ActionExecutor(object):
@staticmethod @staticmethod
def _add_default_properties(event): def _add_default_properties(event):
event[DSProps.ACTION_TYPE] = AType.UPDATE event[DSProps.DATASOURCE_ACTION] = AType.UPDATE
event[DSProps.ENTITY_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

@ -17,7 +17,7 @@ from oslo_log import log as logging
from vitrage.common.constants import EdgeLabel from vitrage.common.constants import EdgeLabel
from vitrage.common.constants import EdgeProperties as EProps from vitrage.common.constants import EdgeProperties as EProps
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.common.constants import EventAction from vitrage.common.constants import GraphAction
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.common.exception import VitrageTransformerError from vitrage.common.exception import VitrageTransformerError
from vitrage.datasources import transformer_base from vitrage.datasources import transformer_base
@ -131,7 +131,7 @@ class EvaluatorEventTransformer(transformer_base.TransformerBase):
return [] return []
def _extract_event_action(self, event): def _extract_graph_action(self, event):
event_type = event[EVALUATOR_EVENT_TYPE] event_type = event[EVALUATOR_EVENT_TYPE]
try: try:
@ -143,11 +143,11 @@ class EvaluatorEventTransformer(transformer_base.TransformerBase):
@staticmethod @staticmethod
def _init_actions(): def _init_actions():
return { return {
UPDATE_VERTEX: EventAction.UPDATE_ENTITY, UPDATE_VERTEX: GraphAction.UPDATE_ENTITY,
ADD_VERTEX: EventAction.CREATE_ENTITY, ADD_VERTEX: GraphAction.CREATE_ENTITY,
REMOVE_VERTEX: EventAction.DELETE_ENTITY, REMOVE_VERTEX: GraphAction.DELETE_ENTITY,
ADD_EDGE: EventAction.UPDATE_RELATIONSHIP, ADD_EDGE: GraphAction.UPDATE_RELATIONSHIP,
REMOVE_EDGE: EventAction.DELETE_RELATIONSHIP REMOVE_EDGE: GraphAction.DELETE_RELATIONSHIP
} }
def _create_entity_key(self, event): def _create_entity_key(self, event):

View File

@ -12,7 +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.
from vitrage.common.constants import ActionType from vitrage.common.constants import DatasourceAction
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
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
@ -38,15 +38,18 @@ 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.ACTION_TYPE: ActionType.INIT_SNAPSHOT}) snap_vals={DSProps.DATASOURCE_ACTION:
DatasourceAction.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.ACTION_TYPE: ActionType.INIT_SNAPSHOT}) snap_vals={DSProps.DATASOURCE_ACTION:
DatasourceAction.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.ACTION_TYPE: ActionType.INIT_SNAPSHOT}) snap_vals={DSProps.DATASOURCE_ACTION:
DatasourceAction.INIT_SNAPSHOT})
return mock_driver.generate_sequential_events_list(gen_list) return mock_driver.generate_sequential_events_list(gen_list)

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 DatasourceAction as DSAction
from vitrage.common.constants import EventAction from vitrage.common.constants import GraphAction
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',
action_type=ActionType.INIT_SNAPSHOT) datasource_action=DSAction.INIT_SNAPSHOT)
# action # action
processor.process_event(event) processor.process_event(event)
@ -57,14 +57,14 @@ 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',
action_type=ActionType.INIT_SNAPSHOT) datasource_action=DSAction.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'
neighbors[0].vertex[VProps.IS_PLACEHOLDER] = False neighbors[0].vertex[VProps.IS_PLACEHOLDER] = False
# action # action
processor._connect_neighbors(neighbors, [], EventAction.UPDATE_ENTITY) processor._connect_neighbors(neighbors, [], GraphAction.UPDATE_ENTITY)
# test assertions # test assertions
neighbor_vertex = processor.entity_graph.get_vertex( neighbor_vertex = processor.entity_graph.get_vertex(

View File

@ -259,7 +259,7 @@ class TestActionExecutor(TestFunctionalBase):
'service': 'Check_MK', 'service': 'Check_MK',
'status': 'CRITICAL', 'status': 'CRITICAL',
'status_info': 'test test test', 'status_info': 'test test test',
'vitrage_action_type': 'snapshot', 'vitrage_datasource_action': 'snapshot',
'vitrage_entity_type': 'nagios', 'vitrage_entity_type': 'nagios',
'vitrage_sample_date': '2016-02-07 15:26:04'} 'vitrage_sample_date': '2016-02-07 15:26:04'}
@ -268,7 +268,7 @@ 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_action_type': 'update', 'vitrage_datasource_action': 'update',
'alarm_name': alarm_name, 'alarm_name': alarm_name,
'state': 'Active', 'state': 'Active',
'type': 'add_vertex', 'type': 'add_vertex',

View File

@ -16,9 +16,10 @@ from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from six.moves import queue from six.moves import queue
from vitrage.common.constants import DatasourceAction
from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import EdgeProperties as EProps from vitrage.common.constants import EdgeProperties as EProps
from vitrage.common.constants import EventAction from vitrage.common.constants import GraphAction
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
from vitrage.evaluator.scenario_evaluator import ScenarioEvaluator from vitrage.evaluator.scenario_evaluator import ScenarioEvaluator
@ -31,7 +32,8 @@ 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, 'action_type': 'snapshot'} _NAGIOS_TEST_INFO = {'resource_name': _TARGET_HOST,
DSProps.DATASOURCE_ACTION: DatasourceAction.SNAPSHOT}
class TestScenarioEvaluator(TestFunctionalBase): class TestScenarioEvaluator(TestFunctionalBase):
@ -237,7 +239,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
# remove WARNING nagios alarm, leaving only CRITICAL one # remove WARNING nagios alarm, leaving only CRITICAL one
warning_test['status'] = 'OK' warning_test['status'] = 'OK'
warning_test[DSProps.EVENT_TYPE] = EventAction.DELETE_ENTITY warning_test[DSProps.EVENT_TYPE] = GraphAction.DELETE_ENTITY
host_v = self.get_host_after_event(event_queue, warning_test, host_v = self.get_host_after_event(event_queue, warning_test,
processor, _TARGET_HOST) processor, _TARGET_HOST)
alarms = \ alarms = \
@ -249,7 +251,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
# next disable the alarm # next disable the alarm
critical_test['status'] = 'OK' critical_test['status'] = 'OK'
critical_test[DSProps.EVENT_TYPE] = EventAction.DELETE_ENTITY critical_test[DSProps.EVENT_TYPE] = GraphAction.DELETE_ENTITY
host_v = self.get_host_after_event(event_queue, critical_test, host_v = self.get_host_after_event(event_queue, critical_test,
processor, _TARGET_HOST) processor, _TARGET_HOST)
alarms = \ alarms = \

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['action_type'] = 'update' update_vals['vitrage_datasource_action'] = '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_entity_type": "consistency", "vitrage_entity_type": "consistency",
"vitrage_action_type": "update", "vitrage_datasource_action": "update",
"vitrage_event_type": "delete_entity", "vitrage_event_type": "delete_entity",
"vitrage_id": "[0-9]{5}" "vitrage_id": "[0-9]{5}"
} }

View File

@ -9,6 +9,6 @@
"service": "compute", "service": "compute",
"vitrage_entity_type": "nova.host", "vitrage_entity_type": "nova.host",
"zone": "zone0", "zone": "zone0",
"vitrage_action_type": "init_snapshot", "vitrage_datasource_action": "init_snapshot",
"vitrage_sample_date": "2015-12-01T12:46:41Z" "vitrage_sample_date": "2015-12-01T12:46:41Z"
} }

View File

@ -1,6 +1,6 @@
{ {
"OS-EXT-STS:task_state": null, "OS-EXT-STS:task_state": null,
"vitrage_action_type": "snapshot", "vitrage_datasource_action": "snapshot",
"vitrage_entity_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": {

View File

@ -1,5 +1,5 @@
{ {
"vitrage_action_type": "update", "vitrage_datasource_action": "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

@ -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_action_type": "snapshot" "vitrage_datasource_action": "snapshot"
} }

View File

@ -4,7 +4,7 @@
"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_action_type": "init_snapshot", "vitrage_datasource_action": "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",

View File

@ -4,7 +4,7 @@
"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_action_type": "update", "vitrage_datasource_action": "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",

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_action_type": "snapshot", "vitrage_datasource_action": "snapshot",
"state": "available", "state": "available",
"vitrage_event_type": "entity_update" "vitrage_event_type": "entity_update"
} }

View File

@ -5,7 +5,7 @@
"status": "In-use", "status": "In-use",
"id": "12345", "id": "12345",
"vitrage_entity_type": "cinder.volume", "vitrage_entity_type": "cinder.volume",
"vitrage_action_type": "snapshot", "vitrage_datasource_action": "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

@ -5,7 +5,7 @@
"status": "In-use", "status": "In-use",
"volume_id": "12345", "volume_id": "12345",
"vitrage_entity_type": "cinder.volume", "vitrage_entity_type": "cinder.volume",
"vitrage_action_type": "update", "vitrage_datasource_action": "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

@ -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_action_type": "snapshot", "vitrage_datasource_action": "snapshot",
"rawtext": "CPU utilization" "rawtext": "CPU utilization"
} }

View File

@ -10,7 +10,7 @@
"hosts": {}, "hosts": {},
"vitrage_sample_date": "2015-12-01T12:46:41Z", "vitrage_sample_date": "2015-12-01T12:46:41Z",
"vitrage_entity_type": "nova.zone", "vitrage_entity_type": "nova.zone",
"vitrage_action_type": "snapshot", "vitrage_datasource_action": "snapshot",
"zoneName": "zone0", "zoneName": "zone0",
"zoneState": { "zoneState": {
"available": "True" "available": "True"

View File

@ -1,5 +1,5 @@
{ {
"vitrage_action_type": "init_snapshot", "vitrage_datasource_action": "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_action_type": "init_snapshot", "vitrage_datasource_action": "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}",

View File

@ -1,5 +1,5 @@
{ {
"vitrage_action_type": "init_snapshot", "vitrage_datasource_action": "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

@ -15,7 +15,7 @@
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 EventAction from vitrage.common.constants import GraphAction
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.consistency import CONSISTENCY_DATASOURCE from vitrage.datasources.consistency import CONSISTENCY_DATASOURCE
@ -42,8 +42,8 @@ class TestConsistencyTransformer(base.BaseTest):
cls.conf.register_opts(cls.OPTS, group=CONSISTENCY_DATASOURCE) cls.conf.register_opts(cls.OPTS, group=CONSISTENCY_DATASOURCE)
cls.transformers[CONSISTENCY_DATASOURCE] = \ cls.transformers[CONSISTENCY_DATASOURCE] = \
ConsistencyTransformer(cls.transformers, cls.conf) ConsistencyTransformer(cls.transformers, cls.conf)
cls.actions = [EventAction.DELETE_ENTITY, cls.actions = [GraphAction.DELETE_ENTITY,
EventAction.REMOVE_DELETED_ENTITY] GraphAction.REMOVE_DELETED_ENTITY]
def test_snapshot_transform(self): def test_snapshot_transform(self):
LOG.debug('Consistency transformer test: transform entity event ' LOG.debug('Consistency transformer test: transform entity event '

View File

@ -15,7 +15,7 @@
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 DatasourceProperties as DSProps from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import EventAction from vitrage.common.constants import GraphAction
from vitrage.datasources.nagios.properties import NagiosProperties as \ from vitrage.datasources.nagios.properties import NagiosProperties as \
NagiosProps NagiosProps
from vitrage.tests.mocks import utils from vitrage.tests.mocks import utils
@ -498,7 +498,7 @@ class NagiosDriverTest(NagiosBaseTest):
self.assertIsNotNone(services, 'No services returned') self.assertIsNotNone(services, 'No services returned')
self.assertEqual(1, len(services)) self.assertEqual(1, len(services))
self._assert_contains(service_data1, services) self._assert_contains(service_data1, services)
self.assertEqual(EventAction.DELETE_ENTITY, self.assertEqual(GraphAction.DELETE_ENTITY,
services[0][DSProps.EVENT_TYPE]) services[0][DSProps.EVENT_TYPE])
# Action - get changes, should not return the deleted alarm again # Action - get changes, should not return the deleted alarm again
@ -539,5 +539,5 @@ class NagiosDriverTest(NagiosBaseTest):
self.assertIsNotNone(services, 'No services returned') self.assertIsNotNone(services, 'No services returned')
self.assertEqual(1, len(services)) self.assertEqual(1, len(services))
self._assert_contains(service_data1, services) self._assert_contains(service_data1, services)
self.assertEqual(EventAction.DELETE_ENTITY, self.assertEqual(GraphAction.DELETE_ENTITY,
services[0][DSProps.EVENT_TYPE]) services[0][DSProps.EVENT_TYPE])

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 DatasourceAction
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 GraphAction
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
@ -104,15 +104,15 @@ class NagiosTransformerTest(base.BaseTest):
def _validate_action(self, alarm, wrapper): def _validate_action(self, alarm, wrapper):
if DSProps.EVENT_TYPE in alarm \ if DSProps.EVENT_TYPE in alarm \
and alarm[DSProps.EVENT_TYPE] in EventAction.__dict__.values(): and alarm[DSProps.EVENT_TYPE] in GraphAction.__dict__.values():
self.assertEqual(alarm[DSProps.EVENT_TYPE], wrapper.action) self.assertEqual(alarm[DSProps.EVENT_TYPE], wrapper.action)
return return
action_type = alarm[DSProps.ACTION_TYPE] ds_action = alarm[DSProps.DATASOURCE_ACTION]
if action_type in (ActionType.SNAPSHOT, ActionType.UPDATE): if ds_action in (DatasourceAction.SNAPSHOT, DatasourceAction.UPDATE):
self.assertEqual(EventAction.UPDATE_ENTITY, wrapper.action) self.assertEqual(GraphAction.UPDATE_ENTITY, wrapper.action)
else: else:
self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action) self.assertEqual(GraphAction.CREATE_ENTITY, wrapper.action)
def _validate_vertex(self, vertex, event): def _validate_vertex(self, vertex, event):
@ -124,7 +124,7 @@ class NagiosTransformerTest(base.BaseTest):
if event_type is not None: if event_type is not None:
self.assertEqual(vertex[VProps.STATE], self.assertEqual(vertex[VProps.STATE],
AlarmProps.INACTIVE_STATE if AlarmProps.INACTIVE_STATE if
EventAction.DELETE_ENTITY == event_type else GraphAction.DELETE_ENTITY == event_type else
AlarmProps.ACTIVE_STATE) AlarmProps.ACTIVE_STATE)
else: else:
actual_state = AlarmProps.INACTIVE_STATE if \ actual_state = AlarmProps.INACTIVE_STATE if \

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 DatasourceAction
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 GraphAction
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,10 +133,10 @@ 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 ActionType.SNAPSHOT == event[DSProps.ACTION_TYPE]: if DatasourceAction.SNAPSHOT == event[DSProps.DATASOURCE_ACTION]:
self.assertEqual(EventAction.UPDATE_ENTITY, wrapper.action) self.assertEqual(GraphAction.UPDATE_ENTITY, wrapper.action)
else: else:
self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action) self.assertEqual(GraphAction.CREATE_ENTITY, wrapper.action)
def _validate_zone_neighbor(self, zone, event): def _validate_zone_neighbor(self, zone, event):
@ -200,30 +200,31 @@ 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.ACTION_TYPE: ActionType.SNAPSHOT}) snap_vals={DSProps.DATASOURCE_ACTION: DatasourceAction.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]
# Test action # Test action
action = host_transformer._extract_event_action(hosts_events[0]) action = host_transformer._extract_graph_action(hosts_events[0])
# Test assertion # Test assertion
self.assertEqual(EventAction.UPDATE_ENTITY, action) self.assertEqual(GraphAction.UPDATE_ENTITY, action)
# Test setup # Test setup
spec_list = mock_sync.simple_host_generators( spec_list = mock_sync.simple_host_generators(
zone_num=1, zone_num=1,
host_num=1, host_num=1,
snapshot_events=1, snapshot_events=1,
snap_vals={DSProps.ACTION_TYPE: ActionType.INIT_SNAPSHOT}) snap_vals={DSProps.DATASOURCE_ACTION:
DatasourceAction.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]
# Test action # Test action
action = host_transformer._extract_event_action(hosts_events[0]) action = host_transformer._extract_graph_action(hosts_events[0])
# Test assertions # Test assertions
self.assertEqual(EventAction.CREATE_ENTITY, action) self.assertEqual(GraphAction.CREATE_ENTITY, action)
# TODO(lhartal): To add extract action from update event # TODO(lhartal): To add extract action from update event

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 DatasourceAction
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 GraphAction
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,11 +118,11 @@ 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)
action_type = event[DSProps.ACTION_TYPE] datasource_action = event[DSProps.DATASOURCE_ACTION]
if action_type == ActionType.INIT_SNAPSHOT: if datasource_action == DatasourceAction.INIT_SNAPSHOT:
self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action) self.assertEqual(GraphAction.CREATE_ENTITY, wrapper.action)
elif action_type == ActionType.SNAPSHOT: elif datasource_action == DatasourceAction.SNAPSHOT:
self.assertEqual(EventAction.UPDATE_ENTITY, wrapper.action) self.assertEqual(GraphAction.UPDATE_ENTITY, wrapper.action)
def test_update_event_transform(self): def test_update_event_transform(self):
LOG.debug('Test tactual transform action for update events') LOG.debug('Test tactual transform action for update events')
@ -149,11 +149,11 @@ class NovaInstanceTransformerTest(base.BaseTest):
event_type = event[DSProps.EVENT_TYPE] event_type = event[DSProps.EVENT_TYPE]
if event_type == 'compute.instance.delete.end': if event_type == 'compute.instance.delete.end':
self.assertEqual(EventAction.DELETE_ENTITY, wrapper.action) self.assertEqual(GraphAction.DELETE_ENTITY, wrapper.action)
elif event_type == 'compute.instance.create.start': elif event_type == 'compute.instance.create.start':
self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action) self.assertEqual(GraphAction.CREATE_ENTITY, wrapper.action)
else: else:
self.assertEqual(EventAction.UPDATE_ENTITY, wrapper.action) self.assertEqual(GraphAction.UPDATE_ENTITY, wrapper.action)
def _validate_vertex_props(self, vertex, event): def _validate_vertex_props(self, vertex, event):

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.ACTION_TYPE]) event[DSProps.DATASOURCE_ACTION])
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,
action_type): datasource_action):
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 DatasourceAction
from vitrage.common.constants import EventAction from vitrage.common.constants import GraphAction
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(ActionType.UPDATE) static_entities = self.static_driver.get_all(DatasourceAction.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(ActionType.UPDATE) entities = self.static_driver.get_all(DatasourceAction.UPDATE)
self.assertEqual(0, len(entities)) self.assertEqual(0, len(entities))
self.conf = cfg.ConfigOpts() self.conf = cfg.ConfigOpts()
@ -88,7 +88,7 @@ class TestStaticDriver(base.BaseTest):
# Action # Action
changes = self.static_driver.get_changes( changes = self.static_driver.get_changes(
EventAction.UPDATE_ENTITY) GraphAction.UPDATE_ENTITY)
# Test Assertions # Test Assertions
self.assertEqual(0, len(changes)) self.assertEqual(0, len(changes))

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 DatasourceAction
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 GraphAction
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
@ -93,7 +93,7 @@ class TestStaticPhysicalDriver(base.BaseTest):
def test_get_all(self): def test_get_all(self):
# Action # Action
static_entities = \ static_entities = \
self.static_physical_driver.get_all(ActionType.UPDATE) self.static_physical_driver.get_all(DatasourceAction.UPDATE)
# Test assertions # Test assertions
self.assertEqual(5, len(static_entities)) self.assertEqual(5, len(static_entities))
@ -101,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(ActionType.UPDATE) entities = self.static_physical_driver.get_all(DatasourceAction.UPDATE)
self.assertEqual(5, len(entities)) self.assertEqual(5, len(entities))
self.conf = cfg.ConfigOpts() self.conf = cfg.ConfigOpts()
@ -111,7 +111,7 @@ class TestStaticPhysicalDriver(base.BaseTest):
# Action # Action
changes = self.static_physical_driver.get_changes( changes = self.static_physical_driver.get_changes(
EventAction.UPDATE_ENTITY) GraphAction.UPDATE_ENTITY)
# Test Assertions # Test Assertions
status = any(change[VProps.TYPE] == SWITCH and status = any(change[VProps.TYPE] == SWITCH and
@ -120,7 +120,7 @@ class TestStaticPhysicalDriver(base.BaseTest):
status = any(change[VProps.TYPE] == SWITCH and status = any(change[VProps.TYPE] == SWITCH and
change[VProps.ID] == '23456' and change[VProps.ID] == '23456' and
change[DSProps.EVENT_TYPE] == EventAction.DELETE_ENTITY change[DSProps.EVENT_TYPE] == GraphAction.DELETE_ENTITY
for change in changes) for change in changes)
self.assertEqual(True, status) self.assertEqual(True, status)
@ -139,7 +139,7 @@ class TestStaticPhysicalDriver(base.BaseTest):
# Action # Action
changes = self.static_physical_driver.get_changes( changes = self.static_physical_driver.get_changes(
EventAction.UPDATE_ENTITY) GraphAction.UPDATE_ENTITY)
# Test Assertions # Test Assertions
self.assertEqual(0, len(changes)) self.assertEqual(0, len(changes))

View File

@ -18,7 +18,7 @@ from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
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 GraphAction
from vitrage.datasources.zabbix.properties import ZabbixProperties as ZProps from vitrage.datasources.zabbix.properties import ZabbixProperties as ZProps
from vitrage.tests.mocks import utils from vitrage.tests.mocks import utils
from vitrage.tests.unit.datasources.zabbix.mock_driver import MockZabbixDriver from vitrage.tests.unit.datasources.zabbix.mock_driver import MockZabbixDriver
@ -394,7 +394,7 @@ class ZabbixDriverTest(ZabbixBaseTest):
self.assertIsNotNone(alarms, 'No alarms returned') self.assertIsNotNone(alarms, 'No alarms returned')
self.assertEqual(1, len(alarms)) self.assertEqual(1, len(alarms))
self._assert_contains(alarm_data1, alarms) self._assert_contains(alarm_data1, alarms)
self.assertEqual(EventAction.DELETE_ENTITY, self.assertEqual(GraphAction.DELETE_ENTITY,
alarms[0][DSProps.EVENT_TYPE]) alarms[0][DSProps.EVENT_TYPE])
# Step 3 - get changes after get all should not return deleted alarm # Step 3 - get changes after get all should not return deleted alarm
@ -418,7 +418,7 @@ class ZabbixDriverTest(ZabbixBaseTest):
self.assertIsNotNone(alarms, 'No alarms returned') self.assertIsNotNone(alarms, 'No alarms returned')
self.assertEqual(1, len(alarms)) self.assertEqual(1, len(alarms))
self._assert_contains(alarm_data1, alarms) self._assert_contains(alarm_data1, alarms)
self.assertEqual(EventAction.DELETE_ENTITY, self.assertEqual(GraphAction.DELETE_ENTITY,
alarms[0][DSProps.EVENT_TYPE]) alarms[0][DSProps.EVENT_TYPE])
def _extract_alarm_data(self, def _extract_alarm_data(self,

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 DatasourceAction
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 GraphAction
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
@ -110,15 +110,15 @@ class ZabbixTransformerTest(base.BaseTest):
def _validate_action(self, alarm, wrapper): def _validate_action(self, alarm, wrapper):
if DSProps.EVENT_TYPE in alarm \ if DSProps.EVENT_TYPE in alarm \
and alarm[DSProps.EVENT_TYPE] in EventAction.__dict__.values(): and alarm[DSProps.EVENT_TYPE] in GraphAction.__dict__.values():
self.assertEqual(alarm[DSProps.EVENT_TYPE], wrapper.action) self.assertEqual(alarm[DSProps.EVENT_TYPE], wrapper.action)
return return
action_type = alarm[DSProps.ACTION_TYPE] ds_action = alarm[DSProps.DATASOURCE_ACTION]
if action_type in (ActionType.SNAPSHOT, ActionType.UPDATE): if ds_action in (DatasourceAction.SNAPSHOT, DatasourceAction.UPDATE):
self.assertEqual(EventAction.UPDATE_ENTITY, wrapper.action) self.assertEqual(GraphAction.UPDATE_ENTITY, wrapper.action)
else: else:
self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action) self.assertEqual(GraphAction.CREATE_ENTITY, wrapper.action)
def _validate_vertex(self, vertex, event): def _validate_vertex(self, vertex, event):

View File

@ -14,7 +14,7 @@
from oslo_config import cfg from oslo_config import cfg
from vitrage.common.constants import ActionType from vitrage.common.constants import DatasourceAction
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.datasources.nagios import NAGIOS_DATASOURCE from vitrage.datasources.nagios import NAGIOS_DATASOURCE
@ -80,24 +80,31 @@ 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.ACTION_TYPE: ActionType.INIT_SNAPSHOT}) snap_vals={DSProps.DATASOURCE_ACTION:
DatasourceAction.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.ACTION_TYPE: ActionType.INIT_SNAPSHOT}) snap_vals={DSProps.DATASOURCE_ACTION:
DatasourceAction.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.ACTION_TYPE: ActionType.INIT_SNAPSHOT}) snap_vals={DSProps.DATASOURCE_ACTION:
DatasourceAction.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, action_type=None, def _create_entity(self,
event_type=None, properties=None): processor=None,
spec_type=None,
datasource_action=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,
action_type=action_type, datasource_action=datasource_action,
event_type=event_type, event_type=event_type,
properties=properties) properties=properties)
@ -112,16 +119,18 @@ class TestEntityGraphUnitBase(base.BaseTest):
return vertex, neighbors, processor return vertex, neighbors, processor
@staticmethod @staticmethod
def _create_event(spec_type=None, action_type=None, def _create_event(spec_type=None,
event_type=None, properties=None): datasource_action=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)
events_list = mock_sync.generate_random_events_list( events_list = mock_sync.generate_random_events_list(
spec_list) spec_list)
# update properties # update properties
if action_type is not None: if datasource_action is not None:
events_list[0][DSProps.ACTION_TYPE] = action_type events_list[0][DSProps.DATASOURCE_ACTION] = datasource_action
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 DatasourceAction as DSAction
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 GraphAction
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,
action_type=ActionType.INIT_SNAPSHOT) datasource_action=DSAction.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.ACTION_TYPE] = ActionType.UPDATE event[DSProps.DATASOURCE_ACTION] = DSAction.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.ACTION_TYPE] = ActionType.UPDATE event[DSProps.DATASOURCE_ACTION] = DSAction.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,
action_type=ActionType.INIT_SNAPSHOT) datasource_action=DSAction.INIT_SNAPSHOT)
vertex2, neighbors2, processor = self._create_entity( vertex2, neighbors2, processor = self._create_entity(
spec_type=self.INSTANCE_SPEC, spec_type=self.INSTANCE_SPEC,
action_type=ActionType.INIT_SNAPSHOT, datasource_action=DSAction.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,
action_type=ActionType.INIT_SNAPSHOT) datasource_action=DSAction.INIT_SNAPSHOT)
vertex2, neighbors2, processor = self._create_entity( vertex2, neighbors2, processor = self._create_entity(
spec_type=self.INSTANCE_SPEC, spec_type=self.INSTANCE_SPEC,
action_type=ActionType.INIT_SNAPSHOT, datasource_action=DSAction.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,
action_type=ActionType.INIT_SNAPSHOT) datasource_action=DSAction.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)
@ -237,19 +237,19 @@ class TestProcessor(TestEntityGraphUnitBase):
# state already exists and its updated # state already exists and its updated
instances[0][0][VProps.STATE] = 'SUSPENDED' instances[0][0][VProps.STATE] = 'SUSPENDED'
instances[0][1]._calculate_aggregated_state(instances[0][0], instances[0][1]._calculate_aggregated_state(instances[0][0],
EventAction.UPDATE_ENTITY) GraphAction.UPDATE_ENTITY)
# vitrage state doesn't exist and its updated # vitrage state doesn't exist and its updated
instances[1][0][VProps.STATE] = None instances[1][0][VProps.STATE] = None
instances[1][1].entity_graph.update_vertex(instances[1][0]) instances[1][1].entity_graph.update_vertex(instances[1][0])
instances[1][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL' instances[1][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
instances[1][1]._calculate_aggregated_state(instances[1][0], instances[1][1]._calculate_aggregated_state(instances[1][0],
EventAction.UPDATE_ENTITY) GraphAction.UPDATE_ENTITY)
# state exists and vitrage state changes # state exists and vitrage state changes
instances[2][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL' instances[2][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
instances[2][1]._calculate_aggregated_state(instances[2][0], instances[2][1]._calculate_aggregated_state(instances[2][0],
EventAction.UPDATE_ENTITY) GraphAction.UPDATE_ENTITY)
# vitrage state exists and state changes # vitrage state exists and state changes
instances[3][0][VProps.STATE] = None instances[3][0][VProps.STATE] = None
@ -257,20 +257,20 @@ class TestProcessor(TestEntityGraphUnitBase):
instances[3][1].entity_graph.update_vertex(instances[3][0]) instances[3][1].entity_graph.update_vertex(instances[3][0])
instances[3][0][VProps.STATE] = 'SUSPENDED' instances[3][0][VProps.STATE] = 'SUSPENDED'
instances[3][1]._calculate_aggregated_state(instances[3][0], instances[3][1]._calculate_aggregated_state(instances[3][0],
EventAction.UPDATE_ENTITY) GraphAction.UPDATE_ENTITY)
# state and vitrage state exists and state changes # state and vitrage state exists and state changes
instances[4][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL' instances[4][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
instances[4][1].entity_graph.update_vertex(instances[4][0]) instances[4][1].entity_graph.update_vertex(instances[4][0])
instances[4][0][VProps.STATE] = 'SUSPENDED' instances[4][0][VProps.STATE] = 'SUSPENDED'
instances[4][1]._calculate_aggregated_state(instances[4][0], instances[4][1]._calculate_aggregated_state(instances[4][0],
EventAction.UPDATE_ENTITY) GraphAction.UPDATE_ENTITY)
# state and vitrage state exists and vitrage state changes # state and vitrage state exists and vitrage state changes
instances[5][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL' instances[5][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
instances[5][1].entity_graph.update_vertex(instances[5][0]) instances[5][1].entity_graph.update_vertex(instances[5][0])
instances[5][1]._calculate_aggregated_state(instances[5][0], instances[5][1]._calculate_aggregated_state(instances[5][0],
EventAction.UPDATE_ENTITY) GraphAction.UPDATE_ENTITY)
# test assertions # test assertions
self.assertEqual('SUSPENDED', self.assertEqual('SUSPENDED',
@ -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,
action_type=ActionType.INIT_SNAPSHOT, datasource_action=DSAction.INIT_SNAPSHOT,
properties=kwargs, properties=kwargs,
processor=processor) processor=processor)

View File

@ -218,7 +218,7 @@ class TemplateSyntaxValidatorTest(base.BaseTest):
action[TemplateFields.ACTION].pop(field_name) action[TemplateFields.ACTION].pop(field_name)
self._test_execution_with_fault_result(template, expected_comment) self._test_execution_with_fault_result(template, expected_comment)
def _test_validate_action_with_invalid_action_type(self): def _test_validate_action_with_invalid_datasource_action(self):
template = self.clone_template template = self.clone_template
scenario = template[TemplateFields.SCENARIOS][0] scenario = template[TemplateFields.SCENARIOS][0]

View File

@ -46,9 +46,11 @@ class BaseMock(testtools.TestCase):
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, 2, 4, snapshot_events=2,
snap_vals={'action_type': 'init_snapshot'}) snap_vals={'vitrage_datasource_action': 'init_snapshot'})
gen_list += mock_sync.simple_host_generators( gen_list += mock_sync.simple_host_generators(
2, 4, 4, snap_vals={'action_type': 'init_snapshot'}) 2, 4, 4,
snap_vals={'vitrage_datasource_action': 'init_snapshot'})
gen_list += mock_sync.simple_instance_generators( gen_list += mock_sync.simple_instance_generators(
4, 15, 15, snap_vals={'action_type': 'init_snapshot'}) 4, 15, 15,
snap_vals={'vitrage_datasource_action': 'init_snapshot'})
return mock_sync.generate_sequential_events_list(gen_list) return mock_sync.generate_sequential_events_list(gen_list)