summaryrefslogtreecommitdiffstats
path: root/veslibrary/ves_clibrary/evel/evel-library/code/evel_library/metadata.c
diff options
context:
space:
mode:
authorChris Donley <christopher.donley@huawei.com>2018-03-29 15:57:25 +0000
committerGerrit Code Review <gerrit@onap.org>2018-03-29 15:57:25 +0000
commitf2e67cf2d7f790c039ebb4b9cfb56f69b2b78dbe (patch)
tree1cbd76e662393d1cbf66b3b57530d68c10ee65da /veslibrary/ves_clibrary/evel/evel-library/code/evel_library/metadata.c
parentfec86afca1c91fef717f2ab09555ff9f29956bb8 (diff)
parentc076f7ddb4cc27a3f626e5c9c96084f8109b6330 (diff)
Merge "Update C library with https batch"
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;
}
/**************************************************************************//**