[PATCH] osmo-gsm-tester[master]: Create Bts abstract class and make OsmoBts inherit from it

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/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Fri Mar 9 17:30:59 UTC 2018


Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/7160

to look at the new patch set (#2).

Create Bts abstract class and make OsmoBts inherit from it

This base class will be used to describe the required accessors for all
BTS objects, be it an osmocom BTS or not.

It is introduced in this commit and will be further used in the future
when adding a NanoBts object.

Change-Id: Ic13133e61abda73a8b507c1a1bd7b98c677460f9
---
A src/osmo_gsm_tester/bts.py
M src/osmo_gsm_tester/bts_osmo.py
2 files changed, 102 insertions(+), 40 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/60/7160/2

diff --git a/src/osmo_gsm_tester/bts.py b/src/osmo_gsm_tester/bts.py
new file mode 100644
index 0000000..289b697
--- /dev/null
+++ b/src/osmo_gsm_tester/bts.py
@@ -0,0 +1,95 @@
+# osmo_gsm_tester: base classes to share code among BTS subclasses.
+#
+# Copyright (C) 2018 by sysmocom - s.f.m.c. GmbH
+#
+# Author: Pau Espin Pedrol <pespin at sysmocom.de>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import pprint
+import tempfile
+from abc import ABCMeta, abstractmethod
+from . import log, config, util, template, process, event_loop, pcu_osmo
+
+class Bts(log.Origin, metaclass=ABCMeta):
+    suite_run = None
+    conf = None
+    bsc = None
+    sgsn = None
+    lac = None
+    rac = None
+    cellid = None
+    bvci = None
+
+##############
+# PROTECTED
+##############
+    def __init__(self, suite_run, conf, name):
+        super().__init__(log.C_RUN, name)
+        self.suite_run = suite_run
+        self.conf = conf
+
+########################
+# PUBLIC - INTERNAL API
+########################
+    @abstractmethod
+    def conf_for_bsc(self):
+        'Used by bsc objects to get path to socket.'
+        pass
+
+    def remote_addr(self):
+        return self.conf.get('addr')
+
+    def cleanup(self):
+        'Nothing to do by default. Subclass can override if required.'
+        pass
+
+###################
+# PUBLIC (test API included)
+###################
+    @abstractmethod
+    def start(self):
+        'Starts BTS proccess and sets self.proc_bts with an object of Process interface'
+        pass
+
+    @abstractmethod
+    def ready_for_pcu(self):
+        'True if the BTS is prepared to have a PCU connected, false otherwise'
+        pass
+
+    @abstractmethod
+    def pcu(self):
+        'Get the Pcu object associated with the BTS'
+        pass
+
+    def set_bsc(self, bsc):
+        self.bsc = bsc
+
+    def set_sgsn(self, sgsn):
+        self.sgsn = sgsn
+
+    def set_lac(self, lac):
+        self.lac = lac
+
+    def set_rac(self, rac):
+        self.rac = rac
+
+    def set_cellid(self, cellid):
+        self.cellid = cellid
+
+    def set_bvci(self, bvci):
+        self.bvci = bvci
+
+# vim: expandtab tabstop=4 shiftwidth=4
diff --git a/src/osmo_gsm_tester/bts_osmo.py b/src/osmo_gsm_tester/bts_osmo.py
index 5ae3392..60b9695 100644
--- a/src/osmo_gsm_tester/bts_osmo.py
+++ b/src/osmo_gsm_tester/bts_osmo.py
@@ -21,26 +21,17 @@
 import pprint
 import tempfile
 from abc import ABCMeta, abstractmethod
-from . import log, config, util, template, process, event_loop, pcu_osmo
+from . import log, config, util, template, process, event_loop, bts, pcu_osmo
 
-class OsmoBts(log.Origin, metaclass=ABCMeta):
-    suite_run = None
+class OsmoBts(bts.Bts, metaclass=ABCMeta):
     proc_bts = None
-    bsc = None
-    sgsn = None
-    lac = None
-    rac = None
-    cellid = None
-    bvci = None
     _pcu = None
 
 ##############
 # PROTECTED
 ##############
     def __init__(self, suite_run, conf, name):
-        super().__init__(log.C_RUN, name)
-        self.suite_run = suite_run
-        self.conf = conf
+        super().__init__(suite_run, conf, name)
         if len(self.pcu_socket_path().encode()) > 107:
             raise log.Error('Path for pcu socket is longer than max allowed len for unix socket path (107):', self.pcu_socket_path())
 
@@ -49,7 +40,7 @@
 ########################
     @abstractmethod
     def conf_for_bsc(self):
-        'Used by bsc objects to get path to socket.'
+        # coming from bts.Bts, we forward the implementation to children.
         pass
 
     @abstractmethod
@@ -62,19 +53,12 @@
         'Used by base class. Subclass can create different pcu implementations.'
         pass
 
-    def remote_addr(self):
-        return self.conf.get('addr')
-
-    def cleanup(self):
-        'Nothing to do by default. Subclass can override if required.'
-        pass
-
 ###################
 # PUBLIC (test API included)
 ###################
     @abstractmethod
     def start(self):
-        'Starts BTS proccess and sets self.proc_bts with an object of Process interface'
+        # coming from bts.Bts, we forward the implementation to children.
         pass
 
     def ready_for_pcu(self):
@@ -86,25 +70,6 @@
         if self._pcu is None:
             self._pcu = self.create_pcu()
         return self._pcu
-
-    def set_bsc(self, bsc):
-        self.bsc = bsc
-
-    def set_sgsn(self, sgsn):
-        self.sgsn = sgsn
-
-    def set_lac(self, lac):
-        self.lac = lac
-
-    def set_rac(self, rac):
-        self.rac = rac
-
-    def set_cellid(self, cellid):
-        self.cellid = cellid
-
-    def set_bvci(self, bvci):
-        self.bvci = bvci
-
 
 class OsmoBtsMainUnit(OsmoBts, metaclass=ABCMeta):
 ##############
@@ -120,6 +85,7 @@
 ########################
     @abstractmethod
     def conf_for_bsc(self):
+        # coming from bts.Bts, we forward the implementation to children.
         pass
 
     def cleanup(self):
@@ -143,4 +109,5 @@
 ###################
     @abstractmethod
     def start(self):
+        # coming from bts.Bts, we forward the implementation to children.
         pass

-- 
To view, visit https://gerrit.osmocom.org/7160
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ic13133e61abda73a8b507c1a1bd7b98c677460f9
Gerrit-PatchSet: 2
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list