[ridtools] Oubli de modif par rapport aux rids
This commit is contained in:
parent
a442fd6b22
commit
97b1db8a56
1 changed files with 7 additions and 6 deletions
|
@ -23,7 +23,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import netaddr
|
||||
|
||||
import itertools
|
||||
import config
|
||||
|
||||
class Rid(object):
|
||||
|
@ -83,8 +83,8 @@ class Rid(object):
|
|||
self.ipv4_dispo = True
|
||||
self.priv = ip.is_private()
|
||||
|
||||
for tp in ['fil', 'adherents', 'wifi', 'adm', 'gratuit', 'personnel-ens', 'serveurs']:
|
||||
for net in config.NETs[tp]:
|
||||
for tp in config.NETs_primaires.keys():
|
||||
for net in config.NETs_primaires[tp]:
|
||||
if ip in netaddr.IPNetwork(net):
|
||||
self.type = tp
|
||||
break
|
||||
|
@ -99,11 +99,12 @@ class Rid(object):
|
|||
else:
|
||||
raise ValueError("%s dans aucun des réseaux gérés par le Cr@ns..." % ip)
|
||||
|
||||
ranges = itertools.chain(*[xrange(a, b+1) for (a,b) in config.rid[self.type]])
|
||||
if not self.rid:
|
||||
self.rid = config.rid[self.type][0] + ip.value - netaddr.IPNetwork(config.NETs[self.type][0]).value
|
||||
self.rid = config.rid[self.type][0][0] + ip.value - netaddr.IPNetwork(config.NETs[self.type][0]).value
|
||||
|
||||
if self.rid > config.rid[self.type][1]:
|
||||
raise ValueError("%s trop élevée pour le réseau '%s'" % (ip, self.type))
|
||||
if self.rid not in ranges:
|
||||
raise ValueError("%s trop hors des plages prévues pour le réseau '%s'" % (ip, self.type))
|
||||
|
||||
if self.type == 'personnel-ens':
|
||||
self.reste = self.rid & 0xff
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue