ms: Allocate default msisdn internally

Don't wait until adding it to the subscriber data base, since the msisdn
may be needed beforehand (for instance in follow up patch to be passed
to osmo-msc configuration to route emergency calls).

Change-Id: I0d6902687e4beb3d6cdcefd4e343f21496100504
This commit is contained in:
Pau Espin 2020-10-15 16:33:47 +02:00 committed by pespin
parent 410912333e
commit 83a2fdca9b
9 changed files with 15 additions and 14 deletions

View File

@ -168,8 +168,7 @@ class AmarisoftEPC(epc.EPC):
def subscriber_add(self, modem, msisdn=None, algo_str=None):
if msisdn is None:
msisdn = self.testenv.msisdn()
modem.set_msisdn(msisdn)
msisdn = modem.msisdn()
if algo_str is None:
algo_str = modem.auth_algo() or util.OSMO_AUTH_ALGO_NONE

View File

@ -183,8 +183,7 @@ class srsEPC(epc.EPC, srslte_common):
def subscriber_add(self, modem, msisdn=None, algo_str=None):
if msisdn is None:
msisdn = self.testenv.msisdn()
modem.set_msisdn(msisdn)
msisdn = modem.msisdn()
if algo_str is None:
algo_str = modem.auth_algo() or util.OSMO_AUTH_ALGO_NONE

View File

@ -106,8 +106,7 @@ class OsmoHlr(log.Origin):
def subscriber_add(self, modem, msisdn=None, algo_str=None):
if msisdn is None:
msisdn = self.testenv.msisdn()
modem.set_msisdn(msisdn)
msisdn = modem.msisdn()
subscriber_id = self.next_subscriber_id
self.next_subscriber_id += 1

View File

@ -42,8 +42,9 @@ class MS(log.Origin, metaclass=ABCMeta):
##############
# PROTECTED
##############
def __init__(self, name, conf):
def __init__(self, name, testenv, conf):
super().__init__(log.C_TST, name)
self.testenv = testenv
self._conf = conf
self._msisdn = None
@ -114,6 +115,9 @@ class MS(log.Origin, metaclass=ABCMeta):
self._msisdn = msisdn
def msisdn(self):
# If none was set, allocate next one available:
if self._msisdn is None:
self.set_msisdn(self.testenv.msisdn())
return self._msisdn
def get_counter(self, counter_name):

View File

@ -82,7 +82,7 @@ class AmarisoftUE(MS):
def __init__(self, testenv, conf):
self._run_node = RunNode.from_conf(conf.get('run_node', {}))
super().__init__('amarisoftue_%s' % self.addr(), conf)
super().__init__('amarisoftue_%s' % self.addr(), testenv, conf)
self.enb = None
self.run_dir = None
self.inst = None
@ -98,7 +98,6 @@ class AmarisoftUE(MS):
self.remote_config_rf_file = None
self.remote_log_file = None
self.remote_ifup_file = None
self.testenv = testenv
if not rf_type_valid(conf.get('rf_dev_type', None)):
raise log.Error('Invalid rf_dev_type=%s' % conf.get('rf_dev_type', None))
if conf.get('rf_dev_type') == 'zmq':

View File

@ -373,7 +373,7 @@ class Modem(MS):
CTX_PROT_IPv46 = 'dual'
def __init__(self, testenv, conf):
super().__init__('modem', conf)
super().__init__('modem', testenv, conf)
_import_external_modules()
self.syspath = conf.get('path')
self.dbuspath = get_dbuspath_from_syspath(self.syspath)

View File

@ -23,6 +23,9 @@ from . import ms
class MSOsmoMobile(ms.MS):
"""Represent a osmocom-bb mobile."""
def __init__(self, testenv, conf):
super().__init__('ms_osmo', testenv, conf)
def cleanup(self):
# do nothing for a virtual resource
pass

View File

@ -77,7 +77,7 @@ class srsUE(MS, srslte_common):
def __init__(self, testenv, conf):
self._run_node = RunNode.from_conf(conf.get('run_node', {}))
super().__init__('srsue_%s' % self.addr(), conf)
super().__init__('srsue_%s' % self.addr(), testenv, conf)
srslte_common.__init__(self)
self.enb = None
self.run_dir = None
@ -96,7 +96,6 @@ class srsUE(MS, srslte_common):
self.remote_metrics_file = None
self.enable_pcap = False
self.num_carriers = 1
self.testenv = testenv
self._additional_args = []
if not rf_type_valid(conf.get('rf_dev_type', None)):
raise log.Error('Invalid rf_dev_type=%s' % conf.get('rf_dev_type', None))

View File

@ -120,8 +120,7 @@ class OsmoNitb(log.Origin):
def subscriber_add(self, modem, msisdn=None, algo=None):
if msisdn is None:
msisdn = self.testenv.msisdn()
modem.set_msisdn(msisdn)
msisdn = modem.msisdn()
if not algo:
alg_str = modem.auth_algo()