1 /**************************************************************************//**
3 * Implementation of EVEL functions to convert common enum types to strings.
8 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 *****************************************************************************/
26 #include "evel_internal.h"
28 /**************************************************************************//**
29 * Map an ::EVEL_COUNTER_CRITICALITIES enum value to the equivalent string.
31 * @param criticality The criticality to convert.
32 * @returns The equivalent string.
33 *****************************************************************************/
34 char * evel_criticality(const EVEL_COUNTER_CRITICALITIES criticality)
42 case EVEL_COUNTER_CRITICALITY_CRIT:
46 case EVEL_COUNTER_CRITICALITY_MAJ:
51 EVEL_ERROR("Unexpected counter criticality %d", criticality);
60 /**************************************************************************//**
61 * Map an ::EVEL_SEVERITIES enum value to the equivalent string.
63 * @param severity The severity to convert.
64 * @returns The equivalent string.
65 *****************************************************************************/
66 char * evel_severity(const EVEL_SEVERITIES severity)
74 case EVEL_SEVERITY_CRITICAL:
78 case EVEL_SEVERITY_MAJOR:
82 case EVEL_SEVERITY_MINOR:
86 case EVEL_SEVERITY_WARNING:
90 case EVEL_SEVERITY_NORMAL:
95 EVEL_ERROR("Unexpected event severity %d", severity);
104 /**************************************************************************//**
105 * Map an ::EVEL_ALERT_ACTIONS enum value to the equivalent string.
107 * @param alert_action The alert_action to convert.
108 * @returns The equivalent string.
109 *****************************************************************************/
110 char * evel_alert_action(const EVEL_ALERT_ACTIONS alert_action)
116 switch (alert_action)
118 case EVEL_ALERT_ACTION_CLEAR:
122 case EVEL_ALERT_ACTION_CONT:
126 case EVEL_ALERT_ACTION_SET:
131 EVEL_ERROR("Unexpected alert action %d", alert_action);
140 /**************************************************************************//**
141 * Map an ::EVEL_ALERT_TYPES enum value to the equivalent string.
143 * @param alert_type The alert_type to convert.
144 * @returns The equivalent string.
145 *****************************************************************************/
146 char * evel_alert_type(const EVEL_ALERT_TYPES alert_type)
154 case EVEL_ALERT_TYPE_CARD:
155 result = "CARD-ANOMALY";
158 case EVEL_ALERT_TYPE_ELEMENT:
159 result = "ELEMENT-ANOMALY";
162 case EVEL_ALERT_TYPE_INTERFACE:
163 result = "INTERFACE-ANOMALY";
166 case EVEL_ALERT_TYPE_SERVICE:
167 result = "SERVICE-ANOMALY";
171 EVEL_ERROR("Unexpected alert type %d", alert_type);
180 /**************************************************************************//**
181 * Map an ::EVEL_EVENT_DOMAINS enum value to the equivalent string.
183 * @param domain The domain to convert.
184 * @returns The equivalent string.
185 *****************************************************************************/
186 char * evel_event_domain(const EVEL_EVENT_DOMAINS domain)
194 case EVEL_DOMAIN_HEARTBEAT:
195 result = "heartbeat";
198 case EVEL_DOMAIN_FAULT:
202 case EVEL_DOMAIN_MEASUREMENT:
203 result = "measurementsForVfScaling";
206 case EVEL_DOMAIN_REPORT:
207 result = "measurementsForVfReporting";
210 case EVEL_DOMAIN_MOBILE_FLOW:
211 result = "mobileFlow";
214 case EVEL_DOMAIN_SERVICE:
215 result = "serviceEvents";
218 case EVEL_DOMAIN_SIGNALING:
219 result = "signaling";
222 case EVEL_DOMAIN_STATE_CHANGE:
223 result = "stateChange";
226 case EVEL_DOMAIN_SYSLOG:
230 case EVEL_DOMAIN_OTHER:
236 EVEL_ERROR("Unexpected domain %d", domain);
245 /**************************************************************************//**
246 * Map an ::EVEL_EVENT_PRIORITIES enum value to the equivalent string.
248 * @param priority The priority to convert.
249 * @returns The equivalent string.
250 *****************************************************************************/
251 char * evel_event_priority(const EVEL_EVENT_PRIORITIES priority)
259 case EVEL_PRIORITY_HIGH:
263 case EVEL_PRIORITY_MEDIUM:
267 case EVEL_PRIORITY_NORMAL:
271 case EVEL_PRIORITY_LOW:
277 EVEL_ERROR("Unexpected priority %d", priority);
286 /**************************************************************************//**
287 * Map an ::EVEL_SOURCE_TYPES enum value to the equivalent string.
289 * @param source_type The source type to convert.
290 * @returns The equivalent string.
291 *****************************************************************************/
292 char * evel_source_type(const EVEL_SOURCE_TYPES source_type)
300 case EVEL_SOURCE_OTHER:
304 case EVEL_SOURCE_ROUTER:
308 case EVEL_SOURCE_SWITCH:
312 case EVEL_SOURCE_HOST:
316 case EVEL_SOURCE_CARD:
320 case EVEL_SOURCE_PORT:
324 case EVEL_SOURCE_SLOT_THRESHOLD:
325 result = "slotThreshold";
328 case EVEL_SOURCE_PORT_THRESHOLD:
329 result = "portThreshold";
332 case EVEL_SOURCE_VIRTUAL_MACHINE:
333 result = "virtualMachine";
336 case EVEL_SOURCE_VIRTUAL_NETWORK_FUNCTION:
337 result = "virtualNetworkFunction";
342 EVEL_ERROR("Unexpected Event Source Type %d", (int) source_type);
351 /**************************************************************************//**
352 * Map an ::EVEL_VF_STATUSES enum value to the equivalent string.
354 * @param vf_status The vf_status to convert.
355 * @returns The equivalent string.
356 *****************************************************************************/
357 char * evel_vf_status(const EVEL_VF_STATUSES vf_status)
365 case EVEL_VF_STATUS_ACTIVE:
369 case EVEL_VF_STATUS_IDLE:
373 case EVEL_VF_STATUS_PREP_TERMINATE:
374 result = "Preparing to terminate";
377 case EVEL_VF_STATUS_READY_TERMINATE:
378 result = "Ready to terminate";
381 case EVEL_VF_STATUS_REQ_TERMINATE:
382 result = "Requesting termination";
387 EVEL_ERROR("Unexpected VF Status %d", vf_status);
396 /**************************************************************************//**
397 * Convert a ::EVEL_ENTITY_STATE to it's string form for JSON encoding.
399 * @param state The entity state to encode.
401 * @returns the corresponding string
402 *****************************************************************************/
403 char * evel_entity_state(const EVEL_ENTITY_STATE state)
411 case EVEL_ENTITY_STATE_IN_SERVICE:
412 result = "inService";
415 case EVEL_ENTITY_STATE_MAINTENANCE:
416 result = "maintenance";
419 case EVEL_ENTITY_STATE_OUT_OF_SERVICE:
420 result = "outOfService";
424 EVEL_ERROR("Unexpected entity state %d", state);
433 /**************************************************************************//**
434 * Convert a ::EVEL_SERVICE_ENDPOINT_DESC to string form for JSON encoding.
436 * @param endpoint_desc endpoint description to encode.
438 * @returns the corresponding string
439 *****************************************************************************/
440 char * evel_service_endpoint_desc(const EVEL_ENTITY_STATE endpoint_desc)
446 switch (endpoint_desc)
448 case EVEL_SERVICE_ENDPOINT_CALLEE:
452 case EVEL_SERVICE_ENDPOINT_CALLER:
457 EVEL_ERROR("Unexpected endpoint description %d", endpoint_desc);