[MERGED] osmo-gsm-tester[master]: nanobts: Bind to specific addr instead of specific iface

2018-03-27 Thread Pau Espin Pedrol
Pau Espin Pedrol has submitted this change and it was merged.

Change subject: nanobts: Bind to specific addr instead of specific iface
..


nanobts: Bind to specific addr instead of specific iface

This way root access is not required.

Change-Id: I02f6fc9e1cb1ea1e1d950eafe22c231a18100f98
---
M example/resources.conf.prod
M example/resources.conf.rnd
M src/osmo_gsm_tester/bts_nanobts.py
M src/osmo_gsm_tester/resource.py
M src/osmo_gsm_tester/util.py
5 files changed, 37 insertions(+), 33 deletions(-)

Approvals:
  Pau Espin Pedrol: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/example/resources.conf.prod b/example/resources.conf.prod
index 9f815b8..230976d 100644
--- a/example/resources.conf.prod
+++ b/example/resources.conf.prod
@@ -49,7 +49,6 @@
   ipa_unit_id: 9
   addr: 10.42.42.53
   band: GSM-1900
-  net_device: enp2s0
   power_supply:
 type: 'sispm'
 device: '01:01:4d:98:24'
diff --git a/example/resources.conf.rnd b/example/resources.conf.rnd
index ae48081..8ccf749 100644
--- a/example/resources.conf.rnd
+++ b/example/resources.conf.rnd
@@ -32,7 +32,6 @@
   ipa_unit_id: 9
   addr: 10.42.42.53
   band: GSM-1900
-  net_device: enp2s0
   power_supply:
 type: 'sispm'
 device: '01:01:55:2e:b6'
diff --git a/src/osmo_gsm_tester/bts_nanobts.py 
b/src/osmo_gsm_tester/bts_nanobts.py
index f666f7a..f42bc6e 100644
--- a/src/osmo_gsm_tester/bts_nanobts.py
+++ b/src/osmo_gsm_tester/bts_nanobts.py
@@ -86,24 +86,25 @@
 ###
 
 def start(self):
-for attr in ['net_device', 'ipa_unit_id']:
-if self.conf.get(attr) is None:
-raise log.Error('No attribute %s provided in conf!' % attr)
+if self.conf.get('ipa_unit_id') is None:
+raise log.Error('No attribute %s provided in conf!' % attr)
 self.run_dir = 
util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name()))
 self._configure()
 
-iface = self.conf.get('net_device')
 unitid = int(self.conf.get('ipa_unit_id'))
 bts_ip = self.remote_addr()
+# This fine for now, however concurrent tests using Nanobts may run 
into "address already in use" since dst is broadcast.
+# Once concurrency is needed, a new config attr should be added to 
have an extra static IP assigned on the main-unit to each Nanobts resource.
+local_bind_ip =util.dst_ip_get_local_bind(bts_ip)
 
 # Make sure nanoBTS is powered and in a clean state:
 self.pwsup.power_cycle(1.0)
 
-pcap_recorder.PcapRecorder(self.suite_run, 
self.run_dir.new_dir('pcap'), iface,
+pcap_recorder.PcapRecorder(self.suite_run, 
self.run_dir.new_dir('pcap'), None,
'host %s and port not 22' % 
self.remote_addr())
 
-self.log('Finding nanobts %s...' % bts_ip)
-ipfind = AbisIpFind(self.suite_run, self.run_dir, iface, 'preconf')
+self.log('Finding nanobts %s, binding on %s...' % (bts_ip, 
local_bind_ip))
+ipfind = AbisIpFind(self.suite_run, self.run_dir, local_bind_ip, 
'preconf')
 ipfind.start()
 ipfind.wait_bts_ready(bts_ip)
 running_unitid = ipfind.get_unitid_by_ip(bts_ip)
@@ -124,7 +125,7 @@
 event_loop.sleep(self, 20)
 
 self.log('Starting to connect to', self.bsc)
-ipfind = AbisIpFind(self.suite_run, self.run_dir, iface, 'postconf')
+ipfind = AbisIpFind(self.suite_run, self.run_dir, local_bind_ip, 
'postconf')
 ipfind.start()
 ipfind.wait_bts_ready(bts_ip)
 self.log('nanoBTS configured and running')
@@ -161,45 +162,36 @@
 run_dir = None
 inst = None
 env = None
-iface = None
+bind_ip = None
 proc = None
 
 BIN_ABISIP_FIND = 'abisip-find'
 BTS_UNIT_ID_RE = re.compile("Unit_ID='(?P\d+)/\d+/\d+'")
 
-def __init__(self, suite_run, parent_run_dir, iface, name_suffix):
+def __init__(self, suite_run, parent_run_dir, bind_ip, name_suffix):
 super().__init__(log.C_RUN, AbisIpFind.BIN_ABISIP_FIND + '-' + 
name_suffix)
 self.suite_run = suite_run
 self.parent_run_dir = parent_run_dir
-self.iface = iface
+self.bind_ip = bind_ip
 self.env = {}
-
-def launch_process(self, binary_name, *args):
-binary = os.path.abspath(self.inst.child('bin', binary_name))
-run_dir = self.run_dir.new_dir(binary_name)
-if not os.path.isfile(binary):
-raise RuntimeError('Binary missing: %r' % binary)
-proc = process.Process(binary_name, run_dir,
-   (binary,) + args,
-   env=self.env)
-self.suite_run.remember_to_stop(proc)
-proc.launch()
-return proc
 
 def start(self):
 self.run_dir = util.Dir(self.parent_run_dir.new_dir(self.name()))
 self.inst = 

osmo-gsm-tester[master]: nanobts: Bind to specific addr instead of specific iface

2018-03-27 Thread Pau Espin Pedrol

Patch Set 3: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/7502
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I02f6fc9e1cb1ea1e1d950eafe22c231a18100f98
Gerrit-PatchSet: 3
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: No


[PATCH] osmo-gsm-tester[master]: nanobts: Bind to specific addr instead of specific iface

2018-03-27 Thread Pau Espin Pedrol
Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/7502

to look at the new patch set (#3).

nanobts: Bind to specific addr instead of specific iface

This way root access is not required.

Change-Id: I02f6fc9e1cb1ea1e1d950eafe22c231a18100f98
---
M example/resources.conf.prod
M example/resources.conf.rnd
M src/osmo_gsm_tester/bts_nanobts.py
M src/osmo_gsm_tester/resource.py
M src/osmo_gsm_tester/util.py
5 files changed, 37 insertions(+), 33 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/02/7502/3

diff --git a/example/resources.conf.prod b/example/resources.conf.prod
index 9f815b8..230976d 100644
--- a/example/resources.conf.prod
+++ b/example/resources.conf.prod
@@ -49,7 +49,6 @@
   ipa_unit_id: 9
   addr: 10.42.42.53
   band: GSM-1900
-  net_device: enp2s0
   power_supply:
 type: 'sispm'
 device: '01:01:4d:98:24'
diff --git a/example/resources.conf.rnd b/example/resources.conf.rnd
index ae48081..8ccf749 100644
--- a/example/resources.conf.rnd
+++ b/example/resources.conf.rnd
@@ -32,7 +32,6 @@
   ipa_unit_id: 9
   addr: 10.42.42.53
   band: GSM-1900
-  net_device: enp2s0
   power_supply:
 type: 'sispm'
 device: '01:01:55:2e:b6'
diff --git a/src/osmo_gsm_tester/bts_nanobts.py 
b/src/osmo_gsm_tester/bts_nanobts.py
index f666f7a..f42bc6e 100644
--- a/src/osmo_gsm_tester/bts_nanobts.py
+++ b/src/osmo_gsm_tester/bts_nanobts.py
@@ -86,24 +86,25 @@
 ###
 
 def start(self):
-for attr in ['net_device', 'ipa_unit_id']:
-if self.conf.get(attr) is None:
-raise log.Error('No attribute %s provided in conf!' % attr)
+if self.conf.get('ipa_unit_id') is None:
+raise log.Error('No attribute %s provided in conf!' % attr)
 self.run_dir = 
util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name()))
 self._configure()
 
-iface = self.conf.get('net_device')
 unitid = int(self.conf.get('ipa_unit_id'))
 bts_ip = self.remote_addr()
+# This fine for now, however concurrent tests using Nanobts may run 
into "address already in use" since dst is broadcast.
+# Once concurrency is needed, a new config attr should be added to 
have an extra static IP assigned on the main-unit to each Nanobts resource.
+local_bind_ip =util.dst_ip_get_local_bind(bts_ip)
 
 # Make sure nanoBTS is powered and in a clean state:
 self.pwsup.power_cycle(1.0)
 
-pcap_recorder.PcapRecorder(self.suite_run, 
self.run_dir.new_dir('pcap'), iface,
+pcap_recorder.PcapRecorder(self.suite_run, 
self.run_dir.new_dir('pcap'), None,
'host %s and port not 22' % 
self.remote_addr())
 
-self.log('Finding nanobts %s...' % bts_ip)
-ipfind = AbisIpFind(self.suite_run, self.run_dir, iface, 'preconf')
+self.log('Finding nanobts %s, binding on %s...' % (bts_ip, 
local_bind_ip))
+ipfind = AbisIpFind(self.suite_run, self.run_dir, local_bind_ip, 
'preconf')
 ipfind.start()
 ipfind.wait_bts_ready(bts_ip)
 running_unitid = ipfind.get_unitid_by_ip(bts_ip)
@@ -124,7 +125,7 @@
 event_loop.sleep(self, 20)
 
 self.log('Starting to connect to', self.bsc)
-ipfind = AbisIpFind(self.suite_run, self.run_dir, iface, 'postconf')
+ipfind = AbisIpFind(self.suite_run, self.run_dir, local_bind_ip, 
'postconf')
 ipfind.start()
 ipfind.wait_bts_ready(bts_ip)
 self.log('nanoBTS configured and running')
@@ -161,45 +162,36 @@
 run_dir = None
 inst = None
 env = None
-iface = None
+bind_ip = None
 proc = None
 
 BIN_ABISIP_FIND = 'abisip-find'
 BTS_UNIT_ID_RE = re.compile("Unit_ID='(?P\d+)/\d+/\d+'")
 
-def __init__(self, suite_run, parent_run_dir, iface, name_suffix):
+def __init__(self, suite_run, parent_run_dir, bind_ip, name_suffix):
 super().__init__(log.C_RUN, AbisIpFind.BIN_ABISIP_FIND + '-' + 
name_suffix)
 self.suite_run = suite_run
 self.parent_run_dir = parent_run_dir
-self.iface = iface
+self.bind_ip = bind_ip
 self.env = {}
-
-def launch_process(self, binary_name, *args):
-binary = os.path.abspath(self.inst.child('bin', binary_name))
-run_dir = self.run_dir.new_dir(binary_name)
-if not os.path.isfile(binary):
-raise RuntimeError('Binary missing: %r' % binary)
-proc = process.Process(binary_name, run_dir,
-   (binary,) + args,
-   env=self.env)
-self.suite_run.remember_to_stop(proc)
-proc.launch()
-return proc
 
 def start(self):
 self.run_dir = util.Dir(self.parent_run_dir.new_dir(self.name()))
 self.inst = 
util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-bsc')))
+
 lib = self.inst.child('lib')
 if not 

osmo-gsm-tester[master]: nanobts: Bind to specific addr instead of specific iface

2018-03-27 Thread Pau Espin Pedrol

Patch Set 2: -Code-Review

-- 
To view, visit https://gerrit.osmocom.org/7502
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I02f6fc9e1cb1ea1e1d950eafe22c231a18100f98
Gerrit-PatchSet: 2
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: No


osmo-gsm-tester[master]: nanobts: Bind to specific addr instead of specific iface

2018-03-27 Thread Pau Espin Pedrol

Patch Set 2: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/7502
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I02f6fc9e1cb1ea1e1d950eafe22c231a18100f98
Gerrit-PatchSet: 2
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: No


osmo-gsm-tester[master]: nanobts: Bind to specific addr instead of specific iface

2018-03-26 Thread Pau Espin Pedrol

Patch Set 2:

(1 comment)

https://gerrit.osmocom.org/#/c/7502/2/COPYING
File COPYING:

Line 1:  GNU GENERAL PUBLIC LICENSE
> ?!?
That was a test to try to retrigger the the job as the gerrit job seems to be 
not working fine.


-- 
To view, visit https://gerrit.osmocom.org/7502
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I02f6fc9e1cb1ea1e1d950eafe22c231a18100f98
Gerrit-PatchSet: 2
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: Yes


osmo-gsm-tester[master]: nanobts: Bind to specific addr instead of specific iface

2018-03-26 Thread Harald Welte

Patch Set 2:

(1 comment)

https://gerrit.osmocom.org/#/c/7502/2/COPYING
File COPYING:

Line 1:  GNU GENERAL PUBLIC LICENSE
?!?


-- 
To view, visit https://gerrit.osmocom.org/7502
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I02f6fc9e1cb1ea1e1d950eafe22c231a18100f98
Gerrit-PatchSet: 2
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: Yes


[PATCH] osmo-gsm-tester[master]: nanobts: Bind to specific addr instead of specific iface

2018-03-26 Thread Pau Espin Pedrol
Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/7502

to look at the new patch set (#2).

nanobts: Bind to specific addr instead of specific iface

This way root access is not required.

Change-Id: I02f6fc9e1cb1ea1e1d950eafe22c231a18100f98
---
M COPYING
M example/resources.conf.prod
M example/resources.conf.rnd
M src/osmo_gsm_tester/bts_nanobts.py
M src/osmo_gsm_tester/resource.py
M src/osmo_gsm_tester/util.py
6 files changed, 38 insertions(+), 34 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/02/7502/2

diff --git a/COPYING b/COPYING
index 94a9ed0..7e0f595 100644
--- a/COPYING
+++ b/COPYING
@@ -1,4 +1,4 @@
-GNU GENERAL PUBLIC LICENSE
+ GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
 
  Copyright (C) 2007 Free Software Foundation, Inc. 
diff --git a/example/resources.conf.prod b/example/resources.conf.prod
index 9f815b8..230976d 100644
--- a/example/resources.conf.prod
+++ b/example/resources.conf.prod
@@ -49,7 +49,6 @@
   ipa_unit_id: 9
   addr: 10.42.42.53
   band: GSM-1900
-  net_device: enp2s0
   power_supply:
 type: 'sispm'
 device: '01:01:4d:98:24'
diff --git a/example/resources.conf.rnd b/example/resources.conf.rnd
index ae48081..8ccf749 100644
--- a/example/resources.conf.rnd
+++ b/example/resources.conf.rnd
@@ -32,7 +32,6 @@
   ipa_unit_id: 9
   addr: 10.42.42.53
   band: GSM-1900
-  net_device: enp2s0
   power_supply:
 type: 'sispm'
 device: '01:01:55:2e:b6'
diff --git a/src/osmo_gsm_tester/bts_nanobts.py 
b/src/osmo_gsm_tester/bts_nanobts.py
index f666f7a..f42bc6e 100644
--- a/src/osmo_gsm_tester/bts_nanobts.py
+++ b/src/osmo_gsm_tester/bts_nanobts.py
@@ -86,24 +86,25 @@
 ###
 
 def start(self):
-for attr in ['net_device', 'ipa_unit_id']:
-if self.conf.get(attr) is None:
-raise log.Error('No attribute %s provided in conf!' % attr)
+if self.conf.get('ipa_unit_id') is None:
+raise log.Error('No attribute %s provided in conf!' % attr)
 self.run_dir = 
util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name()))
 self._configure()
 
