[Kimchi-devel] [PATCH 1/2] Fix non persistent network handling (backend)

Shu Ming shuming at linux.vnet.ibm.com
Fri Mar 21 02:05:02 UTC 2014


在 2014-03-20Thu的 20:54 -0300,Rodrigo Trujillo写道:
> If some network is not persistent and the user tries to stop it, it is
> going to be removed by libvirt and causes an error in Kimchi.
> This patch changes the backend in order to get persistent information.
> 
> Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
> ---
>  src/kimchi/control/networks.py | 3 ++-
>  src/kimchi/model/networks.py   | 9 ++++++++-
>  2 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/src/kimchi/control/networks.py b/src/kimchi/control/networks.py
> index 95e8523..b905891 100644
> --- a/src/kimchi/control/networks.py
> +++ b/src/kimchi/control/networks.py
> @@ -45,4 +45,5 @@ class Network(Resource):
>                  'interface': self.info['interface'],
>                  'subnet': self.info['subnet'],
>                  'dhcp': self.info['dhcp'],
> -                'state': self.info['state']}
> +                'state': self.info['state'],
> +                'persistent': self.info['persistent']}
> diff --git a/src/kimchi/model/networks.py b/src/kimchi/model/networks.py
> index 27abd54..958b75d 100644
> --- a/src/kimchi/model/networks.py
> +++ b/src/kimchi/model/networks.py
> @@ -231,7 +231,8 @@ class NetworkModel(object):
>                  'vms': self._get_vms_attach_to_a_network(name),
>                  'in_use': self._is_network_in_use(name),
>                  'autostart': network.autostart() == 1,
> -                'state':  network.isActive() and "active" or "inactive"}
> +                'state':  network.isActive() and "active" or "inactive",
> +                'persistent': True if network.isPersistent() else False}
> 
>      def _is_network_in_use(self, name):
>          # The network "default" is used for Kimchi proposal and should not be
> @@ -280,8 +281,14 @@ class NetworkModel(object):
>              raise InvalidOperation("KCHNET0018E", {'name': name})
> 
>          network = self.get_network(self.conn.get(), name)
> +        persistent = network.isPersistent()
>          network.destroy()
> 
> +        # If network was not persistent, then it was erased by destroy() and
> +        # must return nothing here, to trigger _redirect() and avoid errors

The comments above are quite confusing.  Where is "_redirect()"?  What
errors are trying to avoid?

> +        if not persistent:
> +            return ""
> +
>      def delete(self, name):
>          if self._is_network_in_use(name):
>              raise InvalidOperation("KCHNET0017E", {'name': name})





More information about the Kimchi-devel mailing list