First commit

This commit is contained in:
Leonardo Bonati
2021-12-08 20:17:46 +00:00
commit 60dffad583
2923 changed files with 463894 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
##############################################################################
#
# Copyright (c) 2019 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.
# 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.
#
##############################################################################
#
# This source code is part of the near-RT RIC (RAN Intelligent Controller)
# platform project (RICP).
#
import config
import redis
import time
def flush():
c = config.redis_ip_address
p = config.redis_ip_port
r = redis.Redis(host=c, port=p, db=0)
r.flushall()
r.set("{e2Manager},E2TAddresses", "[\"10.0.2.15:38000\"]")
r.set("{e2Manager},E2TInstance:10.0.2.15:38000","{\"address\":\"10.0.2.15:38000\",\"associatedRanList\":[],\"keepAliveTimestamp\":" + str(int((time.time()+2) * 1000000000)) + ",\"state\":\"ACTIVE\",\"deletionTimeStamp\":0}")
return True

View File

@@ -0,0 +1,24 @@
##############################################################################
#
# Copyright (c) 2019 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.
# 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.
#
##############################################################################
#
# This source code is part of the near-RT RIC (RAN Intelligent Controller)
# platform project (RICP).
#
redis_ip_address = 'localhost'
redis_ip_port = 6379

View File

@@ -0,0 +1,73 @@
##############################################################################
#
# Copyright (c) 2019 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.
# 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.
#
##############################################################################
import config
import redis
import cleanup_db
import json
def getRedisClientDecodeResponse():
c = config.redis_ip_address
p = config.redis_ip_port
return redis.Redis(host=c, port=p, db=0, decode_responses=True)
def verify_ran_is_associated_with_e2t_instance(ranName, e2tAddress):
r = getRedisClientDecodeResponse()
e2tInstanceJson = r.get("{e2Manager},E2TInstance:"+e2tAddress)
e2tInstanceDic = json.loads(e2tInstanceJson)
assocRanList = e2tInstanceDic.get("associatedRanList")
return ranName in assocRanList
def verify_e2t_instance_has_no_associated_rans(e2tAddress):
r = getRedisClientDecodeResponse()
e2tInstanceJson = r.get("{e2Manager},E2TInstance:"+e2tAddress)
e2tInstanceDic = json.loads(e2tInstanceJson)
assocRanList = e2tInstanceDic.get("associatedRanList")
return not assocRanList
def verify_e2t_instance_exists_in_addresses(e2tAddress):
r = getRedisClientDecodeResponse()
e2tAddressesJson = r.get("{e2Manager},E2TAddresses")
e2tAddresses = json.loads(e2tAddressesJson)
return e2tAddress in e2tAddresses
def verify_e2t_instance_key_exists(e2tAddress):
r = getRedisClientDecodeResponse()
return r.exists("{e2Manager},E2TInstance:"+e2tAddress)
def populate_e2t_instances_in_e2m_db_for_get_e2t_instances_tc():
r = getRedisClientDecodeResponse()
r.set("{e2Manager},E2TAddresses", "[\"e2t.att.com:38000\",\"e2t.att.com:38001\"]")
r.set("{e2Manager},E2TInstance:e2t.att.com:38000", "{\"address\":\"e2t.att.com:38000\",\"associatedRanList\":[\"test1\",\"test2\",\"test3\"],\"keepAliveTimestamp\":1577619310484022369,\"state\":\"ACTIVE\"}")
r.set("{e2Manager},E2TInstance:e2t.att.com:38001", "{\"address\":\"e2t.att.com:38001\",\"associatedRanList\":[],\"keepAliveTimestamp\":1577619310484022369,\"state\":\"ACTIVE\"}")
return True
# def dissociate_ran_from_e2tInstance(ranName, e2tAddress):
# r = getRedisClientDecodeResponse()
# e2tInstanceJson = r.get("{e2Manager},E2TInstance:"+e2tAddress)
# e2tInstanceDic = json.loads(e2tInstanceJson)
# assocRanList = e2tInstanceDic.get("associatedRanList")
# print(assocRanList)
# assocRanList.remove(ranName)
# updatedE2tInstanceJson = json.dumps(e2tInstanceDic)
# print(updatedE2tInstanceJson)
# r.set("{e2Manager},E2TInstance:"+e2tAddress, updatedE2tInstanceJson)
# nodebBytes = r.get("{e2Manager},RAN:"+ranName)
# encoded = nodebBytes.decode().replace(e2tAddress,"").encode()
# r.set("{e2Manager},RAN:"+ranName, encoded)

View File

