Revision 6a2c20f2 lib/client/gnt_network.py

b/lib/client/gnt_network.py
31 31
from ganeti import constants
32 32
from ganeti import opcodes
33 33
from ganeti import utils
34
from ganeti import errors
35 34

  
36 35

  
37 36
#: default list of fields for L{ListNetworks}
......
60 59
  """
61 60
  (network_name, ) = args
62 61

  
63
  if opts.network is None:
64
    raise errors.OpPrereqError("The --network option must be given",
65
                               errors.ECODE_INVAL)
66

  
67 62
  if opts.tags is not None:
68 63
    tags = opts.tags.split(",")
69 64
  else:
......
210 205
  for (name, network, gateway, network6, gateway6,
211 206
       mac_prefix, free_count, reserved_count,
212 207
       mapping, group_list, instances, ext_res, serial, uuid) in result:
213
    size = free_count + reserved_count
214 208
    ToStdout("Network name: %s", name)
215 209
    ToStdout("UUID: %s", uuid)
216 210
    ToStdout("Serial number: %d", serial)
......
219 213
    ToStdout("  IPv6 Subnet: %s", network6)
220 214
    ToStdout("  IPv6 Gateway: %s", gateway6)
221 215
    ToStdout("  Mac Prefix: %s", mac_prefix)
222
    ToStdout("  Size: %d", size)
223
    ToStdout("  Free: %d (%.2f%%)", free_count,
224
             100 * float(free_count) / float(size))
225
    ToStdout("  Usage map:")
226
    idx = 0
227
    for line in textwrap.wrap(mapping, width=64):
228
      ToStdout("     %s %s %d", str(idx).rjust(3), line.ljust(64), idx + 63)
229
      idx += 64
230
    ToStdout("         (X) used    (.) free")
231

  
232
    if ext_res:
233
      ToStdout("  externally reserved IPs:")
234
      for line in textwrap.wrap(ext_res, width=64):
235
        ToStdout("    %s" % line)
216
    pool = free_count or reserved_count or mapping or reserved_count
217
    if pool:
218
      size = free_count + reserved_count
219
      ToStdout("  Size: %d", size)
220
      ToStdout("  Free: %d (%.2f%%)", free_count,
221
               100 * float(free_count) / float(size))
222
      ToStdout("  Usage map:")
223
      idx = 0
224
      for line in textwrap.wrap(mapping, width=64):
225
        ToStdout("     %s %s %d", str(idx).rjust(3), line.ljust(64), idx + 63)
226
        idx += 64
227
      ToStdout("         (X) used    (.) free")
228

  
229
      if ext_res:
230
        ToStdout("  externally reserved IPs:")
231
        for line in textwrap.wrap(ext_res, width=64):
232
          ToStdout("    %s" % line)
236 233

  
237 234
    if group_list:
238 235
      ToStdout("  connected to node groups:")

Also available in: Unified diff