diff --git a/lib/client/gnt_network.py b/lib/client/gnt_network.py index 318e9441a1a7ab1bb9459092c2e06875746cd3d3..a1d3dfdaa75e34dfd02930b953d4183cf0cd0864 100644 --- a/lib/client/gnt_network.py +++ b/lib/client/gnt_network.py @@ -140,11 +140,12 @@ def ShowNetworkConfig(opts, args): cl = GetClient() result = cl.QueryNetworks(fields=["name", "network", "gateway", "free_count", "reserved_count", - "map", "group_links", "inst_list"], + "map", "group_links", "inst_list", + "external_reservations"], names=args, use_locking=False) for (name, network, gateway, free_count, reserved_count, - map, group_links, instances) in result: + map, group_links, instances, ext_res) in result: size = free_count + reserved_count ToStdout("Network name: %s", name) ToStdout(" subnet: %s", network) @@ -159,6 +160,11 @@ def ShowNetworkConfig(opts, args): idx += 64 ToStdout(" (X) used (.) free") + if ext_res: + ToStdout(" externally reserved IPs:") + for line in wrap(ext_res, width=64): + ToStdout(" %s" % line) + if group_links: ToStdout(" connected to node groups:") for conn in group_links: diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 88b1f6f50ab386eb31206784e47be4c24aa95bc9..3a8a2c1662cede63860d51c5449b7de10690bafe 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -12146,6 +12146,7 @@ class _NetworkQuery(_QueryBase): "free_count": pool.GetFreeCount(), "reserved_count": pool.GetReservedCount(), "map": pool.GetMap(), + "external_reservations": ", ".join(pool.GetExternalReservations()), } return query.NetworkQueryData([self._all_networks[uuid] diff --git a/lib/network.py b/lib/network.py index 062bcb60dd96e3c095b7e43bda724ccbdb8feb1f..ee9c7bf6a4ba2ddd4d9d164ecc31641f3e7ec22f 100644 --- a/lib/network.py +++ b/lib/network.py @@ -162,6 +162,11 @@ class AddressPool(object): return _iter_free().next + def GetExternalReservations(self): + """Returns a list of all externally reserved addresses""" + idxs = self.ext_reservations.search("1") + return [str(self.network[idx]) for idx in idxs] + @classmethod def InitializeNetwork(cls, net): """Initialize an L{objects.Network} object diff --git a/lib/query.py b/lib/query.py index 688a851d219cf5804256a953604490484474994c..6c23396c2b12619c62e1eded4ba35e54e65aa787 100644 --- a/lib/query.py +++ b/lib/query.py @@ -1343,6 +1343,7 @@ _NETWORK_STATS_FIELDS = { "free_count": ("FreeCount", QFT_NUMBER), "reserved_count": ("ReservedCount", QFT_NUMBER), "map": ("Map", QFT_TEXT), + "external_reservations": ("ExternalReservations", QFT_TEXT), }