change constants names
event_action to graph_action action_type to datasource_action Closes-Bug: #1622966 Change-Id: I23cd775f0b3aca477f85ff4851e416e8d042efdc
This commit is contained in:
parent
fbfa617246
commit
c7f2468981
@ -64,7 +64,7 @@ class EdgeLabel(object):
|
||||
if not label.startswith(('_', 'labels'))]
|
||||
|
||||
|
||||
class ActionType(object):
|
||||
class DatasourceAction(object):
|
||||
SNAPSHOT = 'snapshot'
|
||||
INIT_SNAPSHOT = 'init_snapshot'
|
||||
UPDATE = 'update'
|
||||
@ -89,12 +89,12 @@ class EntityCategory(object):
|
||||
|
||||
class DatasourceProperties(object):
|
||||
ENTITY_TYPE = 'vitrage_entity_type'
|
||||
ACTION_TYPE = 'vitrage_action_type'
|
||||
DATASOURCE_ACTION = 'vitrage_datasource_action'
|
||||
SAMPLE_DATE = 'vitrage_sample_date'
|
||||
EVENT_TYPE = 'vitrage_event_type'
|
||||
|
||||
|
||||
class EventAction(object):
|
||||
class GraphAction(object):
|
||||
CREATE_ENTITY = 'create_entity'
|
||||
DELETE_ENTITY = 'delete_entity'
|
||||
UPDATE_ENTITY = 'update_entity'
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
from oslo_log import log
|
||||
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.datasources.driver_base import DriverBase
|
||||
|
||||
@ -71,15 +71,15 @@ class AlarmDriverBase(DriverBase):
|
||||
"""
|
||||
pass
|
||||
|
||||
def get_all(self, action_type):
|
||||
def get_all(self, datasource_action):
|
||||
return self.make_pickleable(self._get_all_alarms(),
|
||||
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(),
|
||||
self._entity_type(),
|
||||
action_type)
|
||||
datasource_action)
|
||||
|
||||
def _get_all_alarms(self):
|
||||
alarms = self._get_alarms()
|
||||
@ -105,7 +105,7 @@ class AlarmDriverBase(DriverBase):
|
||||
if filter_(self, alarm, old_alarm):
|
||||
# delete state changed alarm: alarm->OK
|
||||
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)
|
||||
|
||||
self.cache[alarm_key] = alarm, now
|
||||
@ -115,7 +115,7 @@ class AlarmDriverBase(DriverBase):
|
||||
for cached_alarm, timestamp in values:
|
||||
if self._is_erroneous(cached_alarm) and timestamp is not now:
|
||||
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)
|
||||
self.cache.pop(self._alarm_key(cached_alarm))
|
||||
|
||||
|
@ -16,7 +16,7 @@ from oslo_log import log as logging
|
||||
|
||||
from vitrage.common.constants import DatasourceProperties as DSProps
|
||||
from vitrage.common.constants import EntityCategory
|
||||
from vitrage.common.constants import EventAction
|
||||
from vitrage.common.constants import GraphAction
|
||||
from vitrage.datasources.alarm_properties import AlarmProperties as AlarmProps
|
||||
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)
|
||||
if event_type is not None:
|
||||
return AlarmProps.INACTIVE_STATE if \
|
||||
EventAction.DELETE_ENTITY == event_type else \
|
||||
GraphAction.DELETE_ENTITY == event_type else \
|
||||
AlarmProps.ACTIVE_STATE
|
||||
else:
|
||||
return AlarmProps.INACTIVE_STATE if \
|
||||
|
@ -12,7 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# 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.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE
|
||||
from vitrage.datasources.driver_base import DriverBase
|
||||
@ -36,12 +36,12 @@ class CinderVolumeDriver(DriverBase):
|
||||
def extract_events(volumes):
|
||||
return [volume.__dict__ for volume in volumes]
|
||||
|
||||
def get_all(self, action_type):
|
||||
def get_all(self, datasource_action):
|
||||
return self.make_pickleable(
|
||||
self.extract_events(self.client.volumes.list(
|
||||
search_opts={'all_tenants': 1})),
|
||||
CINDER_VOLUME_DATASOURCE,
|
||||
action_type,
|
||||
datasource_action,
|
||||
'manager')
|
||||
|
||||
@staticmethod
|
||||
@ -50,7 +50,7 @@ class CinderVolumeDriver(DriverBase):
|
||||
|
||||
return CinderVolumeDriver.make_pickleable([event],
|
||||
CINDER_VOLUME_DATASOURCE,
|
||||
ActionType.UPDATE)[0]
|
||||
DatasourceAction.UPDATE)[0]
|
||||
|
||||
@staticmethod
|
||||
def get_event_types():
|
||||
|
@ -17,7 +17,7 @@ from oslo_log import log as logging
|
||||
from vitrage.common.constants import DatasourceProperties as DSProps
|
||||
from vitrage.common.constants import EdgeLabel
|
||||
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.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE
|
||||
from vitrage.datasources.cinder.volume.properties import \
|
||||
@ -37,11 +37,11 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
class CinderVolumeTransformer(ResourceTransformerBase):
|
||||
|
||||
# Event types which need to refer them differently
|
||||
UPDATE_EVENT_TYPES = {
|
||||
'volume.delete.end': EventAction.DELETE_ENTITY,
|
||||
'volume.detach.start': EventAction.DELETE_RELATIONSHIP,
|
||||
'volume.attach.end': EventAction.UPDATE_RELATIONSHIP
|
||||
# graph actions which need to refer them differently
|
||||
GRAPH_ACTION_MAPPING = {
|
||||
'volume.delete.end': GraphAction.DELETE_ENTITY,
|
||||
'volume.detach.start': GraphAction.DELETE_RELATIONSHIP,
|
||||
'volume.attach.end': GraphAction.UPDATE_RELATIONSHIP
|
||||
}
|
||||
|
||||
def __init__(self, transformers, conf):
|
||||
|
@ -13,7 +13,7 @@
|
||||
# under the License.
|
||||
|
||||
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.datasources.consistency import CONSISTENCY_DATASOURCE
|
||||
from vitrage.datasources.resource_transformer_base import \
|
||||
@ -23,10 +23,10 @@ import vitrage.graph.utils as graph_utils
|
||||
|
||||
class ConsistencyTransformer(ResourceTransformerBase):
|
||||
|
||||
# Event types which need to refer them differently
|
||||
UPDATE_EVENT_TYPES = {
|
||||
EventAction.DELETE_ENTITY: EventAction.DELETE_ENTITY,
|
||||
EventAction.REMOVE_DELETED_ENTITY: EventAction.REMOVE_DELETED_ENTITY
|
||||
# graph actions which need to refer them differently
|
||||
GRAPH_ACTION_MAPPING = {
|
||||
GraphAction.DELETE_ENTITY: GraphAction.DELETE_ENTITY,
|
||||
GraphAction.REMOVE_DELETED_ENTITY: GraphAction.REMOVE_DELETED_ENTITY
|
||||
}
|
||||
|
||||
def __init__(self, transformers, conf):
|
||||
|
@ -17,9 +17,9 @@ import six
|
||||
|
||||
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 EventAction
|
||||
from vitrage.common.constants import GraphAction
|
||||
from vitrage.common import datetime_utils
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
@ -32,7 +32,7 @@ class DriverBase(object):
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_all(self, action_type):
|
||||
def get_all(self, datasource_action):
|
||||
pass
|
||||
|
||||
def callback_on_fault(self, exception):
|
||||
@ -42,16 +42,16 @@ class DriverBase(object):
|
||||
def _get_end_message(entity_type):
|
||||
end_message = {
|
||||
DSProps.ENTITY_TYPE: entity_type,
|
||||
DSProps.ACTION_TYPE: ActionType.INIT_SNAPSHOT,
|
||||
DSProps.EVENT_TYPE: EventAction.END_MESSAGE
|
||||
DSProps.DATASOURCE_ACTION: DatasourceAction.INIT_SNAPSHOT,
|
||||
DSProps.EVENT_TYPE: GraphAction.END_MESSAGE
|
||||
}
|
||||
return end_message
|
||||
|
||||
def get_changes(self, action_type):
|
||||
def get_changes(self, datasource_action):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def make_pickleable(cls, entities, entity_type, action_type, *args):
|
||||
def make_pickleable(cls, entities, entity_type, datasource_action, *args):
|
||||
pickleable_entities = []
|
||||
|
||||
for entity in entities:
|
||||
@ -59,11 +59,11 @@ class DriverBase(object):
|
||||
entity.pop(field, None)
|
||||
|
||||
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)
|
||||
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))
|
||||
|
||||
return pickleable_entities
|
||||
@ -78,8 +78,8 @@ class DriverBase(object):
|
||||
entity[DSProps.SAMPLE_DATE] = str(datetime_utils.utcnow())
|
||||
|
||||
@staticmethod
|
||||
def _add_action_type(entity, action_type):
|
||||
entity[DSProps.ACTION_TYPE] = action_type
|
||||
def _add_datasource_action(entity, datasource_action):
|
||||
entity[DSProps.DATASOURCE_ACTION] = datasource_action
|
||||
|
||||
@staticmethod
|
||||
@abc.abstractmethod
|
||||
|
@ -12,7 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# 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.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE
|
||||
from vitrage.datasources.driver_base import DriverBase
|
||||
@ -75,7 +75,7 @@ class HeatStackDriver(DriverBase):
|
||||
|
||||
return HeatStackDriver.make_pickleable([event],
|
||||
HEAT_STACK_DATASOURCE,
|
||||
ActionType.UPDATE)[0]
|
||||
DatasourceAction.UPDATE)[0]
|
||||
|
||||
def _filter_resource_types(self):
|
||||
types = self.conf.datasources.types
|
||||
@ -102,11 +102,11 @@ class HeatStackDriver(DriverBase):
|
||||
HeatStackDriver.RESOURCE_TYPE_CONVERSION]
|
||||
return stack
|
||||
|
||||
def get_all(self, action_type):
|
||||
def get_all(self, datasource_action):
|
||||
stacks = HeatStackDriver.client().stacks.list(global_tenant=True)
|
||||
stacks_list = self._make_stacks_list(stacks)
|
||||
stacks_with_resources = self._append_stacks_resources(stacks_list)
|
||||
return self.make_pickleable(stacks_with_resources,
|
||||
HEAT_STACK_DATASOURCE,
|
||||
action_type,
|
||||
datasource_action,
|
||||
'manager')
|
||||
|
@ -15,7 +15,7 @@
|
||||
from vitrage.common.constants import DatasourceProperties as DSProps
|
||||
from vitrage.common.constants import EdgeLabel
|
||||
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.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE
|
||||
from vitrage.datasources.heat.stack import HEAT_STACK_DATASOURCE
|
||||
@ -40,9 +40,9 @@ class HeatStackTransformer(ResourceTransformerBase):
|
||||
'OS::Neutron::Port': NEUTRON_PORT_DATASOURCE
|
||||
}
|
||||
|
||||
# Event types which need to refer them differently
|
||||
UPDATE_EVENT_TYPES = {
|
||||
'orchestration.stack.delete.end': EventAction.DELETE_ENTITY,
|
||||
# graph actions which need to refer them differently
|
||||
GRAPH_ACTION_MAPPING = {
|
||||
'orchestration.stack.delete.end': GraphAction.DELETE_ENTITY,
|
||||
}
|
||||
|
||||
def __init__(self, transformers, conf):
|
||||
|
@ -12,7 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# 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.datasources.neutron.base import NeutronBase
|
||||
from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE
|
||||
@ -33,10 +33,10 @@ class NetworkDriver(NeutronBase):
|
||||
|
||||
return NetworkDriver.make_pickleable([event],
|
||||
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(
|
||||
self.client.list_networks()['networks'],
|
||||
NEUTRON_NETWORK_DATASOURCE,
|
||||
action_type)
|
||||
datasource_action)
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
from vitrage.common.constants import DatasourceProperties as DSProps
|
||||
from vitrage.common.constants import EntityCategory
|
||||
from vitrage.common.constants import EventAction
|
||||
from vitrage.common.constants import GraphAction
|
||||
from vitrage.common.constants import VertexProperties as VProps
|
||||
from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE
|
||||
from vitrage.datasources.resource_transformer_base import \
|
||||
@ -33,9 +33,9 @@ class NetworkTransformer(ResourceTransformerBase):
|
||||
None: ('id',)
|
||||
}
|
||||
|
||||
# Event types which need to refer them differently
|
||||
UPDATE_EVENT_TYPES = {
|
||||
'network.delete.end': EventAction.DELETE_ENTITY,
|
||||
# graph actions which need to refer them differently
|
||||
GRAPH_ACTION_MAPPING = {
|
||||
'network.delete.end': GraphAction.DELETE_ENTITY,
|
||||
}
|
||||
|
||||
def __init__(self, transformers, conf):
|
||||
|
@ -12,7 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# 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.datasources.neutron.base import NeutronBase
|
||||
from vitrage.datasources.neutron.port import NEUTRON_PORT_DATASOURCE
|
||||
@ -32,10 +32,10 @@ class PortDriver(NeutronBase):
|
||||
event[DSProps.EVENT_TYPE] = event_type
|
||||
|
||||
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(
|
||||
self.client.list_ports()['ports'],
|
||||
NEUTRON_PORT_DATASOURCE,
|
||||
action_type)
|
||||
datasource_action)
|
||||
|
@ -18,7 +18,7 @@ from vitrage.datasources.resource_transformer_base import \
|
||||
from vitrage.common.constants import DatasourceProperties as DSProps
|
||||
from vitrage.common.constants import EdgeLabel
|
||||
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.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE
|
||||
from vitrage.datasources.neutron.port import NEUTRON_PORT_DATASOURCE
|
||||
@ -45,9 +45,9 @@ class PortTransformer(ResourceTransformerBase):
|
||||
None: ('fixed_ips',)
|
||||
}
|
||||
|
||||
# Event types which need to refer them differently
|
||||
UPDATE_EVENT_TYPES = {
|
||||
'port.delete.end': EventAction.DELETE_ENTITY,
|
||||
# graph actions which need to refer them differently
|
||||
GRAPH_ACTION_MAPPING = {
|
||||
'port.delete.end': GraphAction.DELETE_ENTITY,
|
||||
}
|
||||
|
||||
def __init__(self, transformers, conf):
|
||||
|
@ -27,9 +27,9 @@ class HostDriver(NovaDriverBase):
|
||||
compute_hosts.append(host_dict)
|
||||
return compute_hosts
|
||||
|
||||
def get_all(self, action_type):
|
||||
def get_all(self, datasource_action):
|
||||
return self.make_pickleable(
|
||||
self.filter_none_compute_hosts(self.client.hosts.list()),
|
||||
NOVA_HOST_DATASOURCE,
|
||||
action_type,
|
||||
datasource_action,
|
||||
'manager')
|
||||
|
@ -12,7 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# 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.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE
|
||||
from vitrage.datasources.nova.nova_driver_base import NovaDriverBase
|
||||
@ -24,12 +24,12 @@ class InstanceDriver(NovaDriverBase):
|
||||
def extract_events(instances):
|
||||
return [instance.__dict__ for instance in instances]
|
||||
|
||||
def get_all(self, action_type):
|
||||
def get_all(self, datasource_action):
|
||||
return self.make_pickleable(
|
||||
self.extract_events(self.client.servers.list(
|
||||
search_opts={'all_tenants': 1})),
|
||||
NOVA_INSTANCE_DATASOURCE,
|
||||
action_type,
|
||||
datasource_action,
|
||||
'manager',
|
||||
'OS-EXT-SRV-ATTR:user_data',
|
||||
'_info')
|
||||
@ -40,7 +40,7 @@ class InstanceDriver(NovaDriverBase):
|
||||
|
||||
return InstanceDriver.make_pickleable([event],
|
||||
NOVA_INSTANCE_DATASOURCE,
|
||||
ActionType.UPDATE)[0]
|
||||
DatasourceAction.UPDATE)[0]
|
||||
|
||||
@staticmethod
|
||||
def get_event_types():
|
||||
|
@ -17,7 +17,7 @@ from oslo_log import log as logging
|
||||
from vitrage.common.constants import DatasourceProperties as DSProps
|
||||
from vitrage.common.constants import EdgeLabel
|
||||
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.datasources.nova.host import NOVA_HOST_DATASOURCE
|
||||
from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE
|
||||
@ -34,9 +34,9 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
class InstanceTransformer(ResourceTransformerBase):
|
||||
|
||||
# Event types which need to refer them differently
|
||||
UPDATE_EVENT_TYPES = {
|
||||
'compute.instance.delete.end': EventAction.DELETE_ENTITY,
|
||||
# graph actions which need to refer them differently
|
||||
GRAPH_ACTION_MAPPING = {
|
||||
'compute.instance.delete.end': GraphAction.DELETE_ENTITY,
|
||||
}
|
||||
|
||||
def __init__(self, transformers, conf):
|
||||
@ -67,8 +67,8 @@ class InstanceTransformer(ResourceTransformerBase):
|
||||
|
||||
sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
|
||||
|
||||
# TODO(Alexey): need to check that only the UPDATE action_type will
|
||||
# update the UPDATE_TIMESTAMP property
|
||||
# TODO(Alexey): need to check that only the UPDATE datasource_action
|
||||
# will update the UPDATE_TIMESTAMP property
|
||||
update_timestamp = self._format_update_timestamp(
|
||||
extract_field_value(entity_event, DSProps.SAMPLE_DATE),
|
||||
sample_timestamp)
|
||||
|
@ -27,9 +27,9 @@ class ZoneDriver(NovaDriverBase):
|
||||
zones_res.append(zone_dict)
|
||||
return zones_res
|
||||
|
||||
def get_all(self, action_type):
|
||||
def get_all(self, datasource_action):
|
||||
return self.make_pickleable(self.filter_internal_zone(
|
||||
self.client.availability_zones.list()),
|
||||
NOVA_ZONE_DATASOURCE,
|
||||
action_type,
|
||||
datasource_action,
|
||||
'manager')
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
from oslo_log import log
|
||||
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
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
@ -49,7 +49,7 @@ class SnapshotsService(DatasourceService):
|
||||
|
||||
snap_scheduler.schedule(
|
||||
func=self.entities_to_queue(ds_driver,
|
||||
ActionType.INIT_SNAPSHOT),
|
||||
DatasourceAction.INIT_SNAPSHOT),
|
||||
standard_interval=standard_interval,
|
||||
fault_interval=fault_interval,
|
||||
times=1,
|
||||
@ -57,7 +57,8 @@ class SnapshotsService(DatasourceService):
|
||||
fault_callback=ds_driver.callback_on_fault)
|
||||
|
||||
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,
|
||||
standard_interval=standard_interval,
|
||||
fault_interval=fault_interval,
|
||||
@ -67,9 +68,9 @@ class SnapshotsService(DatasourceService):
|
||||
|
||||
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():
|
||||
for entity in driver.get_all(action_type):
|
||||
for entity in driver.get_all(datasource_action):
|
||||
self.send_to_queue(entity)
|
||||
return _entities_to_queue
|
||||
|
||||
@ -116,7 +117,7 @@ class ChangesService(DatasourceService):
|
||||
LOG.debug("start get changes")
|
||||
for datasource in self.registered_datasources:
|
||||
try:
|
||||
for entity in datasource.get_changes(ActionType.UPDATE):
|
||||
for entity in datasource.get_changes(DatasourceAction.UPDATE):
|
||||
self.send_to_queue(entity)
|
||||
except Exception as e:
|
||||
LOG.error("Get changes Failed - %s", e.message)
|
||||
|
@ -31,16 +31,16 @@ class StaticDriver(DriverBase):
|
||||
def enrich_event(event, event_type):
|
||||
pass
|
||||
|
||||
def get_all(self, action_type):
|
||||
def get_all(self, datasource_action):
|
||||
"""Query all entities and send events to the vitrage events queue"""
|
||||
return self.make_pickleable(self._get_all_entities(),
|
||||
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(),
|
||||
STATIC_DATASOURCE,
|
||||
action_type)
|
||||
datasource_action)
|
||||
|
||||
def _get_all_entities(self):
|
||||
"""Internal method to get all entities"""
|
||||
|
@ -15,7 +15,7 @@
|
||||
import copy
|
||||
|
||||
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 import file_utils
|
||||
from vitrage.datasources.driver_base import DriverBase
|
||||
@ -38,15 +38,15 @@ class StaticPhysicalDriver(DriverBase):
|
||||
self.cfg = conf
|
||||
self.cache = {}
|
||||
|
||||
def get_all(self, action_type):
|
||||
def get_all(self, datasource_action):
|
||||
return self.make_pickleable(self._get_all_entities(),
|
||||
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(),
|
||||
STATIC_PHYSICAL_DATASOURCE,
|
||||
action_type)
|
||||
datasource_action)
|
||||
|
||||
def _get_all_entities(self):
|
||||
static_entities = []
|
||||
@ -125,10 +125,10 @@ class StaticPhysicalDriver(DriverBase):
|
||||
if not new_entities or old_entity not in new_entities:
|
||||
new_entity = self._find_entity(old_entity, new_entities)
|
||||
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())
|
||||
else:
|
||||
self._set_event_type(new_entity, EventAction.UPDATE_ENTITY)
|
||||
self._set_event_type(new_entity, GraphAction.UPDATE_ENTITY)
|
||||
updates.append(new_entity.copy())
|
||||
|
||||
@staticmethod
|
||||
|
@ -16,7 +16,7 @@ from oslo_log import log as logging
|
||||
|
||||
from vitrage.common.constants import DatasourceProperties as DSProps
|
||||
from vitrage.common.constants import EntityCategory
|
||||
from vitrage.common.constants import EventAction
|
||||
from vitrage.common.constants import GraphAction
|
||||
from vitrage.common.constants import VertexProperties as VProps
|
||||
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
|
||||
from vitrage.datasources.resource_transformer_base import \
|
||||
@ -35,9 +35,9 @@ class StaticPhysicalTransformer(ResourceTransformerBase):
|
||||
RELATION_TYPE = 'relation_type'
|
||||
RELATIONSHIPS_SECTION = 'relationships'
|
||||
|
||||
# Event types which need to refer them differently
|
||||
UPDATE_EVENT_TYPES = {
|
||||
EventAction.DELETE_ENTITY: EventAction.DELETE_ENTITY
|
||||
# graph actions which need to refer them differently
|
||||
GRAPH_ACTION_MAPPING = {
|
||||
GraphAction.DELETE_ENTITY: GraphAction.DELETE_ENTITY
|
||||
}
|
||||
|
||||
def __init__(self, transformers, conf):
|
||||
|
@ -21,9 +21,9 @@ import six
|
||||
from vitrage.common import datetime_utils
|
||||
|
||||
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 EventAction
|
||||
from vitrage.common.constants import GraphAction
|
||||
from vitrage.common.constants import UpdateMethod
|
||||
from vitrage.common.exception import VitrageTransformerError
|
||||
from vitrage.common import utils
|
||||
@ -87,7 +87,7 @@ def convert_timestamp_format(current_timestamp_format, timestamp):
|
||||
|
||||
|
||||
def is_update_event(event):
|
||||
return event[DSProps.ACTION_TYPE] == ActionType.UPDATE
|
||||
return event[DSProps.DATASOURCE_ACTION] == DatasourceAction.UPDATE
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
@ -96,7 +96,8 @@ class TransformerBase(object):
|
||||
KEY_SEPARATOR = ':'
|
||||
QUERY_RESULT = 'graph_query_result'
|
||||
|
||||
UPDATE_EVENT_TYPES = {}
|
||||
# graph actions which need to refer them differently
|
||||
GRAPH_ACTION_MAPPING = {}
|
||||
|
||||
def __init__(self, transformers, conf):
|
||||
self.conf = conf
|
||||
@ -119,13 +120,13 @@ class TransformerBase(object):
|
||||
if not self._is_end_message(entity_event):
|
||||
entity_vertex = self._create_entity_vertex(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)
|
||||
else:
|
||||
return EntityWrapper(self._create_end_vertex(entity_event),
|
||||
None,
|
||||
EventAction.END_MESSAGE)
|
||||
GraphAction.END_MESSAGE)
|
||||
|
||||
def _create_entity_vertex(self, entity_event):
|
||||
if is_update_event(entity_event) and \
|
||||
@ -201,10 +202,10 @@ class TransformerBase(object):
|
||||
"""
|
||||
pass
|
||||
|
||||
def _extract_event_action(self, entity_event):
|
||||
"""Extract event action.
|
||||
def _extract_graph_action(self, entity_event):
|
||||
"""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.
|
||||
|
||||
:param entity_event: event that returns from the driver
|
||||
@ -213,24 +214,24 @@ class TransformerBase(object):
|
||||
"""
|
||||
|
||||
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]
|
||||
|
||||
action_type = entity_event[DSProps.ACTION_TYPE]
|
||||
datasource_action = entity_event[DSProps.DATASOURCE_ACTION]
|
||||
|
||||
if ActionType.UPDATE == action_type:
|
||||
return self.UPDATE_EVENT_TYPES.get(
|
||||
if DatasourceAction.UPDATE == datasource_action:
|
||||
return self.GRAPH_ACTION_MAPPING.get(
|
||||
entity_event.get(DSProps.EVENT_TYPE, None),
|
||||
EventAction.UPDATE_ENTITY)
|
||||
GraphAction.UPDATE_ENTITY)
|
||||
|
||||
if ActionType.SNAPSHOT == action_type:
|
||||
return EventAction.UPDATE_ENTITY
|
||||
if DatasourceAction.SNAPSHOT == datasource_action:
|
||||
return GraphAction.UPDATE_ENTITY
|
||||
|
||||
if ActionType.INIT_SNAPSHOT == action_type:
|
||||
return EventAction.CREATE_ENTITY
|
||||
if DatasourceAction.INIT_SNAPSHOT == datasource_action:
|
||||
return GraphAction.CREATE_ENTITY
|
||||
|
||||
raise VitrageTransformerError(
|
||||
'Invalid action type: (%s)' % action_type)
|
||||
'Invalid action type: (%s)' % datasource_action)
|
||||
|
||||
def _key_values(self, *args):
|
||||
"""A list of key fields
|
||||
@ -252,10 +253,10 @@ class TransformerBase(object):
|
||||
@staticmethod
|
||||
def _is_end_message(entity_event):
|
||||
|
||||
action_type = entity_event[DSProps.ACTION_TYPE]
|
||||
is_snapshot_event = action_type == ActionType.INIT_SNAPSHOT
|
||||
ds_action = entity_event[DSProps.DATASOURCE_ACTION]
|
||||
is_snapshot_event = ds_action == DatasourceAction.INIT_SNAPSHOT
|
||||
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
|
||||
def _format_update_timestamp(update_timestamp, sample_timestamp):
|
||||
|
@ -17,7 +17,7 @@ from collections import namedtuple
|
||||
from oslo_log import log
|
||||
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 import file_utils
|
||||
from vitrage.datasources.alarm_driver_base import AlarmDriverBase
|
||||
@ -183,7 +183,7 @@ class ZabbixDriver(AlarmDriverBase):
|
||||
event[ZProps.RESOURCE_TYPE] = v_resource[ZProps.RESOURCE_TYPE]
|
||||
|
||||
return ZabbixDriver.make_pickleable([event], ZABBIX_DATASOURCE,
|
||||
ActionType.UPDATE)[0]
|
||||
DatasourceAction.UPDATE)[0]
|
||||
|
||||
@staticmethod
|
||||
def get_event_types():
|
||||
|
@ -17,10 +17,10 @@ import time
|
||||
|
||||
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 EntityCategory
|
||||
from vitrage.common.constants import EventAction
|
||||
from vitrage.common.constants import GraphAction
|
||||
from vitrage.common.constants import VertexProperties as VProps
|
||||
from vitrage.common.datetime_utils import utcnow
|
||||
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'
|
||||
': %s', len(old_deleted_entities), 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
|
||||
stale_entities = self._find_stale_entities()
|
||||
@ -90,7 +90,7 @@ class ConsistencyEnforcer(object):
|
||||
'consistency service: %s', len(stale_entities),
|
||||
stale_entities)
|
||||
self._push_events_to_queue(stale_entities,
|
||||
EventAction.DELETE_ENTITY)
|
||||
GraphAction.DELETE_ENTITY)
|
||||
except Exception as e:
|
||||
LOG.exception(
|
||||
'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):
|
||||
old_deduced_alarms = self._find_old_deduced_alarms(timestamp)
|
||||
self._push_events_to_queue(old_deduced_alarms,
|
||||
EventAction.DELETE_ENTITY)
|
||||
GraphAction.DELETE_ENTITY)
|
||||
|
||||
def _push_events_to_queue(self, vertices, action):
|
||||
for vertex in vertices:
|
||||
event = {
|
||||
DSProps.ENTITY_TYPE: CONSISTENCY_DATASOURCE,
|
||||
DSProps.ACTION_TYPE: ActionType.UPDATE,
|
||||
DSProps.DATASOURCE_ACTION: DatasourceAction.UPDATE,
|
||||
DSProps.SAMPLE_DATE: str(utcnow()),
|
||||
DSProps.EVENT_TYPE: action,
|
||||
VProps.VITRAGE_ID: vertex[VProps.VITRAGE_ID]
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
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.datasources.transformer_base import TransformerBase
|
||||
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)
|
||||
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):
|
||||
"""Updates the vertex in the entity graph
|
||||
@ -206,7 +206,7 @@ class Processor(processor.ProcessorBase):
|
||||
self._delete_old_connections(vertex, obsolete_edges)
|
||||
self._connect_neighbors(neighbors,
|
||||
valid_edges,
|
||||
EventAction.UPDATE_ENTITY)
|
||||
GraphAction.UPDATE_ENTITY)
|
||||
|
||||
def _connect_neighbors(self, neighbors, valid_edges, action):
|
||||
"""Updates the neighbor vertex and adds the connection edges """
|
||||
@ -289,28 +289,28 @@ class Processor(processor.ProcessorBase):
|
||||
|
||||
def _initialize_events_actions(self):
|
||||
self.actions = {
|
||||
EventAction.CREATE_ENTITY: self.create_entity,
|
||||
EventAction.UPDATE_ENTITY: self.update_entity,
|
||||
EventAction.DELETE_ENTITY: self.delete_entity,
|
||||
EventAction.UPDATE_RELATIONSHIP: self.update_relationship,
|
||||
EventAction.DELETE_RELATIONSHIP: self.delete_relationship,
|
||||
EventAction.REMOVE_DELETED_ENTITY: self.remove_deleted_entity,
|
||||
GraphAction.CREATE_ENTITY: self.create_entity,
|
||||
GraphAction.UPDATE_ENTITY: self.update_entity,
|
||||
GraphAction.DELETE_ENTITY: self.delete_entity,
|
||||
GraphAction.UPDATE_RELATIONSHIP: self.update_relationship,
|
||||
GraphAction.DELETE_RELATIONSHIP: self.delete_relationship,
|
||||
GraphAction.REMOVE_DELETED_ENTITY: self.remove_deleted_entity,
|
||||
# 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):
|
||||
LOG.debug("calculate event state")
|
||||
|
||||
try:
|
||||
if action in [EventAction.UPDATE_ENTITY,
|
||||
EventAction.DELETE_ENTITY,
|
||||
EventAction.CREATE_ENTITY]:
|
||||
if action in [GraphAction.UPDATE_ENTITY,
|
||||
GraphAction.DELETE_ENTITY,
|
||||
GraphAction.CREATE_ENTITY]:
|
||||
graph_vertex = self.entity_graph.get_vertex(vertex.vertex_id)
|
||||
elif action in [EventAction.END_MESSAGE,
|
||||
EventAction.REMOVE_DELETED_ENTITY,
|
||||
EventAction.UPDATE_RELATIONSHIP,
|
||||
EventAction.DELETE_RELATIONSHIP]:
|
||||
elif action in [GraphAction.END_MESSAGE,
|
||||
GraphAction.REMOVE_DELETED_ENTITY,
|
||||
GraphAction.UPDATE_RELATIONSHIP,
|
||||
GraphAction.DELETE_RELATIONSHIP]:
|
||||
return None
|
||||
else:
|
||||
LOG.error('unrecognized action: %s for vertex: %s',
|
||||
|
@ -16,7 +16,7 @@ import copy
|
||||
|
||||
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 VertexProperties as VProps
|
||||
from vitrage.common import datetime_utils
|
||||
@ -103,7 +103,7 @@ class ActionExecutor(object):
|
||||
@staticmethod
|
||||
def _add_default_properties(event):
|
||||
|
||||
event[DSProps.ACTION_TYPE] = AType.UPDATE
|
||||
event[DSProps.DATASOURCE_ACTION] = AType.UPDATE
|
||||
event[DSProps.ENTITY_TYPE] = VITRAGE_TYPE
|
||||
event[VProps.UPDATE_TIMESTAMP] = str(datetime_utils.utcnow(False))
|
||||
event[VProps.SAMPLE_TIMESTAMP] = str(datetime_utils.utcnow())
|
||||
|
@ -17,7 +17,7 @@ from oslo_log import log as logging
|
||||
from vitrage.common.constants import EdgeLabel
|
||||
from vitrage.common.constants import EdgeProperties as EProps
|
||||
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.exception import VitrageTransformerError
|
||||
from vitrage.datasources import transformer_base
|
||||
@ -131,7 +131,7 @@ class EvaluatorEventTransformer(transformer_base.TransformerBase):
|
||||
|
||||
return []
|
||||
|
||||
def _extract_event_action(self, event):
|
||||
def _extract_graph_action(self, event):
|
||||
event_type = event[EVALUATOR_EVENT_TYPE]
|
||||
|
||||
try:
|
||||
@ -143,11 +143,11 @@ class EvaluatorEventTransformer(transformer_base.TransformerBase):
|
||||
@staticmethod
|
||||
def _init_actions():
|
||||
return {
|
||||
UPDATE_VERTEX: EventAction.UPDATE_ENTITY,
|
||||
ADD_VERTEX: EventAction.CREATE_ENTITY,
|
||||
REMOVE_VERTEX: EventAction.DELETE_ENTITY,
|
||||
ADD_EDGE: EventAction.UPDATE_RELATIONSHIP,
|
||||
REMOVE_EDGE: EventAction.DELETE_RELATIONSHIP
|
||||
UPDATE_VERTEX: GraphAction.UPDATE_ENTITY,
|
||||
ADD_VERTEX: GraphAction.CREATE_ENTITY,
|
||||
REMOVE_VERTEX: GraphAction.DELETE_ENTITY,
|
||||
ADD_EDGE: GraphAction.UPDATE_RELATIONSHIP,
|
||||
REMOVE_EDGE: GraphAction.DELETE_RELATIONSHIP
|
||||
}
|
||||
|
||||
def _create_entity_key(self, event):
|
||||
|
@ -12,7 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# 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.entity_graph.initialization_status import InitializationStatus
|
||||
from vitrage.entity_graph.processor import processor as proc
|
||||
@ -38,15 +38,18 @@ class TestFunctionalBase(TestEntityGraphUnitBase):
|
||||
self.NUM_ZONES,
|
||||
self.NUM_HOSTS,
|
||||
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(
|
||||
self.NUM_ZONES,
|
||||
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(
|
||||
self.NUM_HOSTS,
|
||||
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)
|
||||
|
@ -14,8 +14,8 @@
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from vitrage.common.constants import ActionType
|
||||
from vitrage.common.constants import EventAction
|
||||
from vitrage.common.constants import DatasourceAction as DSAction
|
||||
from vitrage.common.constants import GraphAction
|
||||
from vitrage.common.constants import VertexProperties as VProps
|
||||
from vitrage.datasources.nova.instance.transformer import InstanceTransformer
|
||||
from vitrage.entity_graph.initialization_status import InitializationStatus
|
||||
@ -40,7 +40,7 @@ class TestDatasourceInfoMapperFunctional(TestFunctionalBase):
|
||||
# setup
|
||||
processor = proc.Processor(self.conf, InitializationStatus())
|
||||
event = self._create_event(spec_type='INSTANCE_SPEC',
|
||||
action_type=ActionType.INIT_SNAPSHOT)
|
||||
datasource_action=DSAction.INIT_SNAPSHOT)
|
||||
|
||||
# action
|
||||
processor.process_event(event)
|
||||
@ -57,14 +57,14 @@ class TestDatasourceInfoMapperFunctional(TestFunctionalBase):
|
||||
# setup
|
||||
vertex, neighbors, processor = self._create_entity(
|
||||
spec_type='INSTANCE_SPEC',
|
||||
action_type=ActionType.INIT_SNAPSHOT)
|
||||
datasource_action=DSAction.INIT_SNAPSHOT)
|
||||
self.assertEqual(2, processor.entity_graph.num_vertices())
|
||||
|
||||
neighbors[0].vertex[VProps.STATE] = 'available'
|
||||
neighbors[0].vertex[VProps.IS_PLACEHOLDER] = False
|
||||
|
||||
# action
|
||||
processor._connect_neighbors(neighbors, [], EventAction.UPDATE_ENTITY)
|
||||
processor._connect_neighbors(neighbors, [], GraphAction.UPDATE_ENTITY)
|
||||
|
||||
# test assertions
|
||||
neighbor_vertex = processor.entity_graph.get_vertex(
|
||||
|
@ -259,7 +259,7 @@ class TestActionExecutor(TestFunctionalBase):
|
||||
'service': 'Check_MK',
|
||||
'status': 'CRITICAL',
|
||||
'status_info': 'test test test',
|
||||
'vitrage_action_type': 'snapshot',
|
||||
'vitrage_datasource_action': 'snapshot',
|
||||
'vitrage_entity_type': 'nagios',
|
||||
'vitrage_sample_date': '2016-02-07 15:26:04'}
|
||||
|
||||
@ -268,7 +268,7 @@ class TestActionExecutor(TestFunctionalBase):
|
||||
|
||||
return {'target': target_vertex.vertex_id,
|
||||
'update_timestamp': '2016-03-17 11:33:32.443002',
|
||||
'vitrage_action_type': 'update',
|
||||
'vitrage_datasource_action': 'update',
|
||||
'alarm_name': alarm_name,
|
||||
'state': 'Active',
|
||||
'type': 'add_vertex',
|
||||
|
@ -16,9 +16,10 @@ from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
from six.moves import queue
|
||||
from vitrage.common.constants import DatasourceAction
|
||||
from vitrage.common.constants import DatasourceProperties as DSProps
|
||||
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.datasources.nova.host import NOVA_HOST_DATASOURCE
|
||||
from vitrage.evaluator.scenario_evaluator import ScenarioEvaluator
|
||||
@ -31,7 +32,8 @@ from vitrage.tests.mocks import utils
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
_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):
|
||||
@ -237,7 +239,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
||||
|
||||
# remove WARNING nagios alarm, leaving only CRITICAL one
|
||||
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,
|
||||
processor, _TARGET_HOST)
|
||||
alarms = \
|
||||
@ -249,7 +251,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
|
||||
|
||||
# next disable the alarm
|
||||
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,
|
||||
processor, _TARGET_HOST)
|
||||
alarms = \
|
||||
|
@ -350,7 +350,7 @@ def simple_switch_generators(switch_num, host_num,
|
||||
)
|
||||
if update_events:
|
||||
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(
|
||||
{tg.DYNAMIC_INFO_FKEY: tg.DRIVER_SWITCH_SNAPSHOT_D,
|
||||
tg.STATIC_INFO_FKEY: None,
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"vitrage_sample_date": "2015-12-01T12:46:41Z",
|
||||
"vitrage_entity_type": "consistency",
|
||||
"vitrage_action_type": "update",
|
||||
"vitrage_datasource_action": "update",
|
||||
"vitrage_event_type": "delete_entity",
|
||||
"vitrage_id": "[0-9]{5}"
|
||||
}
|
||||
|
@ -9,6 +9,6 @@
|
||||
"service": "compute",
|
||||
"vitrage_entity_type": "nova.host",
|
||||
"zone": "zone0",
|
||||
"vitrage_action_type": "init_snapshot",
|
||||
"vitrage_datasource_action": "init_snapshot",
|
||||
"vitrage_sample_date": "2015-12-01T12:46:41Z"
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"OS-EXT-STS:task_state": null,
|
||||
"vitrage_action_type": "snapshot",
|
||||
"vitrage_datasource_action": "snapshot",
|
||||
"vitrage_entity_type": "nova.instance",
|
||||
"vitrage_sample_date": "2015-12-01T12:46:41Z",
|
||||
"addresses": {
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"vitrage_action_type": "update",
|
||||
"vitrage_datasource_action": "update",
|
||||
"vitrage_sample_date": "2015-12-01T12:46:41Z",
|
||||
"publisher_id": "compute.emalin-devstack",
|
||||
"vitrage_event_type": "compute.instance.pause.end|compute.instance.delete.end|compute.instance.create.start",
|
||||
|
@ -9,5 +9,5 @@
|
||||
"vitrage_sample_date": "2015-12-01T12:46:41Z",
|
||||
"attempt": "1/1",
|
||||
"status_info": "OK - user: 0\\.6%, system: 0\\.3%, wait: 0\\.4%",
|
||||
"vitrage_action_type": "snapshot"
|
||||
"vitrage_datasource_action": "snapshot"
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
"creation_time": "2016-08-25T13:03:36",
|
||||
"stack_owner": "admin",
|
||||
"project": "a077142e250543be90f6fce8f623d45d",
|
||||
"vitrage_action_type": "init_snapshot",
|
||||
"vitrage_datasource_action": "init_snapshot",
|
||||
"id": "f22416fb-b33c-4e24-822e-0174421f5ece",
|
||||
"stack_status": "CREATE_COMPLETE",
|
||||
"vitrage_sample_date": "2016-08-2515:12:28.281460+00:00",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"stack_name": "newstack",
|
||||
"tenant_id": "a077142e250543be90f6fce8f623d45d",
|
||||
"stack_identity": "d2df0a2a-765c-44ef-b117-32d599bc9c3b",
|
||||
"vitrage_action_type": "update",
|
||||
"vitrage_datasource_action": "update",
|
||||
"create_at": "2016-08-25T15:23:02",
|
||||
"state": "CREATE_COMPLETE",
|
||||
"vitrage_event_type": "orchestration.stack.create.end",
|
||||
|
@ -10,7 +10,7 @@
|
||||
"id": "[1-9]{5}",
|
||||
"vitrage_sample_date": "2015-12-01T12:46:41Z",
|
||||
"type": "switch",
|
||||
"vitrage_action_type": "snapshot",
|
||||
"vitrage_datasource_action": "snapshot",
|
||||
"state": "available",
|
||||
"vitrage_event_type": "entity_update"
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
"status": "In-use",
|
||||
"id": "12345",
|
||||
"vitrage_entity_type": "cinder.volume",
|
||||
"vitrage_action_type": "snapshot",
|
||||
"vitrage_datasource_action": "snapshot",
|
||||
"vitrage_sample_date": "2015-12-01T12:46:41Z",
|
||||
"volume_type": "lvmdriver-1",
|
||||
"size": "1559"
|
||||
|
@ -5,7 +5,7 @@
|
||||
"status": "In-use",
|
||||
"volume_id": "12345",
|
||||
"vitrage_entity_type": "cinder.volume",
|
||||
"vitrage_action_type": "update",
|
||||
"vitrage_datasource_action": "update",
|
||||
"vitrage_event_type": "volume.create.start",
|
||||
"vitrage_sample_date": "2015-12-01T12:46:41Z",
|
||||
"volume_type": "SCSIID",
|
||||
|
@ -12,6 +12,6 @@
|
||||
"vitrage_sample_date": "2015-12-01T12:46:41Z",
|
||||
"value": "1",
|
||||
"priority": "1",
|
||||
"vitrage_action_type": "snapshot",
|
||||
"vitrage_datasource_action": "snapshot",
|
||||
"rawtext": "CPU utilization"
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
"hosts": {},
|
||||
"vitrage_sample_date": "2015-12-01T12:46:41Z",
|
||||
"vitrage_entity_type": "nova.zone",
|
||||
"vitrage_action_type": "snapshot",
|
||||
"vitrage_datasource_action": "snapshot",
|
||||
"zoneName": "zone0",
|
||||
"zoneState": {
|
||||
"available": "True"
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"vitrage_action_type": "init_snapshot",
|
||||
"vitrage_datasource_action": "init_snapshot",
|
||||
"id": "host[0-3]",
|
||||
"name": "host[0-3]",
|
||||
"zone_id": "zone[0-1]",
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"vitrage_action_type": "init_snapshot",
|
||||
"vitrage_datasource_action": "init_snapshot",
|
||||
"image": "cirros-[a-z]+",
|
||||
"status": "ACTIVE",
|
||||
"tenant_id": "[0-9a-f]{32}",
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"vitrage_action_type": "init_snapshot",
|
||||
"vitrage_datasource_action": "init_snapshot",
|
||||
"id": "zone[0-1]",
|
||||
"name": "zone[0-1]",
|
||||
"vitrage_event_type": "update",
|
||||
|
@ -15,7 +15,7 @@
|
||||
from oslo_config import cfg
|
||||
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 VertexProperties as VProps
|
||||
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.transformers[CONSISTENCY_DATASOURCE] = \
|
||||
ConsistencyTransformer(cls.transformers, cls.conf)
|
||||
cls.actions = [EventAction.DELETE_ENTITY,
|
||||
EventAction.REMOVE_DELETED_ENTITY]
|
||||
cls.actions = [GraphAction.DELETE_ENTITY,
|
||||
GraphAction.REMOVE_DELETED_ENTITY]
|
||||
|
||||
def test_snapshot_transform(self):
|
||||
LOG.debug('Consistency transformer test: transform entity event '
|
||||
|
@ -15,7 +15,7 @@
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
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 \
|
||||
NagiosProps
|
||||
from vitrage.tests.mocks import utils
|
||||
@ -498,7 +498,7 @@ class NagiosDriverTest(NagiosBaseTest):
|
||||
self.assertIsNotNone(services, 'No services returned')
|
||||
self.assertEqual(1, len(services))
|
||||
self._assert_contains(service_data1, services)
|
||||
self.assertEqual(EventAction.DELETE_ENTITY,
|
||||
self.assertEqual(GraphAction.DELETE_ENTITY,
|
||||
services[0][DSProps.EVENT_TYPE])
|
||||
|
||||
# Action - get changes, should not return the deleted alarm again
|
||||
@ -539,5 +539,5 @@ class NagiosDriverTest(NagiosBaseTest):
|
||||
self.assertIsNotNone(services, 'No services returned')
|
||||
self.assertEqual(1, len(services))
|
||||
self._assert_contains(service_data1, services)
|
||||
self.assertEqual(EventAction.DELETE_ENTITY,
|
||||
self.assertEqual(GraphAction.DELETE_ENTITY,
|
||||
services[0][DSProps.EVENT_TYPE])
|
||||
|
@ -15,11 +15,11 @@
|
||||
from oslo_config import cfg
|
||||
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 EdgeLabel
|
||||
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 VertexProperties as VProps
|
||||
from vitrage.datasources.alarm_properties import AlarmProperties as AlarmProps
|
||||
@ -104,15 +104,15 @@ class NagiosTransformerTest(base.BaseTest):
|
||||
|
||||
def _validate_action(self, alarm, wrapper):
|
||||
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)
|
||||
return
|
||||
|
||||
action_type = alarm[DSProps.ACTION_TYPE]
|
||||
if action_type in (ActionType.SNAPSHOT, ActionType.UPDATE):
|
||||
self.assertEqual(EventAction.UPDATE_ENTITY, wrapper.action)
|
||||
ds_action = alarm[DSProps.DATASOURCE_ACTION]
|
||||
if ds_action in (DatasourceAction.SNAPSHOT, DatasourceAction.UPDATE):
|
||||
self.assertEqual(GraphAction.UPDATE_ENTITY, wrapper.action)
|
||||
else:
|
||||
self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action)
|
||||
self.assertEqual(GraphAction.CREATE_ENTITY, wrapper.action)
|
||||
|
||||
def _validate_vertex(self, vertex, event):
|
||||
|
||||
@ -124,7 +124,7 @@ class NagiosTransformerTest(base.BaseTest):
|
||||
if event_type is not None:
|
||||
self.assertEqual(vertex[VProps.STATE],
|
||||
AlarmProps.INACTIVE_STATE if
|
||||
EventAction.DELETE_ENTITY == event_type else
|
||||
GraphAction.DELETE_ENTITY == event_type else
|
||||
AlarmProps.ACTIVE_STATE)
|
||||
else:
|
||||
actual_state = AlarmProps.INACTIVE_STATE if \
|
||||
|
@ -17,11 +17,11 @@ import datetime
|
||||
from oslo_config import cfg
|
||||
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 EdgeLabel
|
||||
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 VertexProperties
|
||||
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
|
||||
@ -133,10 +133,10 @@ class NovaHostTransformerTest(base.BaseTest):
|
||||
self.assertEqual(1, len(neighbors))
|
||||
self._validate_zone_neighbor(neighbors[0], event)
|
||||
|
||||
if ActionType.SNAPSHOT == event[DSProps.ACTION_TYPE]:
|
||||
self.assertEqual(EventAction.UPDATE_ENTITY, wrapper.action)
|
||||
if DatasourceAction.SNAPSHOT == event[DSProps.DATASOURCE_ACTION]:
|
||||
self.assertEqual(GraphAction.UPDATE_ENTITY, wrapper.action)
|
||||
else:
|
||||
self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action)
|
||||
self.assertEqual(GraphAction.CREATE_ENTITY, wrapper.action)
|
||||
|
||||
def _validate_zone_neighbor(self, zone, event):
|
||||
|
||||
@ -200,30 +200,31 @@ class NovaHostTransformerTest(base.BaseTest):
|
||||
zone_num=1,
|
||||
host_num=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)
|
||||
host_transformer = self.transformers[NOVA_HOST_DATASOURCE]
|
||||
|
||||
# Test action
|
||||
action = host_transformer._extract_event_action(hosts_events[0])
|
||||
action = host_transformer._extract_graph_action(hosts_events[0])
|
||||
|
||||
# Test assertion
|
||||
self.assertEqual(EventAction.UPDATE_ENTITY, action)
|
||||
self.assertEqual(GraphAction.UPDATE_ENTITY, action)
|
||||
|
||||
# Test setup
|
||||
spec_list = mock_sync.simple_host_generators(
|
||||
zone_num=1,
|
||||
host_num=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)
|
||||
host_transformer = self.transformers[NOVA_HOST_DATASOURCE]
|
||||
|
||||
# Test action
|
||||
action = host_transformer._extract_event_action(hosts_events[0])
|
||||
action = host_transformer._extract_graph_action(hosts_events[0])
|
||||
|
||||
# Test assertions
|
||||
self.assertEqual(EventAction.CREATE_ENTITY, action)
|
||||
self.assertEqual(GraphAction.CREATE_ENTITY, action)
|
||||
|
||||
# TODO(lhartal): To add extract action from update event
|
||||
|
@ -17,11 +17,11 @@ import datetime
|
||||
from oslo_config import cfg
|
||||
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 EdgeLabel
|
||||
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 VertexProperties
|
||||
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
|
||||
@ -118,11 +118,11 @@ class NovaInstanceTransformerTest(base.BaseTest):
|
||||
host_neighbor = wrapper.neighbors[0]
|
||||
self._validate_host_neighbor(host_neighbor, event)
|
||||
|
||||
action_type = event[DSProps.ACTION_TYPE]
|
||||
if action_type == ActionType.INIT_SNAPSHOT:
|
||||
self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action)
|
||||
elif action_type == ActionType.SNAPSHOT:
|
||||
self.assertEqual(EventAction.UPDATE_ENTITY, wrapper.action)
|
||||
datasource_action = event[DSProps.DATASOURCE_ACTION]
|
||||
if datasource_action == DatasourceAction.INIT_SNAPSHOT:
|
||||
self.assertEqual(GraphAction.CREATE_ENTITY, wrapper.action)
|
||||
elif datasource_action == DatasourceAction.SNAPSHOT:
|
||||
self.assertEqual(GraphAction.UPDATE_ENTITY, wrapper.action)
|
||||
|
||||
def test_update_event_transform(self):
|
||||
LOG.debug('Test tactual transform action for update events')
|
||||
@ -149,11 +149,11 @@ class NovaInstanceTransformerTest(base.BaseTest):
|
||||
|
||||
event_type = event[DSProps.EVENT_TYPE]
|
||||
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':
|
||||
self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action)
|
||||
self.assertEqual(GraphAction.CREATE_ENTITY, wrapper.action)
|
||||
else:
|
||||
self.assertEqual(EventAction.UPDATE_ENTITY, wrapper.action)
|
||||
self.assertEqual(GraphAction.UPDATE_ENTITY, wrapper.action)
|
||||
|
||||
def _validate_vertex_props(self, vertex, event):
|
||||
|
||||
|
@ -152,7 +152,7 @@ class NovaZoneTransformerTest(base.BaseTest):
|
||||
self._validate_host_neighbor(neighbor,
|
||||
zone_vertex_id,
|
||||
hosts,
|
||||
event[DSProps.ACTION_TYPE])
|
||||
event[DSProps.DATASOURCE_ACTION])
|
||||
|
||||
self.assertEqual(1,
|
||||
cluster_neighbors_counter,
|
||||
@ -162,7 +162,7 @@ class NovaZoneTransformerTest(base.BaseTest):
|
||||
host_neighbor,
|
||||
zone_vertex_id,
|
||||
hosts,
|
||||
action_type):
|
||||
datasource_action):
|
||||
|
||||
host_vertex = host_neighbor.vertex
|
||||
host_vertex_id = host_vertex.get(VertexProperties.ID)
|
||||
|
@ -15,8 +15,8 @@
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
from vitrage.common.constants import ActionType
|
||||
from vitrage.common.constants import EventAction
|
||||
from vitrage.common.constants import DatasourceAction
|
||||
from vitrage.common.constants import GraphAction
|
||||
from vitrage.datasources.static import driver
|
||||
from vitrage.datasources.static import STATIC_DATASOURCE
|
||||
from vitrage.tests import base
|
||||
@ -70,7 +70,7 @@ class TestStaticDriver(base.BaseTest):
|
||||
|
||||
def test_get_all(self):
|
||||
# Action
|
||||
static_entities = self.static_driver.get_all(ActionType.UPDATE)
|
||||
static_entities = self.static_driver.get_all(DatasourceAction.UPDATE)
|
||||
|
||||
# Test assertions
|
||||
self.assertEqual(0, len(static_entities))
|
||||
@ -78,7 +78,7 @@ class TestStaticDriver(base.BaseTest):
|
||||
# noinspection PyAttributeOutsideInit
|
||||
def test_get_changes(self):
|
||||
# Setup
|
||||
entities = self.static_driver.get_all(ActionType.UPDATE)
|
||||
entities = self.static_driver.get_all(DatasourceAction.UPDATE)
|
||||
self.assertEqual(0, len(entities))
|
||||
|
||||
self.conf = cfg.ConfigOpts()
|
||||
@ -88,7 +88,7 @@ class TestStaticDriver(base.BaseTest):
|
||||
|
||||
# Action
|
||||
changes = self.static_driver.get_changes(
|
||||
EventAction.UPDATE_ENTITY)
|
||||
GraphAction.UPDATE_ENTITY)
|
||||
|
||||
# Test Assertions
|
||||
self.assertEqual(0, len(changes))
|
||||
|
@ -17,9 +17,9 @@ import os
|
||||
from oslo_config import cfg
|
||||
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 EventAction
|
||||
from vitrage.common.constants import GraphAction
|
||||
from vitrage.common.constants import VertexProperties as VProps
|
||||
from vitrage.common import file_utils
|
||||
from vitrage.datasources.static_physical import driver
|
||||
@ -93,7 +93,7 @@ class TestStaticPhysicalDriver(base.BaseTest):
|
||||
def test_get_all(self):
|
||||
# Action
|
||||
static_entities = \
|
||||
self.static_physical_driver.get_all(ActionType.UPDATE)
|
||||
self.static_physical_driver.get_all(DatasourceAction.UPDATE)
|
||||
|
||||
# Test assertions
|
||||
self.assertEqual(5, len(static_entities))
|
||||
@ -101,7 +101,7 @@ class TestStaticPhysicalDriver(base.BaseTest):
|
||||
# noinspection PyAttributeOutsideInit
|
||||
def test_get_changes(self):
|
||||
# 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.conf = cfg.ConfigOpts()
|
||||
@ -111,7 +111,7 @@ class TestStaticPhysicalDriver(base.BaseTest):
|
||||
|
||||
# Action
|
||||
changes = self.static_physical_driver.get_changes(
|
||||
EventAction.UPDATE_ENTITY)
|
||||
GraphAction.UPDATE_ENTITY)
|
||||
|
||||
# Test Assertions
|
||||
status = any(change[VProps.TYPE] == SWITCH and
|
||||
@ -120,7 +120,7 @@ class TestStaticPhysicalDriver(base.BaseTest):
|
||||
|
||||
status = any(change[VProps.TYPE] == SWITCH and
|
||||
change[VProps.ID] == '23456' and
|
||||
change[DSProps.EVENT_TYPE] == EventAction.DELETE_ENTITY
|
||||
change[DSProps.EVENT_TYPE] == GraphAction.DELETE_ENTITY
|
||||
for change in changes)
|
||||
self.assertEqual(True, status)
|
||||
|
||||
@ -139,7 +139,7 @@ class TestStaticPhysicalDriver(base.BaseTest):
|
||||
|
||||
# Action
|
||||
changes = self.static_physical_driver.get_changes(
|
||||
EventAction.UPDATE_ENTITY)
|
||||
GraphAction.UPDATE_ENTITY)
|
||||
|
||||
# Test Assertions
|
||||
self.assertEqual(0, len(changes))
|
||||
|
@ -18,7 +18,7 @@ from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
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.tests.mocks import utils
|
||||
from vitrage.tests.unit.datasources.zabbix.mock_driver import MockZabbixDriver
|
||||
@ -394,7 +394,7 @@ class ZabbixDriverTest(ZabbixBaseTest):
|
||||
self.assertIsNotNone(alarms, 'No alarms returned')
|
||||
self.assertEqual(1, len(alarms))
|
||||
self._assert_contains(alarm_data1, alarms)
|
||||
self.assertEqual(EventAction.DELETE_ENTITY,
|
||||
self.assertEqual(GraphAction.DELETE_ENTITY,
|
||||
alarms[0][DSProps.EVENT_TYPE])
|
||||
|
||||
# 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.assertEqual(1, len(alarms))
|
||||
self._assert_contains(alarm_data1, alarms)
|
||||
self.assertEqual(EventAction.DELETE_ENTITY,
|
||||
self.assertEqual(GraphAction.DELETE_ENTITY,
|
||||
alarms[0][DSProps.EVENT_TYPE])
|
||||
|
||||
def _extract_alarm_data(self,
|
||||
|
@ -15,11 +15,11 @@
|
||||
from oslo_config import cfg
|
||||
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 EdgeLabel
|
||||
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 VertexProperties as VProps
|
||||
from vitrage.common.datetime_utils import format_unix_timestamp
|
||||
@ -110,15 +110,15 @@ class ZabbixTransformerTest(base.BaseTest):
|
||||
|
||||
def _validate_action(self, alarm, wrapper):
|
||||
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)
|
||||
return
|
||||
|
||||
action_type = alarm[DSProps.ACTION_TYPE]
|
||||
if action_type in (ActionType.SNAPSHOT, ActionType.UPDATE):
|
||||
self.assertEqual(EventAction.UPDATE_ENTITY, wrapper.action)
|
||||
ds_action = alarm[DSProps.DATASOURCE_ACTION]
|
||||
if ds_action in (DatasourceAction.SNAPSHOT, DatasourceAction.UPDATE):
|
||||
self.assertEqual(GraphAction.UPDATE_ENTITY, wrapper.action)
|
||||
else:
|
||||
self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action)
|
||||
self.assertEqual(GraphAction.CREATE_ENTITY, wrapper.action)
|
||||
|
||||
def _validate_vertex(self, vertex, event):
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
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 EntityCategory
|
||||
from vitrage.datasources.nagios import NAGIOS_DATASOURCE
|
||||
@ -80,24 +80,31 @@ class TestEntityGraphUnitBase(base.BaseTest):
|
||||
self.NUM_ZONES,
|
||||
self.NUM_HOSTS,
|
||||
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(
|
||||
self.NUM_ZONES,
|
||||
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(
|
||||
self.NUM_HOSTS,
|
||||
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)
|
||||
|
||||
def _create_entity(self, processor=None, spec_type=None, action_type=None,
|
||||
event_type=None, properties=None):
|
||||
def _create_entity(self,
|
||||
processor=None,
|
||||
spec_type=None,
|
||||
datasource_action=None,
|
||||
event_type=None,
|
||||
properties=None):
|
||||
# create instance event with host neighbor
|
||||
event = self._create_event(spec_type=spec_type,
|
||||
action_type=action_type,
|
||||
datasource_action=datasource_action,
|
||||
event_type=event_type,
|
||||
properties=properties)
|
||||
|
||||
@ -112,16 +119,18 @@ class TestEntityGraphUnitBase(base.BaseTest):
|
||||
return vertex, neighbors, processor
|
||||
|
||||
@staticmethod
|
||||
def _create_event(spec_type=None, action_type=None,
|
||||
event_type=None, properties=None):
|
||||
def _create_event(spec_type=None,
|
||||
datasource_action=None,
|
||||
event_type=None,
|
||||
properties=None):
|
||||
# generate event
|
||||
spec_list = mock_sync.simple_instance_generators(1, 1, 1)
|
||||
events_list = mock_sync.generate_random_events_list(
|
||||
spec_list)
|
||||
|
||||
# update properties
|
||||
if action_type is not None:
|
||||
events_list[0][DSProps.ACTION_TYPE] = action_type
|
||||
if datasource_action is not None:
|
||||
events_list[0][DSProps.DATASOURCE_ACTION] = datasource_action
|
||||
|
||||
if event_type is not None:
|
||||
events_list[0][DSProps.EVENT_TYPE] = event_type
|
||||
|
@ -14,9 +14,9 @@
|
||||
|
||||
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 EventAction
|
||||
from vitrage.common.constants import GraphAction
|
||||
from vitrage.common.constants import VertexProperties as VProps
|
||||
from vitrage.common.datetime_utils import utcnow
|
||||
from vitrage.datasources.transformer_base import Neighbor
|
||||
@ -51,13 +51,13 @@ class TestProcessor(TestEntityGraphUnitBase):
|
||||
# check create instance event
|
||||
processor = proc.Processor(self.conf, InitializationStatus())
|
||||
event = self._create_event(spec_type=self.INSTANCE_SPEC,
|
||||
action_type=ActionType.INIT_SNAPSHOT)
|
||||
datasource_action=DSAction.INIT_SNAPSHOT)
|
||||
processor.process_event(event)
|
||||
self._check_graph(processor, self.NUM_VERTICES_AFTER_CREATION,
|
||||
self.NUM_EDGES_AFTER_CREATION)
|
||||
|
||||
# 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['hostname'] = 'new_host'
|
||||
event['instance_id'] = event['id']
|
||||
@ -68,7 +68,7 @@ class TestProcessor(TestEntityGraphUnitBase):
|
||||
self.NUM_EDGES_AFTER_CREATION)
|
||||
|
||||
# check delete instance event
|
||||
event[DSProps.ACTION_TYPE] = ActionType.UPDATE
|
||||
event[DSProps.DATASOURCE_ACTION] = DSAction.UPDATE
|
||||
event[DSProps.EVENT_TYPE] = 'compute.instance.delete.end'
|
||||
processor.process_event(event)
|
||||
self._check_graph(processor, self.NUM_VERTICES_AFTER_DELETION,
|
||||
@ -133,10 +133,10 @@ class TestProcessor(TestEntityGraphUnitBase):
|
||||
# setup
|
||||
vertex1, neighbors1, processor = self._create_entity(
|
||||
spec_type=self.INSTANCE_SPEC,
|
||||
action_type=ActionType.INIT_SNAPSHOT)
|
||||
datasource_action=DSAction.INIT_SNAPSHOT)
|
||||
vertex2, neighbors2, processor = self._create_entity(
|
||||
spec_type=self.INSTANCE_SPEC,
|
||||
action_type=ActionType.INIT_SNAPSHOT,
|
||||
datasource_action=DSAction.INIT_SNAPSHOT,
|
||||
processor=processor)
|
||||
self.assertEqual(2, processor.entity_graph.num_edges())
|
||||
|
||||
@ -155,10 +155,10 @@ class TestProcessor(TestEntityGraphUnitBase):
|
||||
# setup
|
||||
vertex1, neighbors1, processor = self._create_entity(
|
||||
spec_type=self.INSTANCE_SPEC,
|
||||
action_type=ActionType.INIT_SNAPSHOT)
|
||||
datasource_action=DSAction.INIT_SNAPSHOT)
|
||||
vertex2, neighbors2, processor = self._create_entity(
|
||||
spec_type=self.INSTANCE_SPEC,
|
||||
action_type=ActionType.INIT_SNAPSHOT,
|
||||
datasource_action=DSAction.INIT_SNAPSHOT,
|
||||
processor=processor)
|
||||
self.assertEqual(2, processor.entity_graph.num_edges())
|
||||
|
||||
@ -179,7 +179,7 @@ class TestProcessor(TestEntityGraphUnitBase):
|
||||
# setup
|
||||
vertex, neighbors, processor = self._create_entity(
|
||||
spec_type=self.INSTANCE_SPEC,
|
||||
action_type=ActionType.INIT_SNAPSHOT)
|
||||
datasource_action=DSAction.INIT_SNAPSHOT)
|
||||
self.assertEqual(1, processor.entity_graph.num_edges())
|
||||
vertex[VProps.IS_DELETED] = True
|
||||
processor.entity_graph.update_vertex(vertex)
|
||||
@ -237,19 +237,19 @@ class TestProcessor(TestEntityGraphUnitBase):
|
||||
# state already exists and its updated
|
||||
instances[0][0][VProps.STATE] = 'SUSPENDED'
|
||||
instances[0][1]._calculate_aggregated_state(instances[0][0],
|
||||
EventAction.UPDATE_ENTITY)
|
||||
GraphAction.UPDATE_ENTITY)
|
||||
|
||||
# vitrage state doesn't exist and its updated
|
||||
instances[1][0][VProps.STATE] = None
|
||||
instances[1][1].entity_graph.update_vertex(instances[1][0])
|
||||
instances[1][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
|
||||
instances[1][1]._calculate_aggregated_state(instances[1][0],
|
||||
EventAction.UPDATE_ENTITY)
|
||||
GraphAction.UPDATE_ENTITY)
|
||||
|
||||
# state exists and vitrage state changes
|
||||
instances[2][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
|
||||
instances[2][1]._calculate_aggregated_state(instances[2][0],
|
||||
EventAction.UPDATE_ENTITY)
|
||||
GraphAction.UPDATE_ENTITY)
|
||||
|
||||
# vitrage state exists and state changes
|
||||
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][0][VProps.STATE] = 'SUSPENDED'
|
||||
instances[3][1]._calculate_aggregated_state(instances[3][0],
|
||||
EventAction.UPDATE_ENTITY)
|
||||
GraphAction.UPDATE_ENTITY)
|
||||
|
||||
# state and vitrage state exists and state changes
|
||||
instances[4][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
|
||||
instances[4][1].entity_graph.update_vertex(instances[4][0])
|
||||
instances[4][0][VProps.STATE] = 'SUSPENDED'
|
||||
instances[4][1]._calculate_aggregated_state(instances[4][0],
|
||||
EventAction.UPDATE_ENTITY)
|
||||
GraphAction.UPDATE_ENTITY)
|
||||
|
||||
# state and vitrage state exists and vitrage state changes
|
||||
instances[5][0][VProps.VITRAGE_STATE] = 'SUBOPTIMAL'
|
||||
instances[5][1].entity_graph.update_vertex(instances[5][0])
|
||||
instances[5][1]._calculate_aggregated_state(instances[5][0],
|
||||
EventAction.UPDATE_ENTITY)
|
||||
GraphAction.UPDATE_ENTITY)
|
||||
|
||||
# test assertions
|
||||
self.assertEqual('SUSPENDED',
|
||||
@ -302,7 +302,7 @@ class TestProcessor(TestEntityGraphUnitBase):
|
||||
# create instance event with host neighbor
|
||||
(vertex, neighbors, processor) = self._create_entity(
|
||||
spec_type=self.INSTANCE_SPEC,
|
||||
action_type=ActionType.INIT_SNAPSHOT,
|
||||
datasource_action=DSAction.INIT_SNAPSHOT,
|
||||
properties=kwargs,
|
||||
processor=processor)
|
||||
|
||||
|
@ -218,7 +218,7 @@ class TemplateSyntaxValidatorTest(base.BaseTest):
|
||||
action[TemplateFields.ACTION].pop(field_name)
|
||||
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
|
||||
scenario = template[TemplateFields.SCENARIOS][0]
|
||||
|
@ -46,9 +46,11 @@ class BaseMock(testtools.TestCase):
|
||||
def _create_mock_events():
|
||||
gen_list = mock_sync.simple_zone_generators(
|
||||
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(
|
||||
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(
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user