From c076f7ddb4cc27a3f626e5c9c96084f8109b6330 Mon Sep 17 00:00:00 2001 From: Gokul Singaraju Date: Thu, 29 Mar 2018 00:35:42 -0400 Subject: Update C library with https batch Issue-ID: VNFSDK-122 Change-Id: I74556357e5fb534f64476edf34395343453a96e5 Signed-Off-by: Gokul Singaraju --- .../ves_clibrary/VESreporting_vFW/LICENSE.TXT | 2 +- veslibrary/ves_clibrary/VESreporting_vFW/Makefile | 3 +- .../ves_clibrary/VESreporting_vFW/go-client.sh | 2 +- veslibrary/ves_clibrary/VESreporting_vFW/pom.xml | 6 +- .../VESreporting_vFW/vpp_measurement_reporter.c | 11 +- veslibrary/ves_clibrary/VESreporting_vLB/Makefile | 3 +- .../ves_clibrary/VESreporting_vLB/go-client.sh | 2 +- veslibrary/ves_clibrary/VESreporting_vLB/pom.xml | 6 +- .../VESreporting_vLB/vpp_measurement_reporter.c | 11 +- .../ves_clibrary/evel/evel-library/LICENSE.TXT | 4 +- .../evel/evel-library/bldjobs/Makefile | 1 + .../evel-library/code/evel_library/double_list.c | 1 + .../evel/evel-library/code/evel_library/evel.c | 67 +++++++ .../evel/evel-library/code/evel_library/evel.h | 114 +++++++++-- .../evel-library/code/evel_library/evel_batch.c | 150 +++++++++++++++ .../evel-library/code/evel_library/evel_event.c | 208 +++++++++++++++------ .../code/evel_library/evel_event_mgr.c | 188 ++++++++++++++++++- .../evel-library/code/evel_library/evel_fault.c | 2 +- .../code/evel_library/evel_heartbeat_fields.c | 2 +- .../evel-library/code/evel_library/evel_internal.h | 18 ++ .../code/evel_library/evel_internal_event.c | 2 +- .../code/evel_library/evel_json_buffer.c | 2 +- .../code/evel_library/evel_jsonobject.c | 6 +- .../evel-library/code/evel_library/evel_logging.c | 2 +- .../code/evel_library/evel_mobile_flow.c | 2 +- .../evel-library/code/evel_library/evel_option.c | 2 +- .../evel-library/code/evel_library/evel_other.c | 96 +++++----- .../code/evel_library/evel_reporting_measurement.c | 2 +- .../code/evel_library/evel_scaling_measurement.c | 21 ++- .../code/evel_library/evel_sipsignaling.c | 1 + .../evel-library/code/evel_library/evel_strings.c | 2 +- .../evel-library/code/evel_library/evel_syslog.c | 2 +- .../code/evel_library/evel_threshold_cross.c | 2 +- .../evel-library/code/evel_library/evel_throttle.c | 5 +- .../code/evel_library/evel_voicequality.c | 3 +- .../evel-library/code/evel_library/hashtable.c | 1 + .../evel/evel-library/code/evel_library/jsmn.c | 2 +- .../evel/evel-library/code/evel_library/license.md | 4 +- .../evel/evel-library/code/evel_library/metadata.c | 45 ++++- .../evel-library/code/evel_library/ring_buffer.c | 2 +- .../evel/evel-library/code/evel_unit/evel_unit.c | 1 + .../evel/evel-test-collector/LICENSE.md | 2 +- .../evel-test-collector/code/collector/LICENSE.TXT | 2 +- .../code/collector/collector.py | 71 +++++-- .../code/collector/rest_dispatcher.py | 28 +-- .../evel/evel-test-collector/config/collector.conf | 10 + .../event_format_updated.json | 7 +- .../evel/evel-test-collector/docs/ssl_certsample | 15 ++ 48 files changed, 946 insertions(+), 195 deletions(-) create mode 100644 veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_batch.c create mode 100644 veslibrary/ves_clibrary/evel/evel-test-collector/docs/ssl_certsample diff --git a/veslibrary/ves_clibrary/VESreporting_vFW/LICENSE.TXT b/veslibrary/ves_clibrary/VESreporting_vFW/LICENSE.TXT index c081dc2..16285cd 100644 --- a/veslibrary/ves_clibrary/VESreporting_vFW/LICENSE.TXT +++ b/veslibrary/ves_clibrary/VESreporting_vFW/LICENSE.TXT @@ -17,6 +17,6 @@ * limitations under the License. * ============LICENSE_END============================================ * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ECOMP is trademark and service mark of AT&T Intellectual Property. * */ diff --git a/veslibrary/ves_clibrary/VESreporting_vFW/Makefile b/veslibrary/ves_clibrary/VESreporting_vFW/Makefile index e7ac57b..7582b64 100644 --- a/veslibrary/ves_clibrary/VESreporting_vFW/Makefile +++ b/veslibrary/ves_clibrary/VESreporting_vFW/Makefile @@ -17,8 +17,7 @@ CC=gcc ARCH=$(shell getconf LONG_BIT) -#CODE_ROOT=$(CURDIR)/../../.. -CODE_ROOT=../VES5.0/evel/evel-library +CODE_ROOT=$(CURDIR)/../evel/evel-library LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH) INCLUDE_DIR=$(CODE_ROOT)/code/evel_library diff --git a/veslibrary/ves_clibrary/VESreporting_vFW/go-client.sh b/veslibrary/ves_clibrary/VESreporting_vFW/go-client.sh index 3d1b159..116f890 100755 --- a/veslibrary/ves_clibrary/VESreporting_vFW/go-client.sh +++ b/veslibrary/ves_clibrary/VESreporting_vFW/go-client.sh @@ -1,6 +1,6 @@ #!/bin/bash -export LD_LIBRARY_PATH="/opt/VES/libs/x86_64/" +export LD_LIBRARY_PATH="/opt/VES/evel/evel-library/libs/x86_64/" DCAE_COLLECTOR_IP=$(cat /opt/config/dcae_collector_ip.txt) DCAE_COLLECTOR_PORT=$(cat /opt/config/dcae_collector_port.txt) ./vpp_measurement_reporter $DCAE_COLLECTOR_IP $DCAE_COLLECTOR_PORT eth1 diff --git a/veslibrary/ves_clibrary/VESreporting_vFW/pom.xml b/veslibrary/ves_clibrary/VESreporting_vFW/pom.xml index 9b89913..2e0df62 100644 --- a/veslibrary/ves_clibrary/VESreporting_vFW/pom.xml +++ b/veslibrary/ves_clibrary/VESreporting_vFW/pom.xml @@ -26,14 +26,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - org.openecomp.demo.vnf + org.onap.demo.vnf demo-aggregator - 1.1.0-SNAPSHOT + 1.2.0-SNAPSHOT ../../pom.xml 4.0.0 - org.openecomp.demo.vnf.ves + org.onap.demo.vnf.ves5 ves_vfw_reporting diff --git a/veslibrary/ves_clibrary/VESreporting_vFW/vpp_measurement_reporter.c b/veslibrary/ves_clibrary/VESreporting_vFW/vpp_measurement_reporter.c index 4b7d6bd..4cc4ab8 100644 --- a/veslibrary/ves_clibrary/VESreporting_vFW/vpp_measurement_reporter.c +++ b/veslibrary/ves_clibrary/VESreporting_vFW/vpp_measurement_reporter.c @@ -3,7 +3,6 @@ * * 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 @@ -192,9 +191,17 @@ int main(int argc, char** argv) port, /* Port */ NULL, /* optional path */ NULL, /* optional topic */ + 100, /* Ring Buffer size */ 0, /* HTTPS? */ + NULL, /* cert file */ + NULL, /* key file */ + NULL, /* ca info */ + NULL, /* ca file */ + 0, /* verify peer */ + 0, /* verify host */ "", /* Username */ "", /* Password */ + NULL, /* Source ip */ EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */ "vFirewall", /* Role */ 1)) /* Verbosity */ @@ -246,7 +253,7 @@ int main(int argc, char** argv) packets_out_this_round = 0; } - vpp_m = evel_new_measurement(READ_INTERVAL,"Measurement_vVNF","TrafficStats_1.2.3.4"); + vpp_m = evel_new_measurement(READ_INTERVAL,"vFirewallBroadcastPackets","TrafficStats_1.2.3.4"); vnic_performance = (MEASUREMENT_VNIC_PERFORMANCE *)evel_measurement_new_vnic_performance("eth0", "true"); evel_meas_vnic_performance_add(vpp_m, vnic_performance); diff --git a/veslibrary/ves_clibrary/VESreporting_vLB/Makefile b/veslibrary/ves_clibrary/VESreporting_vLB/Makefile index faf004c..dbc6b1b 100644 --- a/veslibrary/ves_clibrary/VESreporting_vLB/Makefile +++ b/veslibrary/ves_clibrary/VESreporting_vLB/Makefile @@ -18,8 +18,7 @@ CC=gcc ARCH=$(shell getconf LONG_BIT) -#CODE_ROOT=$(CURDIR)/../../.. -CODE_ROOT=../VES5.0/evel/evel-library +CODE_ROOT=$(CURDIR)/../evel/evel-library LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH) INCLUDE_DIR=$(CODE_ROOT)/code/evel_library diff --git a/veslibrary/ves_clibrary/VESreporting_vLB/go-client.sh b/veslibrary/ves_clibrary/VESreporting_vLB/go-client.sh index 3d1b159..116f890 100755 --- a/veslibrary/ves_clibrary/VESreporting_vLB/go-client.sh +++ b/veslibrary/ves_clibrary/VESreporting_vLB/go-client.sh @@ -1,6 +1,6 @@ #!/bin/bash -export LD_LIBRARY_PATH="/opt/VES/libs/x86_64/" +export LD_LIBRARY_PATH="/opt/VES/evel/evel-library/libs/x86_64/" DCAE_COLLECTOR_IP=$(cat /opt/config/dcae_collector_ip.txt) DCAE_COLLECTOR_PORT=$(cat /opt/config/dcae_collector_port.txt) ./vpp_measurement_reporter $DCAE_COLLECTOR_IP $DCAE_COLLECTOR_PORT eth1 diff --git a/veslibrary/ves_clibrary/VESreporting_vLB/pom.xml b/veslibrary/ves_clibrary/VESreporting_vLB/pom.xml index 65ee26b..70c906c 100644 --- a/veslibrary/ves_clibrary/VESreporting_vLB/pom.xml +++ b/veslibrary/ves_clibrary/VESreporting_vLB/pom.xml @@ -26,14 +26,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - org.openecomp.demo.vnf + org.onap.demo.vnf demo-aggregator - 1.1.0-SNAPSHOT + 1.2.0-SNAPSHOT ../../pom.xml 4.0.0 - org.openecomp.demo.vnf.ves + org.onap.demo.vnf.ves5 ves_vlb_reporting diff --git a/veslibrary/ves_clibrary/VESreporting_vLB/vpp_measurement_reporter.c b/veslibrary/ves_clibrary/VESreporting_vLB/vpp_measurement_reporter.c index c0c6e01..14ca294 100644 --- a/veslibrary/ves_clibrary/VESreporting_vLB/vpp_measurement_reporter.c +++ b/veslibrary/ves_clibrary/VESreporting_vLB/vpp_measurement_reporter.c @@ -3,7 +3,6 @@ * * 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 @@ -140,9 +139,17 @@ int main(int argc, char** argv) port, /* Port */ NULL, /* optional path */ NULL, /* optional topic */ + 100, /* Ring buffer size */ 0, /* HTTPS? */ + NULL, /* cert file */ + NULL, /* key file */ + NULL, /* ca info */ + NULL, /* ca file */ + 0, /* verify peer */ + 0, /* verify host */ "", /* Username */ "", /* Password */ + NULL, /* Source IP */ EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */ "vLoadBalancer", /* Role */ 1)) /* Verbosity */ @@ -207,7 +214,7 @@ int main(int argc, char** argv) packets_out_this_round = 0; } - vpp_m = evel_new_measurement(READ_INTERVAL,"Measurement_vVNF","TrafficStats_1.2.3.4"); + vpp_m = evel_new_measurement(READ_INTERVAL,"vLoadBalancer","TrafficStats_1.2.3.4"); vnic_performance = (MEASUREMENT_VNIC_PERFORMANCE *)evel_measurement_new_vnic_performance("eth0", "true"); evel_meas_vnic_performance_add(vpp_m, vnic_performance); diff --git a/veslibrary/ves_clibrary/evel/evel-library/LICENSE.TXT b/veslibrary/ves_clibrary/evel/evel-library/LICENSE.TXT index 2d85cf3..31f2520 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/LICENSE.TXT +++ b/veslibrary/ves_clibrary/evel/evel-library/LICENSE.TXT @@ -4,7 +4,7 @@ * 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") + * 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 * @@ -17,6 +17,6 @@ * limitations under the License. * ============LICENSE_END============================================ * - * ECOMP is trademark and service mark of AT&T Intellectual Property. + * ECOMP are trademark and service mark of AT&T Intellectual Property. * */ diff --git a/veslibrary/ves_clibrary/evel/evel-library/bldjobs/Makefile b/veslibrary/ves_clibrary/evel/evel-library/bldjobs/Makefile index 5a3a111..7ddb0b9 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/bldjobs/Makefile +++ b/veslibrary/ves_clibrary/evel/evel-library/bldjobs/Makefile @@ -126,6 +126,7 @@ API_SOURCES=$(EVELLIB_ROOT)/evel.c \ $(EVELLIB_ROOT)/ring_buffer.c \ $(EVELLIB_ROOT)/double_list.c \ $(EVELLIB_ROOT)/hashtable.c \ + $(EVELLIB_ROOT)/evel_batch.c \ $(EVELLIB_ROOT)/evel_event.c \ $(EVELLIB_ROOT)/evel_fault.c \ $(EVELLIB_ROOT)/evel_mobile_flow.c \ diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/double_list.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/double_list.c index 3106074..cd171bc 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/double_list.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/double_list.c @@ -14,6 +14,7 @@ * 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. + * ECOMP is a trademark and service mark of AT&T Intellectual Property. * ****************************************************************************/ diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel.c index dbaf58a..4e4383e 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel.c @@ -67,8 +67,15 @@ char *functional_role = NULL; * @param path The optional path (may be NULL). * @param topic The optional topic part of the URL (may be NULL). * @param secure Whether to use HTTPS (0=HTTP, 1=HTTPS) + * @param cert_file_path Path to client certificate file + * @param key_file_path Path to client key file + * @param ca_info Path to CA cert file + * @param ca_file_path Path to CA cert files + * @param verify_peer SSL verification of peer 0 or 1 + * @param verify_host SSL verification of host 0 or 1 * @param username Username for Basic Authentication of requests. * @param password Password for Basic Authentication of requests. + * @param source_ip The ip of node we represent (NULL for default ip). * @param source_type The kind of node we represent. * @param role The role this node undertakes. * @param verbosity 0 for normal operation, positive values for chattier @@ -82,9 +89,17 @@ EVEL_ERR_CODES evel_initialize(const char * const fqdn, int port, const char * const path, const char * const topic, + int ring_buf_size, int secure, + const char * const cert_file_path, + const char * const key_file_path, + const char * const ca_info, + const char * const ca_file_path, + long verify_peer, + long verify_host, const char * const username, const char * const password, + const char * const source_ip, EVEL_SOURCE_TYPES source_type, const char * const role, int verbosity @@ -134,6 +149,42 @@ EVEL_ERR_CODES evel_initialize(const char * const fqdn, } EVEL_INFO("API transport is: %s", secure ? "HTTPS" : "HTTP"); + if( secure ) { + assert( verify_peer >= 0 ); + assert( verify_host >= 0 ); + if (cert_file_path != NULL) + { + EVEL_INFO("Client cert is: %s", cert_file_path); + } + else + { + EVEL_INFO("No Client cert"); + } + if (key_file_path != NULL) + { + EVEL_INFO("Key file is: %s", key_file_path); + } + else + { + EVEL_INFO("No Key file"); + } + if (ca_file_path != NULL) + { + EVEL_INFO("Client CA certs path is: %s", ca_file_path); + } + else + { + EVEL_INFO("No CA certs path"); + } + if (ca_info != NULL) + { + EVEL_INFO("Client CA cert file is: %s", ca_info); + } + else + { + EVEL_INFO("No CA cert file"); + } + } EVEL_INFO("Event Source Type is: %d", source_type); EVEL_INFO("Functional Role is: %s", role); EVEL_INFO("Log verbosity is: %d", verbosity); @@ -200,6 +251,15 @@ EVEL_ERR_CODES evel_initialize(const char * const fqdn, /***************************************************************************/ rc = event_handler_initialize(event_api_url, throt_api_url, + source_ip, + ring_buf_size, + secure, + cert_file_path, + key_file_path, + ca_info, + ca_file_path, + verify_peer, + verify_host, username, password, verbosity); @@ -388,6 +448,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/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel.h b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel.h index 0ae1713..5c05993 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel.h +++ b/veslibrary/ves_clibrary/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 524288 #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. @@ -1348,9 +1400,17 @@ typedef struct copyright { * @param port The API's port. * @param path The optional path (may be NULL). * @param topic The optional topic part of the URL (may be NULL). + * @param ring_buf_size Ring buffer size (>=100) ~ Avg Messages in 1hr * @param secure Whether to use HTTPS (0=HTTP, 1=HTTPS). + * @param cert_file_path Path to client certificate file + * @param key_file_path Path to client key file + * @param ca_info Path to CA info + * @param ca_file_path Path to CA file + * @param verify_peer SSL verification of peer 0 or 1 + * @param verify_host SSL verification of host 0 or 1 * @param username Username for Basic Authentication of requests. * @param password Password for Basic Authentication of requests. + * @param source_ip The ip of node we represent.(NULL for default ip) * @param source_type The kind of node we represent. * @param role The role this node undertakes. * @param verbosity 0 for normal operation, positive values for chattier @@ -1364,14 +1424,33 @@ EVEL_ERR_CODES evel_initialize(const char * const fqdn, int port, const char * const path, const char * const topic, + int ring_buf_size, int secure, + const char * const cert_file_path, + const char * const key_file_path, + const char * const ca_info, + const char * const ca_file_path, + long verify_peer, + long verify_host, const char * const username, const char * const password, + const char * const source_ip, EVEL_SOURCE_TYPES source_type, const char * const role, int verbosity ); +/**************************************************************************//** + * Initialize value for vm_name for all coming events + * @param source_name Source name string. + * Must confirm with EVEL source name standard + * @returns Status code + * @retval EVEL_SUCCESS On success + * @retval ::EVEL_ERR_CODES On failure. + *****************************************************************************/ +EVEL_ERR_CODES evel_set_source_name(char * src_name); + + /**************************************************************************//** * Clean up the EVEL library. * @@ -1400,6 +1479,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 +1487,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 +1572,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 +4337,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/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_batch.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_batch.c new file mode 100644 index 0000000..a33e5e1 --- /dev/null +++ b/veslibrary/ves_clibrary/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 +#include +#include + +#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/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_event.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_event.c index 9ccadb2..5babb67 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_event.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_event.c @@ -13,7 +13,7 @@ * 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. - * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** @@ -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); @@ -598,6 +621,79 @@ int evel_json_encode_event(char * json, /* Sanity check. */ /***************************************************************************/ assert(jbuf->depth == 0); + if( jbuf->offset >= max_size ){ + EVEL_ERROR("Event exceeded size limit %d", max_size); + assert(0); + } + + EVEL_EXIT(); + + 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(); diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_event_mgr.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_event_mgr.c index 89242e3..fb94daf 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_event_mgr.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_event_mgr.c @@ -13,7 +13,7 @@ * 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. - * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** @@ -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. @@ -113,6 +114,15 @@ static char * evel_throt_api_url; * to be. * @param[in] throt_api_url * The URL where the Throttling API is expected to be. + * @param[in] source_ip Source IP of VES Agent + * @param[in] ring_buf_size Initial size of ring buffer + * @param[in] secure Whether Using http or https + * @param[in] cert_file_path Path to Client Certificate file + * @param[in] key_file_path Path to Client key file + * @param[in] ca_info Path to CA info file + * @param[in] ca_file_path Path to CA file + * @param[in] verify_peer Using peer verification or not 0 or 1 + * @param[in] verify_host Using host verification or not 0 or 1 * @param[in] username The username for the Basic Authentication of requests. * @param[in] password The password for the Basic Authentication of requests. * @param verbosity 0 for normal operation, positive values for chattier @@ -120,12 +130,23 @@ static char * evel_throt_api_url; *****************************************************************************/ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, const char * const throt_api_url, + const char * const source_ip, + int ring_buf_size, + int secure, + const char * const cert_file_path, + const char * const key_file_path, + const char * const ca_info, + const char * const ca_file_path, + long verify_peer, + long verify_host, const char * const username, const char * const password, int verbosity) { int rc = EVEL_SUCCESS; CURLcode curl_rc = CURLE_OK; + char batch_api_url[EVEL_MAX_URL_LEN + 1] = {0}; + char local_address[64]; EVEL_ENTER(); @@ -142,6 +163,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); @@ -235,6 +259,114 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, goto exit_label; } + /***************************************************************************/ + /* configure local ip address if provided */ + /* Default ip if NULL */ + /***************************************************************************/ + if( source_ip != NULL ) + { + snprintf(local_address,sizeof(local_address),source_ip); + if( local_address[0] != '\0' ) + { + curl_rc = curl_easy_setopt(curl_handle, + CURLOPT_INTERFACE, + local_address); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the local address. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + } + } + + /***************************************************************************/ + /* configure SSL options for HTTPS transfers */ + /***************************************************************************/ + if( secure ) + { + if( cert_file_path != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle, + CURLOPT_SSLCERT, + cert_file_path); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the client cert. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + } + + if( key_file_path != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle, + CURLOPT_SSLKEY, + key_file_path); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the client key. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + } + + if( ca_info != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle, + CURLOPT_CAINFO, + ca_info); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the CA cert file. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + } + + if( ca_file_path != NULL ) + { + curl_rc = curl_easy_setopt(curl_handle, + CURLOPT_CAPATH, + ca_file_path); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the CA cert path. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + } + + curl_rc = curl_easy_setopt(curl_handle, + CURLOPT_SSL_VERIFYPEER, + verify_peer); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with SSL Server verification. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + curl_rc = curl_easy_setopt(curl_handle, + CURLOPT_SSL_VERIFYHOST, + verify_host); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with Client host verification. " + "Error code=%d (%s)", curl_rc, curl_err_string); + goto exit_label; + } + + } + + + /***************************************************************************/ /* some servers don't like requests that are made without a user-agent */ /* field, so we provide one. */ @@ -343,6 +475,12 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, /* Initialize a message ring-buffer to be used between the foreground and */ /* the thread which sends the messages. This can't fail. */ /***************************************************************************/ + if( ring_buf_size < EVEL_EVENT_BUFFER_DEPTH ) + { + log_error_state("Warning: Failed to initialize Ring buffer size to %d. ", + ring_buf_size); + goto exit_label; + } ring_buffer_initialize(&event_buffer, EVEL_EVENT_BUFFER_DEPTH); /***************************************************************************/ @@ -469,6 +607,11 @@ EVEL_ERR_CODES event_handler_terminate() free(evel_event_api_url); evel_event_api_url = NULL; } + if (evel_batch_api_url != NULL) + { + free(evel_batch_api_url); + evel_batch_api_url = NULL; + } if (evel_throt_api_url != NULL) { free(evel_throt_api_url); @@ -790,7 +933,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 +972,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/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_fault.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_fault.c index 321d354..38b07a7 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_fault.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_fault.c @@ -13,7 +13,7 @@ * 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. - * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_heartbeat_fields.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_heartbeat_fields.c index 899f1d7..031632a 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_heartbeat_fields.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_heartbeat_fields.c @@ -13,7 +13,7 @@ * 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. - * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_internal.h b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_internal.h index 46f71af..d1a952b 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_internal.h +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_internal.h @@ -174,6 +174,15 @@ typedef struct evel_throttle_spec { * to be. * @param[in] throt_api_url * The URL where the Throttling API is expected to be. + * @param[in] source_ip Source IP of VES Agent + * @param[in] ring_buf_size Initialization size of Ring Buffer + * @param[in] secure Whether Using http or https + * @param[in] cert_file_path Path to Client Certificate file + * @param[in] key_file_path Path to Client key file + * @param[in] ca_info Path to CA info file + * @param[in] ca_file_path Path to CA file + * @param[in] verify_peer Using peer verification or not + * @param[in] verify_host Using host verification or not * @param[in] username The username for the Basic Authentication of requests. * @param[in] password The password for the Basic Authentication of requests. * @param verbosity 0 for normal operation, positive values for chattier @@ -181,6 +190,15 @@ typedef struct evel_throttle_spec { *****************************************************************************/ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, const char * const throt_api_url, + const char * const source_ip, + int ring_buf_size, + int secure, + const char * const cert_file_path, + const char * const key_file_path, + const char * const ca_info, + const char * const ca_file_path, + long verify_peer, + long verify_host, const char * const username, const char * const password, int verbosity); diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_internal_event.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_internal_event.c index 73546c5..dff2bae 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_internal_event.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_internal_event.c @@ -13,7 +13,7 @@ * 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. - * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_json_buffer.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_json_buffer.c index 5467595..cae5ab1 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_json_buffer.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_json_buffer.c @@ -13,7 +13,7 @@ * 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. - * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_jsonobject.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_jsonobject.c index 57e6839..4f788bd 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_jsonobject.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_jsonobject.c @@ -13,7 +13,7 @@ * 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. - * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** @@ -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/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_logging.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_logging.c index f26e487..cb07396 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_logging.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_logging.c @@ -13,7 +13,7 @@ * 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. - * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** * @file diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_mobile_flow.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_mobile_flow.c index 093cb13..90b1a44 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_mobile_flow.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_mobile_flow.c @@ -13,7 +13,7 @@ * 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. - * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** * @file diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_option.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_option.c index dc2e347..7818fe1 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_option.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_option.c @@ -13,7 +13,7 @@ * 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. - * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** * @file diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_other.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_other.c index d68f815..b238e38 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_other.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_other.c @@ -18,9 +18,9 @@ /**************************************************************************//** * @file - * Implementation of EVEL functions relating to Other. + * Implementation of EVEL functions relating to Other domain. * - ****************************************************************************/ + *****************************************************************************/ #include #include @@ -40,7 +40,7 @@ * not used (i.e. posted) it must be released using ::evel_free_other. * @retval NULL Failed to create the event. *****************************************************************************/ -EVENT_OTHER * evel_new_other(const char *ev_name, const char *ev_id) +EVENT_OTHER * evel_new_other(const char* ev_name, const char *ev_id) { EVENT_OTHER * other = NULL; EVEL_ENTER(); @@ -107,18 +107,15 @@ void evel_other_type_set(EVENT_OTHER * other, } /**************************************************************************//** - * Add a json object to jsonObject list. + * Set size of Named arrays hash table * - * 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. + * The max size of hash table is passed * * @param other Pointer to the Other. * @param size size of hashtable *****************************************************************************/ void evel_other_field_set_namedarraysize(EVENT_OTHER * other, const int size) { - OTHER_FIELD * other_field = NULL; EVEL_ENTER(); /***************************************************************************/ @@ -172,19 +169,19 @@ void evel_other_field_add_namedarray(EVENT_OTHER * other, const char *hashname, assert(other_field->value != NULL); - list = ht_get(other->namedarrays, hashname); + list = (DLIST *)ht_get(other->namedarrays, hashname); if( list == NULL ) { DLIST * nlist = malloc(sizeof(DLIST)); dlist_initialize(nlist); dlist_push_last(nlist, other_field); - ht_set(other->namedarrays, hashname, nlist); - EVEL_DEBUG("Created to new table table"); + ht_set(other->namedarrays, hashname,(void*)nlist); + EVEL_DEBUG("Created to new namedarray table %p",nlist); } else { dlist_push_last(list, other_field); - EVEL_DEBUG("Adding to existing table"); + EVEL_DEBUG("Adding to existing table %p",list); } EVEL_EXIT(); @@ -277,9 +274,10 @@ void evel_json_encode_other(EVEL_JSON_BUFFER * jbuf, EVEL_INTERNAL_KEY * keyinst = NULL; DLIST_ITEM * keyinst_field_item = NULL; HASHTABLE_T *ht = NULL; - int i; + int idx; bool itm_added = false; DLIST *itm_list = NULL; + ENTRY_T *entry = NULL; EVEL_ENTER(); @@ -294,33 +292,31 @@ void evel_json_encode_other(EVEL_JSON_BUFFER * jbuf, // iterate through hashtable and print DLIST for each entry + evel_json_checkpoint(jbuf); ht = event->namedarrays; if( ht != NULL ) { if( ht->size > 0) { - for( i = 0; i < ht->size; i++ ) { - if( ht->table[i] != NULL) - { - itm_added = true; - } - } - if( itm_added == true) - { - if (evel_json_open_opt_named_list(jbuf, "hashOfNameValuePairArrays")) - { - for( i = 0; i < ht->size; i++ ) { - if( ht->table[i] != NULL) + evel_json_open_opt_named_list(jbuf, "hashOfNameValuePairArrays"); + for( idx = 0; idx < ht->size; idx++ ) { + if( ht->table[idx] != NULL) { - itm_list = ht->table[i]; + entry = ht->table[idx]; + EVEL_DEBUG("Encoding other %s %p",(char *) (entry->key), entry->value); - if(evel_json_open_opt_named_list(jbuf, ht->table[i]->key)) - { - other_field_item = dlist_get_first(&itm_list); + evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, "name", entry->key); + + itm_list = (DLIST*)(entry->value); + evel_json_open_opt_named_list(jbuf, "arrayOfFields"); + + other_field_item = dlist_get_first(itm_list); while (other_field_item != NULL) { other_field = (OTHER_FIELD *) other_field_item->item; + EVEL_DEBUG("Encoding other %s %s",(char *)other_field->name,(char*)other_field->value); if(other_field != NULL){ evel_json_open_object(jbuf); evel_enc_kv_string(jbuf, "name", other_field->name); @@ -329,17 +325,15 @@ void evel_json_encode_other(EVEL_JSON_BUFFER * jbuf, other_field_item = dlist_get_next(other_field_item); } } - evel_json_close_list(jbuf); - } + evel_json_close_list(jbuf); + evel_json_close_object(jbuf); } - } - - evel_json_close_list(jbuf); - } - - } + evel_json_close_list(jbuf); + + } else { + evel_json_rewind(jbuf); } } @@ -428,23 +422,37 @@ void evel_json_encode_other(EVEL_JSON_BUFFER * jbuf, } + evel_json_checkpoint(jbuf); if( evel_json_open_opt_named_list(jbuf, "nameValuePairs")) { + bool item_added = false; + other_field_item = dlist_get_first(&event->namedvalues); while (other_field_item != NULL) { other_field = (OTHER_FIELD *) other_field_item->item; - assert(other_field != NULL); - - evel_json_open_object(jbuf); - evel_enc_kv_string(jbuf, "name", other_field->name); - evel_enc_kv_string(jbuf, "value", other_field->value); - evel_json_close_object(jbuf); + if(other_field != NULL) + { + evel_json_open_object(jbuf); + evel_enc_kv_string(jbuf, "name", other_field->name); + evel_enc_kv_string(jbuf, "value", other_field->value); + evel_json_close_object(jbuf); + item_added = true; + } other_field_item = dlist_get_next(other_field_item); } - } evel_json_close_list(jbuf); + /*************************************************************************/ + /* If we've not written anything, rewind to before we opened the list. */ + /*************************************************************************/ + if (!item_added) + { + evel_json_rewind(jbuf); + } + + } + evel_enc_version(jbuf, "otherFieldsVersion", event->major_version,event->minor_version); evel_json_close_object(jbuf); diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_reporting_measurement.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_reporting_measurement.c index 60fbad7..0f30372 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_reporting_measurement.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_reporting_measurement.c @@ -13,7 +13,7 @@ * 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. - * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_scaling_measurement.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_scaling_measurement.c index ef4537b..d484b2e 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_scaling_measurement.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_scaling_measurement.c @@ -13,7 +13,7 @@ * 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. - * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** * @file @@ -981,6 +981,25 @@ void evel_measurement_disk_use_mergewritemax_set(MEASUREMENT_DISK_USE * const di evel_set_option_double(&disk_use->mergewritemax, val, "Disk writemax set"); EVEL_EXIT(); } +/**************************************************************************//** + * Set number of logical write operations that were merged into physical read + * operations, e.g., two logical writes were served by one physical disk access; + * provide the average measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ +void evel_measurement_disk_use_mergewriteavg_set(MEASUREMENT_DISK_USE * const disk_use, + const double val) +{ + EVEL_ENTER(); + evel_set_option_double(&disk_use->mergewriteavg, val, "Disk writeavg set"); + EVEL_EXIT(); +} /**************************************************************************//** * Set number of logical write operations that were merged into physical read * operations, e.g., two logical writes were served by one physical disk access; diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_sipsignaling.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_sipsignaling.c index 6d4d5df..efc62db 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_sipsignaling.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_sipsignaling.c @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** * @file diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_strings.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_strings.c index 912537e..3f0e7a4 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_strings.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_strings.c @@ -13,7 +13,7 @@ * 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. - * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** * @file diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_syslog.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_syslog.c index c768e74..06d8163 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_syslog.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_syslog.c @@ -13,7 +13,7 @@ * 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. - * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** * @file diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_threshold_cross.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_threshold_cross.c index ecc4a65..c66b08c 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_threshold_cross.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_threshold_cross.c @@ -13,7 +13,7 @@ * 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. - * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** * @file diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_throttle.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_throttle.c index d6a366d..ac664a1 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_throttle.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_throttle.c @@ -13,7 +13,7 @@ * 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. - * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** @@ -125,6 +125,7 @@ static const char * const evel_json_token_strings[JSON_TOKEN_TYPES] = { /*****************************************************************************/ static const char * evel_domain_strings[EVEL_MAX_DOMAINS] = { "internal", + "batch", "heartbeat", "fault", "measurementsForVfScaling", @@ -134,7 +135,7 @@ static const char * evel_domain_strings[EVEL_MAX_DOMAINS] = { "signaling", "stateChange", "syslog", - "other" + "other", "voiceQuality", "maxDomain" }; diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_voicequality.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_voicequality.c index 4f37138..04238d1 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_voicequality.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/evel_voicequality.c @@ -13,7 +13,7 @@ * 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. - * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** * @file @@ -467,7 +467,6 @@ void evel_json_encode_voice_quality(EVEL_JSON_BUFFER * jbuf, DLIST_ITEM * addlInfoItem = NULL; END_OF_CALL_VOICE_QUALITY_METRICS * vQMetrics = NULL; - DLIST_ITEM * vQMetricsItem = NULL; EVEL_ENTER(); diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/hashtable.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/hashtable.c index 3ad0a78..d0017c9 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/hashtable.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/hashtable.c @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** * @file diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/jsmn.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/jsmn.c index bd3cf42..ae08569 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/jsmn.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/jsmn.c @@ -13,7 +13,7 @@ * 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. - * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ #include "jsmn.h" diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/license.md b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/license.md index 6a119a9..665344d 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/license.md +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/license.md @@ -11,7 +11,8 @@ This Licensing section describes licensing of IPR in the EVEL Library. Copyright © 2017 AT&T Intellectual Property. All rights reserved. -Unless otherwise specified, all software contained herein + +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 @@ -22,6 +23,7 @@ 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. + ECOMP is a trademark and service mark of AT&T Intellectual Property. ## libcurl {#lic_libcurl} diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/metadata.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/metadata.c index 460815b..b865074 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/metadata.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/metadata.c @@ -13,7 +13,7 @@ * 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. - * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** * @file @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -308,17 +309,59 @@ exit_label: return rc; } + /**************************************************************************//** * Initialize default values for vm_name and vm_uuid - for testing purposes. *****************************************************************************/ 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); + } + +} + +/**************************************************************************//** + * Initialize value for vm_name for all coming events + * @param source_name Source name string. + * Must confirm with EVEL source name standard + * @returns Status code + * @retval EVEL_SUCCESS On success + * @retval ::EVEL_ERR_CODES On failure. + *****************************************************************************/ +EVEL_ERR_CODES evel_set_source_name(char * src_name) +{ + if( src_name && src_name[0] ) + { + if( strlen(src_name) < MAX_METADATA_STRING ){ + strcpy(vm_name,src_name); + return EVEL_SUCCESS; + } else + EVEL_DEBUG("Event Source Name too long"); + } + else + EVEL_DEBUG("Invalid Event Source Name string"); + return EVEL_ERR_GEN_FAIL; } /**************************************************************************//** diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/ring_buffer.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/ring_buffer.c index db50a40..ad50874 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/ring_buffer.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/ring_buffer.c @@ -13,7 +13,7 @@ * 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. - * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** * @file diff --git a/veslibrary/ves_clibrary/evel/evel-library/code/evel_unit/evel_unit.c b/veslibrary/ves_clibrary/evel/evel-library/code/evel_unit/evel_unit.c index 8fd00e6..3cfb66b 100644 --- a/veslibrary/ves_clibrary/evel/evel-library/code/evel_unit/evel_unit.c +++ b/veslibrary/ves_clibrary/evel/evel-library/code/evel_unit/evel_unit.c @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ /**************************************************************************//** * @file diff --git a/veslibrary/ves_clibrary/evel/evel-test-collector/LICENSE.md b/veslibrary/ves_clibrary/evel/evel-test-collector/LICENSE.md index 8ed230a..a6642dc 100644 --- a/veslibrary/ves_clibrary/evel/evel-test-collector/LICENSE.md +++ b/veslibrary/ves_clibrary/evel/evel-test-collector/LICENSE.md @@ -13,8 +13,8 @@ * 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. - * ECOMP is a trademark and service mark of AT&T Intellectual Property. * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. ****************************************************************************/ diff --git a/veslibrary/ves_clibrary/evel/evel-test-collector/code/collector/LICENSE.TXT b/veslibrary/ves_clibrary/evel/evel-test-collector/code/collector/LICENSE.TXT index b9c68c6..16285cd 100644 --- a/veslibrary/ves_clibrary/evel/evel-test-collector/code/collector/LICENSE.TXT +++ b/veslibrary/ves_clibrary/evel/evel-test-collector/code/collector/LICENSE.TXT @@ -17,6 +17,6 @@ * limitations under the License. * ============LICENSE_END============================================ * - * ECOMP is trademark and service mark of AT&T Intellectual Property. + * ECOMP is trademark and service mark of AT&T Intellectual Property. * */ diff --git a/veslibrary/ves_clibrary/evel/evel-test-collector/code/collector/collector.py b/veslibrary/ves_clibrary/evel/evel-test-collector/code/collector/collector.py index 8e702aa..58bebc7 100644 --- a/veslibrary/ves_clibrary/evel/evel-test-collector/code/collector/collector.py +++ b/veslibrary/ves_clibrary/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 @@ -38,6 +38,7 @@ import string import json import jsonschema from functools import partial +import ssl _hello_resp = '''\ @@ -407,7 +408,8 @@ USAGE defaults = {'log_file': 'collector.log', 'vel_port': '12233', 'vel_path': '', - 'vel_topic_name': '' + 'vel_topic_name': '', + 'transport_prot': 'http' } overrides = {} config = ConfigParser.SafeConfigParser(defaults) @@ -419,9 +421,16 @@ USAGE log_file = config.get(config_section, 'log_file', vars=overrides) vel_port = config.get(config_section, 'vel_port', vars=overrides) vel_path = config.get(config_section, 'vel_path', vars=overrides) + transport_prot = config.get(config_section, 'protocol', vars=overrides) vel_topic_name = config.get(config_section, 'vel_topic_name', vars=overrides) + + if (transport_prot.lower() != 'http' and transport_prot.lower() != 'https' ): + logger.error('Invalid Transport must be http or https ({0}) ' + 'specified'.format(transport_prot)) + raise RuntimeError('Invalid Transport protcol specified ({0}) ' + 'specified'.format(transport_prot)) global vel_username global vel_password vel_username = config.get(config_section, @@ -457,6 +466,28 @@ USAGE handler = logging.handlers.RotatingFileHandler(log_file, maxBytes=1000000, backupCount=10) + + if (transport_prot.lower() == 'https' ): + transport_prot = transport_prot.lower() + ca_file = config.get(config_section, 'ca_file', vars=overrides) + cert_file = config.get(config_section, 'cert_file', vars=overrides) + key_file = config.get(config_section, 'key_file', vars=overrides) + if not os.path.exists(ca_file): + logger.error('Event Listener SSL CA File ({0}) not found. ' + 'No validation will be undertaken.'.format(ca_file)) + raise RuntimeError('Invalid CA file ({0}) ' + 'specified'.format(ca_file)) + if not os.path.exists(cert_file): + logger.error('Event Listener SSL Certificate File ({0}) not found. ' + 'No validation will be undertaken.'.format(cert_file)) + raise RuntimeError('Invalid Certificate file ({0}) ' + 'specified'.format(cert_file)) + if not os.path.exists(key_file): + logger.error('Event Listener SSL Key File ({0}) not found. ' + 'No validation will be undertaken.'.format(key_file)) + raise RuntimeError('Invalid Key file ({0}) ' + 'specified'.format(key_file)) + if (platform.system() == 'Windows'): date_format = '%Y-%m-%d %H:%M:%S' else: @@ -472,6 +503,7 @@ USAGE # Log the details of the configuration. #---------------------------------------------------------------------- logger.debug('Log file = {0}'.format(log_file)) + logger.debug('Event Listener Transport = {0}'.format(transport_prot)) logger.debug('Event Listener Port = {0}'.format(vel_port)) logger.debug('Event Listener Path = {0}'.format(vel_path)) logger.debug('Event Listener Topic = {0}'.format(vel_topic_name)) @@ -562,11 +594,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) @@ -582,6 +619,10 @@ USAGE dispatcher.register('GET', test_control_url, test_control_listener) httpd = make_server('', int(vel_port), dispatcher) + if (transport_prot == 'https' ): + #httpd.socket = ssl.wrap_socket(httpd.socket, server_side=True, ca_certs = "../../../sslcerts/test.ca.pem", certfile="../../../sslcerts/www.testsite.com.crt", keyfile="../../../sslcerts/www.testsite.com.key", cert_reqs=ssl.CERT_REQUIRED, ssl_version=ssl.PROTOCOL_TLSv1_2) + logger.debug('Invoking HTTP Secure mode : ca file {0} cert file {1} key file {2} '.format(ca_file,cert_file,key_file)) + httpd.socket = ssl.wrap_socket(httpd.socket, server_side=True, ca_certs=ca_file, certfile=cert_file, keyfile=key_file, cert_reqs=ssl.CERT_REQUIRED, ssl_version=ssl.PROTOCOL_TLSv1_2) print('Serving on port {0}...'.format(vel_port)) httpd.serve_forever() diff --git a/veslibrary/ves_clibrary/evel/evel-test-collector/code/collector/rest_dispatcher.py b/veslibrary/ves_clibrary/evel/evel-test-collector/code/collector/rest_dispatcher.py index e3b51aa..e00465a 100644 --- a/veslibrary/ves_clibrary/evel/evel-test-collector/code/collector/rest_dispatcher.py +++ b/veslibrary/ves_clibrary/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/veslibrary/ves_clibrary/evel/evel-test-collector/config/collector.conf b/veslibrary/ves_clibrary/evel/evel-test-collector/config/collector.conf index 3e23c59..6654428 100644 --- a/veslibrary/ves_clibrary/evel/evel-test-collector/config/collector.conf +++ b/veslibrary/ves_clibrary/evel/evel-test-collector/config/collector.conf @@ -60,6 +60,11 @@ vel_path = vendor_event_listener/ vel_username = vel_password = vel_topic_name = example_vnf +protocol = HTTP +#protocol = HTTPS +#ca_file = ../../../sslcerts/test.ca.pem +#cert_file = ../../../sslcerts/www.testsite.com.crt +#key_file = ../../../sslcerts/www.testsite.com.key #------------------------------------------------------------------------------ # Settings to be used when running in a windows test environment rather than @@ -96,4 +101,9 @@ vel_path = vel_username = will vel_password = pill vel_topic_name = +protocol = HTTP +#protocol = HTTPS +#ca_file = ../../../sslcerts/test.ca.pem +#cert_file = ../../../sslcerts/www.testsite.com.crt +#key_file = ../../../sslcerts/www.testsite.com.key diff --git a/veslibrary/ves_clibrary/evel/evel-test-collector/docs/att_interface_definition/event_format_updated.json b/veslibrary/ves_clibrary/evel/evel-test-collector/docs/att_interface_definition/event_format_updated.json index 82339b0..ccfcd25 100644 --- a/veslibrary/ves_clibrary/evel/evel-test-collector/docs/att_interface_definition/event_format_updated.json +++ b/veslibrary/ves_clibrary/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" @@ -1341,7 +1340,7 @@ } } }, - "required": [ "name", "measurements" ] + "required": [ "name", "arrayOfFields" ] }, "otherFields": { "description": "fields for events belonging to the 'other' domain of the commonEventHeader domain enumeration", @@ -1693,11 +1692,11 @@ "type": "string" }, "vfModuleName": { - "description": "ASDC vfModuleName for the vfModule generating the event", + "description": "SDC vfModuleName for the vfModule generating the event", "type": "string" }, "vnfName": { - "description": "ASDC modelName for the VNF generating the event", + "description": "SDC modelName for the VNF generating the event", "type": "string" } }, diff --git a/veslibrary/ves_clibrary/evel/evel-test-collector/docs/ssl_certsample b/veslibrary/ves_clibrary/evel/evel-test-collector/docs/ssl_certsample new file mode 100644 index 0000000..f828177 --- /dev/null +++ b/veslibrary/ves_clibrary/evel/evel-test-collector/docs/ssl_certsample @@ -0,0 +1,15 @@ +# Generate CA key and certificate +openssl genrsa -des3 -out test.ca.key 8192 +openssl req -new -key test.ca.key -x509 -days 30 -out test.ca.crt + +# Generate server key and certificate +openssl genrsa -out www.testsite.com.key 1024 +openssl req -new -key www.testsite.com.key -out www.testsite.com.csr +openssl x509 -req -days 30 -in www.testsite.com.csr -CA test.ca.crt -CAkey test.ca.key -CAcreateserial -out www.testsite.com.crt + +# Generate client key and certificate +openssl genrsa -out testclient.key 1024 +openssl req -new -key testclient.key -out testclient.csr +openssl x509 -req -days 30 -in testclient.csr -CA test.ca.crt -CAkey test.ca.key -CAcreateserial -out testclient.crt + +openssl pkcs12 -export -clcerts -in testclient.crt -inkey testclient.key -out testclient.p12 -- cgit 1.2.3-korg