git://git.onelab.eu
/
plstackapi.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6f6994b
)
start at subnet #1
author
smbaker
<smbaker@fc8-storktest.lan>
Thu, 25 Jul 2013 14:14:57 +0000
(07:14 -0700)
committer
smbaker
<smbaker@fc8-storktest.lan>
Thu, 25 Jul 2013 14:14:57 +0000
(07:14 -0700)
planetstack/core/models/network.py
patch
|
blob
|
history
diff --git
a/planetstack/core/models/network.py
b/planetstack/core/models/network.py
index
be13ea7
..
1ea7115
100644
(file)
--- a/
planetstack/core/models/network.py
+++ b/
planetstack/core/models/network.py
@@
-12,13
+12,15
@@
SUBNET_NODE_BITS = 12 # enough for 4096 bits per subnet
SUBNET_SUBNET_BITS = 12 # enough for 4096 private networks
def find_unused_subnet(base, subnet_bits, node_bits, existing_subnets):
SUBNET_SUBNET_BITS = 12 # enough for 4096 private networks
def find_unused_subnet(base, subnet_bits, node_bits, existing_subnets):
- i=0
+ # start at the first allocatable subnet
+ i=1
while True:
while True:
- subnet_i =
(i<<node_bits) | int(socket.inet_aton(base).encode('hex'),16
)
+ subnet_i =
int(socket.inet_aton(base).encode('hex'),16) | (i<<node_bits
)
subnet = socket.inet_ntoa(hex(subnet_i)[2:].zfill(8).decode('hex')) + "/" + str(32-node_bits)
if (subnet not in existing_subnets):
return subnet
i=i+1
subnet = socket.inet_ntoa(hex(subnet_i)[2:].zfill(8).decode('hex')) + "/" + str(32-node_bits)
if (subnet not in existing_subnets):
return subnet
i=i+1
+ # TODO: we could run out...
class NetworkTemplate(PlCoreBase):
VISIBILITY_CHOICES = (('public', 'public'), ('private', 'private'))
class NetworkTemplate(PlCoreBase):
VISIBILITY_CHOICES = (('public', 'public'), ('private', 'private'))