summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2019-02-27 08:18:38 +0000
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2019-03-05 09:46:57 +0000
commit7424301034ec4a2a4dfafb579d5150baab0f973e (patch)
tree16a88cc7fe311fc3bd87e80c916233da5c204a41
parent44128f91d2ff7be46f6b059726039c9ef2bb3d5b (diff)
resource: Use a factory to initiate a modem
-rw-r--r--src/osmo_gsm_tester/resource.py9
-rw-r--r--src/osmo_gsm_tester/suite.py8
2 files changed, 15 insertions, 2 deletions
diff --git a/src/osmo_gsm_tester/resource.py b/src/osmo_gsm_tester/resource.py
index a536e18..2e7f500 100644
--- a/src/osmo_gsm_tester/resource.py
+++ b/src/osmo_gsm_tester/resource.py
@@ -27,6 +27,7 @@ from . import config
from . import util
from . import schema
from . import bts_sysmo, bts_osmotrx, bts_osmovirtual, bts_octphy, bts_nanobts
+from . import modem
from .util import is_dict, is_list
@@ -104,6 +105,14 @@ KNOWN_BTS_TYPES = {
'nanobts': bts_nanobts.NanoBts,
}
+
+KNOWN_MS_TYPES = {
+ # Map None to ofono for forward compability
+ None: modem.Modem,
+ 'ofono': modem.Modem,
+}
+
+
def register_bts_type(name, clazz):
KNOWN_BTS_TYPES[name] = clazz
diff --git a/src/osmo_gsm_tester/suite.py b/src/osmo_gsm_tester/suite.py
index 39da917..db580ec 100644
--- a/src/osmo_gsm_tester/suite.py
+++ b/src/osmo_gsm_tester/suite.py
@@ -23,7 +23,7 @@ import time
import pprint
from . import config, log, util, resource, test
from .event_loop import MainLoop
-from . import osmo_nitb, osmo_hlr, osmo_mgcpgw, osmo_mgw, osmo_msc, osmo_bsc, osmo_stp, osmo_ggsn, osmo_sgsn, modem, esme, osmocon, ms_driver, iperf3, process
+from . import osmo_nitb, osmo_hlr, osmo_mgcpgw, osmo_mgw, osmo_msc, osmo_bsc, osmo_stp, osmo_ggsn, osmo_sgsn, esme, osmocon, ms_driver, iperf3, process
class Timeout(Exception):
pass
@@ -329,8 +329,12 @@ class SuiteRun(log.Origin):
def modem(self, specifics=None):
conf = self.reserved_resources.get(resource.R_MODEM, specifics=specifics)
+ ms_type = conf.get('type')
+ ms_class = resource.KNOWN_MS_TYPES.get(ms_type)
+ if ms_class is None:
+ raise RuntimeError('No such Modem type is defined: %r' % ms_type)
self.dbg('create Modem object', conf=conf)
- ms = modem.Modem(self, conf)
+ ms = ms_class(self, conf)
self.register_for_cleanup(ms)
return ms