[PATCH] [Kimchi] Fix issue #810

Add an error message asking user to disable NetworkManager. Signed-off-by: Lucio Correia <luciojhc@linux.vnet.ibm.com> --- i18n.py | 1 + model/config.py | 2 ++ model/networks.py | 8 ++++++++ 3 files changed, 11 insertions(+) diff --git a/i18n.py b/i18n.py index 7a72a86..a575922 100644 --- a/i18n.py +++ b/i18n.py @@ -273,6 +273,7 @@ messages = { "KCHNET0024E": _("Unable to redefine interface %(name)s. Details: %(err)s"), "KCHNET0025E": _("Unable to create bridge %(name)s. Details: %(err)s"), "KCHNET0026E": _("Open VSwitch bridges can only host bridged networks."), + "KCHNET0027E": _("Unable to create bridge with NetworkManager enabled. Disable it and try again."), "KCHSR0001E": _("Storage server %(server)s was not used by Kimchi"), diff --git a/model/config.py b/model/config.py index e552edb..5a26957 100644 --- a/model/config.py +++ b/model/config.py @@ -54,6 +54,7 @@ class CapabilitiesModel(object): self.libvirt_stream_protocols = [] self.fc_host_support = False self.kernel_vfio = False + self.nm_running = False self.mem_hotplug_support = False # Subscribe function to set host capabilities to be run when cherrypy @@ -90,6 +91,7 @@ class CapabilitiesModel(object): self.nfs_target_probe = FeatureTests.libvirt_support_nfs_probe(conn) self.fc_host_support = FeatureTests.libvirt_support_fc_host(conn) self.kernel_vfio = FeatureTests.kernel_support_vfio() + self.nm_running = FeatureTests.is_nm_running() self.mem_hotplug_support = FeatureTests.has_mem_hotplug_support(conn) self.libvirt_stream_protocols = [] diff --git a/model/networks.py b/model/networks.py index bfe8d2a..fba181f 100644 --- a/model/networks.py +++ b/model/networks.py @@ -32,6 +32,7 @@ from wok.xmlutils.utils import xpath_get_text from wok.plugins.kimchi import netinfo from wok.plugins.kimchi import network as knetwork +from wok.plugins.kimchi.model.config import CapabilitiesModel from wok.plugins.kimchi.osinfo import defaults as tmpl_defaults from wok.plugins.kimchi.xmlutils.interface import get_iface_xml from wok.plugins.kimchi.xmlutils.network import create_linux_bridge_xml @@ -49,6 +50,8 @@ class NetworksModel(object): if self.conn.isQemuURI(): self._check_default_networks() + self.caps = CapabilitiesModel(**kargs) + def _check_default_networks(self): networks = list(set(tmpl_defaults['networks'])) conn = self.conn.get() @@ -192,6 +195,11 @@ class NetworksModel(object): # User wants Linux bridge network, but didn't specify bridge interface elif params['connection'] == "bridge": + + # libvirt will fail to create bridge if NetworkManager is enabled + if self.caps.nm_running: + raise InvalidParameter('KCHNET0027E') + # create Linux bridge interface first and use it as actual iface iface = self._create_linux_bridge(iface) params['bridge'] = iface -- 1.9.1

Reviewed-by: Daniel Barboza <dhbarboza82@gmail.com> On 01/11/2016 03:45 PM, Lucio Correia wrote:
Add an error message asking user to disable NetworkManager.
Signed-off-by: Lucio Correia <luciojhc@linux.vnet.ibm.com> --- i18n.py | 1 + model/config.py | 2 ++ model/networks.py | 8 ++++++++ 3 files changed, 11 insertions(+)
diff --git a/i18n.py b/i18n.py index 7a72a86..a575922 100644 --- a/i18n.py +++ b/i18n.py @@ -273,6 +273,7 @@ messages = { "KCHNET0024E": _("Unable to redefine interface %(name)s. Details: %(err)s"), "KCHNET0025E": _("Unable to create bridge %(name)s. Details: %(err)s"), "KCHNET0026E": _("Open VSwitch bridges can only host bridged networks."), + "KCHNET0027E": _("Unable to create bridge with NetworkManager enabled. Disable it and try again."),
"KCHSR0001E": _("Storage server %(server)s was not used by Kimchi"),
diff --git a/model/config.py b/model/config.py index e552edb..5a26957 100644 --- a/model/config.py +++ b/model/config.py @@ -54,6 +54,7 @@ class CapabilitiesModel(object): self.libvirt_stream_protocols = [] self.fc_host_support = False self.kernel_vfio = False + self.nm_running = False self.mem_hotplug_support = False
# Subscribe function to set host capabilities to be run when cherrypy @@ -90,6 +91,7 @@ class CapabilitiesModel(object): self.nfs_target_probe = FeatureTests.libvirt_support_nfs_probe(conn) self.fc_host_support = FeatureTests.libvirt_support_fc_host(conn) self.kernel_vfio = FeatureTests.kernel_support_vfio() + self.nm_running = FeatureTests.is_nm_running() self.mem_hotplug_support = FeatureTests.has_mem_hotplug_support(conn)
self.libvirt_stream_protocols = [] diff --git a/model/networks.py b/model/networks.py index bfe8d2a..fba181f 100644 --- a/model/networks.py +++ b/model/networks.py @@ -32,6 +32,7 @@ from wok.xmlutils.utils import xpath_get_text
from wok.plugins.kimchi import netinfo from wok.plugins.kimchi import network as knetwork +from wok.plugins.kimchi.model.config import CapabilitiesModel from wok.plugins.kimchi.osinfo import defaults as tmpl_defaults from wok.plugins.kimchi.xmlutils.interface import get_iface_xml from wok.plugins.kimchi.xmlutils.network import create_linux_bridge_xml @@ -49,6 +50,8 @@ class NetworksModel(object): if self.conn.isQemuURI(): self._check_default_networks()
+ self.caps = CapabilitiesModel(**kargs) + def _check_default_networks(self): networks = list(set(tmpl_defaults['networks'])) conn = self.conn.get() @@ -192,6 +195,11 @@ class NetworksModel(object):
# User wants Linux bridge network, but didn't specify bridge interface elif params['connection'] == "bridge": + + # libvirt will fail to create bridge if NetworkManager is enabled + if self.caps.nm_running: + raise InvalidParameter('KCHNET0027E') + # create Linux bridge interface first and use it as actual iface iface = self._create_linux_bridge(iface) params['bridge'] = iface
participants (3)
-
Aline Manera
-
Daniel Henrique Barboza
-
Lucio Correia