Revision 6a2c20f2

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:")
b/lib/cmdlib.py
16319 16319
    self.add_locks[locking.LEVEL_NETWORK] = self.network_uuid
16320 16320

  
16321 16321
  def CheckPrereq(self):
16322
    if self.op.network is None:
16323
      raise errors.OpPrereqError("Network must be given",
16324
                                 errors.ECODE_INVAL)
16325

  
16326 16322
    try:
16327 16323
      existing_uuid = self.cfg.LookupNetwork(self.op.network_name)
16328 16324
    except errors.OpPrereqError:
b/lib/opcodes.py
2052 2052
  OP_DSC_FIELD = "network_name"
2053 2053
  OP_PARAMS = [
2054 2054
    _PNetworkName,
2055
    ("network", ht.NoDefault, _TIpNetwork4, "IPv4 subnet"),
2055
    ("network", None, ht.TMaybe(_TIpNetwork4), "IPv4 subnet"),
2056 2056
    ("gateway", None, ht.TMaybe(_TIpAddress4), "IPv4 gateway"),
2057 2057
    ("network6", None, ht.TMaybe(_TIpNetwork6), "IPv6 subnet"),
2058 2058
    ("gateway6", None, ht.TMaybe(_TIpAddress6), "IPv6 gateway"),
b/lib/query.py
2641 2641

  
2642 2642
_NETWORK_SIMPLE_FIELDS = {
2643 2643
  "name": ("Network", QFT_TEXT, 0, "Name"),
2644
  "network": ("Subnet", QFT_TEXT, 0, "IPv4 subnet"),
2644
  "network": ("Subnet", QFT_OTHER, 0, "IPv4 subnet"),
2645 2645
  "gateway": ("Gateway", QFT_OTHER, 0, "IPv4 gateway"),
2646 2646
  "network6": ("IPv6Subnet", QFT_OTHER, 0, "IPv6 subnet"),
2647 2647
  "gateway6": ("IPv6Gateway", QFT_OTHER, 0, "IPv6 gateway"),

Also available in: Unified diff