Change in osmo-gsm-tester[master]: resource: Introduce a base class for the modem

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Holger Freyther gerrit-no-reply at lists.osmocom.org
Wed Feb 27 08:39:56 UTC 2019


Holger Freyther has uploaded this change for review. ( https://gerrit.osmocom.org/13076


Change subject: resource: Introduce a base class for the modem
......................................................................

resource: Introduce a base class for the modem

Extract IMSI, KI and authentication algorithm into a base class.

Change-Id: Id547cdcc241a307a2ea59b5fbac6b8d7a9d95639
---
M src/osmo_gsm_tester/modem.py
1 file changed, 21 insertions(+), 10 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/76/13076/1

diff --git a/src/osmo_gsm_tester/modem.py b/src/osmo_gsm_tester/modem.py
index f9b827a..2f1b5a0 100644
--- a/src/osmo_gsm_tester/modem.py
+++ b/src/osmo_gsm_tester/modem.py
@@ -318,6 +318,22 @@
         return self.property_is('Online', True)
 
 
+class ModemBase(log.Origin, metaclass=ABCMeta):
+    """Base for everything about mobile/modem."""
+
+    def __init__(self, name, conf):
+        super().__init__(log.C_TST, name)
+        self._conf = conf
+
+    def imsi(self):
+        return self._conf.get('imsi')
+
+    def ki(self):
+        return self._conf.get('ki')
+
+    def auth_algo(self):
+        return self._conf.get('auth_algo', None)
+
 
 class Modem(log.Origin):
     'convenience for ofono Modem interaction'
@@ -327,16 +343,14 @@
     CTX_PROT_IPv46 = 'dual'
 
     def __init__(self, suite_run, conf):
-        self.suite_run = suite_run
-        self.conf = conf
         self.syspath = conf.get('path')
         self.dbuspath = get_dbuspath_from_syspath(self.syspath)
-        super().__init__(log.C_TST, self.dbuspath)
+        super().__init__(self.dbuspath, conf)
         self.dbg('creating from syspath %s' % self.syspath)
         self.msisdn = None
         self._ki = None
         self._imsi = None
-        self.run_dir = util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name().strip('/')))
+        self.run_dir = util.Dir(suite_run.get_test_run_dir().new_dir(self.name().strip('/')))
         self.sms_received_list = []
         self.dbus = ModemDbusInteraction(self.dbuspath)
         self.register_attempts = 0
@@ -423,7 +437,7 @@
                 self.dbg('got SIM properties', props)
                 self._imsi = props.get('SubscriberIdentity', None)
             else:
-                self._imsi = self.conf.get('imsi')
+                self._imsi = super().imsi()
             if self._imsi is None:
                 raise log.Error('No IMSI')
         return self._imsi
@@ -434,13 +448,10 @@
     def ki(self):
         if self._ki is not None:
             return self._ki
-        return self.conf.get('ki')
-
-    def auth_algo(self):
-        return self.conf.get('auth_algo', None)
+        return super().ki()
 
     def features(self):
-        return self.conf.get('features', [])
+        return self._conf.get('features', [])
 
     def _required_ifaces(self):
         req_ifaces = (I_NETREG,)

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

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id547cdcc241a307a2ea59b5fbac6b8d7a9d95639
Gerrit-Change-Number: 13076
Gerrit-PatchSet: 1
Gerrit-Owner: Holger Freyther <holger at freyther.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190227/13d28bdb/attachment.htm>


More information about the gerrit-log mailing list