-{
- "service_ports":{
- "xapp_port":4560,
- "rmr_port":4561
- },
-
- "rmr":{
- "protPort": "tcp:4560",
- "maxSize": 2072,
- "numWorkers": 1,
- "txMessages": ["RIC_SUB_REQ", "RIC_SUB_DEL_REQ", "RIC_CONTROL_REQ", "A1_POLICY_RESP", "A1_POLICY_QUERY","RIC_HEALTH_CHECK_RESP"],
- "rxMessages": ["RIC_SUB_RESP", "RIC_SUB_FAILURE", "RIC_SUB_DEL_RESP", "RIC_SUB_DEL_FAILURE", "RIC_INDICATION", "RIC_CONTROL_ACK", "RIC_CONTROL_FAILURE","RIC_HEALTH_CHECK_REQ", "A1_POLICY_REQ"],
- "policies": ["1","00000"],
- "file_path":"/tmp/routeinfo/routes.txt",
- "contents": "newrt|start\nrte|0|127.0.0.1:4560\nrte|100|127.0.0.1:4560\nrte|2|127.0.0.1:38000\nrte|10002|127.0.0.1:4560\nrte|10005|127.0.0.1:4560\nrte|10003|127.0.0.1:38000\nrte|12010|127.0.0.1:38000\nrte|12020|127.0.0.1:38000\nrte|12011|127.0.0.1:4560\nrte|12012|127.0.0.1:4560\nrte|12021|127.0.0.1:4560\nrte|12022|127.0.0.1:4560\nrte|20000|127.0.0.1:4560\nrte|12040|127.0.0.1:38000\nrte|20001|127.0.0.1:4566\nrte|20010|127.0.0.1:4560\nrte|20012|127.0.0.1:4560\nnewrt|end"
- },
-
- "envs":{
- "RMR_SEED_RT":"/tmp/routeinfo/routes.txt",
- "RMR_RTG_SVC":"9999",
- "DBAAS_SERVICE_HOST":"127.0.0.1",
- "DBAAS_SERVICE_PORT":"6379",
- "XAPP_NAME":"HELLOWORLD_XAPP",
- "HW_PORTS":"4560",
- "MSG_MAX_BUFFER":"2048",
- "THREADS":"1",
- "VERBOSE":"0",
- "CONFIG_FILE":"config-file.json",
- "GNODEB":"NYC123",
- "XAPP_ID":"3489-er492k-92389",
- "A1_SCHEMA_FILE":"schemas/hwxapp-policy.json",
- "VES_SCHEMA_FILE":"schemas/hwxapp-ves.json",
- "VES_COLLECTOR_URL":"127.0.0.1:6350",
- "VES_MEASUREMENT_INTERVAL":"10",
- "LOG_LEVEL":"MDCLOG_ERR",
- "OPERATING_MODE":"REPORT"
-
- }
-}
+{\r
+ "config-file.json": {\r
+ "xapp_name": "hwxapp",\r
+ "version": "1.0.0",\r
+ "containers": [\r
+ {\r
+ "name": "hwxapp",\r
+ "image": {\r
+ "registry": "nexus3.o-ran-sc.org:10002",\r
+ "name": "o-ran-sc/ric-app-hw",\r
+ "tag": "0.0.1"\r
+ },\r
+ "command": "python3 init.py config-file.json"\r
+ }\r
+ ],\r
+ "livenessProbe": {\r
+ "exec": {\r
+ "command": [\r
+ "/usr/local/bin/health_ck"\r
+ ]\r
+ },\r
+ "initialDelaySeconds": 5,\r
+ "periodSeconds": 15\r
+ },\r
+ "messaging": {\r
+ "ports": [\r
+ {\r
+ "name": "rmr-data",\r
+ "container": "hwxapp",\r
+ "port": 4560,\r
+ "rxMessages": [ \r
+ "RIC_SUB_RESP", \r
+ "RIC_SUB_FAILURE", \r
+ "RIC_SUB_DEL_RESP", "RIC_SUB_DEL_FAILURE", "RIC_INDICATION", "RIC_CONTROL_ACK", "RIC_CONTROL_FAILURE", "A1_POLICY_REQ", "RIC_HEALTH_CHECK_REQ" \r
+ ],\r
+ "txMessages": [ "RIC_SUB_REQ", "RIC_SUB_DEL_REQ", "RIC_CONTROL_REQ", "A1_POLICY_RESP", "A1_POLICY_QUERY", "RIC_HEALTH_CHECK_RESP" ],\r
+ "policies": [1],\r
+ "description": "rmr receive data port for HWxapp"\r
+ },\r
+ {\r
+ "name": "rmr-route",\r
+ "container": "hwxapp",\r
+ "port": 4561,\r
+ "description": "rmr route port for hwxapp"\r
+ }\r
+ ]\r
+ },\r
+ "controls": {\r
+ "ves_collector_address": "xapp-sandbox2.research.att.com:8888"\r
+ },\r
+ "rmr": {\r
+ "protPort": "tcp:4560",\r
+ "maxSize": 2072,\r
+ "numWorkers": 1,\r
+ "txMessages": [\r
+ "RIC_SUB_REQ", "RIC_SUB_DEL_REQ", "RIC_CONTROL_REQ", "A1_POLICY_RESP", "A1_POLICY_QUERY", "RIC_HEALTH_CHECK_RESP"\r
+ ],\r
+ "rxMessages": [\r
+ "RIC_SUB_RESP", \r
+ "RIC_SUB_FAILURE", \r
+ "RIC_SUB_DEL_RESP", "RIC_SUB_DEL_FAILURE", "RIC_INDICATION", "RIC_CONTROL_ACK", "RIC_CONTROL_FAILURE", "A1_POLICY_REQ", "RIC_HEALTH_CHECK_REQ" \r
+ ]\r
+ }\r
+ },\r
+ "controls-schema.json": {\r
+ "$schema": "http://json-schema.org/draft-07/schema#",\r
+ "$id": "#/controls",\r
+ "type": "object",\r
+ "title": "Controls Section Schema",\r
+ "required": [],\r
+ "properties": {\r
+ "ves_collector_address": {\r
+ "$id": "#/controls/ves_collector_address",\r
+ "type": "string",\r
+ "title": "ves_collector_address",\r
+ "default": "localhost:8080",\r
+ "examples": [\r
+ "localhost:8080"\r
+ ]\r
+ }\r
+ }\r
+ }\r
+}
\ No newline at end of file
def parseConfigJson(config):
- for key in config:
- print("Processing ", key);
- if key in ParseSection:
- result = ParseSection[key](config);
- if result == False:
- return False;
+ for k1 in config.keys():
+ for k2 in config[k1].keys():
+ #print(k2);
+ if k2 in ParseSection:
+ result = ParseSection[k2](config[k1]);
+ if result == False:
+ return False;
-
-def getRMRTable(config):
- myKey= "rmr";
- if myKey not in config:
- print(("Error ! No information found for {0} in config\n".format(myKey)));
- return False;
- # Get the rmr routing table
- if "file_path" not in config[myKey]:
- print(("Warning ! No file path specified to store seed routing table. Choosing default = {1}\n".format(default_routing_file)));
- route_file = default_routing_file;
- else:
- route_file = config[myKey]["file_path"];
-
- # Get the rmr routing table contents
- if "contents" not in config[myKey]:
- print("No contents for routing table found in config");
- return False;
- else:
- route_contents = config[myKey]["contents"];
- # Get directory : if not exists create it
- directory = os.path.dirname(route_file);
- if not os.path.exists(directory):
- # create directory
- try:
- os.mkdir(directory);
- except OSError as oe:
- print(("Error making directory {0}. Reason = {1}\n".format(directory, oe)));
- return False;
-
- # Write contents to file
- try:
- with open(route_file, "w") as f :
- f.write(config[myKey]["contents"]);
- f.close();
- except Exception as e:
- print(("Error writing contents to file {0}. Reason = {1}\n".format(route_file, e)));
- return False;
-
- # Set the environment variable
- os.environ["RMR_SEED_RT"] = route_file;
-
-def getPort(config):
- myKey = "service_ports";
- if myKey not in config:
+def getMessagingInfo(config):
+ if 'messaging' in config.keys() and 'ports' in config['messaging'].keys():
+ port_list = config['messaging']['ports']
+ for portdesc in port_list :
+ if 'port' in portdesc.keys() and 'name' in portdesc.keys() and portdesc['name'] == 'rmr-data':
+ lport = portdesc['port']
+ # Set the environment variable
+ os.environ["HW_PORT"] = str(lport)
+ return True;
+ if lport == 0:
+ print("Error! No valid listening port");
+ return False;
+
+def getXappName(config):
+ myKey = "xapp_name";
+ if myKey not in config.keys():
print(("Error ! No information found for {0} in config\n".format(myKey)));
return False;
- port_config = config[myKey];
- if "xapp_port" in port_config:
- try:
- xapp_port = int(port_config["xapp_port"]);
- if xapp_port < 1024:
- raise Exception("Port must be > 1024");
- except Exception as e:
- print(("Error processing xapp port {0}. Reason = {1}\n".format(port_config["xapp_port"], e)));
- return False;
- else:
- xapp_port = 0;
-
-
-def getEnvs(config):
- myKey = "envs";
- if myKey not in config:
- print(("Error ! No information found for {0} in config\n".format(myKey)));
- return False;
-
- env_config = config[myKey];
-
- for env_key in env_config:
- os.environ[env_key] = env_config[env_key];
- print("Set environment variable {0} = {1}\n".format(env_key, os.environ[env_key]));
-
- return True;
-
-
-# Global variables ...
-xapp_subprocess = None;
-xapp_pid = None;
-ParseSection = {};
-xapp_port = 0;
-ParseSection["rmr"] = getRMRTable;
-ParseSection["envs"] = getEnvs;
+ xapp_name = config[myKey];
+ os.environ["XAPP_NAME"] = xapp_name;
default_routing_file = "/tmp/routeinfo/routes.txt";
+lport = 0;
+ParseSection = {};
+ParseSection["xapp_name"] = getXappName;
+ParseSection["messaging"] = getMessagingInfo;
#================================================================
import subprocess;
# cmd = ["../src/hw_xapp_main"];
cmd = ["/usr/local/bin/hw_xapp_main"];
- if xapp_port > 0:
- cmd.append("-p");
- cmd.append(xapp_port);
if len(sys.argv) > 1:
config_file = sys.argv[1];
sys.exit(1);
result = parseConfigJson(config);
-
+ time.sleep(10);
if result == False:
print("Error parsing json. Not executing xAPP");
sys.exit(1);
--- /dev/null
+newrt|start
+rte|100|127.0.0.1:4560
+rte|101|127.0.0.1:38000
+rte|20010|127.0.0.1:4560
+rte|20011|127.0.0.1:38000
+rte|20012|127.0.0.1:4560
+rte|12010|127.0.0.1:38000
+rte|12011|127.0.0.1:4560
+rte|12012|127.0.0.1:4560
+rte|12020|127.0.0.1:38000
+rte|12021|127.0.0.1:4560
+rte|12022|127.0.0.1:4560
+newrt|end