Change in ...osmo-gsm-tester[master]: Support SC5 power cycling through powersupply

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Tue Sep 10 12:49:30 UTC 2019


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-gsm-tester/+/15465


Change subject: Support SC5 power cycling through powersupply
......................................................................

Support SC5 power cycling through powersupply

* Add powersupply related code to bts_osmotrx.py to power cycle the
board.
* Each time the board is started, we need to unlock the RF (start TRX
implementation).

Change-Id: I8a1428c1ff90c9f5b42d7ffe86a6fc763819cba2
---
M example/resources.conf.prod
M src/osmo_gsm_tester/bts_osmotrx.py
2 files changed, 104 insertions(+), 18 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/65/15465/1

diff --git a/example/resources.conf.prod b/example/resources.conf.prod
index ef6e37b..e8fe2b0 100644
--- a/example/resources.conf.prod
+++ b/example/resources.conf.prod
@@ -71,8 +71,14 @@
   ciphers: [a5_0, a5_1]
   trx_list:
     - arfcn: 878
+      power_supply:
+        type: 'intellinet'
+        device: '10.42.42.250'
+        port: '5'
   osmo_trx:
-    launch_trx: false
+    type: sc5
+    launch_trx: true
+    remote_user: root
     clock_reference: external
     trx_ip: 10.42.42.112
     max_trxd_version: 0
diff --git a/src/osmo_gsm_tester/bts_osmotrx.py b/src/osmo_gsm_tester/bts_osmotrx.py
index b3738d2..bafa389 100644
--- a/src/osmo_gsm_tester/bts_osmotrx.py
+++ b/src/osmo_gsm_tester/bts_osmotrx.py
@@ -22,6 +22,7 @@
 import pprint
 from abc import ABCMeta, abstractmethod
 from . import log, config, util, template, process, bts_osmo
+from . import powersupply
 from .event_loop import MainLoop
 
 class OsmoBtsTrx(bts_osmo.OsmoBtsMainUnit):
@@ -39,6 +40,7 @@
         self.run_dir = None
         self.inst = None
         self.trx = None
+        self.pwsup_list = []
         self.env = {}
         self.gen_conf = {}
 
@@ -92,6 +94,20 @@
             self.dbg(r)
             f.write(r)
 
+        self.pwsup_list = [None] * self.num_trx()
+        # Construct trx_list appending with empty dicts if needed:
+        conf_trx_list = self.conf.get('trx_list', [])
+        conf_trx_list = conf_trx_list + [{}] * (self.num_trx() - len(conf_trx_list))
+        for trx_i in range(self.num_trx()):
+            pwsup_opt = conf_trx_list[trx_i].get('power_supply', {})
+            if not pwsup_opt:
+                self.dbg('no power_supply configured for TRX %d' % trx_i)
+                continue
+            pwsup_type = pwsup_opt.get('type')
+            if not pwsup_type:
+                raise log.Error('No type attribute provided in power_supply conf for TRX %d!' % trx_i)
+            self.pwsup_list[trx_i] = powersupply.get_instance_by_type(pwsup_type, pwsup_opt)
+
     def launch_trx_enabled(self):
         return util.str2bool(self.gen_conf['osmo_bts_trx'].get('osmo_trx', {}).get('launch_trx'))
 
@@ -109,6 +125,15 @@
     def conf_for_osmotrx(self):
         return dict(osmo_trx=self.gen_conf['osmo_bts_trx'].get('osmo_trx', {}))
 
+    def cleanup(self):
+        i = 0
+        for pwsup in self.pwsup_list:
+            if pwsup:
+                self.dbg('Powering off TRX %d' % i)
+                pwsup.power_set(False)
+            i = i + 1
+        self.pwsup_list = []
+
 ###################
 # PUBLIC (test API included)
 ###################
@@ -121,6 +146,14 @@
         self.run_dir = util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name()))
         self.configure()
 
+        # Power cycle all TRX if needed (right now only TRX0 for SC5):
+        i = 0
+        for pwsup in self.pwsup_list:
+            if pwsup:
+                self.dbg('Powering cycling TRX %d' % i)
+                pwsup.power_cycle(1.0)
+            i = i + 1
+
         if self.launch_trx_enabled():
             self.trx = OsmoTrx.get_instance_by_type(self.get_osmo_trx_type(), self.suite_run, self.conf_for_osmotrx())
             self.trx.start(keepalive)
@@ -138,7 +171,45 @@
                             '-i', self.bsc.addr())
         self.suite_run.poll()
 
-class OsmoTrx(log.Origin, metaclass=ABCMeta):
+
+################################################################################
+# TRX
+################################################################################
+
+class Trx(log.Origin, metaclass=ABCMeta):
+##############
+# PROTECTED
+##############
+    def __init__(self, suite_run, conf, name):
+        super().__init__(log.C_RUN, name)
+        self.suite_run = suite_run
+        self.conf = conf
+        self.run_dir = util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name()))
+        self.listen_ip = conf.get('osmo_trx', {}).get('trx_ip')
+        self.remote_user = conf.get('osmo_trx', {}).get('remote_user', None)
+
+    @classmethod
+    def get_instance_by_type(cls, type, suite_run, conf):
+        KNOWN_OSMOTRX_TYPES = {
+            'uhd': OsmoTrxUHD,
+            'lms': OsmoTrxLMS,
+            'sc5': TrxSC5
+        }
+        osmo_trx_class = KNOWN_OSMOTRX_TYPES.get(type)
+        return osmo_trx_class(suite_run, conf)
+
+##############
+# PUBLIC (test API included)
+##############
+    @abstractmethod
+    def start(self, keepalive=False):
+        pass
+
+    @abstractmethod
+    def trx_ready(self):
+        pass
+
+class OsmoTrx(Trx, metaclass=ABCMeta):
 
     CONF_OSMO_TRX = 'osmo-trx.cfg'
     REMOTE_DIR = '/osmo-gsm-tester-trx/last_run'
@@ -148,27 +219,13 @@
 # PROTECTED
 ##############
     def __init__(self, suite_run, conf):
-        super().__init__(log.C_RUN, self.binary_name())
-        self.suite_run = suite_run
-        self.conf = conf
+        super().__init__(suite_run, conf, self.binary_name())
         self.env = {}
         self.log("OSMOTRX CONF: %r" % conf)
-        self.listen_ip = conf.get('osmo_trx', {}).get('trx_ip')
         self.bts_ip = conf.get('osmo_trx', {}).get('bts_ip')
-        self.remote_user = conf.get('osmo_trx', {}).get('remote_user', None)
-        self.run_dir = None
         self.inst = None
         self.proc_trx = None
 
-    @classmethod
-    def get_instance_by_type(cls, type, suite_run, conf):
-        KNOWN_OSMOTRX_TYPES = {
-            'uhd': OsmoTrxUHD,
-            'lms': OsmoTrxLMS,
-        }
-        osmo_trx_class = KNOWN_OSMOTRX_TYPES.get(type)
-        return osmo_trx_class(suite_run, conf)
-
     @abstractmethod
     def binary_name(self):
         'Used by base class. Subclass can create different OsmoTRX implementations.'
@@ -242,7 +299,6 @@
 # PUBLIC (test API included)
 ##############
     def start(self, keepalive=False):
-        self.run_dir = util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name()))
         self.configure()
         self.inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-trx')))
         if not self.remote_user:
@@ -293,4 +349,28 @@
     def binary_name(self):
         return OsmoTrxLMS.BIN_TRX
 
+class TrxSC5(Trx):
+
+    def __init__(self, suite_run, conf):
+        super().__init__(suite_run, conf, "sc5-trx")
+        self.ready = False
+
+    def start(self, keepalive=False):
+        name = "ssh_sc5_ccli"
+        run_dir = self.run_dir.new_dir(name)
+        popen_args = ('/cx/bin/ccli', '-c', 'gsm.unlock')
+        proc = process.RemoteProcess(name, run_dir, self.remote_user, self.listen_ip, None,
+                                     popen_args)
+        keep_trying = 10
+        while proc.respawn_sync(raise_nonsuccess=False) != 0 and keep_trying > 0:
+            keep_trying = keep_trying - 1
+            self.log('Configuring SC5 TRX failed, retrying %d more times' % keep_trying)
+            MainLoop.sleep(self, 5)
+        if keep_trying == 0 or 'OK' not in (proc.get_stdout() or ''):
+            raise log.Error('Failed configuring SC5!')
+        self.ready = True
+
+    def trx_ready(self):
+        return self.ready
+
 # vim: expandtab tabstop=4 shiftwidth=4

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/15465
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Change-Id: I8a1428c1ff90c9f5b42d7ffe86a6fc763819cba2
Gerrit-Change-Number: 15465
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190910/7f4420ef/attachment.htm>


More information about the gerrit-log mailing list