Changeset 1170
- Timestamp:
- 12/05/06 17:02:24 (6 years ago)
- Location:
- ccsd
- Files:
-
- 7 added
- 4 edited
-
private/templates/host/clients_conf.tmpl (modified) (1 diff)
-
private/templates/host/hostapd (added)
-
private/templates/host/hostapd/hostapd.tmpl (added)
-
private/templates/host/hostapd_default.tmpl (added)
-
private/templates/host/interfaces.tmpl (modified) (3 diffs)
-
private/templates/network/cfconf/cf_hostapd.tmpl (added)
-
private/templates/network/services/ap_plans.tmpl (added)
-
trunk/crcnetd/modules/ccs_hostapd.py (modified) (2 diffs)
-
trunk/crcnetd/modules/ccs_radius.py (modified) (5 diffs)
-
trunk/dbschema/hostapd.dropschema (added)
-
trunk/dbschema/hostapd.schema (added)
Legend:
- Unmodified
- Added
- Removed
-
ccsd/private/templates/host/clients_conf.tmpl
r1169 r1170 14 14 commentStartToken = !! 15 15 #end compiler-settings 16 !set %radius = %service ["radius"]16 !set %radius = %services["radius"] 17 17 ############################################################# 18 18 # -
ccsd/private/templates/host/interfaces.tmpl
r926 r1170 12 12 #from crcnetd._utils.ccsd_cfengine import ccs_template 13 13 #extends ccs_template 14 #if "hostapd" in $services.keys() 15 #set $hostapd = $services["hostapd"] 16 #else 17 #set $hostapd = None 18 #end if 14 19 ## 15 20 ## Real template output starts below here … … 59 64 auto $iface.name 60 65 #end if 66 ## Add hostapd allow- class line if necessary 67 #if $hostapd is not None and $hostapd.interfaceEnabled($session_id, $iface.interface_id) 68 allow-hostapd $iface.name 69 #end if 61 70 ${c}iface $iface.name inet static 62 71 $c address $iface.ip_address … … 94 103 #end if 95 104 $c wireless_essid $iface.essid 105 ## Add hostapd startup stanza if necessary 106 #if $hostapd is not None and $hostapd.interfaceEnabled($session_id, $iface.interface_id) 107 $c hostapd_config /etc/hostapd/hostapd-${iface.name}.conf 108 #end if 96 109 #end if 97 110 ## Create bridge interface if required -
ccsd/trunk/crcnetd/modules/ccs_hostapd.py
r1135 r1170 32 32 pass 33 33 34 def hostapdInterfaceEnabled(session_id, interface_id): 35 """Returns true if the hostapd service is enabled on the specified iface""" 36 session = getSessionE(session_id) 37 38 r = session.getCountOf("SELECT count(*) FROM hostapd_interface WHERE " \ 39 "interface_id=%s", (interface_id)) 40 if r == 1: 41 return True 42 43 return False 44 34 45 class hostapd_service(ccsd_service): 35 46 """Configures the hostapd service on a host""" … … 42 53 # Call base class setup 43 54 ccsd_service.__init__(self, session_id, service_id) 55 56 @registerEvent("hostapdInterfaceEnabled") 57 @exportViaXMLRPC(SESSION_RW, AUTH_ADMINISTRATOR, True) 58 def enableHostAPdInterface(self, host_id, interface_id): 59 """Enables HostAPd on the specified interface""" 60 session = getSessionE(self._session_id) 61 62 if hostapdInterfaceEnabled(self._session_id, interface_id): 63 raise hostapd_error("HostAPd already enabled on interface!") 64 65 session.execute("INSERT INTO hostapd_interface (interface_id) " \ 66 "VALUES (%s)", (interface_id)) 67 68 # Raise the event 69 triggerHostEvent(self._session_id, "hostapdInterfaceEnabled", \ 70 service_id=self.service_id, host_id=host_id, \ 71 interface_id=interface_id) 72 73 return True 74 75 @registerEvent("hostapdInterfaceDisabled") 76 @exportViaXMLRPC(SESSION_RW, AUTH_ADMINISTRATOR, True) 77 def disableHostAPdInterface(self, host_id, interface_id): 78 """Disables HostAPd on the specified interface""" 79 session = getSessionE(self._session_id) 80 81 session.execute("DELETE FROM hostapd_interface WHERE " \ 82 "interface_id=%s", (interface_id)) 83 84 # Raise the event 85 triggerHostEvent(self._session_id, "hostapdInterfaceDisabled", \ 86 service_id=self.service_id, host_id=host_id, \ 87 interface_id=interface_id) 88 89 return True 90 91 def getInterfaces(self, host_id): 92 """Returns details about interface that have hostapd enabled on them""" 93 session = getSessionE(self._session_id) 94 95 return session.query("SELECT i.*, CASE WHEN hi.interface_id IS NULL " \ 96 "THEN FALSE ELSE TRUE END AS hostapd_enabled " \ 97 "FROM interface i LEFT JOIN hostapd_interface hi ON " \ 98 "i.interface_id=hi.interface_id WHERE i.host_id=%s AND " \ 99 "i.master_interface='t'", (host_id)) 100 101 @exportViaXMLRPC(SESSION_RO, AUTH_ADMINISTRATOR, True, \ 102 "getHostHostAPdDetails") 103 def getHostDetails(self, host_id): 104 """Returns data relating to HostAPd on a host""" 105 session = getSessionE(self._session_id) 106 107 service = ccsd_service.getHostDetails(self, host_id) 108 service["interfaces"] = self.getInterfaces(host_id) 109 110 return service 111 112 def getPlans(self): 113 session = getSessionE(self._session_id) 114 115 plans = {} 116 117 for row in session.query("SELECT * FROM radius_plan", ()): 118 plans[row["plan_name"]] = row 119 120 return plans 121 122 def getNetworkTemplateVariables(self): 123 """Returns a dictionary containing template variables for all hosts 124 125 See the getTemplateVariables function for more details. 126 """ 127 128 # Call base class to get the basics 129 variables = ccsd_service.getNetworkTemplateVariables(self) 130 131 # Make the function available to templates 132 variables["interfaceEnabled"] = hostapdInterfaceEnabled 133 134 # List of RADIUS plans 135 variables["plans"] = self.getPlans() 136 137 return variables 44 138 45 139 @staticmethod -
ccsd/trunk/crcnetd/modules/ccs_radius.py
r1134 r1170 23 23 from crcnetd._utils.ccsd_log import * 24 24 from crcnetd._utils.ccsd_events import * 25 from crcnetd._utils.ccsd_config import config_get_required 25 26 from crcnetd._utils.ccsd_session import getSession, getSessionE 26 27 from crcnetd._utils.ccsd_service import ccsd_service, registerService, \ … … 31 32 class ccs_radius_error(ccsd_error): 32 33 pass 34 35 AUTHIP_PROPERTY = "auth_ip" 36 ACCTIP_PROPERTY = "acct_ip" 37 AUTHPORT_PROPERTY = "auth_port" 38 ACCTPORT_PROPERTY = "acct_port" 33 39 34 40 @catchEvent("serviceAdded") … … 78 84 for row in res: 79 85 clients[row["host_name"]] = filter_keys(row) 80 print clients81 86 return clients 87 88 def getNetworkTemplateVariables(self): 89 variables = ccsd_service.getNetworkTemplateVariables(self) 90 variables["clients"] = self.getClients() 91 return variables 82 92 83 93 def getHostTemplateVariables(self, host_id): … … 89 99 # Call base class to get the basics 90 100 variables = ccsd_service.getHostTemplateVariables(self, host_id) 91 92 variables["clients"] = self.getClients()93 94 101 return variables 95 102 … … 110 117 service_id = session.getCountOf("SELECT currval('" \ 111 118 "service_service_id_seq') AS server_id", ()) 119 default_ip = getIP(config_get_required("network", "server_name")) 120 session.execute("INSERT INTO service_prop (service_prop_id, " \ 121 "service_id, prop_name, prop_type, default_value, " \ 122 "required) VALUES (DEFAULT, %s, %s, 'string', %s, 'f')", \ 123 (service_id, AUTHIP_PROPERTY, default_ip)) 124 session.execute("INSERT INTO service_prop (service_prop_id, " \ 125 "service_id, prop_name, prop_type, default_value, " \ 126 "required) VALUES (DEFAULT, %s, %s, 'string', %s, 'f')", \ 127 (service_id, ACCTIP_PROPERTY, default_ip)) 128 session.execute("INSERT INTO service_prop (service_prop_id, " \ 129 "service_id, prop_name, prop_type, default_value, " \ 130 "required) VALUES (DEFAULT, %s, %s, 'integer', %s, 'f')", \ 131 (service_id, AUTHPORT_PROPERTY, 1812)) 132 session.execute("INSERT INTO service_prop (service_prop_id, " \ 133 "service_id, prop_name, prop_type, default_value, " \ 134 "required) VALUES (DEFAULT, %s, %s, 'integer', %s, 'f')", \ 135 (service_id, ACCTPORT_PROPERTY, 1813)) 112 136 113 137 # Commit the changese
Note: See TracChangeset
for help on using the changeset viewer.
