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
This commit is contained in:
parent
5df8dd2a2a
commit
404e150c69
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue