Ignore the exception on GET for Stop (deactivate) of
transient Networks.
---
src/kimchi/control/networks.py | 11 +++++++++--
src/kimchi/model/networks.py | 6 +++++-
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/kimchi/control/networks.py b/src/kimchi/control/networks.py
index 7cb1572..14d6324 100644
--- a/src/kimchi/control/networks.py
+++ b/src/kimchi/control/networks.py
@@ -20,7 +20,6 @@
from kimchi.control.base import Collection, Resource
from kimchi.control.utils import UrlSubNode
-
@UrlSubNode('networks', True)
class Networks(Collection):
def __init__(self, model):
@@ -33,11 +32,19 @@ def __init__(self, model):
class Network(Resource):
def __init__(self, model, ident):
super(Network, self).__init__(model, ident)
+ _ignore_not_found = False
+ try:
+ # the test driver causes an exception in is_persistent()
+ _ignore_not_found = \
+ not model.network_is_persistent(self.ident.decode('utf-8'))
+ except Exception:
+ pass
self.role_key = 'network'
self.admin_methods = ['PUT', 'POST', 'DELETE']
self.uri_fmt = "/networks/%s"
self.activate = self.generate_action_handler('activate')
- self.deactivate = self.generate_action_handler('deactivate')
+ self.deactivate = self.generate_action_handler('deactivate', \
+ ignore_not_found=_ignore_not_found)
@property
def data(self):
diff --git a/src/kimchi/model/networks.py b/src/kimchi/model/networks.py
index 7265c64..969d922 100644
--- a/src/kimchi/model/networks.py
+++ b/src/kimchi/model/networks.py
@@ -261,7 +261,11 @@ def lookup(self, name):
'in_use': self._is_network_in_use(name),
'autostart': network.autostart() == 1,
'state': network.isActive() and "active" or
"inactive",
- 'persistent': True if network.isPersistent() else False}
+ 'persistent': self.is_persistent(name)}
+
+ def is_persistent(self, name):
+ network = self.get_network(self.conn.get(), name)
+ return 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
--
1.9.3