* Correction de plusieurs bugs, on peut théoriquement créer des machines
Mais il faut éviter, parce qu'elles peuvent prendre des ip en .0 ou .255 Il reste quelques détails genre 'historique' et 'ouverture de ports' à régler...
This commit is contained in:
parent
e3e0485045
commit
18571ae112
3 changed files with 42 additions and 15 deletions
29
attributs.py
29
attributs.py
|
@ -35,7 +35,7 @@
|
|||
|
||||
import re, sys, netaddr, time
|
||||
from unicodedata import normalize
|
||||
from crans_utils import format_tel, format_mac, mailexist, validate_name
|
||||
from crans_utils import format_tel, format_mac, mailexist, validate_name, ip4_of_rid, ip6_of_mac
|
||||
|
||||
sys.path.append("/usr/scripts/gestion")
|
||||
import config, annuaires_pg
|
||||
|
@ -177,8 +177,8 @@ class objectClass(Attr):
|
|||
""" Internal purpose (et à fin pédagogique) """
|
||||
|
||||
def parse_value(self, val, ldif):
|
||||
if val not in [ 'top', 'posixAccount', 'shadowAccount', 'proprio',
|
||||
'adherent', 'club', 'machine', 'machineCrans',
|
||||
if val not in [ 'top', 'organizationalUnit', 'posixAccount', 'shadowAccount',
|
||||
'proprio', 'adherent', 'club', 'machine', 'machineCrans',
|
||||
'borneWifi', 'machineWifi', 'machineFixe',
|
||||
'cransAccount', 'service', 'facture', 'freeMid' ]:
|
||||
raise ValueError("Pourquoi insérer un objectClass=%r ?" % val)
|
||||
|
@ -399,7 +399,7 @@ class dnsAttr(Attr):
|
|||
def parse_value(self, dns, ldif):
|
||||
dns = dns.lower()
|
||||
name, net = dns.split('.', 1)
|
||||
if self.ctxt_check and (net not in ['crans.org', 'wifi.crans.org'] or
|
||||
if self.ctxt_check and (net not in ['adm.crans.org', 'crans.org', 'wifi.crans.org'] or
|
||||
not re.match('[a-z][-_a-z0-9]+', name)):
|
||||
raise ValueError("Nom d'hote invalide %r" % dns)
|
||||
self.value = dns
|
||||
|
@ -443,7 +443,7 @@ class macAddress(Attr):
|
|||
|
||||
class ipHostNumber(Attr):
|
||||
singlevalue = True
|
||||
optional = False
|
||||
optional = True
|
||||
unique = True
|
||||
legend = u"Adresse IPv4 de la machine"
|
||||
hname = "IPv4"
|
||||
|
@ -452,12 +452,28 @@ class ipHostNumber(Attr):
|
|||
|
||||
def parse_value(self, ip, ldif):
|
||||
if ip == '<automatique>':
|
||||
ip = Rid(rid= ldif['rid'][0]).ipv4()
|
||||
ip = ip4_of_rid(ldif['rid'][0])
|
||||
self.value = netaddr.ip.IPAddress(ip)
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.value)
|
||||
|
||||
class ip6HostNumber(Attr):
|
||||
singlevalue = True
|
||||
optional = True
|
||||
unique = True
|
||||
legend = u"Adresse IPv6 de la machine"
|
||||
hname = "IPv6"
|
||||
category = 'base_tech'
|
||||
can_modify = [nounou]
|
||||
|
||||
def parse_value(self, ip, ldif):
|
||||
if ip == '<automatique>':
|
||||
ip = ip6_of_mac(ldif['macAddress'][0], ldif['rid'][0])
|
||||
self.value = netaddr.ip.IPAddress(ip)
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.value)
|
||||
|
||||
class mid(Attr):
|
||||
singlevalue = True
|
||||
|
@ -804,6 +820,7 @@ CRANS_ATTRIBUTES= {
|
|||
'sshFingerprint' : sshFingerprint,
|
||||
'macAddress': macAddress,
|
||||
'ipHostNumber': ipHostNumber,
|
||||
'ip6HostNumber': ip6HostNumber,
|
||||
'hostAlias' : hostAlias,
|
||||
'ipsec' : ipsec,
|
||||
'puissance' : puissance,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue