diff options
author | Marco Platania <platania@research.att.com> | 2017-11-30 22:24:22 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2017-11-30 22:24:22 +0000 |
commit | c7e7c06b7d9e1e7fb35592e53ff70685182ff9c5 (patch) | |
tree | 8f25eb17869c5169b3dbf316a783f3f47aa878fd /vnfs | |
parent | 2f9f3cbc3dff79b801624485473fdd35430ea897 (diff) | |
parent | f9cbe4b0ecf250f970cd8ed37b4ba3e9e8af1396 (diff) |
Merge "Implement batching of VES events"
Diffstat (limited to 'vnfs')
15 files changed, 479 insertions, 106 deletions
diff --git a/vnfs/VES5.0/evel/evel-library/bldjobs/Makefile b/vnfs/VES5.0/evel/evel-library/bldjobs/Makefile index 3bd9e129..1c327d3d 100644 --- a/vnfs/VES5.0/evel/evel-library/bldjobs/Makefile +++ b/vnfs/VES5.0/evel/evel-library/bldjobs/Makefile @@ -146,6 +146,7 @@ API_SOURCES=$(EVELLIB_ROOT)/evel.c \ $(EVELLIB_ROOT)/evel_threshold_cross.c \ $(EVELLIB_ROOT)/evel_voicequality.c \ $(EVELLIB_ROOT)/evel_logging.c \ + $(EVELLIB_ROOT)/evel_batch.c \ $(EVELLIB_ROOT)/jsmn.c API_OBJECTS=$(API_SOURCES:.c=.o) -include $(API_SOURCES:.c=.d) diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.c b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.c index dbaf58ad..246ed5de 100644 --- a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.c +++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.c @@ -388,6 +388,13 @@ void evel_free_event(void * event) free(evt_ptr); break; + case EVEL_DOMAIN_BATCH: + EVEL_DEBUG("Event is a Batch at %lp", evt_ptr); + evel_free_batch((EVENT_HEADER *)evt_ptr); + memset(evt_ptr, 0, sizeof(EVENT_HEADER)); + free(evt_ptr); + break; + default: EVEL_ERROR("Unexpected event domain (%d)", evt_ptr->event_domain); assert(0); diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.h b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.h index 0ae1713e..6b7a8720 100644 --- a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.h +++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.h @@ -1,5 +1,3 @@ -#ifndef EVEL_INCLUDED -#define EVEL_INCLUDED /*************************************************************************//** * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. @@ -29,6 +27,9 @@ * be one of ::EVEL_ERR_CODES. *****************************************************************************/ +#ifndef EVEL_INCLUDED +#define EVEL_INCLUDED + #ifdef __cplusplus extern "C" { #endif @@ -86,7 +87,7 @@ typedef enum { /* Maximum string lengths. */ /*****************************************************************************/ #define EVEL_MAX_STRING_LEN 4096 -#define EVEL_MAX_JSON_BODY 16000 +#define EVEL_MAX_JSON_BODY 160000 #define EVEL_MAX_ERROR_STRING_LEN 255 #define EVEL_MAX_URL_LEN 511 @@ -117,6 +118,7 @@ static const int EVEL_EVENT_BUFFER_DEPTH = 100; *****************************************************************************/ typedef enum { EVEL_DOMAIN_INTERNAL, /** Internal event, not for external routing. */ + EVEL_DOMAIN_BATCH, /** Batch event, composite event. */ EVEL_DOMAIN_HEARTBEAT, /** A Heartbeat event (event header only). */ EVEL_DOMAIN_FAULT, /** A Fault event. */ EVEL_DOMAIN_MEASUREMENT, /** A Measurement for VF Scaling event. */ @@ -400,9 +402,11 @@ typedef struct internal_header_fields /*****************************************************************************/ /* Supported Common Event Header version. */ /*****************************************************************************/ -#define EVEL_HEADER_MAJOR_VERSION 1 -#define EVEL_HEADER_MINOR_VERSION 2 +#define EVEL_HEADER_MAJOR_VERSION 3 +#define EVEL_HEADER_MINOR_VERSION 0 +#define EVEL_BATCH_MAJOR_VERSION 1 +#define EVEL_BATCH_MINOR_VERSION 0 /**************************************************************************//** * Event header. * JSON equivalent field: commonEventHeader @@ -436,9 +440,57 @@ typedef struct event_header { EVEL_OPTION_INTHEADER_FIELDS internal_field; EVEL_OPTION_STRING nfcnaming_code; EVEL_OPTION_STRING nfnaming_code; + DLIST batch_events; } EVENT_HEADER; +/**************************************************************************//** + * Initialize a newly created event header. + * + * @param header Pointer to the header being initialized. + * @param eventname Eventname string + * @param eventid Event id : unique id for classification and analysis + * @param header Pointer to the header being initialized. + *****************************************************************************/ +void evel_init_header_nameid(EVENT_HEADER * const header,const char *const eventname, const char *eventid); + +/**************************************************************************//** + * Create a new Batch event. + * + * @note The mandatory fields on the Batch must be supplied to this factory + * function and are immutable once set. Optional fields have explicit + * setter functions, but again values may only be set once so that the + * Batch has immutable properties. At this time evename and eventid + * for batch events are set but not used in json encoding + * @returns pointer to the newly manufactured ::EVENT_HEADER. If the event is + * not used (i.e. posted) it must be released using ::evel_free_batch. + * @retval NULL Failed to create the event. + *****************************************************************************/ +EVENT_HEADER * evel_new_batch(const char* ev_name, const char *ev_id); + + +/**************************************************************************//** + * Add an Event into Batch Event + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param other Pointer to the Batch Event. + * @param jsonobj Pointer to additional Event + *****************************************************************************/ +void evel_batch_add_event(EVENT_HEADER * batchev, EVENT_HEADER *child); + +/**************************************************************************//** + * Free an Batch. + * + * Free off the Batch supplied. Will free all the contained allocated memory. + * + * @note It does not free the Batch itself, since that may be part of a + * larger structure. + *****************************************************************************/ +void evel_free_batch(EVENT_HEADER * event); + /*****************************************************************************/ /* Supported Fault version. */ /*****************************************************************************/ @@ -1082,8 +1134,8 @@ typedef struct mobile_gtp_per_flow_metrics { /*****************************************************************************/ /* Supported Mobile Flow version. */ /*****************************************************************************/ -#define EVEL_MOBILE_FLOW_MAJOR_VERSION 1 -#define EVEL_MOBILE_FLOW_MINOR_VERSION 2 +#define EVEL_MOBILE_FLOW_MAJOR_VERSION 2 +#define EVEL_MOBILE_FLOW_MINOR_VERSION 0 /**************************************************************************//** * Mobile Flow. @@ -1179,8 +1231,8 @@ typedef struct other_field { /*****************************************************************************/ /* Supported Signaling version. */ /*****************************************************************************/ -#define EVEL_SIGNALING_MAJOR_VERSION 2 -#define EVEL_SIGNALING_MINOR_VERSION 1 +#define EVEL_SIGNALING_MAJOR_VERSION 1 +#define EVEL_SIGNALING_MINOR_VERSION 0 /**************************************************************************//** * Vendor VNF Name fields. @@ -1277,8 +1329,8 @@ typedef struct state_change_additional_field { /*****************************************************************************/ /* Supported Syslog version. */ /*****************************************************************************/ -#define EVEL_SYSLOG_MAJOR_VERSION 1 -#define EVEL_SYSLOG_MINOR_VERSION 2 +#define EVEL_SYSLOG_MAJOR_VERSION 3 +#define EVEL_SYSLOG_MINOR_VERSION 0 /**************************************************************************//** * Syslog. @@ -1400,6 +1452,7 @@ void evel_free_event(void * event); * Encode the event as a JSON event object according to AT&T's schema. * * @param json Pointer to where to store the JSON encoded data. + * @param mode Event mode or Batch mode * @param max_size Size of storage available in json_body. * @param event Pointer to the ::EVENT_HEADER to encode. * @returns Number of bytes actually written. @@ -1407,7 +1460,9 @@ void evel_free_event(void * event); int evel_json_encode_event(char * json, int max_size, EVENT_HEADER * event); - +int evel_json_encode_batch_event(char * json, + int max_size, + EVENT_HEADER * event); /**************************************************************************//** * Initialize an event instance id. * @@ -1490,8 +1545,8 @@ EVENT_HEADER * evel_new_heartbeat(void); * * @note that the heartbeat is just a "naked" commonEventHeader! * - * @param event_name Unique Event Name confirming Domain AsdcModel Description - * @param event_id A universal identifier of the event for: troubleshooting correlation, analysis, etc + * @param event_name Unique Event Name: {DomainAbbreviation}_{AsdcModel or ApplicationPlatform}_{DescriptionOfInfoBeingConveyed} + * @param event_id A universal identifier of the event for: troubleshooting, cross-referencing of alarms for alarm correlation, offline log analysis, etc * * @returns pointer to the newly manufactured ::EVENT_HEADER. If the event is * not used it must be released using ::evel_free_event @@ -4255,8 +4310,8 @@ typedef struct perf_counter { /*****************************************************************************/ /* Supported Threshold Crossing version. */ /*****************************************************************************/ -#define EVEL_THRESHOLD_CROSS_MAJOR_VERSION 1 -#define EVEL_THRESHOLD_CROSS_MINOR_VERSION 1 +#define EVEL_THRESHOLD_CROSS_MAJOR_VERSION 2 +#define EVEL_THRESHOLD_CROSS_MINOR_VERSION 0 /**************************************************************************//** * Threshold Crossing. diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_batch.c b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_batch.c new file mode 100644 index 00000000..a33e5e12 --- /dev/null +++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_batch.c @@ -0,0 +1,150 @@ +/*************************************************************************//** + * + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * + * Unless otherwise specified, all software contained herein is + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************/ + +/**************************************************************************//** + * @file + * Source module implementing EVEL Batch API. + * + * This file implements the EVEL Batch API which is intended to provide a + * simple wrapper around packaging multiple EVEL messages into single HTTP(S) package + * This is implemented per VES 5.3 standards. Currently max size of package is 160K + * + ****************************************************************************/ + +#include <string.h> +#include <assert.h> +#include <stdlib.h> + +#include "evel.h" +#include "evel_internal.h" + +/**************************************************************************//** + * Create a new empty Batch event. + * + * @note The mandatory fields on the Batch must be supplied to this factory + * function and are immutable once set. Optional fields have explicit + * setter functions, but again values may only be set once so that the + * Batch has immutable properties. + * @params Event name and Event id are dummy strings. Not encoded into JSON + * @returns pointer to the newly manufactured ::EVENT_HEADER. If the event is + * not used (i.e. posted) it must be released using ::evel_free_batch. + * @retval NULL Failed to create the event. + *****************************************************************************/ +EVENT_HEADER * evel_new_batch(const char* ev_name, const char *ev_id) +{ + EVENT_HEADER * other = NULL; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + + /***************************************************************************/ + /* Allocate the Batch. */ + /***************************************************************************/ + other = malloc(sizeof(EVENT_HEADER)); + if (other == NULL) + { + log_error_state("Out of memory"); + goto exit_label; + } + memset(other, 0, sizeof(EVENT_HEADER)); + EVEL_DEBUG("New Batch is at %lp", other); + + /***************************************************************************/ + /* Initialize the header & the Batch fields. Optional string values are */ + /* uninitialized (NULL). */ + /***************************************************************************/ + evel_init_header_nameid(other,ev_name,ev_id); + other->event_domain = EVEL_DOMAIN_BATCH; + other->major_version = EVEL_BATCH_MAJOR_VERSION; + other->minor_version = EVEL_BATCH_MINOR_VERSION; + + dlist_initialize(&other->batch_events); + +exit_label: + EVEL_EXIT(); + return other; +} + + +/**************************************************************************//** + * Add an additional VES Message into Batch Event + * + * The function may be called as many times without reaching 160K max json size + * limit. + * The max limit is only checked at encoding time and error generated + * + * @param batchev Pointer to already created new Batch Event. + * @param child Pointer to additional VES Event + *****************************************************************************/ +void evel_batch_add_event(EVENT_HEADER * batchev, EVENT_HEADER *child) +{ + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(batchev != NULL); + assert(batchev->event_domain == EVEL_DOMAIN_BATCH); + assert(child != NULL); + + EVEL_DEBUG("Adding Batch event"); + + dlist_push_last(&batchev->batch_events, child); + + EVEL_EXIT(); +} + + +/**************************************************************************//** + * Free a Batch Event. + * + * Free off the Batch supplied. Will free all the contained VES message memory. + * + * @note It does not free the Batch itself, since that may be part of a + * larger structure. + *****************************************************************************/ +void evel_free_batch(EVENT_HEADER * event) +{ + EVENT_HEADER * batch_field = NULL; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. As an internal API we don't allow freeing NULL */ + /* events as we do on the public API. */ + /***************************************************************************/ + assert(event != NULL); + assert(event->event_domain == EVEL_DOMAIN_BATCH); + + /***************************************************************************/ + /* Free all internal strings then the header itself. */ + /***************************************************************************/ + batch_field = dlist_pop_last(&event->batch_events); + while (batch_field != NULL) + { + EVEL_DEBUG("Freeing Batch Event (%s, %s)", + batch_field->event_name, + batch_field->event_id); + evel_free_event(batch_field); + batch_field = dlist_pop_last(&event->batch_events); + } + + EVEL_EXIT(); +} diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event.c b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event.c index 4de49bcf..c9bb4345 100644 --- a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event.c +++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event.c @@ -183,6 +183,7 @@ void evel_init_header(EVENT_HEADER * const header,const char *const eventname) evel_force_option_string(&header->reporting_entity_id, openstack_vm_uuid()); evel_force_option_string(&header->source_id, openstack_vm_uuid()); evel_init_option_intheader(&header->internal_field); + dlist_initialize(&header->batch_events); EVEL_EXIT(); } @@ -192,6 +193,9 @@ void evel_init_header(EVENT_HEADER * const header,const char *const eventname) * Initialize a newly created event header. * * @param header Pointer to the header being initialized. + * @param eventname Eventname string + * @param eventid Event id : unique id for classification and analysis + * @param header Pointer to the header being initialized. *****************************************************************************/ void evel_init_header_nameid(EVENT_HEADER * const header,const char *const eventname, const char *eventid) { @@ -232,6 +236,7 @@ void evel_init_header_nameid(EVENT_HEADER * const header,const char *const event evel_force_option_string(&header->reporting_entity_id, openstack_vm_uuid()); evel_force_option_string(&header->source_id, openstack_vm_uuid()); evel_init_option_intheader(&header->internal_field); + dlist_initialize(&header->batch_events); EVEL_EXIT(); } @@ -505,6 +510,78 @@ void evel_free_header(EVENT_HEADER * const event) EVEL_EXIT(); } + +/**************************************************************************//** + * Encode the event as a JSON event object according to AT&T's schema. + * + * @param json Pointer to where to store the JSON encoded data. + * @param max_size Size of storage available in json_body. + * @param event Pointer to the ::EVENT_HEADER to encode. + * @returns Number of bytes actually written. + *****************************************************************************/ +void evel_json_encode_eventtype( + EVEL_JSON_BUFFER * jbuf, + EVENT_HEADER * event) +{ + switch (event->event_domain) + { + case EVEL_DOMAIN_HEARTBEAT: + evel_json_encode_header(jbuf, event); + break; + + case EVEL_DOMAIN_FAULT: + evel_json_encode_fault(jbuf, (EVENT_FAULT *)event); + break; + + case EVEL_DOMAIN_MEASUREMENT: + evel_json_encode_measurement(jbuf, (EVENT_MEASUREMENT *)event); + break; + + case EVEL_DOMAIN_MOBILE_FLOW: + evel_json_encode_mobile_flow(jbuf, (EVENT_MOBILE_FLOW *)event); + break; + + case EVEL_DOMAIN_REPORT: + evel_json_encode_report(jbuf, (EVENT_REPORT *)event); + break; + + case EVEL_DOMAIN_HEARTBEAT_FIELD: + evel_json_encode_hrtbt_field(jbuf, (EVENT_HEARTBEAT_FIELD *)event); + break; + + case EVEL_DOMAIN_SIPSIGNALING: + evel_json_encode_signaling(jbuf, (EVENT_SIGNALING *)event); + break; + + case EVEL_DOMAIN_STATE_CHANGE: + evel_json_encode_state_change(jbuf, (EVENT_STATE_CHANGE *)event); + break; + + case EVEL_DOMAIN_SYSLOG: + evel_json_encode_syslog(jbuf, (EVENT_SYSLOG *)event); + break; + + case EVEL_DOMAIN_OTHER: + evel_json_encode_other(jbuf, (EVENT_OTHER *)event); + break; + + case EVEL_DOMAIN_VOICE_QUALITY: + evel_json_encode_voice_quality(jbuf, (EVENT_VOICE_QUALITY *)event); + break; + + case EVEL_DOMAIN_THRESHOLD_CROSS: + evel_json_encode_threshold_cross(jbuf, (EVENT_THRESHOLD_CROSS *)event); + break; + + case EVEL_DOMAIN_INTERNAL: + default: + EVEL_ERROR("Unexpected domain %d", event->event_domain); + assert(0); + } +} + + + /**************************************************************************//** * Encode the event as a JSON event object according to AT&T's schema. * @@ -535,61 +612,7 @@ int evel_json_encode_event(char * json, evel_json_open_object(jbuf); evel_json_open_named_object(jbuf, "event"); - switch (event->event_domain) - { - case EVEL_DOMAIN_HEARTBEAT: - evel_json_encode_header(jbuf, event); - break; - - case EVEL_DOMAIN_FAULT: - evel_json_encode_fault(jbuf, (EVENT_FAULT *)event); - break; - - case EVEL_DOMAIN_MEASUREMENT: - evel_json_encode_measurement(jbuf, (EVENT_MEASUREMENT *)event); - break; - - case EVEL_DOMAIN_MOBILE_FLOW: - evel_json_encode_mobile_flow(jbuf, (EVENT_MOBILE_FLOW *)event); - break; - - case EVEL_DOMAIN_REPORT: - evel_json_encode_report(jbuf, (EVENT_REPORT *)event); - break; - - case EVEL_DOMAIN_HEARTBEAT_FIELD: - evel_json_encode_hrtbt_field(jbuf, (EVENT_HEARTBEAT_FIELD *)event); - break; - - case EVEL_DOMAIN_SIPSIGNALING: - evel_json_encode_signaling(jbuf, (EVENT_SIGNALING *)event); - break; - - case EVEL_DOMAIN_STATE_CHANGE: - evel_json_encode_state_change(jbuf, (EVENT_STATE_CHANGE *)event); - break; - - case EVEL_DOMAIN_SYSLOG: - evel_json_encode_syslog(jbuf, (EVENT_SYSLOG *)event); - break; - - case EVEL_DOMAIN_OTHER: - evel_json_encode_other(jbuf, (EVENT_OTHER *)event); - break; - - case EVEL_DOMAIN_VOICE_QUALITY: - evel_json_encode_voice_quality(jbuf, (EVENT_VOICE_QUALITY *)event); - break; - - case EVEL_DOMAIN_THRESHOLD_CROSS: - evel_json_encode_threshold_cross(jbuf, (EVENT_THRESHOLD_CROSS *)event); - break; - - case EVEL_DOMAIN_INTERNAL: - default: - EVEL_ERROR("Unexpected domain %d", event->event_domain); - assert(0); - } + evel_json_encode_eventtype(jbuf, event); evel_json_close_object(jbuf); evel_json_close_object(jbuf); @@ -603,6 +626,75 @@ int evel_json_encode_event(char * json, return jbuf->offset; } +/**************************************************************************//** + * Encode the event as a JSON event object according to AT&T's schema. + * + * @param json Pointer to where to store the JSON encoded data. + * @param max_size Size of storage available in json_body. + * @param event Pointer to the ::EVENT_HEADER to encode. + * @returns Number of bytes actually written. + *****************************************************************************/ +int evel_json_encode_batch_event(char * json, + int max_size, + EVENT_HEADER * event) +{ + EVEL_JSON_BUFFER json_buffer; + EVEL_JSON_BUFFER *jbuf = &json_buffer; + EVEL_THROTTLE_SPEC * throttle_spec; + int tot_size = 0; + EVENT_HEADER * batch_field = NULL; + DLIST_ITEM * batch_field_item = NULL; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Get the latest throttle specification for the domain. */ + /***************************************************************************/ + throttle_spec = evel_get_throttle_spec(event->event_domain); + + /***************************************************************************/ + /* Initialize the JSON_BUFFER and open the top-level objects. */ + /***************************************************************************/ + if (event->event_domain == EVEL_DOMAIN_BATCH){ + evel_json_buffer_init(jbuf, json, max_size, throttle_spec); + + if(dlist_count(&event->batch_events) > 0) + { + evel_json_open_object(jbuf); + evel_json_open_named_list(jbuf, "eventList"); + batch_field_item = dlist_get_first(&event->batch_events); + while (batch_field_item != NULL) + { + batch_field = (EVENT_HEADER *) batch_field_item->item; + if(batch_field != NULL){ + EVEL_DEBUG("Batch Event %p %p added curr fsize %d offset %d depth %d check %d", batch_field_item->item, batch_field, tot_size,jbuf->offset,jbuf->depth,jbuf->checkpoint); + evel_json_open_object(jbuf); + evel_json_encode_eventtype(jbuf, batch_field); + evel_json_close_object(jbuf); + + tot_size += jbuf->offset; + EVEL_DEBUG("Batch Event result size %d offset %d depth %d check %d", tot_size,jbuf->offset,jbuf->depth,jbuf->checkpoint); + if( tot_size >= max_size ){ + EVEL_ERROR("Batch Event exceeded size limit %d", tot_size); + assert(0); + } + batch_field_item = dlist_get_next(batch_field_item); + } + } + evel_json_close_list(jbuf); + evel_json_close_object(jbuf); + } + + } + /***************************************************************************/ + /* Sanity check. */ + /***************************************************************************/ + //assert(jbuf->depth == 0); + + EVEL_EXIT(); + + return jbuf->offset; +} /**************************************************************************//** diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event_mgr.c b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event_mgr.c index 572df148..9d3aa610 100644 --- a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event_mgr.c +++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event_mgr.c @@ -102,6 +102,7 @@ static EVT_HANDLER_STATE evt_handler_state = EVT_HANDLER_UNINITIALIZED; *****************************************************************************/ static char * evel_event_api_url; static char * evel_throt_api_url; +static char * evel_batch_api_url; /**************************************************************************//** * Initialize the event handler. @@ -126,6 +127,7 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, { int rc = EVEL_SUCCESS; CURLcode curl_rc = CURLE_OK; + char batch_api_url[EVEL_MAX_URL_LEN + 1] = {0}; EVEL_ENTER(); @@ -142,6 +144,9 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, /***************************************************************************/ evel_event_api_url = strdup(event_api_url); assert(evel_event_api_url != NULL); + sprintf(batch_api_url,"%s/eventBatch",event_api_url); + evel_batch_api_url = strdup(batch_api_url); + assert(evel_batch_api_url != NULL); evel_throt_api_url = strdup(throt_api_url); assert(evel_throt_api_url != NULL); @@ -790,7 +795,37 @@ static void * event_handler(void * arg __attribute__ ((unused))) /* Internal events get special treatment while regular events get posted */ /* to the far side. */ /*************************************************************************/ - if (msg->event_domain != EVEL_DOMAIN_INTERNAL) + if (msg->event_domain == EVEL_DOMAIN_BATCH ) + { + EVEL_DEBUG("Batch event received"); + + /***********************************************************************/ + /* Encode the event in JSON. */ + /***********************************************************************/ + json_size = evel_json_encode_batch_event(json_body, EVEL_MAX_JSON_BODY, msg); + + /***************************************************************************/ + /* Set the URL for the API. */ + /***************************************************************************/ + curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, evel_batch_api_url); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the Batch API URL. " + "Error code=%d (%s)", curl_rc, curl_err_string); + } + + /***********************************************************************/ + /* Send the JSON across the API. */ + /***********************************************************************/ + EVEL_DEBUG("Sending Batch JSON of size %d is: %s", json_size, json_body); + rc = evel_post_api(json_body, json_size); + if (rc != EVEL_SUCCESS) + { + EVEL_ERROR("Failed to transfer the data. Error code=%d", rc); + } + } + else if (msg->event_domain != EVEL_DOMAIN_INTERNAL ) { EVEL_DEBUG("External event received"); @@ -799,6 +834,17 @@ static void * event_handler(void * arg __attribute__ ((unused))) /***********************************************************************/ json_size = evel_json_encode_event(json_body, EVEL_MAX_JSON_BODY, msg); + /***************************************************************************/ + /* Set the URL for the API. */ + /***************************************************************************/ + curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, evel_event_api_url); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the API URL. " + "Error code=%d (%s)", curl_rc, curl_err_string); + } + /***********************************************************************/ /* Send the JSON across the API. */ /***********************************************************************/ diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_jsonobject.c b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_jsonobject.c index 85f65ca1..4f788bd1 100644 --- a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_jsonobject.c +++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_jsonobject.c @@ -113,7 +113,7 @@ EVEL_JSON_OBJECT_INSTANCE * evel_new_jsonobjinstance(const char *const yourjson) assert(len > 0); /***************************************************************************/ - /* Validate JSON for json object + /* Validate JSON for json object */ /***************************************************************************/ jsmn_init(&p); resultCode = jsmn_parse(&p, yourjson, len, tokens, sizeof(tokens)/sizeof(tokens[0])); @@ -397,7 +397,7 @@ void evel_free_jsonobjinst(EVEL_JSON_OBJECT_INSTANCE * objinst) free(objinst->jsonstring); /***************************************************************************/ - /* Free all internal internal keys + /* Free all internal internal keys */ /***************************************************************************/ other_field = dlist_pop_last(&objinst->object_keys); while (other_field != NULL) diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_other.c b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_other.c index 4888d28e..774c5223 100644 --- a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_other.c +++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_other.c @@ -118,7 +118,6 @@ void evel_other_type_set(EVENT_OTHER * other, *****************************************************************************/ void evel_other_field_set_namedarraysize(EVENT_OTHER * other, const int size) { - OTHER_FIELD * other_field = NULL; EVEL_ENTER(); /***************************************************************************/ diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_reporting_measurement.c b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_reporting_measurement.c index 0f303728..aa6675fd 100644 --- a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_reporting_measurement.c +++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_reporting_measurement.c @@ -330,7 +330,7 @@ void evel_json_encode_report(EVEL_JSON_BUFFER * jbuf, { evel_json_open_object(jbuf); evel_enc_kv_string(jbuf, "name", measurement_group->name); - evel_json_open_named_list(jbuf, "arrayOfFields"); + evel_json_open_named_list(jbuf, "measurements"); /*********************************************************************/ /* Measurements list. */ diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_scaling_measurement.c b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_scaling_measurement.c index b73eb978..cb3e88fb 100644 --- a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_scaling_measurement.c +++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_scaling_measurement.c @@ -3519,7 +3519,7 @@ void evel_json_encode_measurement(EVEL_JSON_BUFFER * jbuf, { evel_json_open_object(jbuf); evel_enc_kv_string(jbuf, "name", measurement_group->name); - evel_json_open_opt_named_list(jbuf, "arrayOfFields"); + evel_json_open_opt_named_list(jbuf, "measurements"); /*********************************************************************/ /* Measurements list. */ diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/metadata.c b/vnfs/VES5.0/evel/evel-library/code/evel_library/metadata.c index 62ea6b51..fceb893c 100644 --- a/vnfs/VES5.0/evel/evel-library/code/evel_library/metadata.c +++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/metadata.c @@ -23,6 +23,7 @@ #include <string.h> #include <assert.h> #include <malloc.h> +#include <unistd.h> #include <curl/curl.h> @@ -313,12 +314,30 @@ exit_label: *****************************************************************************/ void openstack_metadata_initialize() { + char hostname[MAX_METADATA_STRING]; + + FILE * f = fopen ("/proc/sys/kernel/random/uuid", "r"); + strncpy(vm_uuid, "Dummy VM UUID - No Metadata available", MAX_METADATA_STRING); strncpy(vm_name, "Dummy VM name - No Metadata available", MAX_METADATA_STRING); + + if( gethostname(hostname, 1024) != -1 ) + strcpy(vm_name,hostname); + + if (f) + { + if (fgets(vm_uuid,MAX_METADATA_STRING, f)!=NULL) + { + vm_uuid[strlen( vm_uuid ) - 1 ] = '\0'; + EVEL_DEBUG("VM UUID: %s", vm_uuid); + } + fclose (f); + } + } /**************************************************************************//** diff --git a/vnfs/VES5.0/evel/evel-test-collector/code/collector/collector.py b/vnfs/VES5.0/evel/evel-test-collector/code/collector/collector.py index 8e702aa7..b9473ae5 100644 --- a/vnfs/VES5.0/evel/evel-test-collector/code/collector/collector.py +++ b/vnfs/VES5.0/evel/evel-test-collector/code/collector/collector.py @@ -7,20 +7,20 @@ Only intended for test purposes. License ------- - * =================================================================== - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * =================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + =================================================================== + Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + =================================================================== + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. ''' from rest_dispatcher import PathDispatcher, set_404_content @@ -562,11 +562,16 @@ USAGE else '') throttle_url = '/{0}eventListener/v{1}/clientThrottlingState'.\ format(vel_path, api_version) + batch_url = '/{0}eventListener/v{1}/eventBatch'.\ + format(vel_path, api_version) set_404_content(root_url) dispatcher = PathDispatcher() vendor_event_listener = partial(listener, schema = vel_schema) dispatcher.register('GET', root_url, vendor_event_listener) dispatcher.register('POST', root_url, vendor_event_listener) + batch_event_listener = partial(listener, schema = vel_schema) + dispatcher.register('GET', batch_url, batch_event_listener) + dispatcher.register('POST', batch_url, batch_event_listener) vendor_throttle_listener = partial(listener, schema = throttle_schema) dispatcher.register('GET', throttle_url, vendor_throttle_listener) dispatcher.register('POST', throttle_url, vendor_throttle_listener) diff --git a/vnfs/VES5.0/evel/evel-test-collector/code/collector/rest_dispatcher.py b/vnfs/VES5.0/evel/evel-test-collector/code/collector/rest_dispatcher.py index e3b51aa6..e00465a4 100644 --- a/vnfs/VES5.0/evel/evel-test-collector/code/collector/rest_dispatcher.py +++ b/vnfs/VES5.0/evel/evel-test-collector/code/collector/rest_dispatcher.py @@ -7,20 +7,20 @@ Only intended for test purposes. License ------- - * =================================================================== - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * =================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + =================================================================== + Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + =================================================================== + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. ''' diff --git a/vnfs/VES5.0/evel/evel-test-collector/docs/att_interface_definition/event_format_updated.json b/vnfs/VES5.0/evel/evel-test-collector/docs/att_interface_definition/event_format_updated.json index 160add52..7dfef260 100644 --- a/vnfs/VES5.0/evel/evel-test-collector/docs/att_interface_definition/event_format_updated.json +++ b/vnfs/VES5.0/evel/evel-test-collector/docs/att_interface_definition/event_format_updated.json @@ -10,7 +10,6 @@ "description": "You may not use this file except in compliance with the License.You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0",
"type": "string"
},
- "licenseLink": "http://www.apache.org/licenses/LICENSE-2.0",
"condition1": {
"description": "Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an AS IS BASIS,",
"type": "string"
diff --git a/vnfs/VES5.0/evel/evel-test-collector/scripts/linux/go-collector.sh b/vnfs/VES5.0/evel/evel-test-collector/scripts/linux/go-collector.sh index 31fd8af4..31fd8af4 100644..100755 --- a/vnfs/VES5.0/evel/evel-test-collector/scripts/linux/go-collector.sh +++ b/vnfs/VES5.0/evel/evel-test-collector/scripts/linux/go-collector.sh |