<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 01/13/2015 10:55 AM, Aline Manera
wrote:<br>
</div>
<blockquote cite="mid:54B515D9.8080407@linux.vnet.ibm.com"
type="cite">
<br>
On 09/01/2015 16:43, Rodrigo Trujillo wrote:
<br>
<blockquote type="cite">This patch changes the error message
returned by backend, adding the
<br>
name of virtual machines that are prohibiting the network to be
removed
<br>
or deactivated. In other words, the vms linked to that network.
<br>
MSG example:
<br>
"Unable to delete network NET1. There are some virtual machines
['VM1',
<br>
'VM2', 'VM3'] and/or templates linked to this network
<br>
</blockquote>
<br>
Just a minor comment to make the error message more professional
<br>
<br>
Instead of "Unable to delete network NET1. There are some virtual
machines *['VM1', 'VM2', 'VM3'] *and/or templates linked to this
network "
<br>
display "Unable to delete network NET1. There are some virtual
machines *VM1, VM2, VM3* and/or templates linked to this network
<br>
</blockquote>
<br>
ACK =]<br>
<br>
<blockquote cite="mid:54B515D9.8080407@linux.vnet.ibm.com"
type="cite">
<br>
<blockquote type="cite">Signed-off-by: Rodrigo Trujillo
<a class="moz-txt-link-rfc2396E" href="mailto:rodrigo.trujillo@linux.vnet.ibm.com"><rodrigo.trujillo@linux.vnet.ibm.com></a>
<br>
---
<br>
src/kimchi/i18n.py | 4 ++--
<br>
src/kimchi/model/networks.py | 10 ++++++++--
<br>
2 files changed, 10 insertions(+), 4 deletions(-)
<br>
<br>
diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
<br>
index e3a051c..30ec89a 100644
<br>
--- a/src/kimchi/i18n.py
<br>
+++ b/src/kimchi/i18n.py
<br>
@@ -229,8 +229,8 @@ messages = {
<br>
"KCHNET0014E": _("Network interface must be a string"),
<br>
"KCHNET0015E": _("Network VLAN ID must be an integer
between 1 and 4094"),
<br>
"KCHNET0016E": _("Specify name and type to create a
Network"),
<br>
- "KCHNET0017E": _("Unable to delete network %(name)s. There
are some virtual machines and/or templates linked to this
network."),
<br>
- "KCHNET0018E": _("Unable to deactivate network %(name)s.
There are some virtual machines and/or templates linked to this
network."),
<br>
+ "KCHNET0017E": _("Unable to delete network %(name)s. There
are some virtual machines %(vms)s and/or templates linked to
this network."),
<br>
+ "KCHNET0018E": _("Unable to deactivate network %(name)s.
There are some virtual machines %(vms)s and/or templates linked
to this network."),
<br>
"KCHNET0019E": _("Bridge device %(name)s can not be the
trunk device of a VLAN."),
<br>
"KCHNET0020E": _("Failed to activate interface %(iface)s:
%(err)s."),
<br>
"KCHNET0021E": _("Failed to activate interface %(iface)s.
Please check the physical link status."),
<br>
diff --git a/src/kimchi/model/networks.py
b/src/kimchi/model/networks.py
<br>
index 1e94fd2..04783c4 100644
<br>
--- a/src/kimchi/model/networks.py
<br>
+++ b/src/kimchi/model/networks.py
<br>
@@ -313,14 +313,20 @@ class NetworkModel(object):
<br>
<br>
def deactivate(self, name):
<br>
if self._is_network_in_use(name):
<br>
- raise InvalidOperation("KCHNET0018E", {'name':
name})
<br>
+ vms = self._get_vms_attach_to_a_network(name)
<br>
+ if not vms:
<br>
+ vms = ""
<br>
</blockquote>
<br>
To do what I suggested below:
<br>
<br>
vms = []
<br>
<br>
<blockquote type="cite">+ raise
InvalidOperation("KCHNET0018E", {'name': name, 'vms': vms})
<br>
</blockquote>
<br>
And then:
<br>
<br>
raise InvalidOperation("KCHNET0018E", {'name': name, 'vms': *",
".join(vms)*})
<br>
<br>
<br>
<blockquote type="cite">
<br>
network = self.get_network(self.conn.get(), name)
<br>
network.destroy()
<br>
<br>
def delete(self, name):
<br>
if self._is_network_in_use(name):
<br>
- raise InvalidOperation("KCHNET0017E", {'name':
name})
<br>
+ vms = self._get_vms_attach_to_a_network(name)
<br>
+ if not vms:
<br>
+ vms = ""
<br>
+ raise InvalidOperation("KCHNET0017E", {'name':
name, 'vms': vms})
<br>
<br>
network = self.get_network(self.conn.get(), name)
<br>
if network.isActive():
<br>
</blockquote>
<br>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Kimchi-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Kimchi-devel@ovirt.org">Kimchi-devel@ovirt.org</a>
<a class="moz-txt-link-freetext" href="http://lists.ovirt.org/mailman/listinfo/kimchi-devel">http://lists.ovirt.org/mailman/listinfo/kimchi-devel</a>
</pre>
</blockquote>
<br>
</body>
</html>