Esempio n. 1
0
 def start(self):
     """Start the Server
     """
     JNTServer.start(self)
     JNTControllerManager.start_controller(self, self.section, self.options, cmd_classes=[COMMAND_UPDATE], hadd=None, name="Raspberry Pi Server",
         product_name="Raspberry Pi Server", product_type="Raspberry Pi Server")
     JNTControllerManager.start_controller_timer(self)
Esempio n. 2
0
 def start(self):
     """Start the DHCP Server
     """
     logger.info("Start the server")
     self.lease_mgr = LeaseManager(self.options)
     #~ self.uuid = self.options.get_option(self.section, 'uuid')
     #~ if self.uuid == None:
         #~ self.uuid = muuid.uuid1()
         #~ self.options.set_option(self.section, 'uuid', '%s'%self.uuid)
     self.loop_sleep = 0.25
     loop_sleep = self.options.get_option('system','loop_sleep')
     if loop_sleep is not None:
         try:
             self.loop_sleep = int(loop_sleep)
         except Exception:
             logger.exception("[%s] - Exception when retrieving value of loop_sleep. Use default value instead", self.__class__.__name__)
     self.network = DhcpNetwork(self._stopevent, self.options, is_primary=True, is_secondary=False, do_heartbeat_dispatch=True)
     JNTDBServer.start(self)
     JNTControllerManager.start_controller(self, self.section, self.options, cmd_classes=[COMMAND_DHCPD], hadd=None, name="DHCP Server",
         product_name="DHCP Server", product_type="DHCP Server")
     self.mqtt_resolv = MQTTClient(options=self.options.data, loop_sleep=self.loop_sleep)
     self.mqtt_resolv.connect()
     self.mqtt_resolv.start()
     #~ print "self.network.resolv_timeout", self.network.resolv_timeout
     self.resolv_timer = threading.Timer(self.network.resolv_timeout, self.resolv_heartbeat)
     self.resolv_timer.start()
     self.network.boot({0:self.get_controller_hadd()}, loop_sleep=self.loop_sleep)
     self.mqtt_client = MQTTClient(options=self.options.data, loop_sleep=self.loop_sleep)
     self.mqtt_client.add_topic(topic='/dhcp/lease/new', callback=self.mqtt_on_lease_new)
     self.mqtt_client.add_topic(topic='/dhcp/lease/repair', callback=self.mqtt_on_lease_repair)
     self.mqtt_client.add_topic(topic='/dhcp/lease/lock', callback=self.mqtt_on_lease_lock)
     self.mqtt_client.add_topic(topic='/dhcp/lease/remove', callback=self.mqtt_on_lease_remove)
     self.mqtt_client.add_topic(topic='/dhcp/lease/release', callback=self.mqtt_on_lease_release)
     self.mqtt_client.add_topic(topic='/dhcp/heartbeat#', callback=self.mqtt_on_heartbeat)
     self.mqtt_client.add_topic(topic='/dhcp/resolv/hadd', callback=self.mqtt_on_resolv_hadd)
     self.mqtt_client.add_topic(topic='/dhcp/resolv/name', callback=self.mqtt_on_resolv_name)
     self.mqtt_client.add_topic(topic='/dhcp/resolv/cmd_classes', callback=self.mqtt_on_resolv_cmd_classes)
     self.mqtt_client.connect()
     self.mqtt_client.subscribe(topic='/dhcp/#', callback=self.mqtt_on_message)
     self.mqtt_client.start()
     self.heartbeat_timer = threading.Timer(self.lease_mgr.heartbeat_timeout, self.check_heartbeat)
     self.heartbeat_timer.start()
     #ProgrammingError: (pysqlite2.dbapi2.ProgrammingError) SQLite objects created in a thread can only be used in that same thread.
     #The object was created in thread id 139632282289984 and this is thread id 139632153548544
     #[SQL: u'SELECT dhcpd_lease.add_ctrl AS dhcpd_lease_add_ctrl, dhcpd_lease.add_node AS dhcpd_lease_add_node, dhcpd_lease.name AS dhcpd_lease_name, dhcpd_lease.location AS dhcpd_lease_location, dhcpd_lease.cmd_classes AS dhcpd_lease_cmd_classes, dhcpd_lease.state AS dhcpd_lease_state, dhcpd_lease.last_seen AS dhcpd_lease_last_seen \nFROM dhcpd_lease'] [parameters: [immutabledict({})]]
     #self.lease_mgr.start(self.dbsession)
     #Use a new session for the lease
     self.lease_mgr.start(self.create_session(), self.network.heartbeat_cache)
     JNTControllerManager.start_controller_timer(self)