blob: 8eed8cf73fb4d823f42e3e78804343745578dab7 [file] [log] [blame]
Neels Hofmeyr17c139e2017-04-12 02:42:02 +02001# osmo_gsm_tester: specifics for running an osmo-bts-trx
Neels Hofmeyr3531a192017-03-28 14:30:28 +02002#
3# Copyright (C) 2016-2017 by sysmocom - s.f.m.c. GmbH
4#
5# Author: Neels Hofmeyr <neels@hofmeyr.de>
6#
7# This program is free software: you can redistribute it and/or modify
Harald Welte27205342017-06-03 09:51:45 +02008# it under the terms of the GNU General Public License as
Neels Hofmeyr3531a192017-03-28 14:30:28 +02009# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Welte27205342017-06-03 09:51:45 +020015# GNU General Public License for more details.
Neels Hofmeyr3531a192017-03-28 14:30:28 +020016#
Harald Welte27205342017-06-03 09:51:45 +020017# You should have received a copy of the GNU General Public License
Neels Hofmeyr3531a192017-03-28 14:30:28 +020018# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20import os
Neels Hofmeyr943c81d2017-05-22 20:16:03 +020021import pprint
Pau Espin Pedrol0d455042018-08-27 17:07:41 +020022from abc import ABCMeta, abstractmethod
Pau Espin Pedrole1a58bd2020-04-10 20:46:07 +020023from ..core import log, config, util, template, process, remote
Pau Espin Pedrolea8c3d42020-05-04 12:05:05 +020024from ..core import schema
Pau Espin Pedrole1a58bd2020-04-10 20:46:07 +020025from ..core.event_loop import MainLoop
Pau Espin Pedrole8bbcbf2020-04-10 19:51:31 +020026from . import powersupply, bts_osmo
Neels Hofmeyr3531a192017-03-28 14:30:28 +020027
Pau Espin Pedrolea8c3d42020-05-04 12:05:05 +020028def on_register_schemas():
29 resource_schema = {
30 'osmo_trx.launch_trx': schema.BOOL_STR,
31 'osmo_trx.type': schema.STR,
32 'osmo_trx.clock_reference': schema.OSMO_TRX_CLOCK_REF,
33 'osmo_trx.trx_ip': schema.IPV4,
34 'osmo_trx.remote_user': schema.STR,
35 'osmo_trx.dev_args': schema.STR,
36 'osmo_trx.multi_arfcn': schema.BOOL_STR,
37 'osmo_trx.max_trxd_version': schema.UINT,
38 'osmo_trx.channels[].rx_path': schema.STR,
39 'osmo_trx.channels[].tx_path': schema.STR,
40 }
41 schema.register_resource_schema('bts', resource_schema)
42
Pau Espin Pedrolc9817a52017-12-13 19:52:27 +010043class OsmoBtsTrx(bts_osmo.OsmoBtsMainUnit):
Pau Espin Pedrol2e542952017-12-14 19:08:51 +010044##############
45# PROTECTED
46##############
Neels Hofmeyr3531a192017-03-28 14:30:28 +020047
Neels Hofmeyr3531a192017-03-28 14:30:28 +020048 BIN_BTS_TRX = 'osmo-bts-trx'
49 BIN_PCU = 'osmo-pcu'
50
Neels Hofmeyr17c139e2017-04-12 02:42:02 +020051 CONF_BTS_TRX = 'osmo-bts-trx.cfg'
52
Pau Espin Pedrola442cb82020-05-05 12:54:37 +020053 def __init__(self, testenv, conf):
54 super().__init__(testenv, conf, OsmoBtsTrx.BIN_BTS_TRX, 'osmo_bts_trx')
Pau Espin Pedrol58603672018-08-09 13:45:55 +020055 self.run_dir = None
56 self.inst = None
57 self.trx = None
Pau Espin Pedrol55cee162019-09-10 13:47:04 +020058 self.pwsup_list = []
Neels Hofmeyr3531a192017-03-28 14:30:28 +020059 self.env = {}
Pau Espin Pedrol0d455042018-08-27 17:07:41 +020060 self.gen_conf = {}
Pau Espin Pedrol404e1502017-08-22 11:17:43 +020061
62 def trx_remote_ip(self):
Pau Espin Pedrol0d455042018-08-27 17:07:41 +020063 conf_ip = self.conf.get('osmo_trx', {}).get('trx_ip', None)
Pau Espin Pedrol404e1502017-08-22 11:17:43 +020064 if conf_ip is not None:
65 return conf_ip
66 # if 'trx_remote_ip' is not configured, use same IP as BTS
67 return self.remote_addr()
68
Pau Espin Pedrolb1526b92018-05-22 20:32:30 +020069 def launch_process(self, keepalive, binary_name, *args):
Neels Hofmeyr3531a192017-03-28 14:30:28 +020070 binary = os.path.abspath(self.inst.child('bin', binary_name))
71 run_dir = self.run_dir.new_dir(binary_name)
72 if not os.path.isfile(binary):
73 raise RuntimeError('Binary missing: %r' % binary)
74 proc = process.Process(binary_name, run_dir,
75 (binary,) + args,
76 env=self.env)
Pau Espin Pedrola442cb82020-05-05 12:54:37 +020077 self.testenv.remember_to_stop(proc, keepalive)
Neels Hofmeyr3531a192017-03-28 14:30:28 +020078 proc.launch()
Neels Hofmeyrfd39f3e2017-05-07 02:02:35 +020079 return proc
Neels Hofmeyr3531a192017-03-28 14:30:28 +020080
81 def configure(self):
Neels Hofmeyrc4ba4a62017-05-18 19:31:44 +020082 if self.bsc is None:
83 raise RuntimeError('BTS needs to be added to a BSC or NITB before it can be configured')
Neels Hofmeyr17c139e2017-04-12 02:42:02 +020084 self.config_file = self.run_dir.new_file(OsmoBtsTrx.CONF_BTS_TRX)
Neels Hofmeyr3531a192017-03-28 14:30:28 +020085 self.dbg(config_file=self.config_file)
86
87 values = dict(osmo_bts_trx=config.get_defaults('osmo_bts_trx'))
Pau Espin Pedrol0d455042018-08-27 17:07:41 +020088 config.overlay(values, dict(osmo_bts_trx=dict(osmo_trx=config.get_defaults('osmo_trx'))))
Pau Espin Pedrola442cb82020-05-05 12:54:37 +020089 config.overlay(values, self.testenv.suite().config())
Pau Espin Pedrol329b6f42017-08-08 13:55:24 +020090 config.overlay(values, {
91 'osmo_bts_trx': {
92 'oml_remote_ip': self.bsc.addr(),
Pau Espin Pedrol15aae982017-09-08 13:55:54 +020093 'pcu_socket_path': self.pcu_socket_path(),
Pau Espin Pedrol0d455042018-08-27 17:07:41 +020094 'osmo_trx': {
95 'bts_ip': self.remote_addr(),
96 'trx_ip': self.trx_remote_ip(),
Pau Espin Pedrol29b71322020-04-06 18:14:29 +020097 'egprs': 'enable' if self.egprs_enabled() else 'disable',
Pau Espin Pedrol44b7ea12018-09-17 20:24:13 +020098 'channels': [{} for trx_i in range(self.num_trx())]
Pau Espin Pedrol0d455042018-08-27 17:07:41 +020099 }
Pau Espin Pedrol329b6f42017-08-08 13:55:24 +0200100 }
101 })
102 config.overlay(values, { 'osmo_bts_trx': self.conf })
Neels Hofmeyr943c81d2017-05-22 20:16:03 +0200103
Pau Espin Pedrol0d455042018-08-27 17:07:41 +0200104 self.gen_conf = values
Neels Hofmeyr943c81d2017-05-22 20:16:03 +0200105 self.dbg('OSMO-BTS-TRX CONFIG:\n' + pprint.pformat(values))
Neels Hofmeyr3531a192017-03-28 14:30:28 +0200106
107 with open(self.config_file, 'w') as f:
Neels Hofmeyr17c139e2017-04-12 02:42:02 +0200108 r = template.render(OsmoBtsTrx.CONF_BTS_TRX, values)
Neels Hofmeyr3531a192017-03-28 14:30:28 +0200109 self.dbg(r)
110 f.write(r)
111
Pau Espin Pedrol55cee162019-09-10 13:47:04 +0200112 self.pwsup_list = [None] * self.num_trx()
113 # Construct trx_list appending with empty dicts if needed:
114 conf_trx_list = self.conf.get('trx_list', [])
115 conf_trx_list = conf_trx_list + [{}] * (self.num_trx() - len(conf_trx_list))
116 for trx_i in range(self.num_trx()):
117 pwsup_opt = conf_trx_list[trx_i].get('power_supply', {})
118 if not pwsup_opt:
119 self.dbg('no power_supply configured for TRX %d' % trx_i)
120 continue
121 pwsup_type = pwsup_opt.get('type')
122 if not pwsup_type:
123 raise log.Error('No type attribute provided in power_supply conf for TRX %d!' % trx_i)
124 self.pwsup_list[trx_i] = powersupply.get_instance_by_type(pwsup_type, pwsup_opt)
125
Pau Espin Pedrol0d455042018-08-27 17:07:41 +0200126 def launch_trx_enabled(self):
127 return util.str2bool(self.gen_conf['osmo_bts_trx'].get('osmo_trx', {}).get('launch_trx'))
128
129 def get_osmo_trx_type(self):
130 return self.gen_conf['osmo_bts_trx'].get('osmo_trx', {}).get('type')
131
Pau Espin Pedrol2e542952017-12-14 19:08:51 +0100132########################
133# PUBLIC - INTERNAL API
134########################
Neels Hofmeyrc4ba4a62017-05-18 19:31:44 +0200135 def conf_for_bsc(self):
Pau Espin Pedrole5194622018-05-07 13:36:58 +0200136 values = self.conf_for_bsc_prepare()
Neels Hofmeyr3531a192017-03-28 14:30:28 +0200137 self.dbg(conf=values)
138 return values
139
Pau Espin Pedrol0d455042018-08-27 17:07:41 +0200140 def conf_for_osmotrx(self):
141 return dict(osmo_trx=self.gen_conf['osmo_bts_trx'].get('osmo_trx', {}))
142
Pau Espin Pedrol55cee162019-09-10 13:47:04 +0200143 def cleanup(self):
144 i = 0
145 for pwsup in self.pwsup_list:
146 if pwsup:
147 self.dbg('Powering off TRX %d' % i)
148 pwsup.power_set(False)
149 i = i + 1
150 self.pwsup_list = []
151
Pau Espin Pedrol2e542952017-12-14 19:08:51 +0100152###################
153# PUBLIC (test API included)
154###################
Pau Espin Pedrolb1526b92018-05-22 20:32:30 +0200155 def start(self, keepalive=False):
Pau Espin Pedrol2e542952017-12-14 19:08:51 +0100156 if self.bsc is None:
157 raise RuntimeError('BTS needs to be added to a BSC or NITB before it can be started')
Pau Espin Pedrola442cb82020-05-05 12:54:37 +0200158 self.testenv.poll()
Pau Espin Pedrol2e542952017-12-14 19:08:51 +0100159
160 self.log('Starting to connect to', self.bsc)
Pau Espin Pedrol2a2d8462020-05-11 10:56:52 +0200161 self.run_dir = util.Dir(self.testenv.test().get_run_dir().new_dir(self.name()))
Pau Espin Pedrol2e542952017-12-14 19:08:51 +0100162 self.configure()
163
Pau Espin Pedrol55cee162019-09-10 13:47:04 +0200164 # Power cycle all TRX if needed (right now only TRX0 for SC5):
165 i = 0
166 for pwsup in self.pwsup_list:
167 if pwsup:
168 self.dbg('Powering cycling TRX %d' % i)
169 pwsup.power_cycle(1.0)
170 i = i + 1
171
Pau Espin Pedrol2e542952017-12-14 19:08:51 +0100172 if self.launch_trx_enabled():
Pau Espin Pedrola442cb82020-05-05 12:54:37 +0200173 self.trx = OsmoTrx.get_instance_by_type(self.get_osmo_trx_type(), self.testenv, self.conf_for_osmotrx())
Pau Espin Pedrolb1526b92018-05-22 20:32:30 +0200174 self.trx.start(keepalive)
Pau Espin Pedrol0d455042018-08-27 17:07:41 +0200175 self.log('Waiting for %s to start up...' % self.trx.name())
Pau Espin Pedrol664e3832020-06-10 19:30:33 +0200176 MainLoop.wait(self.trx.trx_ready)
Pau Espin Pedrol2e542952017-12-14 19:08:51 +0100177
Pau Espin Pedrola442cb82020-05-05 12:54:37 +0200178 self.inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-bts')))
Pau Espin Pedrol2e542952017-12-14 19:08:51 +0100179 lib = self.inst.child('lib')
180 if not os.path.isdir(lib):
181 raise RuntimeError('No lib/ in %r' % self.inst)
182 self.env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) }
183
Pau Espin Pedrolb1526b92018-05-22 20:32:30 +0200184 self.proc_bts = self.launch_process(keepalive, OsmoBtsTrx.BIN_BTS_TRX, '-r', '1',
Pau Espin Pedrol2e542952017-12-14 19:08:51 +0100185 '-c', os.path.abspath(self.config_file),
Pau Espin Pedrolc93707f2019-08-05 18:19:45 +0200186 '-i', self.bsc.addr())
Pau Espin Pedrola442cb82020-05-05 12:54:37 +0200187 self.testenv.poll()
Pau Espin Pedrol2e542952017-12-14 19:08:51 +0100188
Pau Espin Pedrol55cee162019-09-10 13:47:04 +0200189
190################################################################################
191# TRX
192################################################################################
193
194class Trx(log.Origin, metaclass=ABCMeta):
195##############
196# PROTECTED
197##############
Pau Espin Pedrola442cb82020-05-05 12:54:37 +0200198 def __init__(self, testenv, conf, name):
Pau Espin Pedrol55cee162019-09-10 13:47:04 +0200199 super().__init__(log.C_RUN, name)
Pau Espin Pedrola442cb82020-05-05 12:54:37 +0200200 self.testenv = testenv
Pau Espin Pedrol55cee162019-09-10 13:47:04 +0200201 self.conf = conf
Pau Espin Pedrol2a2d8462020-05-11 10:56:52 +0200202 self.run_dir = util.Dir(self.testenv.test().get_run_dir().new_dir(self.name()))
Pau Espin Pedrol55cee162019-09-10 13:47:04 +0200203 self.listen_ip = conf.get('osmo_trx', {}).get('trx_ip')
204 self.remote_user = conf.get('osmo_trx', {}).get('remote_user', None)
205
206 @classmethod
Pau Espin Pedrola442cb82020-05-05 12:54:37 +0200207 def get_instance_by_type(cls, type, testenv, conf):
Pau Espin Pedrol55cee162019-09-10 13:47:04 +0200208 KNOWN_OSMOTRX_TYPES = {
209 'uhd': OsmoTrxUHD,
210 'lms': OsmoTrxLMS,
211 'sc5': TrxSC5
212 }
213 osmo_trx_class = KNOWN_OSMOTRX_TYPES.get(type)
Pau Espin Pedrola442cb82020-05-05 12:54:37 +0200214 return osmo_trx_class(testenv, conf)
Pau Espin Pedrol55cee162019-09-10 13:47:04 +0200215
216##############
217# PUBLIC (test API included)
218##############
219 @abstractmethod
220 def start(self, keepalive=False):
221 pass
222
223 @abstractmethod
224 def trx_ready(self):
225 pass
226
227class OsmoTrx(Trx, metaclass=ABCMeta):
Pau Espin Pedrol47738532017-08-15 16:20:07 +0200228
Pau Espin Pedroledcc8d22018-03-04 19:58:23 +0100229 CONF_OSMO_TRX = 'osmo-trx.cfg'
Pau Espin Pedrola9006df2018-10-01 12:26:39 +0200230 REMOTE_DIR = '/osmo-gsm-tester-trx/last_run'
Pau Espin Pedrol302c7562018-10-02 13:08:02 +0200231 WRAPPER_SCRIPT = 'ssh_sigkiller.sh'
Pau Espin Pedrol47738532017-08-15 16:20:07 +0200232
Pau Espin Pedrol0d455042018-08-27 17:07:41 +0200233##############
234# PROTECTED
235##############
Pau Espin Pedrola442cb82020-05-05 12:54:37 +0200236 def __init__(self, testenv, conf):
237 super().__init__(testenv, conf, self.binary_name())
Pau Espin Pedrol47738532017-08-15 16:20:07 +0200238 self.env = {}
Pau Espin Pedrola9006df2018-10-01 12:26:39 +0200239 self.log("OSMOTRX CONF: %r" % conf)
Pau Espin Pedrola9006df2018-10-01 12:26:39 +0200240 self.bts_ip = conf.get('osmo_trx', {}).get('bts_ip')
Pau Espin Pedrol0d455042018-08-27 17:07:41 +0200241 self.inst = None
242 self.proc_trx = None
243
Pau Espin Pedrol0d455042018-08-27 17:07:41 +0200244 @abstractmethod
245 def binary_name(self):
246 'Used by base class. Subclass can create different OsmoTRX implementations.'
247 pass
Pau Espin Pedrol47738532017-08-15 16:20:07 +0200248
Pau Espin Pedroledcc8d22018-03-04 19:58:23 +0100249 def configure(self):
250 self.config_file = self.run_dir.new_file(OsmoTrx.CONF_OSMO_TRX)
251 self.dbg(config_file=self.config_file)
252
Pau Espin Pedrol0d455042018-08-27 17:07:41 +0200253 values = self.conf
Pau Espin Pedrol1ff03762018-10-02 15:50:48 +0200254
255 # we don't need to enable multi-arfcn for single channel
256 if len(values.get('osmo_trx', {}).get('channels', [])) > 1:
257 multi_arfcn_bool = util.str2bool(values.get('osmo_trx', {}).get('multi_arfcn', False))
258 else:
259 multi_arfcn_bool = False
Pau Espin Pedrol94eab262018-09-17 20:25:55 +0200260 config.overlay(values, { 'osmo_trx': { 'multi_arfcn': multi_arfcn_bool } })
Pau Espin Pedroledcc8d22018-03-04 19:58:23 +0100261
262 self.dbg('OSMO-TRX CONFIG:\n' + pprint.pformat(values))
263
264 with open(self.config_file, 'w') as f:
265 r = template.render(OsmoTrx.CONF_OSMO_TRX, values)
266 self.dbg(r)
267 f.write(r)
268
Pau Espin Pedrola9006df2018-10-01 12:26:39 +0200269 def launch_process_local(self, keepalive, binary_name, *args):
Pau Espin Pedrol47738532017-08-15 16:20:07 +0200270 binary = os.path.abspath(self.inst.child('bin', binary_name))
271 run_dir = self.run_dir.new_dir(binary_name)
272 if not os.path.isfile(binary):
273 raise RuntimeError('Binary missing: %r' % binary)
274 proc = process.Process(binary_name, run_dir,
275 (binary,) + args,
276 env=self.env)
Pau Espin Pedrola442cb82020-05-05 12:54:37 +0200277 self.testenv.remember_to_stop(proc, keepalive)
Pau Espin Pedrol47738532017-08-15 16:20:07 +0200278 proc.launch()
279 return proc
280
Pau Espin Pedroldd710222019-11-26 14:33:09 +0100281 def start_remotely(self, keepalive):
282 # Run remotely through ssh. We need to run osmo-trx under a wrapper
283 # script since osmo-trx ignores SIGHUP and will keep running after
284 # we close local ssh session. The wrapper script catches SIGHUP and
285 # sends SIGINT to it.
Pau Espin Pedrol2eafb032020-01-29 17:56:14 +0100286
287 rem_host = remote.RemoteHost(self.run_dir, self.remote_user, self.listen_ip)
288
289 remote_prefix_dir = util.Dir(OsmoTrx.REMOTE_DIR)
290 remote_run_dir = util.Dir(remote_prefix_dir.child(self.binary_name()))
Pau Espin Pedroldd710222019-11-26 14:33:09 +0100291 remote_config_file = remote_run_dir.child(OsmoTrx.CONF_OSMO_TRX)
292
Pau Espin Pedrol2eafb032020-01-29 17:56:14 +0100293 have_inst = rem_host.inst_compatible_for_remote()
Pau Espin Pedroldd710222019-11-26 14:33:09 +0100294 if have_inst:
Pau Espin Pedrola442cb82020-05-05 12:54:37 +0200295 self.inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-trx')))
Pau Espin Pedroldd710222019-11-26 14:33:09 +0100296
Pau Espin Pedrol2eafb032020-01-29 17:56:14 +0100297 rem_host.recreate_remote_dir(remote_prefix_dir)
298 if have_inst:
299 self.remote_inst = util.Dir(remote_prefix_dir.child(os.path.basename(str(self.inst))))
300 rem_host.create_remote_dir(self.remote_inst)
301 rem_host.scp('scp-inst-to-remote', str(self.inst), remote_prefix_dir)
302 rem_host.create_remote_dir(remote_run_dir)
303 rem_host.scp('scp-cfg-to-remote', self.config_file, remote_config_file)
Pau Espin Pedroldd710222019-11-26 14:33:09 +0100304
305 if have_inst:
Pau Espin Pedrolf6d45ad2020-02-11 14:39:15 +0100306 remote_env = { 'LD_LIBRARY_PATH': self.remote_inst.child('lib') }
Pau Espin Pedroldd710222019-11-26 14:33:09 +0100307 remote_binary = self.remote_inst.child('bin', self.binary_name())
Pau Espin Pedrol2eafb032020-01-29 17:56:14 +0100308 args = (remote_binary, '-C', remote_config_file)
Pau Espin Pedroldd710222019-11-26 14:33:09 +0100309 else: # Use whatever is available i nremote system PATH:
Pau Espin Pedrolf6d45ad2020-02-11 14:39:15 +0100310 remote_env = {}
Pau Espin Pedrol2eafb032020-01-29 17:56:14 +0100311 remote_binary = self.binary_name()
312 args = (remote_binary, '-C', remote_config_file)
Pau Espin Pedrol0d64f162020-05-25 15:44:09 +0200313 # Run remotely through ssh. We need to run binary under a wrapper
314 # script since osmo-trx ignores SIGHUP and will keep running after
315 # we close local ssh session. The wrapper script catches SIGHUP and
316 # sends SIGINT to it.
317 self.proc_trx = rem_host.RemoteProcessSafeExit(self.binary_name(), remote_run_dir, args, remote_env=remote_env)
Pau Espin Pedrola442cb82020-05-05 12:54:37 +0200318 self.testenv.remember_to_stop(self.proc_trx, keepalive)
Pau Espin Pedrol2eafb032020-01-29 17:56:14 +0100319 self.proc_trx.launch()
Pau Espin Pedroldd710222019-11-26 14:33:09 +0100320
Pau Espin Pedrol0d455042018-08-27 17:07:41 +0200321##############
322# PUBLIC (test API included)
323##############
324 def start(self, keepalive=False):
Pau Espin Pedrol0d455042018-08-27 17:07:41 +0200325 self.configure()
Pau Espin Pedroldd710222019-11-26 14:33:09 +0100326 if self.remote_user:
327 self.start_remotely(keepalive)
328 return
329 # Run locally if ssh user is not set
Pau Espin Pedrola442cb82020-05-05 12:54:37 +0200330 self.inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-trx')))
Pau Espin Pedroldd710222019-11-26 14:33:09 +0100331 lib = self.inst.child('lib')
332 self.env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) }
333 self.proc_trx = self.launch_process_local(keepalive, self.binary_name(),
334 '-C', os.path.abspath(self.config_file))
Pau Espin Pedrol0d455042018-08-27 17:07:41 +0200335
Pau Espin Pedrol47738532017-08-15 16:20:07 +0200336 def trx_ready(self):
337 if not self.proc_trx or not self.proc_trx.is_running:
338 return False
339 return '-- Transceiver active with' in (self.proc_trx.get_stdout() or '')
Pau Espin Pedrol0d455042018-08-27 17:07:41 +0200340
341class OsmoTrxUHD(OsmoTrx):
342 BIN_TRX = 'osmo-trx-uhd'
343
Pau Espin Pedrola442cb82020-05-05 12:54:37 +0200344 def __init__(self, testenv, conf):
345 super().__init__(testenv, conf)
Pau Espin Pedrol0d455042018-08-27 17:07:41 +0200346
347 def binary_name(self):
348 return OsmoTrxUHD.BIN_TRX
349
Pau Espin Pedrole789f0c2018-08-27 18:45:01 +0200350class OsmoTrxLMS(OsmoTrx):
351 BIN_TRX = 'osmo-trx-lms'
352
Pau Espin Pedrola442cb82020-05-05 12:54:37 +0200353 def __init__(self, testenv, conf):
354 super().__init__(testenv, conf)
Pau Espin Pedrole789f0c2018-08-27 18:45:01 +0200355
356 def binary_name(self):
357 return OsmoTrxLMS.BIN_TRX
358
Pau Espin Pedrol55cee162019-09-10 13:47:04 +0200359class TrxSC5(Trx):
360
Pau Espin Pedrola442cb82020-05-05 12:54:37 +0200361 def __init__(self, testenv, conf):
362 super().__init__(testenv, conf, "sc5-trx")
Pau Espin Pedrol55cee162019-09-10 13:47:04 +0200363 self.ready = False
364
365 def start(self, keepalive=False):
366 name = "ssh_sc5_ccli"
367 run_dir = self.run_dir.new_dir(name)
368 popen_args = ('/cx/bin/ccli', '-c', 'gsm.unlock')
369 proc = process.RemoteProcess(name, run_dir, self.remote_user, self.listen_ip, None,
370 popen_args)
371 keep_trying = 10
372 while keep_trying > 0:
373 if proc.respawn_sync(raise_nonsuccess=False) == 0 and 'OK' in (proc.get_stdout() or ''):
374 break
375 keep_trying = keep_trying - 1
376 self.log('Configuring SC5 TRX failed, retrying %d more times' % keep_trying)
Pau Espin Pedrol664e3832020-06-10 19:30:33 +0200377 MainLoop.sleep(5)
Pau Espin Pedrol55cee162019-09-10 13:47:04 +0200378 if keep_trying == 0:
379 raise log.Error('Failed configuring SC5!')
380 self.ready = True
381
382 def trx_ready(self):
383 return self.ready
384
Neels Hofmeyr3531a192017-03-28 14:30:28 +0200385# vim: expandtab tabstop=4 shiftwidth=4