Commit b124b12d authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

Display IP pool map in network-inspect command

parent fe68a4c0
......@@ -58,11 +58,12 @@ class Command(BaseCommand):
sep = '-' * 80 + '\n'
labels = ('name', 'backend-name', 'state', 'owner', 'subnet', 'gateway',
'max_prefix', 'link', 'public', 'dhcp', 'type', 'deleted',
'action')
'action', 'pool')
fields = (net.name, net.backend_id, net.state, str(net.userid),
str(net.subnet), str(net.gateway), str(net.mac_prefix),
str(net.link), str(net.public), str(net.dhcp),
str(net.type), str(net.deleted), str(net.action))
str(net.type), str(net.deleted), str(net.action),
str(splitPoolMap(net.pool.get_map(), 64)))
self.stdout.write(sep)
self.stdout.write('State of Network in DB\n')
......@@ -99,3 +100,13 @@ class Command(BaseCommand):
backend.clustername)
else:
raise e
def splitPoolMap(s, count):
splited = [''.join(x) for x in zip(*[list(s[z::count]) for z in
range(count)])]
acc = []
for i in range(0, len(splited)):
acc.append(str(i * count).ljust(4) + ' ' + splited[i] + ' ' +
str((i + 1) * count - 1).ljust(4))
return '\n' + '\n'.join(acc)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment