1 ##############################################################################
3 # Copyright (c) 2019 AT&T Intellectual Property.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 ##############################################################################
24 def getRedisClientDecodeResponse():
25 c = config.redis_ip_address
26 p = config.redis_ip_port
27 return redis.Redis(host=c, port=p, db=0, decode_responses=True)
29 def verify_ran_is_associated_with_e2t_instance(ranName, e2tAddress):
30 r = getRedisClientDecodeResponse()
31 e2tInstanceJson = r.get("{e2Manager},E2TInstance:"+e2tAddress)
32 e2tInstanceDic = json.loads(e2tInstanceJson)
33 assocRanList = e2tInstanceDic.get("associatedRanList")
34 return ranName in assocRanList
36 # def dissociate_ran_from_e2tInstance(ranName, e2tAddress):
37 # r = getRedisClientDecodeResponse()
38 # e2tInstanceJson = r.get("{e2Manager},E2TInstance:"+e2tAddress)
39 # e2tInstanceDic = json.loads(e2tInstanceJson)
40 # assocRanList = e2tInstanceDic.get("associatedRanList")
42 # assocRanList.remove(ranName)
43 # updatedE2tInstanceJson = json.dumps(e2tInstanceDic)
44 # print(updatedE2tInstanceJson)
45 # r.set("{e2Manager},E2TInstance:"+e2tAddress, updatedE2tInstanceJson)
46 # nodebBytes = r.get("{e2Manager},RAN:"+ranName)
47 # encoded = nodebBytes.decode().replace(e2tAddress,"").encode()
48 # r.set("{e2Manager},RAN:"+ranName, encoded)