@@ -0,0 +1,58 @@
##############################################################################
#
# Copyright (c) 2019 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.
# 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.
#
##############################################################################
import config
import redis
def getRedisClientDecodeResponse():
c = config.redis_ip_address
p = config.redis_ip_port
return redis.Redis(host=c, port=p, db=0, decode_responses=True)
def verify_e2t_addresses_key():
r = getRedisClientDecodeResponse()
value = "[\"10.0.2.15:38000\"]"
return r.get("{e2Manager},E2TAddresses") == value
def verify_e2t_instance_key():
r = getRedisClientDecodeResponse()
e2_address = "\"address\":\"10.0.2.15:38000\""
e2_associated_ran_list = "\"associatedRanList\":[]"
e2_state = "\"state\":\"ACTIVE\""
e2_db_instance = r.get("{e2Manager},E2TInstance:10.0.2.15:38000")
if e2_db_instance.find(e2_address) < 0:
return False
if e2_db_instance.find(e2_associated_ran_list) < 0:
return False
if e2_db_instance.find(e2_state) < 0:
return False
return True

View File

@@ -0,0 +1,40 @@
##############################################################################
#
# Copyright (c) 2019 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.
# 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.
#
##############################################################################
#
# This source code is part of the near-RT RIC (RAN Intelligent Controller)
# platform project (RICP).
#
def find_error(directory,filename, message):
path = '/'
file_path = directory + path + filename
f = open(file_path, 'r')
for l in f:
if l.find(message) > 0:
return True
return False

View File

@@ -0,0 +1,43 @@
##############################################################################
#
# Copyright (c) 2019 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.
# 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.
#
##############################################################################
#
# This source code is part of the near-RT RIC (RAN Intelligent Controller)
# platform project (RICP).
#
def verify_logs(directory,filename,mtype,meid):
path = '/'
file_path = directory + path + filename
f = open(file_path, 'r')
for l in f:
if (meid is not None):
if l.find(mtype) > 0 and l.find(meid) > 0:
return True
else:
if l.find(mtype) > 0:
return True
return False

View File

@@ -0,0 +1,59 @@
##############################################################################
#
# Copyright (c) 2019 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.
# 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.
#
##############################################################################
#
# This source code is part of the near-RT RIC (RAN Intelligent Controller)
# platform project (RICP).
#
import config
import redis
import cleanup_db
def add():
c = config.redis_ip_address
p = config.redis_ip_port
r = redis.Redis(host=c, port=p, db=0)
cleanup_db.flush()
r.set("{e2Manager},ENB:02f829:007a80", "\n\x05test1\x12\t10.0.2.15\x18\xc9+ \x01*\x10\n\x0602f829\x12\x06007a800\x01:3\b\x01\x12/\bc\x12\x0f02f829:0007ab50\x1a\x040102\"\x0602f829*\n\n\b\b\x01\x10\x01\x18\x04 \x040\x01")
r.set("{e2Manager},RAN:test1","\x12\t10.0.2.15\x18\xc9+ \x03H\x01R\x02\b\t")
r.set("{e2Manager},PCI:test1:63" , "\b\x01\x12/\bc\x12\x0f02f829:0007ab50\x1a\x040102\"\x0602f829*\n\n\b\b\x01\x10\x01\x18\x04 \x040\x01")
r.set("{e2Manager},CELL:02f829:0007ab50" , "\b\x01\x12/\bc\x12\x0f02f829:0007ab50\x1a\x040102\"\x0602f829*\n\n\b\b\x01\x10\x01\x18\x04 \x040\x01")
r.sadd("{e2Manager},ENB" , "\n\x05test1\x12\x10\n\x0602f829\x12\x06007a80")
r.set("{e2Manager},GNB:03f829:002234", "\n\x05test2\x12\t10.0.2.16\x18\xc9+ \x01*\x10\n\x0702f829\x12\x070012340\x02BI\nG\nE\bc\x12\x1102f829:0008ab0120*\x0602f8290\x01:$\n\"\n\t\bd\"\x05\b\t\x12\x01\t\x12\t\bd\"\x05\b\t\x12\x01\t\x1a\x04\b\x01\x10\x01\"\x04\b\x01\x10\x01")
r.set("{e2Manager},RAN:test2", "\n\x05test2\x12\t10.0.2.15\x18\xc9+ \x01*\x10\n\x0702f829\x12\x070012340\x03BI\nG\nE\bc\x12\x1103f829:0008ab0120*\x0602f8290\x01:$\n\"\n\t\bd\"\x05\b\t\x12\x01\t\x12\t\bd\"\x05\b\t\x12\x01\t\x1a\x04\b\x01\x10\x01\"\x04\b\x01\x10\x01")
r.set("{e2Manager},PCI:test2:63", "\b\x02\x1aG\nE\bc\x12\x1102f829:0008ab0120*\x0702f8290\x01:$\n\"\n\t\bd\"\x05\b\t\x12\x01\t\x12\t\bd\"\x05\b\t\x12\x01\t\x1a\x04\b\x01\x10\x01\"\x04\b\x01\x10\x01")
r.set("{e2Manager},NRCELL:02f829:0007ab0120", "\b\x02\x1aG\nE\bc\x12\x1102f829:0007ab0120*\x0602f8290\x01:$\n\"\n\t\bd\"\x05\b\t\x12\x01\t\x12\t\bd\"\x05\b\t\x12\x01\t\x1a\x04\b\x01\x10\x01\"\x04\b\x01\x10\x01")
r.sadd("{e2Manager},GNB","\n\x05test2\x12\x10\n\x0603f829\x12\x06001234")
return True

