[Kimchi-devel] [PATCH v3] Add vm names to delete/deactivate network error message
Rodrigo Trujillo
rodrigo.trujillo at linux.vnet.ibm.com
Tue Jan 13 15:17:12 UTC 2015
This patch changes the error message returned by backend, adding the
name of virtual machines that are prohibiting the network to be removed
or deactivated. In other words, the vms linked to that network.
MSG example:
"Unable to delete network NET1. There are some virtual machines ['VM1',
'VM2', 'VM3'] and/or templates linked to this network
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
---
src/kimchi/i18n.py | 4 ++--
src/kimchi/model/networks.py | 10 ++++++++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index e3a051c..30ec89a 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -229,8 +229,8 @@ messages = {
"KCHNET0014E": _("Network interface must be a string"),
"KCHNET0015E": _("Network VLAN ID must be an integer between 1 and 4094"),
"KCHNET0016E": _("Specify name and type to create a Network"),
- "KCHNET0017E": _("Unable to delete network %(name)s. There are some virtual machines and/or templates linked to this network."),
- "KCHNET0018E": _("Unable to deactivate network %(name)s. There are some virtual machines and/or templates linked to this network."),
+ "KCHNET0017E": _("Unable to delete network %(name)s. There are some virtual machines %(vms)s and/or templates linked to this network."),
+ "KCHNET0018E": _("Unable to deactivate network %(name)s. There are some virtual machines %(vms)s and/or templates linked to this network."),
"KCHNET0019E": _("Bridge device %(name)s can not be the trunk device of a VLAN."),
"KCHNET0020E": _("Failed to activate interface %(iface)s: %(err)s."),
"KCHNET0021E": _("Failed to activate interface %(iface)s. Please check the physical link status."),
diff --git a/src/kimchi/model/networks.py b/src/kimchi/model/networks.py
index 1e94fd2..1fdb494 100644
--- a/src/kimchi/model/networks.py
+++ b/src/kimchi/model/networks.py
@@ -313,14 +313,20 @@ class NetworkModel(object):
def deactivate(self, name):
if self._is_network_in_use(name):
- raise InvalidOperation("KCHNET0018E", {'name': name})
+ vms = self._get_vms_attach_to_a_network(name)
+ vms.sort()
+ raise InvalidOperation("KCHNET0018E", {'name': name,
+ 'vms': ', '.join(vms)})
network = self.get_network(self.conn.get(), name)
network.destroy()
def delete(self, name):
if self._is_network_in_use(name):
- raise InvalidOperation("KCHNET0017E", {'name': name})
+ vms = self._get_vms_attach_to_a_network(name)
+ vms.sort()
+ raise InvalidOperation("KCHNET0017E", {'name': name,
+ 'vms': ', '.join(vms)})
network = self.get_network(self.conn.get(), name)
if network.isActive():
--
1.9.3
More information about the Kimchi-devel
mailing list