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
Review at https://gerrit.osmocom.org/2676
ofono_client: Discover modem path from imsi
Change-Id: Ib9f4de81abc18e8db0c15df965e4811b6513e1b1
---
M example/resources.conf
M src/osmo_gsm_tester/ofono_client.py
M src/osmo_gsm_tester/osmo_nitb.py
3 files changed, 65 insertions(+), 14 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/76/2676/1
diff --git a/example/resources.conf b/example/resources.conf
index cd0216e..b7ac5a3 100644
--- a/example/resources.conf
+++ b/example/resources.conf
@@ -60,21 +60,17 @@
modem:
- label: sierra_1
- path: '/sierra_1'
imsi: '901700000009031'
ki: '80A37E6FDEA931EAC92FFA5F671EFEAD'
- label: sierra_2
- path: '/sierra_2'
imsi: '901700000009029'
ki: '00969E283349D354A8239E877F2E0866'
- label: gobi_0
- path: '/gobi_0'
imsi: '901700000009030'
ki: 'BB70807226393CDBAC8DD3439FF54252'
- label: gobi_3
- path: '/gobi_3'
imsi: '901700000009032'
ki: '2F70DCA43C45ACB97E947FDD0C7CA30A'
diff --git a/src/osmo_gsm_tester/ofono_client.py b/src/osmo_gsm_tester/ofono_client.py
index faa9192..8659e36 100644
--- a/src/osmo_gsm_tester/ofono_client.py
+++ b/src/osmo_gsm_tester/ofono_client.py
@@ -31,6 +31,7 @@
I_MODEM = 'org.ofono.Modem'
I_NETREG = 'org.ofono.NetworkRegistration'
I_SMS = 'org.ofono.MessageManager'
+I_SIM = 'org.ofono.SimManager'
class DeferredHandling:
defer_queue = []
@@ -77,16 +78,74 @@
'convenience for ofono Modem interaction'
msisdn = None
sms_received_list = None
+ imsi_modem_map = None
+
+ @staticmethod
+ def modem_is_powered(modem_obj, val):
+ modem_prop = modem_obj[I_MODEM].GetProperties()
+ return modem_prop.get('Powered') == val
+
+ @staticmethod
+ def modem_has_val_in_property(modem_obj, iface, prop_name, val):
+ modem_prop = modem_obj[iface].GetProperties()
+ return val in modem_prop.get(prop_name)
+
+ @staticmethod
+ def build_imsi_modem_map(log_obj):
+ Modem.imsi_modem_map = {}
+ test.poll()
+ modems = list_modems()
+ for modem_path, prop in modems:
+ log_obj.dbg('Discovering imsi for modem %s' % modem_path)
+ modem_obj = systembus_get(modem_path)
+ modem_prop = modem_obj[I_MODEM].GetProperties()
+ powered = modem_prop.get('Powered')
+ if not powered:
+ print('Powering on %s' % modem_path)
+ modem_obj[I_MODEM].SetProperty('Powered', Variant('b', True))
+ test.wait(Modem.modem_is_powered, modem_obj, True)
+
+ try:
+ has_sim_feature = True
+ test.wait(Modem.modem_has_val_in_property, modem_obj, I_MODEM, 'Features', 'sim')
+ except RuntimeError:
+ has_sim_feature = False
+ log_obj.dbg('modem %s has no sim feature, skipping' % modem_path)
+ if has_sim_feature:
+ test.wait(Modem.modem_has_val_in_property, modem_obj, I_MODEM, 'Interfaces', I_SIM)
+ sim_prop = modem_obj[I_SIM].GetProperties()
+ imsi = sim_prop.get('SubscriberIdentity')
+ if imsi:
+ Modem.imsi_modem_map[imsi] = modem_path
+
+ #Leave in same status as it was:
+ if not powered:
+ modem_obj[I_MODEM].SetProperty('Powered', Variant('b', False))
+ test.wait(Modem.modem_is_powered, modem_obj, False)
+ log_obj.log('imsi->modem map:', Modem.imsi_modem_map)
def __init__(self, conf):
+ if Modem.imsi_modem_map is None:
+ Modem.build_imsi_modem_map(self)
self.conf = conf
- self.path = conf.get('path')
- self.set_name(self.path)
+ self.label = conf.get('label')
+ self.imsi = conf.get('imsi')
+ self.set_name(self.label if self.label else self.imsi)
self.set_log_category(log.C_BUS)
+ if not self.imsi:
+ with self:
+ raise RuntimeError('No IMSI')
self._dbus_obj = None
self._interfaces = set()
self._connected_signals = util.listdict()
self.sms_received_list = []
+ # Try to find path if not provided:
+ self.path = conf.get('path')
+ if not self.path:
+ self.path = Modem.imsi_modem_map.get(self.imsi)
+ if not self.path:
+ with self:
+ raise RuntimeError('Unable to find modem with IMSI %s (%s)' % (self.imsi, self.label))
# init interfaces and connect to signals:
self.dbus_obj()
test.poll()
@@ -95,11 +154,7 @@
self.msisdn = msisdn
def imsi(self):
- imsi = self.conf.get('imsi')
- if not imsi:
- with self:
- raise RuntimeError('No IMSI')
- return imsi
+ return self.imsi
def ki(self):
return self.conf.get('ki')
diff --git a/src/osmo_gsm_tester/osmo_nitb.py b/src/osmo_gsm_tester/osmo_nitb.py
index 13dfe27..33463c8 100644
--- a/src/osmo_gsm_tester/osmo_nitb.py
+++ b/src/osmo_gsm_tester/osmo_nitb.py
@@ -96,12 +96,12 @@
if msisdn is None:
msisdn = self.suite_run.resources_pool.next_msisdn(modem)
modem.set_msisdn(msisdn)
- self.log('Add subscriber', msisdn=msisdn, imsi=modem.imsi())
+ self.log('Add subscriber', msisdn=msisdn, imsi=modem.imsi)
with self:
- OsmoNitbCtrl(self).subscriber_add(modem.imsi(), msisdn, modem.ki())
+ OsmoNitbCtrl(self).subscriber_add(modem.imsi, msisdn, modem.ki())
def subscriber_attached(self, *modems):
- return self.imsi_attached(*[m.imsi() for m in modems])
+ return self.imsi_attached(*[m.imsi for m in modems])
def imsi_attached(self, *imsis):
attached = self.imsi_list_attached()
--
To view, visit https://gerrit.osmocom.org/2676
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib9f4de81abc18e8db0c15df965e4811b6513e1b1
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>