View File

@@ -0,0 +1,68 @@
##############################################################################
#
# Copyright (c) 2019 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.
# 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.
#
##############################################################################
#
# This source code is part of the near-RT RIC (RAN Intelligent Controller)
# platform project (RICP).
#
import redis
import config
def getRedisClient():
c = config.redis_ip_address
p = config.redis_ip_port
return redis.Redis(host=c, port=p, db=0)
def verify_value():
r = getRedisClient()
value = "\b\x98\xf7\xdd\xa3\xc7\xb4\x83\xde\x15\x12\x11\n\x0f02f829:0007ab00"
if r.get("{e2Manager},LOAD:test1") != value:
return True
else:
return False
def add():
r = getRedisClient()
r.set("{e2Manager},LOAD:test1", "\b\x98\xf7\xdd\xa3\xc7\xb4\x83\xde\x15\x12\x11\n\x0f02f829:0007ab00")
if r.exists("{e2Manager},LOAD:test1"):
return True
else:
return False
def verify():
r = getRedisClient()
if r.exists("{e2Manager},LOAD:test1"):
return True
else:
return False

View File

@@ -0,0 +1,97 @@
##############################################################################
#
# Copyright (c) 2019 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.
# 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.
#
##############################################################################
import config
import redis
import json
def getRedisClientDecodeResponse():
c = config.redis_ip_address
p = config.redis_ip_port
return redis.Redis(host=c, port=p, db=0, decode_responses=True)
def set_general_config_resource_status_false():
r = getRedisClientDecodeResponse()
r.set("{rsm},CFG:GENERAL:v1.0.0" , "{\"enableResourceStatus\":false,\"partialSuccessAllowed\":true,\"prbPeriodic\":true,\"tnlLoadIndPeriodic\":true,\"wwLoadIndPeriodic\":true,\"absStatusPeriodic\":true,\"rsrpMeasurementPeriodic\":true,\"csiPeriodic\":true,\"periodicityMs\":1,\"periodicityRsrpMeasurementMs\":3,\"periodicityCsiMs\":3}")
def verify_rsm_ran_info_start_false():
r = getRedisClientDecodeResponse()
value = "{\"ranName\":\"test1\",\"enb1MeasurementId\":1,\"enb2MeasurementId\":0,\"action\":\"start\",\"actionStatus\":false}"
return r.get("{rsm},RAN:test1") == value
def verify_rsm_ran_info_start_true():
r = getRedisClientDecodeResponse()
rsmInfoStr = r.get("{rsm},RAN:test1")
rsmInfoJson = json.loads(rsmInfoStr)
response = rsmInfoJson["ranName"] == "test1" and rsmInfoJson["enb1MeasurementId"] == 1 and rsmInfoJson["enb2MeasurementId"] != 1 and rsmInfoJson["action"] == "start" and rsmInfoJson["actionStatus"] == True
return response
def verify_rsm_ran_info_stop_false():
r = getRedisClientDecodeResponse()
rsmInfoStr = r.get("{rsm},RAN:test1")
rsmInfoJson = json.loads(rsmInfoStr)
response = rsmInfoJson["ranName"] == "test1" and rsmInfoJson["enb1MeasurementId"] == 1 and rsmInfoJson["action"] == "stop" and rsmInfoJson["actionStatus"] == False
return response
def verify_rsm_ran_info_stop_true():
r = getRedisClientDecodeResponse()
rsmInfoStr = r.get("{rsm},RAN:test1")
rsmInfoJson = json.loads(rsmInfoStr)
response = rsmInfoJson["ranName"] == "test1" and rsmInfoJson["action"] == "stop" and rsmInfoJson["actionStatus"] == True
return response
def verify_general_config_enable_resource_status_true():
r = getRedisClientDecodeResponse()
configStr = r.get("{rsm},CFG:GENERAL:v1.0.0")
configJson = json.loads(configStr)
return configJson["enableResourceStatus"] == True
def verify_general_config_enable_resource_status_false():
r = getRedisClientDecodeResponse()
configStr = r.get("{rsm},CFG:GENERAL:v1.0.0")
configJson = json.loads(configStr)
return configJson["enableResourceStatus"] == False