- print 'ip route del default'
- #call('ip route del default', shell=True)
- print self._render_config('hop', dict(
- hops = self.hops,
- ))
- #call(self._render_config('hop', dict(
- #hops = self.hops,
- #)
- #), shell=True)
+ try:
+ call('ip route del default', shell=True)
+ except ExecutionError, e:
+ print e
+ try:
+ call(self._render_config('hop', dict(
+ hops = self.hops,
+ )
+ ), shell=True)
+ except ExecutionError, e:
+ print e
+
+
+ def handle_timer(self):
+ self.refresh_devices()
+
+
+ def refresh_devices(self):
+ devices = get_network_devices()
+ #add not registered devices
+ for k,v in devices.items():
+ if k not in self.devices:
+ self.devices[k] = v
+ #delete dead devices
+ for k in self.devices.keys():
+ if k not in devices:
+ del self.devices[k]
+