Change in docker-playground[master]: osmo-ci-latest: Add options to change mcc/mnc for SIM card data

Daniel Willmann gerrit-no-reply at lists.osmocom.org
Thu Mar 28 12:24:02 UTC 2019


Daniel Willmann has uploaded this change for review. ( https://gerrit.osmocom.org/13440


Change subject: osmo-ci-latest: Add options to change mcc/mnc for SIM card data
......................................................................

osmo-ci-latest: Add options to change mcc/mnc for SIM card data

Change-Id: Ica348dc12f07a1a57729c4d97a40cf9c04e975c9
---
M osmo-cn-latest/create_hlr.py
1 file changed, 24 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/docker-playground refs/changes/40/13440/1

diff --git a/osmo-cn-latest/create_hlr.py b/osmo-cn-latest/create_hlr.py
index 4285ea6..b754af7 100755
--- a/osmo-cn-latest/create_hlr.py
+++ b/osmo-cn-latest/create_hlr.py
@@ -3,8 +3,17 @@
 import csv
 import sys
 import sqlite3
+from optparse import OptionParser
 
-# 3G
+def parse_options():
+    parser = OptionParser()
+
+    parser.add_option("-c", "--mcc", dest="mcc", help="Mobile Country Code")
+    parser.add_option("-n", "--mnc", dest="mnc", help="Mobile Network Code")
+    (options, args) = parser.parse_args()
+
+    return options, args
+
 def create_hlr_3g(db):
 	conn = sqlite3.connect(db)
 	c = conn.execute(
@@ -112,7 +121,10 @@
 	conn.commit()
 	conn.close()
 
-def main(infilename):
+def main():
+        options, args = parse_options()
+
+        infilename = args[0]
 	csvfields = ['name', 'iccid', 'mcc', 'mnc', 'imsi', 'extension', 'smsp', 'ki', 'opc', 'adm1']
 
 	create_hlr_3g("hlr.db")
@@ -124,12 +136,18 @@
 
 	cw.writeheader()
 	for row in cr:
+		imsi = row['imsi']
+                if options.mcc:
+                    imsi = options.mcc + imsi[3:]
+                if options.mnc:
+                    imsi = imsi[0:3] + options.mnc + imsi[5:]
+                    
 		data = {}
 		data['name'] = "Subscriber " + row['iccid'][-6:-1]
 		data['iccid'] = row['iccid']
-		data['mcc'] = row['imsi'][0:3]
-		data['mnc'] = row['imsi'][3:5]
-		data['imsi'] = row['imsi']
+                data['imsi'] = imsi
+		data['mcc'] = data['imsi'][0:3]
+		data['mnc'] = data['imsi'][3:5]
 		data['ki'] = row['ki']
 		data['opc'] = row['opc']
 		data['extension'] = row['iccid'][-6:-1]
@@ -143,5 +161,5 @@
 
 
 if __name__ == '__main__':
-    main(sys.argv[1])
+    main()
 

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

Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ica348dc12f07a1a57729c4d97a40cf9c04e975c9
Gerrit-Change-Number: 13440
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Willmann <dwillmann at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190328/303da150/attachment-0001.html>


More information about the gerrit-log mailing list