summaryrefslogtreecommitdiffstats
path: root/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/metadata.c
diff options
context:
space:
mode:
authorGokul Singaraju <gs244f@att.com>2018-03-29 00:35:42 -0400
committerGokul Singaraju <gs244f@att.com>2018-03-29 00:37:49 -0400
commitc076f7ddb4cc27a3f626e5c9c96084f8109b6330 (patch)
tree4a76f334ec79377435398db8d373f5864e6c39f4 /veslibrary/ves_clibrary/evel/evel-library/code/evel_library/metadata.c
parent628dd1bb98a25508f6fae41fe4ab249338abf53b (diff)
Update C library with https batch
Issue-ID: VNFSDK-122 Change-Id: I74556357e5fb534f64476edf34395343453a96e5 Signed-Off-by: Gokul Singaraju <gs244f@att.com>
Diffstat (limited to 'veslibrary/ves_clibrary/evel/evel-library/code/evel_library/metadata.c')
-rw-r--r--veslibrary/ves_clibrary/evel/evel-library/code/evel_library/metadata.c45
1 files changed, 44 insertions, 1 deletions
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 <string.h>
#include <assert.h>
#include <malloc.h>
+#include <unistd.h>
#include <curl/curl.h>
@@ -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;
}
/**************************************************************************//**