[PATCH][Wok] Fix notification api message return
by Rodrigo Trujillo
When Wok receives a notifications request, it is using "pop" to retrieve
plugin name. This actions removes plugin entry from the dictionary, so
in next request it is not able to know what plugin is, then message is
not returned, just {"CODE": "CODE"}.
This patch fixes this problem.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo(a)linux.vnet.ibm.com>
---
src/wok/model/notifications.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/wok/model/notifications.py b/src/wok/model/notifications.py
index 55bd178..e83ac56 100644
--- a/src/wok/model/notifications.py
+++ b/src/wok/model/notifications.py
@@ -72,8 +72,8 @@ class NotificationModel(object):
# use WokMessage to translate the notification
if notification:
- timestamp = notification['timestamp']
- plugin = notification.pop('_plugin_name', None)
+ timestamp = notification.get('timestamp', None)
+ plugin = notification.get('_plugin_name', None)
message = WokMessage(str(id), notification, plugin).get_text()
return {"code": id, "message": message, "timestamp": timestamp}
--
2.1.0
8 years, 7 months
[PATCH][Kimchi] Load Kimchi when started by command line and libvirt is not running
by Rodrigo Trujillo
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(a)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
8 years, 7 months
[PATCH][Kimchi] Remove notification message if Libvirt is back
by Rodrigo Trujillo
If libvirt service stops and back again, the UI keeps showing the
notification message until user clicks on 'X' (close) button.
To avoid the wrong message, kimchi will remove the notification in
backend as soon as it notice that Libvirt is up and running.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo(a)linux.vnet.ibm.com>
---
model/libvirtconnection.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/model/libvirtconnection.py b/model/libvirtconnection.py
index d11b8a6..d7c74bc 100644
--- a/model/libvirtconnection.py
+++ b/model/libvirtconnection.py
@@ -21,7 +21,8 @@ import libvirt
import threading
import time
-from wok.model.notifications import add_notification
+from wok.model.notifications import add_notification, del_notification
+from wok.model.notifications import notificationsStore
from wok.utils import wok_log
from wok.plugins.kimchi.utils import is_libvirtd_up
@@ -90,6 +91,12 @@ class LibvirtConnection(object):
wok_log.error('Libvirt service is not active.')
add_notification('KCHCONN0002E', plugin_name='/plugins/kimchi')
return None
+ elif (notificationsStore.get('KCHCONN0002E') is not None):
+ try:
+ del_notification('KCHCONN0002E')
+ except:
+ # If notification was not found, just ignore
+ pass
with LibvirtConnection._connectionLock:
conn = self._connections.get(conn_id)
--
2.1.0
8 years, 7 months
[PATCH][Wok] Issue #121: Unicode error in wok.utils.run_command if cmd & error has non-ascii characters
by archus@linux.vnet.ibm.com
From: Archana Singh <archus(a)linux.vnet.ibm.com>
If command to be run has any non-ascii characters(encoded/unicode value),
then the error message might also contain non-ascii characters(encoded/unicode value).
If command has encoded value and error has unicode value then combining both
into a string result unicode value which will have encoded value result into UnicodeError.
For e.g
command: u'modinfo -0 \xe1'
error: modinfo: ERROR: Module \xc3\xa1 not found. (Note:- It has encoded value of u'\xe1')
Combining both into string message:
"error: %s returned from cmd: %s"%(error, ' '.join(cmd)) result into
UnicodeDecodeError: UnicodeDecodeError('ascii', 'error: modinfo:
ERROR: Module \xc3\xa1 not found.\n returned from cmd: ', 30, 31, 'ordinal not in range(128)')
Fixed this by converting both to unicode format before combining into message.
Signed-off-by: Archana Singh <archus(a)linux.vnet.ibm.com>
---
src/wok/utils.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/wok/utils.py b/src/wok/utils.py
index b37518f..918fd26 100644
--- a/src/wok/utils.py
+++ b/src/wok/utils.py
@@ -273,7 +273,8 @@ def run_command(cmd, timeout=None, silent=False, tee=None,
returncode = proc.returncode
if returncode != 0:
msg = "rc: %s error: %s returned from cmd: %s" %\
- (returncode, error, ' '.join(cmd))
+ (returncode, decode_value(error),
+ decode_value(' '.join(cmd)))
if silent:
wok_log.debug(msg)
@@ -282,7 +283,7 @@ def run_command(cmd, timeout=None, silent=False, tee=None,
wok_log.error(msg)
elif error:
wok_log.debug("error: %s returned from cmd: %s",
- error, ' '.join(cmd))
+ decode_value(error), decode_value(' '.join(cmd)))
if timeout_flag[0]:
msg = ("subprocess is killed by signal.SIGKILL for "
--
2.5.0
8 years, 7 months
[PATCH V2][Wok 12/12] Added tests/fvt/config file into backlist.
by archus@linux.vnet.ibm.com
From: Archana Singh <archus(a)linux.vnet.ibm.com>
Signed-off-by: Archana Singh <archus(a)linux.vnet.ibm.com>
---
IBM-license-blacklist | 1 +
1 file changed, 1 insertion(+)
diff --git a/IBM-license-blacklist b/IBM-license-blacklist
index ce64618..41db1c8 100644
--- a/IBM-license-blacklist
+++ b/IBM-license-blacklist
@@ -99,3 +99,4 @@ ui/libs/typeahead/typeahead.bundle.min.js
ui/robots.txt
ui/libs/jquery-containsNC/LICENSE
ui/libs/jquery-containsNC/jquery.containsNC.js
+tests/fvt/config
--
2.5.0
8 years, 7 months
[PATCH V2][Wok 11/12] FVT: Added Readme instruction for running fvt testcases.
by archus@linux.vnet.ibm.com
From: Archana Singh <archus(a)linux.vnet.ibm.com>
Added Readme instruction for running fvt testcases.
Signed-off-by: Archana Singh <archus(a)linux.vnet.ibm.com>
---
docs/README.md | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/docs/README.md b/docs/README.md
index 8e14672..56e8144 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -74,6 +74,14 @@ Build and Install
# Optional if running from the source tree
$ sudo make install
+FVT Testing
+-----------------
+
+ $ sudo pip install virtualenv
+ $ make check-fvt
+
+After all fvt tests are executed, a summary will be displayed containing any errors/failures which might have occurred.
+
Starting up Wok
---------------
--
2.5.0
8 years, 7 months
[PATCH V2][Wok 10/12] FVT: Added check-fvt to run FVT testcases using make and venv dir to be cleaned.
by archus@linux.vnet.ibm.com
From: Archana Singh <archus(a)linux.vnet.ibm.com>
Added check-fvt to run FVT testcases using make and venv dir to be cleaned.
Signed-off-by: Archana Singh <archus(a)linux.vnet.ibm.com>
---
Makefile.am | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Makefile.am b/Makefile.am
index 325d0c9..9827e66 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -52,6 +52,7 @@ check-local:
find . -path './.git' -prune -o \
-name '*.py' -o -name '*.py.in' | \
xargs $(PYFLAKES) | \
+ grep -w -v "venv" | \
while read LINE; do echo "$$LINE"; false; done \
else \
find . -name '*.py' -o -name '*.py.in' | \
@@ -70,6 +71,10 @@ check-local:
/bin/bash check-IBM-license-header.sh ; \
fi
+check-fvt:
+ tests/fvt/run_tests.sh
+ rm -fr venv
+
# Link built mo files in the source tree to enable use of translations from
# within the source tree
all-local:
@@ -185,5 +190,6 @@ VERSION:
clean-local:
rm -rf mo rpm
+ rm -rf mo rpm tests/fvt/venv
CLEANFILES = wok.spec `find "$(top_srcdir)" -type f -name "*.pyc" -print`
--
2.5.0
8 years, 7 months
[PATCH V2][Wok 09/12] FVT: Added FVT Makefile path in AC_CONFIG_FILES list.
by archus@linux.vnet.ibm.com
From: Archana Singh <archus(a)linux.vnet.ibm.com>
Added fvt's Makefile path in AC_CONFIG_FILES list.
Signed-off-by: Archana Singh <archus(a)linux.vnet.ibm.com>
---
configure.ac | 1 +
1 file changed, 1 insertion(+)
diff --git a/configure.ac b/configure.ac
index 002774d..1c64367 100644
--- a/configure.ac
+++ b/configure.ac
@@ -153,6 +153,7 @@ AC_CONFIG_FILES([
contrib/wok.spec.fedora
contrib/wok.spec.suse
tests/Makefile
+ tests/fvt/Makefile
],[
chmod +x po/gen-pot
])
--
2.5.0
8 years, 7 months
[PATCH V2][Wok 08/12] FVT: Added fvt as subdirs and check-fvt to run fvt testcases using make.
by archus@linux.vnet.ibm.com
From: Archana Singh <archus(a)linux.vnet.ibm.com>
Added fvt as subdirs and check-fvt to run fvt testcases using make.
Signed-off-by: Archana Singh <archus(a)linux.vnet.ibm.com>
---
tests/Makefile.am | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9ead666..656cfae 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -17,6 +17,8 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+SUBDIRS = fvt
+
EXTRA_DIST = \
Makefile.am \
run_tests.sh.in \
@@ -46,5 +48,10 @@ check-local:
$(MKDIR_P) $(top_srcdir)/data/screenshots
./run_tests.sh
+check-fvt:
+ fvt/run_tests.sh
+ rm -fr venv
+
+
BUILT_SOURCES = test_config.py
CLEANFILES = run_tests.sh test_config.py
--
2.5.0
8 years, 7 months
[PATCH V2][Wok 07/12] FVT: Makefile needed for build and run fvt.
by archus@linux.vnet.ibm.com
From: Archana Singh <archus(a)linux.vnet.ibm.com>
Makefile for building and running fvt.
Signed-off-by: Archana Singh <archus(a)linux.vnet.ibm.com>
---
tests/fvt/Makefile.am | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
create mode 100644 tests/fvt/Makefile.am
diff --git a/tests/fvt/Makefile.am b/tests/fvt/Makefile.am
new file mode 100644
index 0000000..c1d3934
--- /dev/null
+++ b/tests/fvt/Makefile.am
@@ -0,0 +1,43 @@
+#
+# Project Wok
+#
+# Copyright IBM Corp, 2016
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+EXTRA_DIST = \
+ Makefile.am \
+ run_tests.sh.in \
+ $(wildcard *.py) \
+ $(NULL)
+
+noinst_SCRIPTS = run_tests.sh
+
+do_substitution = \
+ sed -e 's,[@]HAVE_PYMOD_UNITTEST[@],$(HAVE_PYMOD_UNITTEST),g' \
+ -e 's,[@]PYTHON_VERSION[@],$(PYTHON_VERSION),g'
+
+run_tests.sh: run_tests.sh.in Makefile
+ $(do_substitution) < $(srcdir)/run_tests.sh.in > run_tests.sh
+ chmod +x run_tests.sh
+
+CLEANFILES = run_tests.sh
+
+check-fvt:
+ ./run_tests.sh
+ rm -fr venv
+
+clean-local:
+ rm -fr venv
--
2.5.0
8 years, 7 months