summaryrefslogtreecommitdiffstats
path: root/src/osmo_gsm_tester
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2018-03-08 17:50:14 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2018-03-15 11:29:35 +0100
commit52ad3a66d2f79ea366379b69cb16db9ae50b9664 (patch)
tree3b70b7b6ae0ea5d7e7ee1738d4646a377b13de8c /src/osmo_gsm_tester
parent4fbdc35e952717068e667e501d7f6c5c9701610c (diff)
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
Diffstat (limited to 'src/osmo_gsm_tester')
-rw-r--r--src/osmo_gsm_tester/bts.py95
-rw-r--r--src/osmo_gsm_tester/bts_osmo.py47
2 files changed, 102 insertions, 40 deletions
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@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 os
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 @@ class OsmoBts(log.Origin, metaclass=ABCMeta):
########################
@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 @@ class OsmoBts(log.Origin, metaclass=ABCMeta):
'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):
@@ -87,25 +71,6 @@ class OsmoBts(log.Origin, metaclass=ABCMeta):
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):
##############
# PROTECTED
@@ -120,6 +85,7 @@ class OsmoBtsMainUnit(OsmoBts, metaclass=ABCMeta):
########################
@abstractmethod
def conf_for_bsc(self):
+ # coming from bts.Bts, we forward the implementation to children.
pass
def cleanup(self):
@@ -143,4 +109,5 @@ class OsmoBtsMainUnit(OsmoBts, metaclass=ABCMeta):
###################
@abstractmethod
def start(self):
+ # coming from bts.Bts, we forward the implementation to children.
pass