-iface = self.conf.get('net_device')
 unitid = int(self.conf.get('ipa_unit_id'))
 bts_ip = self.remote_addr()
+# This fine for now, however concurrent tests using Nanobts may run 
into "address already in use" since dst is broadcast.
+# Once concurrency is needed, a new config attr should be added to 
have an extra static IP assigned on the main-unit to each Nanobts resource.
+local_bind_ip =util.dst_ip_get_local_bind(bts_ip)
 
 # Make sure nanoBTS is powered and in a clean state:
 self.pwsup.power_cycle(1.0)
 
-pcap_recorder.PcapRecorder(self.suite_run, 
self.run_dir.new_dir('pcap'), iface,
+pcap_recorder.PcapRecorder(self.suite_run, 
self.run_dir.new_dir('pcap'), None,
'host %s and port not 22' % 
self.remote_addr())
 
-self.log('Finding nanobts %s...' % bts_ip)
-ipfind = AbisIpFind(self.suite_run, self.run_dir, iface, 'preconf')
+self.log('Finding nanobts %s, binding on %s...' % (bts_ip, 
local_bind_ip))
+ipfind = AbisIpFind(self.suite_run, self.run_dir, local_bind_ip, 
'preconf')
 ipfind.start()
 ipfind.wait_bts_ready(bts_ip)
 running_unitid = ipfind.get_unitid_by_ip(bts_ip)
@@ -124,7 +125,7 @@
 event_loop.sleep(self, 20)
 
 self.log('Starting to connect to', self.bsc)
-ipfind = AbisIpFind(self.suite_run, self.run_dir, iface, 'postconf')
+ipfind = AbisIpFind(self.suite_run, self.run_dir, local_bind_ip, 
'postconf')
 ipfind.start()
 ipfind.wait_bts_ready(bts_ip)
 self.log('nanoBTS configured and running')
@@ -161,45 +162,36 @@
 run_dir = None
 inst = None
 env = None
-iface = None
+bind_ip = None
 proc = None
 
 BIN_ABISIP_FIND = 'abisip-find'
 BTS_UNIT_ID_RE = re.compile("Unit_ID='(?P\d+)/\d+/\d+'")
 
-def __init__(self, suite_run, parent_run_dir, iface, name_suffix):
+def __init__(self, suite_run, parent_run_dir, bind_ip, name_suffix):
 super().__init__(log.C_RUN, AbisIpFind.BIN_ABISIP_FIND + '-' + 
name_suffix)
 self.suite_run = suite_run
 self.parent_run_dir = parent_run_dir
-self.iface = iface
+self.bind_ip = bind_ip
 self.env = {}
-
-def launch_process(self, binary_name, *args):
-binary = os.path.abspath(self.inst.child('bin', binary_name))
-run_dir = self.run_dir.new_dir(binary_name)
-if not os.path.isfile(binary):
-raise RuntimeError('Binary missing: %r' % binary)
-proc = process.Process(binary_name, run_dir,
-   (binary,) + args,
-   env=self.env)
-