Create bts abstract classes to avoid code duplication and ease development

A lot of code can be shared by all osmocom related BTS we currently use
(sysmo, octphy, trx). This commits moves all this easily shareable code
to an abstract class OsmoBts which all (osmocom) BTS use.

Some bits of code do not apply for osmo-bts-sysmo but it's still shared
by BTS running in the main unit (octphy, trx), for instance the pcu
socket handling. Those are put together in OsmoBtsMainUnit.

This way we have:
log.Origin<-OsmoBts<-OsmoBtsMainUnit<-OsmoBtsOctphy
log.Origin<-OsmoBts<-OsmoBtsMainUnit<-OsmoBtsTrx
log.Origin<-OsmoBts<-OsmoBtsSysmo

Also take the chance to categorize the different APIs in the new
abstract class based on their use and scope.

Some code changes while moving which were required:
- A new protected abstract API "create_pcu", which returns an object of
"pcu" interface. Subclasses implement this API returning either a
PcySysmo or a PcuOsmo object. This is needed to abstract the pcu()
getter into the base class.
- For BTS running in the main unit, pcu_sk_tmp_dir object is allocated
when first used (API pcu_socket_path()) instead of doing it in the
constructor. This is moved into OsmoBtsMainUnit

Change-Id: I86db35a7f2497d37360b2c56affa8bf6bf704ee2
diff --git a/src/osmo_gsm_tester/bts_sysmo.py b/src/osmo_gsm_tester/bts_sysmo.py
index 1d2dbf6..d286d02 100644
--- a/src/osmo_gsm_tester/bts_sysmo.py
+++ b/src/osmo_gsm_tester/bts_sysmo.py
@@ -19,33 +19,20 @@
 
 import os
 import pprint
-from . import log, config, util, template, process, pcu_sysmo
+from . import log, config, util, template, process, pcu_sysmo, bts_osmo
 
-class SysmoBts(log.Origin):
-    suite_run = None
-    bsc = None
-    sgsn = None
+class SysmoBts(bts_osmo.OsmoBts):
     run_dir = None
     inst = None
     remote_inst = None
-    remote_env = None
     remote_dir = None
-    lac = None
-    rac = None
-    cellid = None
-    bvci = None
-    proc_bts = None
-    _pcu = None
 
     REMOTE_DIR = '/osmo-gsm-tester-bts'
     BTS_SYSMO_BIN = 'osmo-bts-sysmo'
     BTS_SYSMO_CFG = 'osmo-bts-sysmo.cfg'
 
     def __init__(self, suite_run, conf):
-        super().__init__(log.C_RUN, self.BTS_SYSMO_BIN)
-        self.suite_run = suite_run
-        self.conf = conf
-        self.remote_env = {}
+        super().__init__(suite_run, conf, SysmoBts.BTS_SYSMO_BIN)
         self.remote_user = 'root'
 
     def start(self):
@@ -91,15 +78,9 @@
 
         self.proc_bts = self.launch_remote('osmo-bts-sysmo', args, remote_cwd=remote_run_dir)
 
-    def cleanup(self):
-        pass
-
     def _direct_pcu_enabled(self):
         return util.str2bool(self.conf.get('direct_pcu'))
 
-    def pcu_socket_path(self):
-        return os.path.join(SysmoBts.REMOTE_DIR, 'pcu_bts')
-
     def _process_remote(self, name, popen_args, remote_cwd=None):
         run_dir = self.run_dir.new_dir(name)
         return process.RemoteProcess(name, run_dir, self.remote_user, self.remote_addr(), remote_cwd,
@@ -128,13 +109,8 @@
             log.ctx(proc)
             raise log.Error('Exited in error')
 
-    def pcu(self):
-        if self._pcu is None:
-            self._pcu = pcu_sysmo.OsmoPcuSysmo(self.suite_run, self, self.conf)
-        return self._pcu
-
-    def remote_addr(self):
-        return self.conf.get('addr')
+    def create_pcu(self):
+        return pcu_sysmo.OsmoPcuSysmo(self.suite_run, self, self.conf)
 
     def pcu_socket_path(self):
         return os.path.join(SysmoBts.REMOTE_DIR, 'pcu_bts')
@@ -182,27 +158,4 @@
         self.dbg(conf=values)
         return values
 
-    def ready_for_pcu(self):
-        if not self.proc_bts or not self.proc_bts.is_running:
-            return False
-        return 'BTS is up' in (self.proc_bts.get_stderr() or '')
-
-    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