def handleHostApEvent(eventName, host_id, session_id, service_id): """Receives service callbacks to update the radius client table""" session = getSessionE(session_id) hostapService = -1 ethernetService = -1 # Ignore events that don't relate to the hostap or ethernet customer # services try: hostapService = getServiceID(session_id, "hostapd") except ccs_service_error: # Hostapd service not installed pass try: ethernetService = getServiceID(session_id, "ethernet_customer") except ccs_service_error: # Ethernet customer service not installed pass if int(service_id) not in [hostapService, ethernetService]: return if eventName == "serviceAdded": # Create a RADIUS client record for this host session.execute("INSERT INTO radius_client (host_id, secret) " \ "VALUES (%s, %s)", (host_id, createPassword(16))) elif eventName == "serviceRemoved": # Remove the RADIUS client record for this host # XXX: Don't remove, the other service might still want it #session.execute("DELETE FROM radius_client WHERE host_id=%s", # (host_id)) pass else: # Invalid event pass
def handleBindEvent(eventName, host_id, session_id, service_id): """Receives service callbacks to update the dns server table""" session = getSessionE(session_id) try: bindService = getServiceID(session_id, "bind") except ccs_bind_error: # BIND service not installed return False if int(service_id) != bindService: return False if eventName == "serviceAdded": session.execute("INSERT INTO dns_server (dns_server_id, " \ "host_id, is_master) VALUES (DEFAULT, %s, 'f')", (host_id)) elif eventName == "serviceRemoved": session.execute("DELETE FROM dns_server WHERE host_id=%s", (host_id)) return True
def hasServiceEnabledByName(self, service_name): service_id = getServiceID(self._session_id, service_name) return self.hasServiceEnabled(service_id)