Skip to content
Snippets Groups Projects
Commit 5f64f0ea authored by Shayan Hajipour's avatar Shayan Hajipour
Browse files

service_2_bwInfo function bug resolved: change in config rules applied in the function

parent f6afa0c7
No related branches found
No related tags found
2 merge requests!294Release TeraFlowSDN 4.0,!196Resolve "(CTTC) Incorrect endpoint lookup in NBI ETSI BWM plugin"
...@@ -31,7 +31,7 @@ LOGGER = logging.getLogger(__name__) ...@@ -31,7 +31,7 @@ LOGGER = logging.getLogger(__name__)
ENDPOINT_SETTINGS_KEY = '/device[{:s}]/endpoint[{:s}]/vlan[{:d}]/settings' ENDPOINT_SETTINGS_KEY = '/device[{:s}]/endpoint[{:s}]/vlan[{:d}]/settings'
DEVICE_SETTINGS_KEY = '/device[{:s}]/settings' DEVICE_SETTINGS_KEY = '/device[{:s}]/settings'
RE_CONFIG_RULE_IF_SUBIF = re.compile(r'^\/interface\[([^\]]+)\]\/subinterface\[([^\]]+)\]$') RE_CONFIG_RULE_IF_SUBIF = re.compile(r'^\/interface\[([^\]]+)\]\/subinterface\[([^\]]+)\]$')
MEC_CONSIDERED_FIELDS = ['requestType', 'sessionFilter', 'fixedAllocation', 'allocationDirection'] MEC_CONSIDERED_FIELDS = ['requestType', 'sessionFilter', 'fixedAllocation', 'allocationDirection', 'fixedBWPriority']
ALLOCATION_DIRECTION_DESCRIPTIONS = { ALLOCATION_DIRECTION_DESCRIPTIONS = {
'00' : 'Downlink (towards the UE)', '00' : 'Downlink (towards the UE)',
'01' : 'Uplink (towards the application/session)', '01' : 'Uplink (towards the application/session)',
...@@ -59,12 +59,19 @@ def service_2_bwInfo(service: Service) -> dict: ...@@ -59,12 +59,19 @@ def service_2_bwInfo(service: Service) -> dict:
break break
for config_rule in service.service_config.config_rules: for config_rule in service.service_config.config_rules:
resource_value_json = json.loads(config_rule.custom.resource_value)
if config_rule.custom.resource_key != '/request':
continue
for key in ['allocationDirection', 'fixedBWPriority', 'requestType', 'sourceIp', 'sourcePort', 'dstPort', 'protocol', 'sessionFilter']: for key in ['allocationDirection', 'fixedBWPriority', 'requestType', 'sourceIp', 'sourcePort', 'dstPort', 'protocol', 'sessionFilter']:
if config_rule.custom.resource_key == key: if key not in resource_value_json:
if key != 'sessionFilter': continue
response[key] = config_rule.custom.resource_value
else: if key == 'sessionFilter':
response[key] = json.loads(config_rule.custom.resource_value) response[key] = [resource_value_json[key]]
elif key == 'requestType':
response[key] = str(resource_value_json[key])
else:
response[key] = resource_value_json[key]
unixtime = time.time() unixtime = time.time()
response['timeStamp'] = { # Time stamp to indicate when the corresponding information elements are sent response['timeStamp'] = { # Time stamp to indicate when the corresponding information elements are sent
...@@ -76,8 +83,6 @@ def service_2_bwInfo(service: Service) -> dict: ...@@ -76,8 +83,6 @@ def service_2_bwInfo(service: Service) -> dict:
def bwInfo_2_service(client, bw_info: dict) -> Service: def bwInfo_2_service(client, bw_info: dict) -> Service:
# add description to allocationDirection code # add description to allocationDirection code
if ad_code := bw_info.get('allocationDirection'):
bw_info['allocationDirection'] = {'code': ad_code, 'description': ALLOCATION_DIRECTION_DESCRIPTIONS[ad_code]}
if 'sessionFilter' in bw_info: if 'sessionFilter' in bw_info:
bw_info['sessionFilter'] = bw_info['sessionFilter'][0] # Discard other items in sessionFilter field bw_info['sessionFilter'] = bw_info['sessionFilter'][0] # Discard other items in sessionFilter field
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment