Change in osmo-gsm-tester[master]: nanobts: Use -G parameter of ipaccess-config to avoid need to restart...

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/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Mon Nov 12 17:46:43 UTC 2018


Pau Espin Pedrol has uploaded this change for review. ( https://gerrit.osmocom.org/11750


Change subject: nanobts: Use -G parameter of ipaccess-config to avoid need to restart nanoBTS
......................................................................

nanobts: Use -G parameter of ipaccess-config to avoid need to restart nanoBTS

If OML IP doesn't need to be changed because it's the one already
configured, then there's no need to set + restart the nanoBTS, which
means we can speed up a test running a nanoBTS by aprox 2 minutes per
nanoBTS used.

Change-Id: I2871dee3de11512250445127f0b807a8990fd4c6
---
M src/osmo_gsm_tester/bts_nanobts.py
1 file changed, 33 insertions(+), 18 deletions(-)



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

diff --git a/src/osmo_gsm_tester/bts_nanobts.py b/src/osmo_gsm_tester/bts_nanobts.py
index ab75b16..80f65f4 100644
--- a/src/osmo_gsm_tester/bts_nanobts.py
+++ b/src/osmo_gsm_tester/bts_nanobts.py
@@ -19,6 +19,7 @@
 
 import os
 import re
+import json
 from . import log, config, util, process, pcap_recorder, bts, pcu
 from . import powersupply
 from .event_loop import MainLoop
@@ -122,24 +123,30 @@
             ipfind.stop()
 
             ipconfig = IpAccessConfig(self.suite_run, self.run_dir, bts_trx_ip)
+            running_oml_ip = ipconfig.get_oml_ip()
+
             if running_unitid != unitid or running_trx != trx_i:
                 if not ipconfig.set_unit_id(unitid, trx_i, False):
                     raise log.Error('Failed configuring unit id %d trx %d' % (unitid, trx_i))
-            # Apply OML IP and restart nanoBTS as it is required to apply the changes.
-            if not ipconfig.set_oml_ip(self.bsc.addr(), True):
-                raise log.Error('Failed configuring OML IP %s' % bts_trx_ip)
 
-            # Let some time for BTS to restart. It takes much more than 20 secs, and
-            # this way we make sure we don't catch responses in abisip-find prior to
-            # BTS restarting.
-            MainLoop.sleep(self, 20)
+            if running_oml_ip != self.bsc.addr():
+                # Apply OML IP and restart nanoBTS as it is required to apply the changes.
+                if not ipconfig.set_oml_ip(self.bsc.addr(), True):
+                    raise log.Error('Failed configuring OML IP %s' % bts_trx_ip)
 
-            self.log('Starting to connect id %d trx %d to' % (unitid, trx_i), self.bsc)
-            ipfind = AbisIpFind(self.suite_run, self.run_dir, local_bind_ip, 'postconf')
-            ipfind.start()
-            ipfind.wait_bts_ready(bts_trx_ip)
-            self.log('nanoBTS id %d trx %d configured and running' % (unitid, trx_i))
-            ipfind.stop()
+                # Let some time for BTS to restart. It takes much more than 20 secs, and
+                # this way we make sure we don't catch responses in abisip-find prior to
+                # BTS restarting.
+                MainLoop.sleep(self, 20)
+
+                self.log('Starting to connect id %d trx %d to' % (unitid, trx_i), self.bsc)
+                ipfind = AbisIpFind(self.suite_run, self.run_dir, local_bind_ip, 'postconf')
+                ipfind.start()
+                ipfind.wait_bts_ready(bts_trx_ip)
+                self.log('nanoBTS id %d trx %d configured and running' % (unitid, trx_i))
+                ipfind.stop()
+            else:
+                self.log('nanoBTS id %d trx %d no need to change OML IP and restart' % (unitid, trx_i))
 
         MainLoop.wait(self, self.bsc.bts_is_connected, self, timeout=600)
         self.log('nanoBTS connected to BSC')
@@ -274,20 +281,28 @@
     def set_unit_id(self, unitid, trx_num, restart=False):
         uid_str = '%d/0/%d' % (unitid, trx_num)
         if restart:
-            retcode = self.run('unitid', '--restart', '--unit-id', '%s' % uid_str, self.bts_ip)
+            retcode = self.run('setunitid', '--restart', '--unit-id', '%s' % uid_str, self.bts_ip)
         else:
-            retcode = self.run('unitid', '--unit-id', '%s' % uid_str, self.bts_ip)
+            retcode = self.run('setunitid', '--unit-id', '%s' % uid_str, self.bts_ip)
         if retcode != 0:
-            log.err('ipaccess-config --unit-id %s returned error code %d' % (uid_str, retcode))
+            self.err('ipaccess-config --unit-id %s returned error code %d' % (uid_str, retcode))
         return retcode == 0
 
     def set_oml_ip(self, omlip, restart=False):
         if restart:
-            retcode = self.run('oml', '--restart', '--oml-ip', omlip, self.bts_ip)
+            retcode = self.run('setoml', '--restart', '--oml-ip', omlip, self.bts_ip)
         else:
-            retcode = self.run('oml', '--oml-ip', omlip, self.bts_ip)
+            retcode = self.run('setoml', '--oml-ip', omlip, self.bts_ip)
         if retcode != 0:
             self.error('ipaccess-config --oml-ip %s returned error code %d' % (omlip, retcode))
         return retcode == 0
 
+    def get_oml_ip(self):
+        retcode = self.run('getoml', '-G', self.bts_ip)
+        if retcode != 0:
+            raise log.Error('ipaccess-config -G %s returned error code %d' % (self.bts_ip, retcode))
+        output = self.proc.get_stdout()
+        json_data = json.loads(output)
+        return json_data['primary_oml_ip']
+
 # vim: expandtab tabstop=4 shiftwidth=4

-- 
To view, visit https://gerrit.osmocom.org/11750
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2871dee3de11512250445127f0b807a8990fd4c6
Gerrit-Change-Number: 11750
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181112/1674659c/attachment.htm>


More information about the gerrit-log mailing list