From 96050ed6e29a98c8be7044f81436e8d9ad50b5d7 Mon Sep 17 00:00:00 2001 From: Matthew Johnson Date: Thu, 29 Apr 2021 17:31:57 -0700 Subject: [PATCH] [misc] Use correct units and session types when upgrading (#968) * [misc] Set slice session type when upgrading * [misc] Use correct units when upgrading The old UI specified units in kbps, which corresponds to enum 1, not enum 0, in the new schema and UI. --- misc/db/python/SchemaUpdater.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/misc/db/python/SchemaUpdater.py b/misc/db/python/SchemaUpdater.py index 03a21a774..0178fec4a 100644 --- a/misc/db/python/SchemaUpdater.py +++ b/misc/db/python/SchemaUpdater.py @@ -39,14 +39,14 @@ def create_v1_from_v0(old_sub): # Remove old PDN info del new_sub['pdn'] - # Set AMBR Values to new format (Old format is in bits per second) + # Set AMBR Values to new format (Old format is in kbps per second) new_sub['ambr']['uplink'] = {} new_sub['ambr']['uplink']['value'] = old_sub['ambr']['uplink'] - new_sub['ambr']['uplink']['unit'] = 0 + new_sub['ambr']['uplink']['unit'] = 1 new_sub['ambr']['downlink'] = {} new_sub['ambr']['downlink']['value'] = old_sub['ambr']['downlink'] - new_sub['ambr']['downlink']['unit'] = 0 + new_sub['ambr']['downlink']['unit'] = 1 #Propogate APN / DDN Slice Details new_sub['slice'] = [] @@ -66,15 +66,21 @@ def _create_session_from_pdn(pdn): """Builds a new session object from an existing PDN""" session = {} session['name'] = pdn['apn'] - session['type'] = pdn['type'] + + if pdn['type'] in {1, 2, 3}: + session['type'] = pdn['type'] + else: + # Default to IPv4 for old networks being upgraded with an invalid type + session['type'] = 1 + session['ambr'] = { "uplink": { "value": pdn['ambr']['uplink'], - "unit": 0 + "unit": 1 }, "downlink": { "value": pdn['ambr']['downlink'], - "unit": 0 + "unit": 1 } }