Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Benjamin Graillot
scripts
Commits
97b1db8a
Commit
97b1db8a
authored
May 30, 2013
by
Pierre-Elliott Bécue
Browse files
[ridtools] Oubli de modif par rapport aux rids
parent
a442fd6b
Changes
1
Hide whitespace changes
Inline
Side-by-side
gestion/ridtools.py
View file @
97b1db8a
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
netaddr
import
netaddr
import
itertools
import
config
import
config
class
Rid
(
object
):
class
Rid
(
object
):
...
@@ -83,8 +83,8 @@ class Rid(object):
...
@@ -83,8 +83,8 @@ class Rid(object):
self
.
ipv4_dispo
=
True
self
.
ipv4_dispo
=
True
self
.
priv
=
ip
.
is_private
()
self
.
priv
=
ip
.
is_private
()
for
tp
in
[
'fil'
,
'adherents'
,
'wifi'
,
'adm'
,
'gratuit'
,
'personnel-ens'
,
'serveurs'
]
:
for
tp
in
config
.
NETs_primaires
.
keys
()
:
for
net
in
config
.
NETs
[
tp
]:
for
net
in
config
.
NETs
_primaires
[
tp
]:
if
ip
in
netaddr
.
IPNetwork
(
net
):
if
ip
in
netaddr
.
IPNetwork
(
net
):
self
.
type
=
tp
self
.
type
=
tp
break
break
...
@@ -99,11 +99,12 @@ class Rid(object):
...
@@ -99,11 +99,12 @@ class Rid(object):
else
:
else
:
raise
ValueError
(
"%s dans aucun des réseaux gérés par le Cr@ns..."
%
ip
)
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
:
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
]
:
if
self
.
rid
not
in
ranges
:
raise
ValueError
(
"%s trop
élevée
pour le réseau '%s'"
%
(
ip
,
self
.
type
))
raise
ValueError
(
"%s trop
hors des plages prévues
pour le réseau '%s'"
%
(
ip
,
self
.
type
))
if
self
.
type
==
'personnel-ens'
:
if
self
.
type
==
'personnel-ens'
:
self
.
reste
=
self
.
rid
&
0xff
self
.
reste
=
self
.
rid
&
0xff
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment