aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlton MacDonald <alton.kenneth.macdonald@fokus.fraunhofer.de>2013-12-11 11:52:28 +0100
committerAlton MacDonald <alton.kenneth.macdonald@fokus.fraunhofer.de>2013-12-11 11:52:28 +0100
commitc512fd826427e508a8735a9b54cc770fa09a5368 (patch)
tree59397c655d6cfae388e49bde86ec4f2ca151c340
parent51f696bf9ab1a2b061d48ef644480efa96e4158d (diff)
added error exceptions for DB locking and added third state to BTS notification
-rw-r--r--hlr_mgmt/RegisterIMEI.py2
-rw-r--r--hlr_mgmt/SubscriberMonitor.py42
-rw-r--r--hlr_mgmt/__init__.py2
-rw-r--r--hlr_mgmt/templates/bts.mako20
-rw-r--r--hlr_mgmt/templates/layout.mako2
-rw-r--r--hlr_mgmt/templates/scripts.mako20
-rw-r--r--hlr_mgmt/views.py14
7 files changed, 62 insertions, 40 deletions
diff --git a/hlr_mgmt/RegisterIMEI.py b/hlr_mgmt/RegisterIMEI.py
index 3df58a4..6dad6aa 100644
--- a/hlr_mgmt/RegisterIMEI.py
+++ b/hlr_mgmt/RegisterIMEI.py
@@ -116,7 +116,7 @@ class RegisterIMEI(threading.Thread):
def run(self):
log.debug("starting RegisterIMEI deamon")
- self.sqlconn = sqlite3.connect(self.HLR_DB)
+ self.sqlconn = sqlite3.connect(self.HLR_DB,60)
self.cursor = self.sqlconn.cursor()
return self.authorize_imei(self.imei)
diff --git a/hlr_mgmt/SubscriberMonitor.py b/hlr_mgmt/SubscriberMonitor.py
index 50a4704..e4632d3 100644
--- a/hlr_mgmt/SubscriberMonitor.py
+++ b/hlr_mgmt/SubscriberMonitor.py
@@ -39,25 +39,39 @@ class SubscriberMonitor(threading.Thread):
self.bsc_conn = telnet_backend(ip, port)
self.active_subscribers = collections.defaultdict()
self.active = True
-
+
+ def is_running(self):
+ return self.active
+
+ def connect_to_db(self):
self.sqlconn = sqlite3.connect(self.HLR_DB, check_same_thread = False)
self.cursor = self.sqlconn.cursor()
+ def disconnect_from_db(self):
+ try:
+ self.sqlconn.close()
+ except:
+ pass
+
def run(self):
- self.get_active_subs()
- while(self.active):
- self.check_new_subs()
- self.get_active_subs()
- time.sleep(60)
- def stop(self):
- self.active = False
+ self.connect_to_db()
+ self.get_active_subs()
+ while(self.active):
+ try:
+ self.check_new_subs()
+ self.get_active_subs()
+ except sqlite3.OperationalError:
+ pass
+ time.sleep(60)
+ def stop(self):
+ self.active = False
+ self.disconnect_from_db()
- def restart(self):
- self.active_subscribers = collections.defaultdict()
- self.active = True
-
- def is_running(self):
- return self.active
+ def restart(self):
+ self.active_subscribers = collections.defaultdict()
+ self.active = True
+ self.disconnect_from_db()
+ self.connect_to_db()
def get_active_subs(self):
# query active subscribers
diff --git a/hlr_mgmt/__init__.py b/hlr_mgmt/__init__.py
index c5b6350..2b257f8 100644
--- a/hlr_mgmt/__init__.py
+++ b/hlr_mgmt/__init__.py
@@ -91,7 +91,7 @@ def load_settings():
# mcc_mnc was obtained manually from http://mobile-network-codes.com/mobile-network-codes-country-codes.asp
# initiates SubscriberMonitor
- subMonitor = SubscriberMonitor(settings['provider'], settings['db'], ip=settings['bsc_ip'] port=settings['bsc_port'])
+ subMonitor = SubscriberMonitor(settings['provider'], settings['db'], ip=settings['bsc_ip'], port=settings['bsc_port'])
subMonitor.setDaemon(True)
subMonitor.start()
settings['subMonitor'] = subMonitor
diff --git a/hlr_mgmt/templates/bts.mako b/hlr_mgmt/templates/bts.mako
index 0f7a08b..04159b7 100644
--- a/hlr_mgmt/templates/bts.mako
+++ b/hlr_mgmt/templates/bts.mako
@@ -12,10 +12,14 @@
% if bts and phys_cfg:
<ul class="nav nav-tabs">
% for i in range(0,len(bts)):
- % if bts[i].has_key('ip'):
- <li><a href="#bts_${i}" data-toggle="tab"><h5><span class="badge badge-success"><i class="icon-map-marker icon-white"></span></i> BTS ${i}</h5></a></li>
+ % if bts[i]['oml_state']:
+ % if bts[i].has_key('ip'):
+ <li><a href="#bts_${i}" data-toggle="tab"><h5><span class="badge badge-success"><i class="icon-map-marker icon-white"></span></i> BTS ${i}</h5></a></li>
+ % else:
+ <li><a href="#bts_${i}" data-toggle="tab"><h5><span class="badge badge-warning"><i class="icon-warning-sign icon-white"></span></i> BTS ${i}</h5></a></li>
+ % endif
% else:
- <li><a href="#bts_${i}" data-toggle="tab"><h5><span class="badge badge-warning"><i class="icon-warning-sign icon-white"></span></i> BTS ${i}</h5></a></li>
+ <li><a href="#bts_${i}" data-toggle="tab"><h5><span class="badge badge-important"><i class="icon-exclamation-sign icon-white"></span></i> BTS ${i}</h5></a></li>
% endif
% endfor
</ul>
@@ -27,10 +31,14 @@
<div class="tab-pane" id="bts_${i}">
% endif
<h3>BTS ${i}
- % if bts[i].has_key('ip'):
- (${bts[i]['ip']})
+ % if bts[i]['oml_state']:
+ % if bts[i].has_key('ip'):
+ (${bts[i]['ip']})
+ % else:
+ (OML connected without IP address)
+ % endif
% else:
- (not connected)
+ (OML disconnected)
% endif
<br/>${bts[i]['description']}
</h3>
diff --git a/hlr_mgmt/templates/layout.mako b/hlr_mgmt/templates/layout.mako
index dabffe5..b259009 100644
--- a/hlr_mgmt/templates/layout.mako
+++ b/hlr_mgmt/templates/layout.mako
@@ -36,7 +36,7 @@
<div class="fluid-container">
<div class="fluid-row">
<div class="span2 affix" style="height:100%;">
- <a href="http://www.fokus.fraunhofer.de/de/rescon/index.html">
+ <a href="http://www.fokus.fraunhofer.de/en/net/index.html">
<img src="/static/images/FOKUS.png">
</a>
<ul class="nav nav-list bs-docs-sidenav">
diff --git a/hlr_mgmt/templates/scripts.mako b/hlr_mgmt/templates/scripts.mako
index 589c8fc..6d76daf 100644
--- a/hlr_mgmt/templates/scripts.mako
+++ b/hlr_mgmt/templates/scripts.mako
@@ -28,7 +28,7 @@
</tr>
</thead>
<tbody>
- <tr><td>LCR</td>
+ <tr><td>LCR <div class="pull-right">(Local GSM Call Routing)</div></td>
% if service_status['lcr']:
% if service_status['lcr'].find("running")>0:
<td><span class="label label-success">Running</span></td>
@@ -43,7 +43,7 @@
<reload><a href="${request.route_url('manage_service', service='lcr', action=2)}"><span class="badge badge-info"><i class="icon-repeat icon-white"></i></span></a></reload>
<stop><a href="${request.route_url('manage_service', service='lcr', action=3)}"><span class="badge badge-important"><i class="icon-pause icon-white"></i></span></a></stop>
</td></tr>
- <tr><td>Asterisk</td>
+ <tr><td>Asterisk <div class="pull-right">(External Call Routing)</div></td>
% if service_status['asterisk']:
% if service_status['asterisk'].find("failed")<0:
<td><span class="label label-success">Running</span></td>
@@ -58,7 +58,7 @@
<reload><a href="${request.route_url('manage_service', service='asterisk', action=2)}"><span class="badge badge-info"><i class="icon-repeat icon-white"></i></span></a></reload>
<stop><a href="${request.route_url('manage_service', service='asterisk', action=3)}"><span class="badge badge-important"><i class="icon-pause icon-white"></i></span></a></stop>
</td></tr>
- <tr><td>GGSN</td>
+ <tr><td>GGSN <div class="pull-right">(Data Gateway)</div></td>
% if service_status['ggsn']:
% if service_status['ggsn'].find("failed")<0:
<td><span class="label label-success">Running</span></td>
@@ -73,7 +73,7 @@
<reload><a href="${request.route_url('manage_service', service='ggsn', action=2)}"><span class="badge badge-info"><i class="icon-repeat icon-white"></i></span></a></reload>
<stop><a href="${request.route_url('manage_service', service='ggsn', action=3)}"><span class="badge badge-important"><i class="icon-pause icon-white"></i></span></a></stop>
</td></tr>
- <tr><td>OpenBSC</td>
+ <tr><td>OpenBSC <div class="pull-right">(Controls GSM Access)</div></td>
% if service_status['nitb']:
% if service_status['nitb'].find("failed")<0:
<td><span class="label label-success">Running</span></td>
@@ -88,7 +88,7 @@
<reload><a href="${request.route_url('manage_service', service='nitb', action=2)}"><span class="badge badge-info"><i class="icon-repeat icon-white"></i></span></a></reload>
<stop><a href="${request.route_url('manage_service', service='nitb', action=3)}"><span class="badge badge-important"><i class="icon-pause icon-white"></i></span></a></stop>
</td></tr>
- <tr><td>OsmoSGSN</td>
+ <tr><td>OsmoSGSN <div class="pull-right">(GPRS Data Interface)</div></td>
% if service_status['sgsn']:
% if service_status['sgsn'].find("failed")<0:
<td><span class="label label-success">Running</span></td>
@@ -103,15 +103,11 @@
<reload><a href="${request.route_url('manage_service', service='sgsn', action=2)}"><span class="badge badge-info"><i class="icon-repeat icon-white"></i></span></a></reload>
<stop><a href="${request.route_url('manage_service', service='sgsn', action=3)}"><span class="badge badge-important"><i class="icon-pause icon-white"></i></span></a></stop>
</td></tr>
- <tr><td><strong><em>SubscriberMonitor</em></strong></td>
+ <tr><td><strong><em>SubscriberMonitor</em></strong> <div class="pull-right">(Greets users with SMS)</div></td>
% if service_status['subMonitor']:
- % if service_status['subMonitor']==True:
- <td><span class="label label-success">Running</span></td>
- % else:
- <td><span class="label label-important">Stopped</span></td>
- % endif
+ <td><span class="label label-success">Running</span></td>
% else:
- <td><span class="label label-warning">ERROR</span></td>
+ <td><span class="label label-important">Stopped</span></td>
% endif
<td>
<start><a href="${request.route_url('manage_service', service='subMonitor', action=1)}"><span class="badge badge-success"><i class="icon-play icon-white"></i></span></a></start>
diff --git a/hlr_mgmt/views.py b/hlr_mgmt/views.py
index 98ff47a..50f0ef0 100644
--- a/hlr_mgmt/views.py
+++ b/hlr_mgmt/views.py
@@ -52,11 +52,14 @@ def connect_sgsn(settings):
return sgsn
def db_execute(db, sql_string, params=None):
- if params==None:
- rs = db.execute(sql_string)
- else:
- rs = db.execute(sql_string, params)
- db.commit()
+ try:
+ if params==None:
+ rs = db.execute(sql_string)
+ else:
+ rs = db.execute(sql_string, params)
+ db.commit()
+ except sqlite3.OperationalError:
+ rs = []
return rs
def db_query(db, sql_string, params=None):
@@ -240,6 +243,7 @@ def bts_view(request):
bts[i]['timeslots'] = collections.defaultdict()
bts[i]['stats'] = bsc.get_bts_info(str(i))
bts[i]['description'] = bts[i]['stats'][1].split(": ")[1].strip()
+ bts[i]['oml_state'] = (bts[i]['stats'][15].split(": ")[1] == "connected.")
for j in range(0,8):
helper = bsc.get_timeslot_info(str(i), str(j))
bts[i]['timeslots'][j] = helper[0].replace("cfg","cfg:") + "," + helper[1]