aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2018-05-07 02:26:18 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2018-05-07 11:20:23 +0200
commit530681fd86c4a4dab18e4575c9cdf339623ffa49 (patch)
treeb62114751f9ee402c856b8f435dabf6854a7eaf5
parentc9b63767963d70574783de147d455f19bb4f9214 (diff)
bts: Refactor conf_for_bsc_osmo
Move duplicated code into a method in the superclass. Change-Id: Ie27932f94142f667c3fb8c054b77e04afa0d5cbb
-rw-r--r--src/osmo_gsm_tester/bts_nanobts.py16
-rw-r--r--src/osmo_gsm_tester/bts_octphy.py16
-rw-r--r--src/osmo_gsm_tester/bts_osmo.py17
-rw-r--r--src/osmo_gsm_tester/bts_osmotrx.py16
-rw-r--r--src/osmo_gsm_tester/bts_sysmo.py16
5 files changed, 21 insertions, 60 deletions
diff --git a/src/osmo_gsm_tester/bts_nanobts.py b/src/osmo_gsm_tester/bts_nanobts.py
index 6350c56..a930442 100644
--- a/src/osmo_gsm_tester/bts_nanobts.py
+++ b/src/osmo_gsm_tester/bts_nanobts.py
@@ -56,21 +56,7 @@ class NanoBts(bts.Bts):
########################
def conf_for_bsc(self):
- values = config.get_defaults('bsc_bts')
- config.overlay(values, config.get_defaults('nanobts'))
- if self.lac is not None:
- config.overlay(values, { 'location_area_code': self.lac })
- if self.rac is not None:
- config.overlay(values, { 'routing_area_code': self.rac })
- if self.cellid is not None:
- config.overlay(values, { 'cell_identity': self.cellid })
- if self.bvci is not None:
- config.overlay(values, { 'bvci': self.bvci })
- config.overlay(values, self.conf)
-
- sgsn_conf = {} if self.sgsn is None else self.sgsn.conf_for_client()
- config.overlay(values, sgsn_conf)
-
+ values = self.conf_for_bsc_osmo('nanobts')
# Hack until we have proper ARFCN resource allocation support (OS#2230)
band = values.get('band')
trx_list = values.get('trx_list')
diff --git a/src/osmo_gsm_tester/bts_octphy.py b/src/osmo_gsm_tester/bts_octphy.py
index f48afcc..70deba3 100644
--- a/src/osmo_gsm_tester/bts_octphy.py
+++ b/src/osmo_gsm_tester/bts_octphy.py
@@ -112,21 +112,7 @@ class OsmoBtsOctphy(bts_osmo.OsmoBtsMainUnit):
# PUBLIC - INTERNAL API
########################
def conf_for_bsc(self):
- values = config.get_defaults('bsc_bts')
- config.overlay(values, config.get_defaults('osmo_bts_octphy'))
- if self.lac is not None:
- config.overlay(values, { 'location_area_code': self.lac })
- if self.rac is not None:
- config.overlay(values, { 'routing_area_code': self.rac })
- if self.cellid is not None:
- config.overlay(values, { 'cell_identity': self.cellid })
- if self.bvci is not None:
- config.overlay(values, { 'bvci': self.bvci })
- config.overlay(values, self.conf)
-
- sgsn_conf = {} if self.sgsn is None else self.sgsn.conf_for_client()
- config.overlay(values, sgsn_conf)
-
+ values = self.conf_for_bsc_osmo('osmo_bts_octphy')
self.dbg(conf=values)
return values
diff --git a/src/osmo_gsm_tester/bts_osmo.py b/src/osmo_gsm_tester/bts_osmo.py
index be87b9d..d0ba557 100644
--- a/src/osmo_gsm_tester/bts_osmo.py
+++ b/src/osmo_gsm_tester/bts_osmo.py
@@ -35,6 +35,23 @@ class OsmoBts(bts.Bts, metaclass=ABCMeta):
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())
+ def conf_for_bsc_osmo(self, bts_defaults_name):
+ values = config.get_defaults('bsc_bts')
+ config.overlay(values, config.get_defaults(bts_defaults_name))
+ if self.lac is not None:
+ config.overlay(values, { 'location_area_code': self.lac })
+ if self.rac is not None:
+ config.overlay(values, { 'routing_area_code': self.rac })
+ if self.cellid is not None:
+ config.overlay(values, { 'cell_identity': self.cellid })
+ if self.bvci is not None:
+ config.overlay(values, { 'bvci': self.bvci })
+ config.overlay(values, self.conf)
+
+ sgsn_conf = {} if self.sgsn is None else self.sgsn.conf_for_client()
+ config.overlay(values, sgsn_conf)
+ return values
+
########################
# PUBLIC - INTERNAL API
########################
diff --git a/src/osmo_gsm_tester/bts_osmotrx.py b/src/osmo_gsm_tester/bts_osmotrx.py
index bd8aedf..f1a9bdf 100644
--- a/src/osmo_gsm_tester/bts_osmotrx.py
+++ b/src/osmo_gsm_tester/bts_osmotrx.py
@@ -92,21 +92,7 @@ class OsmoBtsTrx(bts_osmo.OsmoBtsMainUnit):
# PUBLIC - INTERNAL API
########################
def conf_for_bsc(self):
- values = config.get_defaults('bsc_bts')
- config.overlay(values, config.get_defaults('osmo_bts_trx'))
- if self.lac is not None:
- config.overlay(values, { 'location_area_code': self.lac })
- if self.rac is not None:
- config.overlay(values, { 'routing_area_code': self.rac })
- if self.cellid is not None:
- config.overlay(values, { 'cell_identity': self.cellid })
- if self.bvci is not None:
- config.overlay(values, { 'bvci': self.bvci })
- config.overlay(values, self.conf)
-
- sgsn_conf = {} if self.sgsn is None else self.sgsn.conf_for_client()
- config.overlay(values, sgsn_conf)
-
+ values = self.conf_for_bsc_osmo('osmo_bts_trx')
self.dbg(conf=values)
return values
diff --git a/src/osmo_gsm_tester/bts_sysmo.py b/src/osmo_gsm_tester/bts_sysmo.py
index 7a41033..c9978e5 100644
--- a/src/osmo_gsm_tester/bts_sysmo.py
+++ b/src/osmo_gsm_tester/bts_sysmo.py
@@ -103,21 +103,7 @@ class SysmoBts(bts_osmo.OsmoBts):
return os.path.join(SysmoBts.REMOTE_DIR, 'pcu_bts')
def conf_for_bsc(self):
- values = config.get_defaults('bsc_bts')
- config.overlay(values, config.get_defaults('osmo_bts_sysmo'))
- if self.lac is not None:
- config.overlay(values, { 'location_area_code': self.lac })
- if self.rac is not None:
- config.overlay(values, { 'routing_area_code': self.rac })
- if self.cellid is not None:
- config.overlay(values, { 'cell_identity': self.cellid })
- if self.bvci is not None:
- config.overlay(values, { 'bvci': self.bvci })
- config.overlay(values, self.conf)
-
- sgsn_conf = {} if self.sgsn is None else self.sgsn.conf_for_client()
- config.overlay(values, sgsn_conf)
-
+ values = self.conf_for_bsc_osmo('osmo_bts_sysmo')
self.dbg(conf=values)
return values