[Kimchi-devel] [PATCH][Kimchi] Load Kimchi when started by command line and libvirt is not running
Rodrigo Trujillo
rodrigo.trujillo at linux.vnet.ibm.com
Sun May 29 23:12:09 UTC 2016
Kimchi is able to detect and continue running if libvirt stops and back.
However if libvirt is not up and host admin tries to start Wok, Kimchi
is going to crash in feature tests and when loads models.
This patch fixes this issues, then Wok does not break and is able to
load and start Kimchi. When libivirt service is back, Kimchi is able to
run feature tests and set the capabilities again, restoring all
features.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
---
model/config.py | 17 ++++++++++++++---
model/networks.py | 5 +++--
model/storagepools.py | 5 +++--
model/storagevolumes.py | 7 ++++++-
4 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/model/config.py b/model/config.py
index 36fce74..fc4b285 100644
--- a/model/config.py
+++ b/model/config.py
@@ -89,6 +89,10 @@ class CapabilitiesModel(object):
def _set_depend_capabilities(self):
wok_log.info("\n*** Kimchi: Running dependable feature tests ***")
conn = self.conn.get()
+ if conn is None:
+ wok_log.info("*** Kimchi: Dependable feature tests not completed "
+ "***\n")
+ return
self.qemu_stream = FeatureTests.qemu_supports_iso_stream()
msg = "QEMU stream support .......: %s"
wok_log.info(msg % str(self.qemu_stream))
@@ -104,6 +108,12 @@ class CapabilitiesModel(object):
def _set_capabilities(self):
wok_log.info("\n*** Kimchi: Running feature tests ***")
+ self.libvirtd_running = is_libvirtd_up()
+ msg = "Service Libvirtd running ...: %s"
+ wok_log.info(msg % str(self.libvirtd_running))
+ if self.libvirtd_running == False:
+ wok_log.info("*** Kimchi: Feature tests not completed ***\n")
+ return
conn = self.conn.get()
self.nfs_target_probe = FeatureTests.libvirt_support_nfs_probe(conn)
msg = "NFS Target Probe support ...: %s"
@@ -120,9 +130,6 @@ class CapabilitiesModel(object):
self.mem_hotplug_support = FeatureTests.has_mem_hotplug_support(conn)
msg = "Memory Hotplug support .....: %s"
wok_log.info(msg % str(self.mem_hotplug_support))
- self.libvirtd_running = is_libvirtd_up()
- msg = "Service Libvirtd running ...: %s"
- wok_log.info(msg % str(self.libvirtd_running))
wok_log.info("*** Kimchi: Feature tests completed ***\n")
_set_capabilities.priority = 90
@@ -148,6 +155,10 @@ class CapabilitiesModel(object):
'nm_running': FeatureTests.is_nm_running(),
'mem_hotplug_support': False,
'libvirtd_running': False}
+ elif self.libvirtd_running == False:
+ # Libvirt returned, run tests again
+ self._set_capabilities()
+ self._set_depend_capabilities()
return {'libvirt_stream_protocols': self.libvirt_stream_protocols,
'qemu_spice': self._qemu_support_spice(),
diff --git a/model/networks.py b/model/networks.py
index e04c8e4..3b2a9e2 100644
--- a/model/networks.py
+++ b/model/networks.py
@@ -49,8 +49,9 @@ KIMCHI_BRIDGE_PREFIX = 'kb'
class NetworksModel(object):
def __init__(self, **kargs):
self.conn = kargs['conn']
- if self.conn.isQemuURI():
- self._check_default_networks()
+ if self.conn.get() is not None:
+ if self.conn.isQemuURI():
+ self._check_default_networks()
self.caps = CapabilitiesModel(**kargs)
diff --git a/model/storagepools.py b/model/storagepools.py
index be06988..3f6a734 100644
--- a/model/storagepools.py
+++ b/model/storagepools.py
@@ -65,8 +65,9 @@ class StoragePoolsModel(object):
self.caps = CapabilitiesModel(**kargs)
self.device = DeviceModel(**kargs)
- if self.conn.isQemuURI():
- self._check_default_pools()
+ if self.conn.get() is not None:
+ if self.conn.isQemuURI():
+ self._check_default_pools()
def _check_default_pools(self):
pools = {}
diff --git a/model/storagevolumes.py b/model/storagevolumes.py
index da42e85..70cad4f 100644
--- a/model/storagevolumes.py
+++ b/model/storagevolumes.py
@@ -275,7 +275,10 @@ class StorageVolumeModel(object):
self.task = TaskModel(**kargs)
self.storagevolumes = StorageVolumesModel(**kargs)
self.storagepool = StoragePoolModel(**kargs)
- self.libvirt_user = UserTests().probe_user()
+ if self.conn.get() is not None:
+ self.libvirt_user = UserTests().probe_user()
+ else:
+ self.libvirt_user = None
@staticmethod
def get_storagevolume(poolname, name, conn):
@@ -332,6 +335,8 @@ class StorageVolumeModel(object):
isvalid = False
used_by = get_disk_used_by(self.objstore, self.conn, path)
+ if (self.libvirt_user is None):
+ self.libvirt_user = UserTests().probe_user()
ret, _ = probe_file_permission_as_user(path, self.libvirt_user)
res = dict(type=VOLUME_TYPE_MAP[info[0]],
capacity=info[1],
--
2.1.0
More information about the Kimchi-devel
mailing list