def _create_vertex(self, entity_event): update_timestamp = datetime_utils.change_time_str_format( entity_event[NagiosProperties.LAST_CHECK], '%Y-%m-%d %H:%M:%S', tbase.TIMESTAMP_FORMAT) sample_timestamp = entity_event[DSProps.SAMPLE_DATE] update_timestamp = self._format_update_timestamp( update_timestamp, sample_timestamp) severity = entity_event[NagiosProperties.STATUS] entity_state = AlarmProps.ALARM_INACTIVE_STATE if \ severity == NagiosStatus.OK else AlarmProps.ALARM_ACTIVE_STATE metadata = { VProps.NAME: entity_event[NagiosProperties.SERVICE], VProps.SEVERITY: severity, VProps.INFO: entity_event[NagiosProperties.STATUS_INFO] } return graph_utils.create_vertex( self._create_entity_key(entity_event), entity_category=EntityCategory.ALARM, entity_type=entity_event[DSProps.SYNC_TYPE], entity_state=entity_state, sample_timestamp=sample_timestamp, update_timestamp=update_timestamp, metadata=metadata)
def _create_vertex(self, entity_event): update_timestamp = datetime_utils.change_time_str_format( entity_event[NagiosProperties.LAST_CHECK], '%Y-%m-%d %H:%M:%S', tbase.TIMESTAMP_FORMAT) sample_timestamp = entity_event[DSProps.SAMPLE_DATE] update_timestamp = self._format_update_timestamp(update_timestamp, sample_timestamp) severity = entity_event[NagiosProperties.STATUS] entity_state = AlarmProps.ALARM_INACTIVE_STATE if \ severity == NagiosStatus.OK else AlarmProps.ALARM_ACTIVE_STATE metadata = { VProps.NAME: entity_event[NagiosProperties.SERVICE], VProps.SEVERITY: severity, VProps.INFO: entity_event[NagiosProperties.STATUS_INFO] } return graph_utils.create_vertex( self._create_entity_key(entity_event), entity_category=EntityCategory.ALARM, entity_type=entity_event[DSProps.SYNC_TYPE], entity_state=entity_state, sample_timestamp=sample_timestamp, update_timestamp=update_timestamp, metadata=metadata)
def convert_timestamp_format(current_timestamp_format, timestamp): return datetime_utils.change_time_str_format( timestamp, current_timestamp_format, TIMESTAMP_FORMAT )
def _unify_time_format(entity_event): try: entity_event[ZProps.TIMESTAMP] = format_unix_timestamp( entity_event[ZProps.LAST_CHANGE], tbase.TIMESTAMP_FORMAT) except ValueError: entity_event[ZProps.TIMESTAMP] = change_time_str_format( entity_event[ZProps.LAST_CHANGE], ZProps.ZABBIX_TIMESTAMP_FORMAT, tbase.TIMESTAMP_FORMAT)
def _create_nagios_neighbors(self, entity_event): vitrage_id = self._create_entity_key(entity_event) timestamp = datetime_utils.change_time_str_format( entity_event[NagiosProperties.LAST_CHECK], '%Y-%m-%d %H:%M:%S', tbase.TIMESTAMP_FORMAT) resource_type = entity_event[NagiosProperties.RESOURCE_TYPE] if resource_type: return [ self._create_neighbor( vitrage_id, timestamp, resource_type, entity_event[NagiosProperties.RESOURCE_NAME]) ] return []
def _create_nagios_neighbors(self, entity_event): vitrage_id = self._create_entity_key(entity_event) timestamp = datetime_utils.change_time_str_format( entity_event[NagiosProperties.LAST_CHECK], '%Y-%m-%d %H:%M:%S', tbase.TIMESTAMP_FORMAT) resource_type = entity_event[NagiosProperties.RESOURCE_TYPE] if resource_type == NOVA_HOST_DATASOURCE or resource_type == SWITCH: return [self._create_neighbor( vitrage_id, timestamp, resource_type, entity_event[NagiosProperties.RESOURCE_NAME])] return []
def convert_timestamp_format(current_timestamp_format, timestamp): return datetime_utils.change_time_str_format(timestamp, current_timestamp_format, TIMESTAMP_FORMAT)
def _timestamp(entity_event): return datetime_utils.change_time_str_format( entity_event[AodhProps.TIMESTAMP], '%Y-%m-%dT%H:%M:%S.%f', tbase.TIMESTAMP_FORMAT)
def _timestamp(entity_event): return datetime_utils.change_time_str_format( entity_event[AodhProps.TIMESTAMP], '%Y-%m-%dT%H:%M:%S.%f', tbase.TIMESTAMP_FORMAT)