1 /*************************************************************************//**
3 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
5 * Unless otherwise specified, all software contained herein is
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
17 ****************************************************************************/
18 /**************************************************************************//**
20 * Implementation of EVEL functions to convert common enum types to strings.
22 ****************************************************************************/
28 #include "evel_internal.h"
30 /**************************************************************************//**
31 * Map an ::EVEL_COUNTER_CRITICALITIES enum value to the equivalent string.
33 * @param criticality The criticality to convert.
34 * @returns The equivalent string.
35 *****************************************************************************/
36 char * evel_criticality(const EVEL_COUNTER_CRITICALITIES criticality)
44 case EVEL_COUNTER_CRITICALITY_CRIT:
48 case EVEL_COUNTER_CRITICALITY_MAJ:
53 EVEL_ERROR("Unexpected counter criticality %d", criticality);
62 /**************************************************************************//**
63 * Map an ::EVEL_SEVERITIES enum value to the equivalent string.
65 * @param severity The severity to convert.
66 * @returns The equivalent string.
67 *****************************************************************************/
68 char * evel_severity(const EVEL_SEVERITIES severity)
76 case EVEL_SEVERITY_CRITICAL:
80 case EVEL_SEVERITY_MAJOR:
84 case EVEL_SEVERITY_MINOR:
88 case EVEL_SEVERITY_WARNING:
92 case EVEL_SEVERITY_NORMAL:
97 EVEL_ERROR("Unexpected event severity %d", severity);
106 /**************************************************************************//**
107 * Map an ::EVEL_ALERT_ACTIONS enum value to the equivalent string.
109 * @param alert_action The alert_action to convert.
110 * @returns The equivalent string.
111 *****************************************************************************/
112 char * evel_alert_action(const EVEL_ALERT_ACTIONS alert_action)
118 switch (alert_action)
120 case EVEL_ALERT_ACTION_CLEAR:
124 case EVEL_ALERT_ACTION_CONT:
128 case EVEL_ALERT_ACTION_SET:
133 EVEL_ERROR("Unexpected alert action %d", alert_action);
142 /**************************************************************************//**
143 * Map an ::EVEL_ALERT_TYPES enum value to the equivalent string.
145 * @param alert_type The alert_type to convert.
146 * @returns The equivalent string.
147 *****************************************************************************/
148 char * evel_alert_type(const EVEL_ALERT_TYPES alert_type)
156 case EVEL_ALERT_TYPE_CARD:
157 result = "CARD-ANOMALY";
160 case EVEL_ALERT_TYPE_ELEMENT:
161 result = "ELEMENT-ANOMALY";
164 case EVEL_ALERT_TYPE_INTERFACE:
165 result = "INTERFACE-ANOMALY";
168 case EVEL_ALERT_TYPE_SERVICE:
169 result = "SERVICE-ANOMALY";
173 EVEL_ERROR("Unexpected alert type %d", alert_type);
182 /**************************************************************************//**
183 * Map an ::EVEL_EVENT_DOMAINS enum value to the equivalent string.
185 * @param domain The domain to convert.
186 * @returns The equivalent string.
187 *****************************************************************************/
188 char * evel_event_domain(const EVEL_EVENT_DOMAINS domain)
196 case EVEL_DOMAIN_HEARTBEAT:
197 result = "heartbeat";
200 case EVEL_DOMAIN_FAULT:
204 case EVEL_DOMAIN_MEASUREMENT:
205 result = "measurementsForVfScaling";
208 case EVEL_DOMAIN_REPORT:
209 result = "measurementsForVfReporting";
212 case EVEL_DOMAIN_MOBILE_FLOW:
213 result = "mobileFlow";
216 case EVEL_DOMAIN_HEARTBEAT_FIELD:
217 result = "heartbeat";
220 case EVEL_DOMAIN_SIPSIGNALING:
221 result = "sipSignaling";
224 case EVEL_DOMAIN_STATE_CHANGE:
225 result = "stateChange";
228 case EVEL_DOMAIN_SYSLOG:
232 case EVEL_DOMAIN_OTHER:
236 case EVEL_DOMAIN_VOICE_QUALITY:
237 result = "voiceQuality";
240 case EVEL_DOMAIN_THRESHOLD_CROSS:
241 result = "thresholdCrossingAlert";
246 EVEL_ERROR("Unexpected domain %d", domain);
255 /**************************************************************************//**
256 * Map an ::EVEL_EVENT_PRIORITIES enum value to the equivalent string.
258 * @param priority The priority to convert.
259 * @returns The equivalent string.
260 *****************************************************************************/
261 char * evel_event_priority(const EVEL_EVENT_PRIORITIES priority)
269 case EVEL_PRIORITY_HIGH:
273 case EVEL_PRIORITY_MEDIUM:
277 case EVEL_PRIORITY_NORMAL:
281 case EVEL_PRIORITY_LOW:
287 EVEL_ERROR("Unexpected priority %d", priority);
296 /**************************************************************************//**
297 * Map an ::EVEL_SOURCE_TYPES enum value to the equivalent string.
299 * @param source_type The source type to convert.
300 * @returns The equivalent string.
301 *****************************************************************************/
302 char * evel_source_type(const EVEL_SOURCE_TYPES source_type)
310 case EVEL_SOURCE_OTHER:
314 case EVEL_SOURCE_ROUTER:
318 case EVEL_SOURCE_SWITCH:
322 case EVEL_SOURCE_HOST:
326 case EVEL_SOURCE_CARD:
330 case EVEL_SOURCE_PORT:
334 case EVEL_SOURCE_SLOT_THRESHOLD:
335 result = "slotThreshold";
338 case EVEL_SOURCE_PORT_THRESHOLD:
339 result = "portThreshold";
342 case EVEL_SOURCE_VIRTUAL_MACHINE:
343 result = "virtualMachine";
346 case EVEL_SOURCE_VIRTUAL_NETWORK_FUNCTION:
347 result = "virtualNetworkFunction";
352 EVEL_ERROR("Unexpected Event Source Type %d", (int) source_type);
361 /**************************************************************************//**
362 * Map an ::EVEL_VF_STATUSES enum value to the equivalent string.
364 * @param vf_status The vf_status to convert.
365 * @returns The equivalent string.
366 *****************************************************************************/
367 char * evel_vf_status(const EVEL_VF_STATUSES vf_status)
375 case EVEL_VF_STATUS_ACTIVE:
379 case EVEL_VF_STATUS_IDLE:
383 case EVEL_VF_STATUS_PREP_TERMINATE:
384 result = "Preparing to terminate";
387 case EVEL_VF_STATUS_READY_TERMINATE:
388 result = "Ready to terminate";
391 case EVEL_VF_STATUS_REQ_TERMINATE:
392 result = "Requesting termination";
397 EVEL_ERROR("Unexpected VF Status %d", vf_status);
406 /**************************************************************************//**
407 * Convert a ::EVEL_ENTITY_STATE to it's string form for JSON encoding.
409 * @param state The entity state to encode.
411 * @returns the corresponding string
412 *****************************************************************************/
413 char * evel_entity_state(const EVEL_ENTITY_STATE state)
421 case EVEL_ENTITY_STATE_IN_SERVICE:
422 result = "inService";
425 case EVEL_ENTITY_STATE_MAINTENANCE:
426 result = "maintenance";
429 case EVEL_ENTITY_STATE_OUT_OF_SERVICE:
430 result = "outOfService";
434 EVEL_ERROR("Unexpected entity state %d", state);
443 /**************************************************************************//**
444 * Convert a ::EVEL_SERVICE_ENDPOINT_DESC to string form for JSON encoding.
446 * @param endpoint_desc endpoint description to encode.
448 * @returns the corresponding string
449 *****************************************************************************/
450 char * evel_service_endpoint_desc(const EVEL_ENTITY_STATE endpoint_desc)
456 switch (endpoint_desc)
458 case EVEL_SERVICE_ENDPOINT_CALLEE:
462 case EVEL_SERVICE_ENDPOINT_CALLER:
467 EVEL_ERROR("Unexpected endpoint description %d", endpoint_desc);