From 404e150c691bbdc9f03e95b14d123cebda4bca9c Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Tue, 22 Aug 2017 11:17:43 +0200 Subject: bts_osmotrx: Support configuring bts addr, trx_remote_ip and launch_trx We may want to support running a device which runs its own TRX (osmo-trx or different implementation). Furthermore, this TRX may be available in some specific hwardare rather than on the main unit. This makes it easy to configure OsmoBtsTrx to launch it's own osmo-trx or not. In case it is launched, all IPs are configured correctly to ensure connection can be established. Before this commit, osmo-trx was binding to 127.0.0.1. Now we can support multiple osmo-trx being launched on the main unit. Change-Id: I825ed1fc0c3fe75d196db90c1508283fbd04acf8 --- example/resources.conf | 10 +++++++- src/osmo_gsm_tester/bts_osmotrx.py | 30 ++++++++++++++++------ src/osmo_gsm_tester/config.py | 1 - src/osmo_gsm_tester/resource.py | 2 ++ src/osmo_gsm_tester/schema.py | 6 ++++- .../templates/osmo-bts-trx.cfg.tmpl | 2 ++ src/osmo_gsm_tester/util.py | 9 +++++++ 7 files changed, 49 insertions(+), 11 deletions(-) diff --git a/example/resources.conf b/example/resources.conf index 0260815..a09e80a 100644 --- a/example/resources.conf +++ b/example/resources.conf @@ -17,8 +17,16 @@ bts: - label: Ettus B210 type: osmo-bts-trx ipa_unit_id: 6 - addr: 10.42.42.116 + addr: 10.42.42.50 band: GSM-1800 + launch_trx: true + +- label: sysmoCell 5000 + type: osmo-bts-trx + ipa_unit_id: 7 + addr: 10.42.42.51 + band: GSM-1800 + trx_remote_ip: 10.42.42.112 arfcn: - arfcn: 512 diff --git a/src/osmo_gsm_tester/bts_osmotrx.py b/src/osmo_gsm_tester/bts_osmotrx.py index 9795a58..b5262a2 100644 --- a/src/osmo_gsm_tester/bts_osmotrx.py +++ b/src/osmo_gsm_tester/bts_osmotrx.py @@ -41,8 +41,17 @@ class OsmoBtsTrx(log.Origin): self.env = {} def remote_addr(self): - # FIXME - return '127.0.0.1' + return self.conf.get('addr') + + def trx_remote_ip(self): + conf_ip = self.conf.get('trx_remote_ip', None) + if conf_ip is not None: + return conf_ip + # if 'trx_remote_ip' is not configured, use same IP as BTS + return self.remote_addr() + + def launch_trx_enabled(self): + return util.str2bool(self.conf.get('launch_trx')) def start(self): if self.bsc is None: @@ -53,10 +62,11 @@ class OsmoBtsTrx(log.Origin): self.run_dir = util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name())) self.configure() - self.trx = OsmoTrx(self.suite_run) - self.trx.start() - self.log('Waiting for osmo-trx to start up...') - event_loop.wait(self, self.trx.trx_ready) + if self.launch_trx_enabled(): + self.trx = OsmoTrx(self.suite_run, self.trx_remote_ip(), self.remote_addr()) + self.trx.start() + self.log('Waiting for osmo-trx to start up...') + event_loop.wait(self, self.trx.trx_ready) self.inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst(OsmoBtsTrx.BIN_BTS_TRX))) lib = self.inst.child('lib') @@ -93,6 +103,8 @@ class OsmoBtsTrx(log.Origin): config.overlay(values, { 'osmo_bts_trx': { 'oml_remote_ip': self.bsc.addr(), + 'trx_local_ip': self.remote_addr(), + 'trx_remote_ip': self.trx_remote_ip(), 'pcu_socket_path': os.path.join(str(self.run_dir), 'pcu_bts') } }) @@ -124,17 +136,19 @@ class OsmoTrx(log.Origin): BIN_TRX = 'osmo-trx' - def __init__(self, suite_run): + def __init__(self, suite_run, listen_ip, bts_ip): super().__init__(log.C_RUN, OsmoTrx.BIN_TRX) self.suite_run = suite_run self.env = {} + self.listen_ip = listen_ip + self.bts_ip = bts_ip def start(self): self.run_dir = util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name())) self.inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst(OsmoTrx.BIN_TRX))) lib = self.inst.child('lib') self.env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) } - self.proc_trx = self.launch_process(OsmoTrx.BIN_TRX, '-x') + self.proc_trx = self.launch_process(OsmoTrx.BIN_TRX, '-x', '-j', self.listen_ip, '-i', self.bts_ip) def launch_process(self, binary_name, *args): binary = os.path.abspath(self.inst.child('bin', binary_name)) diff --git a/src/osmo_gsm_tester/config.py b/src/osmo_gsm_tester/config.py index 20ae83e..f6e81ac 100644 --- a/src/osmo_gsm_tester/config.py +++ b/src/osmo_gsm_tester/config.py @@ -271,5 +271,4 @@ def overlay(dest, src): dest[i] = overlay(dest[i], src[i]) return dest return src - # vim: expandtab tabstop=4 shiftwidth=4 diff --git a/src/osmo_gsm_tester/resource.py b/src/osmo_gsm_tester/resource.py index 8eec71e..9470f48 100644 --- a/src/osmo_gsm_tester/resource.py +++ b/src/osmo_gsm_tester/resource.py @@ -54,6 +54,8 @@ RESOURCES_SCHEMA = { 'bts[].ipa_unit_id': schema.INT, 'bts[].addr': schema.IPV4, 'bts[].band': schema.BAND, + 'bts[].trx_remote_ip': schema.IPV4, + 'bts[].launch_trx': schema.BOOL_STR, 'bts[].trx_list[].hw_addr': schema.HWADDR, 'bts[].trx_list[].net_device': schema.STR, 'arfcn[].arfcn': schema.INT, diff --git a/src/osmo_gsm_tester/schema.py b/src/osmo_gsm_tester/schema.py index d652aa7..4c9b9cd 100644 --- a/src/osmo_gsm_tester/schema.py +++ b/src/osmo_gsm_tester/schema.py @@ -20,7 +20,7 @@ import re from . import log -from .util import is_dict, is_list +from .util import is_dict, is_list, str2bool KEY_RE = re.compile('[a-zA-Z][a-zA-Z0-9_]*') IPV4_RE = re.compile('([0-9]{1,3}.){3}[0-9]{1,3}') @@ -63,21 +63,25 @@ def msisdn(val): INT = 'int' STR = 'str' +BOOL_STR = 'bool_str' BAND = 'band' IPV4 = 'ipv4' HWADDR = 'hwaddr' IMSI = 'imsi' KI = 'ki' MSISDN = 'msisdn' +TRX_REMOTE_IP = 'trx_remote_ip' SCHEMA_TYPES = { INT: int, STR: str, + BOOL_STR: str2bool, BAND: band, IPV4: ipv4, HWADDR: hwaddr, IMSI: imsi, KI: ki, MSISDN: msisdn, + TRX_REMOTE_IP: ipv4, } def validate(config, schema): diff --git a/src/osmo_gsm_tester/templates/osmo-bts-trx.cfg.tmpl b/src/osmo_gsm_tester/templates/osmo-bts-trx.cfg.tmpl index ddfd483..950c03e 100644 --- a/src/osmo_gsm_tester/templates/osmo-bts-trx.cfg.tmpl +++ b/src/osmo_gsm_tester/templates/osmo-bts-trx.cfg.tmpl @@ -17,6 +17,8 @@ phy 0 instance 0 osmotrx rx-gain 25 osmotrx tx-attenuation oml + osmotrx ip local ${osmo_bts_trx.trx_local_ip} + osmotrx ip remote ${osmo_bts_trx.trx_remote_ip} bts 0 band ${osmo_bts_trx.band} ipa unit-id ${osmo_bts_trx.ipa_unit_id} 0 diff --git a/src/osmo_gsm_tester/util.py b/src/osmo_gsm_tester/util.py index 602ae45..af6a2f0 100644 --- a/src/osmo_gsm_tester/util.py +++ b/src/osmo_gsm_tester/util.py @@ -305,4 +305,13 @@ def input_polling(prompt, poll_func): input_thread.join() return input_thread.result +def str2bool(val): + if val is None or not val: + return False + if val.upper() in ['FALSE', 'NO', 'OFF']: + return False + if val.upper() in ['TRUE','YES', 'ON']: + return True + raise ValueError('Invalid BOOL field: %r' % val) + # vim: expandtab tabstop=4 shiftwidth=4 -- cgit v1.2.3