Change in osmo-gsm-tester[master]: resource: Use a factory to initiate a modem

Holger Freyther gerrit-no-reply at lists.osmocom.org
Tue Mar 5 15:49:11 UTC 2019


Holger Freyther has submitted this change and it was merged. ( https://gerrit.osmocom.org/13075 )

Change subject: resource: Use a factory to initiate a modem
......................................................................

resource: Use a factory to initiate a modem

Change-Id: I4baa791c92196cda477b2d969d4f67dfbe1152af
---
M src/osmo_gsm_tester/resource.py
M src/osmo_gsm_tester/suite.py
2 files changed, 15 insertions(+), 2 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Pau Espin Pedrol: Looks good to me, approved



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 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 @@
         '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 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 @@
 
     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
 

-- 
To view, visit https://gerrit.osmocom.org/13075
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I4baa791c92196cda477b2d969d4f67dfbe1152af
Gerrit-Change-Number: 13075
Gerrit-PatchSet: 7
Gerrit-Owner: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190305/98bd6fd9/attachment.html>


More information about the gerrit-log mailing list