radius client modify and delete work
This commit is contained in:
1 parent
c4bf859bfb
commit
c24da12fe1
9 files changed
+307
-18
No files matched your search
@@ -27,6 +27,7 @@ import user
|
||||
import group
|
||||
import ipa
|
||||
import config
|
||||
import radius_client
|
||||
|
||||
class IPAClient:
|
||||
|
||||
@@ -332,6 +333,11 @@ class IPAClient:
|
||||
|
||||
return entries
|
||||
|
||||
# radius support
|
||||
def get_radius_client_by_ip_addr(self,ip_addr,sattrs=None):
|
||||
result = self.transport.get_radius_client_by_ip_addr(ip_addr,sattrs)
|
||||
return radius_client.RadiusClient(result)
|
||||
|
||||
def add_radius_client(self,client):
|
||||
client_dict = client.toDict()
|
||||
|
||||
@@ -342,3 +348,10 @@ class IPAClient:
|
||||
result = self.transport.add_radius_client(client_dict)
|
||||
return result
|
||||
|
||||
def update_radius_client(self,client):
|
||||
result = self.transport.update_radius_client(client.origDataDict(), client.toDict())
|
||||
return result
|
||||
|
||||
def delete_radius_client(self,ip_addr):
|
||||
return self.transport.delete_radius_client(ip_addr)
|
||||
|
||||
@@ -33,15 +33,15 @@ __all__ = ['RadiusClient',
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
dotted_octet_RE = re.compile(r"^(\d+)\.(\d+)\.(\d+)\.(\d+)(/(\d+))?$")
|
||||
dns_RE = re.compile(r"^[a-zA-Z][a-zA-Z.-]+$")
|
||||
dotted_octet_re = re.compile(r"^(\d+)\.(\d+)\.(\d+)\.(\d+)(/(\d+))?$")
|
||||
dns_re = re.compile(r"^[a-zA-Z][a-zA-Z0-9.-]+$")
|
||||
# secret, name, nastype all have 31 char max in freeRADIUS, max ip address len is 255
|
||||
valid_secret_len = (1,31)
|
||||
valid_name_len = (1,31)
|
||||
valid_nastype_len = (1,31)
|
||||
valid_ip_addr_len = (1,255)
|
||||
|
||||
valid_ip_addr_msg = "IP address must be either a DNS name or a dotted octet with optional mask"
|
||||
valid_ip_addr_msg = "IP address must be either a DNS name (letters,digits,dot,hyphen, beginning with a letter),or a dotted octet followed by an optional mask (e.g 192.168.1.0/24)"
|
||||
valid_desc_msg = "Description must text string"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@@ -72,7 +72,7 @@ def valid_ip_addr(text):
|
||||
# is it a dotted octet? If so there should be 4 integers seperated
|
||||
# by a dot and each integer should be between 0 and 255
|
||||
# there may be an optional mask preceded by a slash (e.g. 1.2.3.4/24)
|
||||
match = dotted_octet_RE.search(text)
|
||||
match = dotted_octet_re.search(text)
|
||||
if match:
|
||||
# dotted octet notation
|
||||
i = 1
|
||||
@@ -88,8 +88,8 @@ def valid_ip_addr(text):
|
||||
return False
|
||||
return True
|
||||
else:
|
||||
# DNS name, can contain letters, dot and hypen
|
||||
if dns_RE.search(text): return True
|
||||
# DNS name, can contain letters, numbers, dot and hypen, must start with a letter
|
||||
if dns_re.search(text): return True
|
||||
return False
|
||||
|
||||
def validate_length(value, limits):
|
||||
|
||||
@@ -592,6 +592,21 @@ class RPCClient:
|
||||
|
||||
return ipautil.unwrap_binary_data(result)
|
||||
|
||||
# radius support
|
||||
|
||||
def get_radius_client_by_ip_addr(self,ip_addr,sattrs=None):
|
||||
server = self.setup_server()
|
||||
if sattrs is None:
|
||||
sattrs = "__NONE__"
|
||||
try:
|
||||
result = server.get_radius_client_by_ip_addr(ip_addr, sattrs)
|
||||
except xmlrpclib.Fault, fault:
|
||||
raise ipaerror.gen_exception(fault.faultCode, fault.faultString)
|
||||
except socket.error, (value, msg):
|
||||
raise xmlrpclib.Fault(value, msg)
|
||||
|
||||
return ipautil.unwrap_binary_data(result)
|
||||
|
||||
def add_radius_client(self,client):
|
||||
server = self.setup_server()
|
||||
|
||||
@@ -603,4 +618,30 @@ class RPCClient:
|
||||
raise xmlrpclib.Fault(value, msg)
|
||||
|
||||
return ipautil.unwrap_binary_data(result)
|
||||
|
||||
def update_radius_client(self,oldclient,newclient):
|
||||
server = self.setup_server()
|
||||
|
||||
try:
|
||||
result = server.update_radius_client(ipautil.wrap_binary_data(oldclient),
|
||||
ipautil.wrap_binary_data(newclient))
|
||||
except xmlrpclib.Fault, fault:
|
||||
raise ipaerror.gen_exception(fault.faultCode, fault.faultString)
|
||||
except socket.error, (value, msg):
|
||||
raise xmlrpclib.Fault(value, msg)
|
||||
|
||||
return ipautil.unwrap_binary_data(result)
|
||||
|
||||
|
||||
def delete_radius_client(self,ip_addr):
|
||||
server = self.setup_server()
|
||||
|
||||
try:
|
||||
result = server.delete_radius_client(ip_addr)
|
||||
except xmlrpclib.Fault, fault:
|
||||
raise ipaerror.gen_exception(fault.faultCode, fault.faultString)
|
||||
except socket.error, (value, msg):
|
||||
raise xmlrpclib.Fault(value, msg)
|
||||
|
||||
return ipautil.unwrap_binary_data(result)
|
||||
|
||||
Reference in new issue
Block a user