HelloWorld E2SM source
[ric-app/hw.git] / src / xapp-utils / xapp_config.cc
index f9a4640..8f1ef67 100644 (file)
@@ -1,7 +1,7 @@
 /*
 ==================================================================================
 
-        Copyright (c) 2018-2019 AT&T Intellectual Property.
+        Copyright (c) 2019-2020 AT&T Intellectual Property.
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
@@ -37,12 +37,8 @@ void XappSettings::loadCmdlineSettings(int argc, char **argv){
                                {"xappid", required_argument, 0, 'x'},
                                {"port", required_argument, 0, 'p'},
                                {"threads", required_argument,    0, 't'},
-                               {"a1-schema", required_argument, 0, 'a'},
-                               {"ves-schema", required_argument, 0, 'v'},
-                               {"ves-url", required_argument, 0, 'u'},
                                {"ves-interval", required_argument, 0, 'i'},
-                               {"gNodeB", required_argument, 0, 'g'},
-                               {"opmode", required_argument, 0, 'c'}
+                               {"gNodeB", required_argument, 0, 'g'}
 
            };
 
@@ -64,7 +60,7 @@ void XappSettings::loadCmdlineSettings(int argc, char **argv){
                    break;
 
                  case 'p':
-                   theSettings[HW_PORTS].assign(optarg);
+                   theSettings[HW_PORT].assign(optarg);
                    break;
 
                  case 't':
@@ -72,41 +68,12 @@ void XappSettings::loadCmdlineSettings(int argc, char **argv){
                    mdclog_write(MDCLOG_INFO, "Number of threads set to %s from command line e\n", theSettings[THREADS].c_str());
                    break;
 
-                 case 'a':
-                       theSettings[A1_SCHEMA_FILE].assign(optarg);
-                   mdclog_write(MDCLOG_INFO, "Schema file set to %s from command line ", theSettings[A1_SCHEMA_FILE].c_str());
-                   break;
-
-                 case 'v':
-                   theSettings[VES_SCHEMA_FILE].assign(optarg);
-                   mdclog_write(MDCLOG_INFO, "VES Schema file set to %s from command line ", theSettings[VES_SCHEMA_FILE].c_str());
-                   break;
-
-                 case 'c':
-                   theSettings[OPERATING_MODE].assign(optarg);
-                   mdclog_write(MDCLOG_INFO, "Operating mode set from command line to %s\n", theSettings[OPERATING_MODE].c_str());
-                   break;
-
-                 case 'u':
-                   theSettings[VES_COLLECTOR_URL].assign(optarg);
-                   mdclog_write(MDCLOG_INFO, "VES collector url set to %s from command line ", theSettings[VES_COLLECTOR_URL].c_str());
-                   break;
 
                  case 'x':
                    theSettings[XAPP_ID].assign(optarg);
                    mdclog_write(MDCLOG_INFO, "XAPP ID set to  %s from command line ", theSettings[XAPP_ID].c_str());
                    break;
 
-                 case 'i':
-                       theSettings[VES_MEASUREMENT_INTERVAL].assign(optarg);
-                   mdclog_write(MDCLOG_INFO, "Measurement interval set to %s from command line\n", theSettings[VES_MEASUREMENT_INTERVAL].c_str());
-                   break;
-
-                 case 'g':
-                   theSettings[GNODEB].assign(optarg);
-                   mdclog_write(MDCLOG_INFO, "gNodeB List set to %s from command line ", theSettings[GNODEB].c_str());
-                   break;
-
                  case 'h':
                    usage(argv[0]);
                    exit(0);
@@ -123,45 +90,26 @@ void XappSettings::loadDefaultSettings(){
 
 
                 if(theSettings[XAPP_NAME].empty()){
-                 theSettings[XAPP_NAME] = DEFAULT_PORT;
+                 theSettings[XAPP_NAME] = DEFAULT_XAPP_NAME;
                  }
 
                  if(theSettings[XAPP_ID].empty()){
-                         theSettings[XAPP_ID] = DEFAULT_PORT;
+                         theSettings[XAPP_ID] = DEFAULT_XAPP_NAME; //for now xapp_id is same as xapp_name since single xapp instance.
                  }
                  if(theSettings[LOG_LEVEL].empty()){
                          theSettings[LOG_LEVEL] = DEFAULT_LOG_LEVEL;
                  }
-                 if(theSettings[HW_PORTS].empty()){
-                         theSettings[HW_PORTS] = DEFAULT_PORT;
+                 if(theSettings[HW_PORT].empty()){
+                         theSettings[HW_PORT] = DEFAULT_PORT;
                  }
                  if(theSettings[MSG_MAX_BUFFER].empty()){
-                         theSettings[MSG_MAX_BUFFER] = DEFAULT_BUFFER;
-                 }
-
-                 if(theSettings[A1_SCHEMA_FILE].empty()){
-                         theSettings[A1_SCHEMA_FILE] = DEFAULT_A1_SCHEMA_FILE;
+                         theSettings[MSG_MAX_BUFFER] = DEFAULT_MSG_MAX_BUFFER;
                  }
 
-                 if(theSettings[VES_SCHEMA_FILE].empty()){
-                         theSettings[VES_SCHEMA_FILE] = DEFAULT_VES_SCHEMA_FILE;
-                 }
+                if(theSettings[THREADS].empty()){
+                                         theSettings[THREADS] = DEFAULT_THREADS;
+                                 }
 
-                 if(theSettings[VES_COLLECTOR_URL].empty()){
-                         theSettings[VES_COLLECTOR_URL] = DEFAULT_VES_COLLECTOR_URL;
-                 }
-
-                if(theSettings[VES_MEASUREMENT_INTERVAL].empty()){
-                         theSettings[VES_MEASUREMENT_INTERVAL] = DEFAULT_VES_MEASUREMENT_INTERVAL;
-                 }
-
-                if(theSettings[GNODEB].empty()){
-                         theSettings[GNODEB] = DEFAULT_GNODEB;
-                 }
-
-                if(theSettings[OPERATING_MODE].empty()){
-                         theSettings[OPERATING_MODE] = DEFAULT_OPERATING_MODE;
-                 }
 
 }
 
@@ -176,39 +124,15 @@ void XappSettings::loadEnvVarSettings(){
                   mdclog_write(MDCLOG_INFO,"Xapp ID set to %s from environment variable", theSettings[XAPP_ID].c_str());
          }
 
-         if (const char *env_ports = std::getenv("HW_PORTS")){
-                 theSettings[HW_PORTS].assign(env_ports);
-                 mdclog_write(MDCLOG_INFO,"Ports set to %s from environment variable", theSettings[HW_PORTS].c_str());
+         if (const char *env_ports = std::getenv("HW_PORT")){
+                 theSettings[HW_PORT].assign(env_ports);
+                 mdclog_write(MDCLOG_INFO,"Ports set to %s from environment variable", theSettings[HW_PORT].c_str());
          }
          if (const char *env_ports = std::getenv("MSG_MAX_BUFFER")){
                          theSettings[MSG_MAX_BUFFER].assign(env_ports);
                          mdclog_write(MDCLOG_INFO,"Ports set to %s from environment variable", theSettings[MSG_MAX_BUFFER].c_str());
                  }
 
-        if (const char *env_schema = std::getenv("A1_SCHEMA_FILE")){
-                 theSettings[A1_SCHEMA_FILE].assign(env_schema);
-                 mdclog_write(MDCLOG_INFO, "A1 Schema file set to %s from environment variable", theSettings[A1_SCHEMA_FILE].c_str());
-         }
-         if (const char *env_schema = std::getenv("VES_SCHEMA_FILE")){
-                 theSettings[VES_SCHEMA_FILE].assign(env_schema);
-                 mdclog_write(MDCLOG_INFO, "VES Schema file set to %s from environment variable", theSettings[VES_SCHEMA_FILE].c_str());
-         }
-         if (const char *env_schema = std::getenv("VES_COLLECTOR_URL")){
-                 theSettings[VES_COLLECTOR_URL].assign(env_schema);
-                 mdclog_write(MDCLOG_INFO, "VES Collector url set to %s from environment variable", theSettings[VES_COLLECTOR_URL].c_str());
-
-         }
-         if (const char *env_schema = std::getenv("VES_MEASUREMENT_INTERVAL")){
-                 theSettings[VES_MEASUREMENT_INTERVAL].assign(env_schema);
-                 mdclog_write(MDCLOG_INFO, "VES Measurement Interval set to %s from environment variable", theSettings[VES_MEASUREMENT_INTERVAL].c_str());
-         }
-
-         if (char *env_gnodeb = std::getenv("GNODEB")){
-                 theSettings[GNODEB].assign(env_gnodeb);
-                 mdclog_write(MDCLOG_INFO, "GNODEB file set to %s from environment variable", theSettings[GNODEB].c_str());
-         }
-
-
 }
 
 void XappSettings::usage(char *command){
@@ -216,11 +140,5 @@ void XappSettings::usage(char *command){
        std::cout <<" --name[-n] xapp_instance_name "<< std::endl;
     std::cout <<" --port[-p] port to listen on e.g tcp:4561  "<< std::endl;
     std::cout << "--threads[-t] number of listener threads "<< std::endl ;
-    std::cout << "--a1-schema[-a] a1 schema file location" << std::endl;
-    std::cout << "--ves-schema[-v] ves schema file location" << std::endl;
-    std::cout << "--samples [-s]  samples file location with samples for all jsons" << std::endl;
-    std::cout << "--ves-url [-u] ves collector url" << std::endl;
-    std::cout << "--gNodeB[][-g] gNodeB" << std::endl;
-    std::cout << "--interval[-i] measurement interval to send to ves collector (in seconds)" << std::endl;
-    std::cout << "--opmode [-c] type of operatoring mode : either REPORT or CONTROL. In REPORT, does not send a control message back to gNodeB" << std::endl;
+
 }