Revision 53195377 lib/client/gnt_network.py

b/lib/client/gnt_network.py
60 60
  """
61 61
  (network_name, ) = args
62 62

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

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

  
236
    if ext_res:
237
      ToStdout("  externally reserved IPs:")
238
      for line in textwrap.wrap(ext_res, width=64):
239
        ToStdout("    %s" % line)
222
    if pool:
223
      size = free_count + reserved_count
224
      ToStdout("  Size: %d", size)
225
      ToStdout("  Free: %d (%.2f%%)", free_count,
226
               100 * float(free_count) / float(size))
227
      ToStdout("  Usage map:")
228
      idx = 0
229
      for line in textwrap.wrap(mapping, width=64):
230
        ToStdout("     %s %s %d", str(idx).rjust(3), line.ljust(64), idx + 63)
231
        idx += 64
232
      ToStdout("         (X) used    (.) free")
233

  
234
      if ext_res:
235
        ToStdout("  externally reserved IPs:")
236
        for line in textwrap.wrap(ext_res, width=64):
237
          ToStdout("    %s" % line)
240 238

  
241 239
    if group_list:
242 240
      ToStdout("  connected to node groups:")

Also available in: Unified diff