[Kimchi-devel] [PATCH] Add vm names to delete/deactivate network error message

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Tue Jan 13 13:25:23 UTC 2015


On 01/13/2015 10:55 AM, Aline Manera wrote:
>
> On 09/01/2015 16:43, Rodrigo Trujillo wrote:
>> 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
>
> Just a minor comment to make the error message more professional
>
> Instead of "Unable to delete network NET1. There are some virtual 
> machines *['VM1', 'VM2', 'VM3'] *and/or templates linked to this 
> network "
> display "Unable to delete network NET1. There are some virtual 
> machines *VM1, VM2, VM3* and/or templates linked to this network

ACK   =]

>
>> 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..04783c4 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)
>> +            if not vms:
>> +                vms = ""
>
> To do what I suggested below:
>
> vms = []
>
>> +            raise InvalidOperation("KCHNET0018E", {'name': name, 
>> 'vms': vms})
>
> And then:
>
> 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)
>> +            if not vms:
>> +                vms = ""
>> +            raise InvalidOperation("KCHNET0017E", {'name': name, 
>> 'vms': vms})
>>
>>           network = self.get_network(self.conn.get(), name)
>>           if network.isActive():
>
>
>
>
> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/kimchi-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/kimchi-devel/attachments/20150113/325ec1c9/attachment.html>


More information about the Kimchi-devel mailing list