Revision 5e1a5f9b

b/snf-cyclades-app/synnefo/logic/management/commands/network-inspect.py
37 37

  
38 38
from synnefo.db.models import Backend, Network, BackendNetwork
39 39
from synnefo.util.rapi import GanetiApiError
40

  
40
from util import pool_map_chunks
41 41

  
42 42
class Command(BaseCommand):
43 43
    help = "Inspect a network on DB and Ganeti."
......
103 103

  
104 104

  
105 105
def splitPoolMap(s, count):
106
    splited = [''.join(x) for x in zip(*[list(s[z::count]) for z in
107
                range(count)])]
106
    chunks = pool_map_chunks(s, count)
108 107
    acc = []
109
    for i in range(0, len(splited)):
110
        acc.append(str(i * count).ljust(4) + ' ' + splited[i] + ' ' +
111
                   str((i + 1) * count - 1).ljust(4))
108
    count = 0
109
    for chunk in chunks:
110
        chunk_len = len(chunk)
111
        acc.append(str(count).rjust(3) + ' ' + chunk + ' ' +
112
                   str(count + chunk_len - 1).ljust(4))
113
        count += chunk_len
112 114
    return '\n' + '\n'.join(acc)
b/snf-cyclades-app/synnefo/logic/management/commands/pool-show.py
79 79
            line = '%s: %s\n' % (key.rjust(16), val)
80 80
            self.stdout.write(line.encode('utf8'))
81 81

  
82
        step = type_=='bridge' and 64 or 80
82
        step = (type_ == 'bridge') and 64 or 80
83 83
        print_map('Pool', pool.to_map(), step, self.stdout)
84 84
        print_map('Reserved', bitarray_to_map(pool.reserved), step, self.stdout)
85 85

  
......
89 89
    out.write(sep + "\n")
90 90
    out.write("%s: \n" % name)
91 91
    out.write(sep + "\n")
92
    i = 0
93
    for p in pool_map_chunks(pool_map, step):
94
        out.write(("%d " % i).rjust(4))
95
        out.write(("|" + p + " |%d\n") % ( i + step - 1))
96
        i += step
92
    count = 0
93
    for chunk in pool_map_chunks(pool_map, step):
94
        chunk_len = len(chunk)
95
        out.write(("%s" % count).rjust(4))
96
        out.write((chunk + " %d\n") % (count + chunk_len - 1))
97
        count += chunk_len

Also available in: Unified diff