- NetworkManager does not (fully) support bridges yet and there is no
portable/bullet-proof way to solve any possible issue that may happen
to libvirt bridge creation due to NM problems.
- This commit adds a new capability to inform the frontend whether the
NM is running or not, so the frontend could inform the user about it.
Signed-off-by: Jose Ricardo Ziviani <joserz(a)linux.vnet.ibm.com>
---
src/kimchi/model/config.py | 1 +
src/kimchi/model/featuretests.py | 28 ++++++++++++++++++++++++++++
tests/test_rest.py | 3 ++-
3 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/src/kimchi/model/config.py b/src/kimchi/model/config.py
index 1c43360..a417c9b 100644
--- a/src/kimchi/model/config.py
+++ b/src/kimchi/model/config.py
@@ -140,6 +140,7 @@ class CapabilitiesModel(object):
'federation': kconfig.get("server",
"federation"),
'auth': kconfig.get("authentication",
"method"),
'kernel_vfio': self.kernel_vfio,
+ 'nm_running': FeatureTests.is_nm_running(),
}
diff --git a/src/kimchi/model/featuretests.py b/src/kimchi/model/featuretests.py
index 4aac8ed..64f2c01 100644
--- a/src/kimchi/model/featuretests.py
+++ b/src/kimchi/model/featuretests.py
@@ -223,3 +223,31 @@ class FeatureTests(object):
kimchi_log.warning("Unable to load Kernal module vfio-pci.")
return False
return True
+
+ @staticmethod
+ def is_nm_running():
+ '''Tries to determine whether NetworkManager is
running.'''
+
+ # force the language to original
+ env = {'LANG': 'C'}
+
+ nmcli = ['nmcli',
+ '-t',
+ '--fields',
+ 'running',
+ 'general',
+ 'status']
+
+ # there are different ways to know if NM is running and it
+ # depends on the version, so if one command fails we try the
+ # next one. Otherwise we assume NM is not running.
+ out, _, rc = run_command(nmcli, timeout=1.0, env=env)
+ if rc != 0:
+ # change option from 'general' to 'nm'
+ nmcli[4] = 'nm'
+ out, _, rc = run_command(nmcli, timeout=1.0, env=env)
+
+ if rc == 0 and out.rstrip('\n') == 'running':
+ return True
+
+ return False
diff --git a/tests/test_rest.py b/tests/test_rest.py
index 16ff41d..603e531 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -1098,7 +1098,8 @@ class RestTests(unittest.TestCase):
keys = [u'libvirt_stream_protocols', u'qemu_stream',
u'qemu_spice',
u'screenshot', u'system_report_tool',
u'update_tool',
- u'repo_mngt_tool', u'federation', u'kernel_vfio',
u'auth']
+ u'repo_mngt_tool', u'federation', u'kernel_vfio',
u'auth',
+ u'nm_running']
self.assertEquals(sorted(keys), sorted(conf.keys()))
def test_peers(self):
--
1.9.1