X-Git-Url: https://git.llucax.com/software/pymin.git/blobdiff_plain/758d3079a17194172b723101a57cb9af6af3a34e..3c717546f26524f438aeadc7776b57579400f7cb:/pymin/services/ip/__init__.py?ds=inline diff --git a/pymin/services/ip/__init__.py b/pymin/services/ip/__init__.py index e626ab7..560e2f5 100644 --- a/pymin/services/ip/__init__.py +++ b/pymin/services/ip/__init__.py @@ -187,6 +187,7 @@ class IpHandler(Restorable, ConfigWriter, TransactionalHandler): self._config_writer_cfg_dir = config_dir self._config_build_templates() self._restore() + self._write_config() self.addr = AddressHandler(self) self.route = RouteHandler(self) self.dev = DeviceHandler(self) @@ -225,9 +226,26 @@ class IpHandler(Restorable, ConfigWriter, TransactionalHandler): ), shell=True) + 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] = Device(k,v) + #delete dead devices + for k in self.devices.keys(): + if k not in devices: + del self.devices[k] + + + if __name__ == '__main__': - ip = IpHandler() + ip = IpHanlder() print '----------------------' ip.hop.add('201.21.32.53','eth0') ip.hop.add('205.65.65.25','eth1')