[PATCH 0/4] Fixes for Wok and Kimchi
by Aline Manera
Aline Manera (4):
Remove any WOK error message from Kimchi
Provide a meaningful message to WOKUTILS0001E
Move validate_repo_url() and check_url_path() from Wok to Kimchi
Use absolute import path
src/wok/control/tasks.py | 4 +-
src/wok/i18n.py | 2 +-
src/wok/plugins/kimchi/__init__.py | 2 +-
src/wok/plugins/kimchi/control/host.py | 2 +-
src/wok/plugins/kimchi/control/storagepools.py | 3 +-
src/wok/plugins/kimchi/control/vms.py | 2 +-
src/wok/plugins/kimchi/distroloader.py | 3 +-
src/wok/plugins/kimchi/i18n.py | 1 +
src/wok/plugins/kimchi/isoinfo.py | 3 +-
src/wok/plugins/kimchi/mockmodel.py | 36 ++++++++--------
src/wok/plugins/kimchi/model/config.py | 22 +++++-----
src/wok/plugins/kimchi/model/diskutils.py | 3 +-
src/wok/plugins/kimchi/model/host.py | 6 +--
src/wok/plugins/kimchi/model/hostdev.py | 2 +-
src/wok/plugins/kimchi/model/interfaces.py | 2 +-
src/wok/plugins/kimchi/model/model.py | 2 +-
src/wok/plugins/kimchi/model/storagepools.py | 6 +--
src/wok/plugins/kimchi/model/storageservers.py | 3 +-
src/wok/plugins/kimchi/model/storagetargets.py | 4 +-
src/wok/plugins/kimchi/model/storagevolumes.py | 5 ++-
src/wok/plugins/kimchi/model/templates.py | 2 +-
src/wok/plugins/kimchi/model/vmhostdevs.py | 8 ++--
src/wok/plugins/kimchi/model/vmifaces.py | 4 +-
src/wok/plugins/kimchi/model/vms.py | 13 +++---
src/wok/plugins/kimchi/model/vmsnapshots.py | 4 +-
src/wok/plugins/kimchi/model/vmstorages.py | 11 ++---
src/wok/plugins/kimchi/repositories.py | 9 ++--
src/wok/plugins/kimchi/scan.py | 2 +-
src/wok/plugins/kimchi/screenshot.py | 2 +-
src/wok/plugins/kimchi/swupdate.py | 8 ++--
src/wok/plugins/kimchi/tests/utils.py | 7 ++-
src/wok/plugins/kimchi/utils.py | 60 +++++++++++++++++++++++++-
src/wok/plugins/kimchi/vmtemplate.py | 21 +++++----
src/wok/plugins/kimchi/xmlutils/disk.py | 2 +-
src/wok/utils.py | 55 -----------------------
35 files changed, 167 insertions(+), 154 deletions(-)
--
2.1.0
9 years, 2 months
[PATCH V3] Fix issue #738 - Part 2: Split Wok and Kimchi object stores
by Lucio Correia
Wok and Kimchi currently share the same object store. This
patch creates a specific store for Kimchi and uses it as
default location for Kimchi's model.
Signed-off-by: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
---
Makefile.am | 3 ++-
contrib/wok.spec.fedora.in | 2 +-
contrib/wok.spec.suse.in | 2 +-
src/wok/plugins/kimchi/Makefile.am | 2 --
src/wok/plugins/kimchi/config.py.in | 4 ++++
src/wok/plugins/kimchi/contrib/kimchi.spec.fedora.in | 1 -
src/wok/plugins/kimchi/contrib/kimchi.spec.suse.in | 1 -
src/wok/plugins/kimchi/model/model.py | 3 ++-
src/wok/plugins/kimchi/root.py | 1 +
src/wok/plugins/kimchi/tests/test_mockmodel.py | 2 +-
10 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 3d3b5d6..430d6bc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -81,6 +81,7 @@ install-deb: install
cp -R $(top_srcdir)/contrib/wokd-upstart.conf.debian \
$(DESTDIR)/etc/init/wokd.conf; \
fi
+ $(MKDIR_P) $(DESTDIR)/$(localstatedir)/lib/wok/
$(MKDIR_P) $(DESTDIR)/usr/lib/firewalld/services
cp -R $(top_srcdir)/src/firewalld.xml \
$(DESTDIR)/usr/lib/firewalld/services/wokd.xml
@@ -126,7 +127,7 @@ install-data-local:
mkdir -p $(DESTDIR)/etc/init.d/; \
$(INSTALL_DATA) contrib/wokd.sysvinit $(DESTDIR)/etc/init.d/wokd; \
chmod +x $(DESTDIR)/etc/init.d/wokd; \
- fi; \
+ fi; \
if test -d /usr/lib/firewalld/services/; then \
mkdir -p $(DESTDIR)/usr/lib/firewalld/services/; \
$(INSTALL_DATA) src/firewalld.xml $(DESTDIR)/usr/lib/firewalld/services/wokd.xml; \
diff --git a/contrib/wok.spec.fedora.in b/contrib/wok.spec.fedora.in
index 7987fa8..ff7589d 100644
--- a/contrib/wok.spec.fedora.in
+++ b/contrib/wok.spec.fedora.in
@@ -135,7 +135,7 @@ rm -rf $RPM_BUILD_ROOT
%endif
%changelog
-* Fri Jun 19 2015 Lucio Correia <luciojhc(a)linux.vnet.ibm.com> 1.6
+* Fri Jun 19 2015 Lucio Correia <luciojhc(a)linux.vnet.ibm.com> 2.0
- Rename to wokd
- Remove kimchi specifics
diff --git a/contrib/wok.spec.suse.in b/contrib/wok.spec.suse.in
index f749b9e..088aa95 100644
--- a/contrib/wok.spec.suse.in
+++ b/contrib/wok.spec.suse.in
@@ -115,7 +115,7 @@ rm -rf $RPM_BUILD_ROOT
%changelog
-* Fri Jun 19 2015 Lucio Correia <luciojhc(a)linux.vnet.ibm.com> 1.6
+* Fri Jun 19 2015 Lucio Correia <luciojhc(a)linux.vnet.ibm.com> 2.0
- Rename to wokd
- Remove kimchi specifics
diff --git a/src/wok/plugins/kimchi/Makefile.am b/src/wok/plugins/kimchi/Makefile.am
index 47212fe..82c4b19 100644
--- a/src/wok/plugins/kimchi/Makefile.am
+++ b/src/wok/plugins/kimchi/Makefile.am
@@ -99,7 +99,6 @@ config.py: config.py.in Makefile
install-deb: install
cp -R $(top_srcdir)/contrib/DEBIAN $(DESTDIR)/
mkdir -p $(DESTDIR)/$(localstatedir)/lib/kimchi
- touch $(DESTDIR)/$(localstatedir)/lib/wok/objectstore
mkdir -p $(DESTDIR)/$(localstatedir)/lib/kimchi/vnc-tokens
mkdir -p $(DESTDIR)/$(localstatedir)/lib/kimchi/debugreports
mkdir -p $(DESTDIR)/$(localstatedir)/lib/kimchi/screenshots
@@ -144,7 +143,6 @@ install-data-local:
$(INSTALL_DATA) contrib/kimchid.service.fedora $(DESTDIR)/etc/systemd/system/wokd.service.d/kimchi.conf; \
fi; \
$(MKDIR_P) $(DESTDIR)/$(localstatedir)/lib/kimchi/
- touch $(DESTDIR)/$(localstatedir)/lib/wok/objectstore
$(MKDIR_P) $(DESTDIR)$(kimchidir)
$(INSTALL_DATA) API.json $(DESTDIR)$(kimchidir)/API.json
mkdir -p $(DESTDIR)/$(localstatedir)/lib/kimchi/vnc-tokens
diff --git a/src/wok/plugins/kimchi/config.py.in b/src/wok/plugins/kimchi/config.py.in
index 6ae0ccd..43e94e1 100644
--- a/src/wok/plugins/kimchi/config.py.in
+++ b/src/wok/plugins/kimchi/config.py.in
@@ -42,6 +42,10 @@ def get_debugreports_path():
return os.path.join(PluginPaths('kimchi').state_dir, 'debugreports')
+def get_object_store():
+ return os.path.join(PluginPaths('kimchi').state_dir, 'objectstore')
+
+
def get_screenshot_path():
return os.path.join(PluginPaths('kimchi').state_dir, 'screenshots')
diff --git a/src/wok/plugins/kimchi/contrib/kimchi.spec.fedora.in b/src/wok/plugins/kimchi/contrib/kimchi.spec.fedora.in
index e4b7b6d..52bd23e 100644
--- a/src/wok/plugins/kimchi/contrib/kimchi.spec.fedora.in
+++ b/src/wok/plugins/kimchi/contrib/kimchi.spec.fedora.in
@@ -103,7 +103,6 @@ rm -rf $RPM_BUILD_ROOT
%{_sharedstatedir}/kimchi/screenshots/
%{_sharedstatedir}/kimchi/vnc-tokens/
%{_sharedstatedir}/kimchi/
-%{_sharedstatedir}/wok/objectstore
%changelog
diff --git a/src/wok/plugins/kimchi/contrib/kimchi.spec.suse.in b/src/wok/plugins/kimchi/contrib/kimchi.spec.suse.in
index 03dfa7b..142ff4b 100644
--- a/src/wok/plugins/kimchi/contrib/kimchi.spec.suse.in
+++ b/src/wok/plugins/kimchi/contrib/kimchi.spec.suse.in
@@ -90,7 +90,6 @@ rm -rf $RPM_BUILD_ROOT
%{_var}/lib/kimchi/screenshots/
%{_var}/lib/kimchi/vnc-tokens/
%{_var}/lib/kimchi/
-%{_var}/lib/wok/objectstore
%changelog
diff --git a/src/wok/plugins/kimchi/model/model.py b/src/wok/plugins/kimchi/model/model.py
index 8335552..7316874 100644
--- a/src/wok/plugins/kimchi/model/model.py
+++ b/src/wok/plugins/kimchi/model/model.py
@@ -22,6 +22,7 @@ import os
from wok.basemodel import BaseModel
from wok.objectstore import ObjectStore
+from wok.plugins.kimchi import config
from wok.utils import import_module, listPathModules
from libvirtconnection import LibvirtConnection
@@ -41,7 +42,7 @@ class Model(BaseModel):
return instances
- self.objstore = ObjectStore(objstore_loc)
+ self.objstore = ObjectStore(objstore_loc or config.get_object_store())
self.conn = LibvirtConnection(libvirt_uri)
kargs = {'objstore': self.objstore, 'conn': self.conn}
models = []
diff --git a/src/wok/plugins/kimchi/root.py b/src/wok/plugins/kimchi/root.py
index 9cbc70f..c59f859 100644
--- a/src/wok/plugins/kimchi/root.py
+++ b/src/wok/plugins/kimchi/root.py
@@ -54,6 +54,7 @@ class KimchiRoot(WokRoot):
self.messages = messages
make_dirs = [
+ os.path.dirname(os.path.abspath(config.get_object_store())),
os.path.abspath(config.get_distros_store()),
os.path.abspath(config.get_debugreports_path()),
os.path.abspath(config.get_screenshot_path())
diff --git a/src/wok/plugins/kimchi/tests/test_mockmodel.py b/src/wok/plugins/kimchi/tests/test_mockmodel.py
index ffbf8d5..2e6b60f 100644
--- a/src/wok/plugins/kimchi/tests/test_mockmodel.py
+++ b/src/wok/plugins/kimchi/tests/test_mockmodel.py
@@ -135,7 +135,7 @@ class MockModelTests(unittest.TestCase):
self.assertEquals(get_template_default('old', 'memory'),
info['memory'])
self.assertEquals(1, info['cpus'])
- self.assertEquals('images/icon-vm.png', info['icon'])
+ self.assertEquals('plugins/kimchi/images/icon-vm.png', info['icon'])
self.assertEquals(stats_keys, set(info['stats'].keys()))
self.assertEquals('vnc', info['graphics']['type'])
self.assertEquals('127.0.0.1', info['graphics']['listen'])
--
1.9.1
9 years, 2 months
[PATCH V3] Fix Kimchi model
by Lucio Correia
With the Kimchi/Wok split, the Tasks model is now outside of
Kimchi's model tree and needs to be imported separately. This
patch does that and creates function get_instances() to
avoid code duplication.
It also fixes related documentation and URIs to use
/plugins/kimchi/tasks, which is now exported by Kimchi.
Signed-off-by: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
---
src/wok/plugins/kimchi/docs/API.md | 33 ++++++++++++++++++++++
src/wok/plugins/kimchi/model/model.py | 28 +++++++++++++-----
src/wok/plugins/kimchi/tests/test_host.py | 4 +--
.../plugins/kimchi/tests/test_mock_storagepool.py | 2 +-
.../kimchi/tests/test_model_storagevolume.py | 8 +++---
src/wok/plugins/kimchi/tests/test_rest.py | 24 ++++++++--------
src/wok/plugins/kimchi/ui/js/src/kimchi.api.js | 4 +--
7 files changed, 75 insertions(+), 28 deletions(-)
diff --git a/src/wok/plugins/kimchi/docs/API.md b/src/wok/plugins/kimchi/docs/API.md
index ccc843f..e7f399b 100644
--- a/src/wok/plugins/kimchi/docs/API.md
+++ b/src/wok/plugins/kimchi/docs/API.md
@@ -35,6 +35,39 @@ the following general conventions:
* Variable segments in the URI begin with a ':' and should replaced with the
appropriate resource identifier.
+
+### Collection: Tasks
+
+**URI:** /plugins/kimchi/tasks
+
+**Methods:**
+
+* **GET**: Retrieve a summarized list of current Kimchi specific Tasks (stored
+in Kimchi's object store)
+
+### Resource: Task
+
+**URI:** /plugins/kimchi/tasks/*:id*
+
+A task represents an asynchronous operation that is being performed by the
+server.
+
+**Methods:**
+
+* **GET**: Retrieve the full description of the Task
+ * id: The Task ID is used to identify this Task in the API.
+ * status: The current status of the Task
+ * running: The task is running
+ * finished: The task has finished successfully
+ * failed: The task failed
+ * message: Human-readable details about the Task status
+ * target_uri: Resource URI related to the Task
+* **POST**: *See Task Actions*
+
+**Actions (POST):**
+
+*No actions defined*
+
### Collection: Virtual Machines
**URI:** /plugins/kimchi/vms
diff --git a/src/wok/plugins/kimchi/model/model.py b/src/wok/plugins/kimchi/model/model.py
index 0c94f63..8335552 100644
--- a/src/wok/plugins/kimchi/model/model.py
+++ b/src/wok/plugins/kimchi/model/model.py
@@ -30,23 +30,37 @@ from libvirtconnection import LibvirtConnection
class Model(BaseModel):
def __init__(self, libvirt_uri=None, objstore_loc=None):
+ def get_instances(module_name):
+ instances = []
+ module = import_module(module_name)
+ members = inspect.getmembers(module, inspect.isclass)
+ for cls_name, instance in members:
+ if inspect.getmodule(instance) == module and \
+ cls_name.endswith('Model'):
+ instances.append(instance)
+
+ return instances
+
self.objstore = ObjectStore(objstore_loc)
self.conn = LibvirtConnection(libvirt_uri)
kargs = {'objstore': self.objstore, 'conn': self.conn}
+ models = []
+ # Import task model from Wok
+ instances = get_instances('wok.model.tasks')
+ for instance in instances:
+ models.append(instance(**kargs))
+
+ # Import all Kimchi plugin models
this = os.path.basename(__file__)
this_mod = os.path.splitext(this)[0]
- models = []
for mod_name in listPathModules(os.path.dirname(__file__)):
if mod_name.startswith("_") or mod_name == this_mod:
continue
- module = import_module('plugins.kimchi.model.' + mod_name)
- members = inspect.getmembers(module, inspect.isclass)
- for cls_name, instance in members:
- if inspect.getmodule(instance) == module:
- if cls_name.endswith('Model'):
- models.append(instance(**kargs))
+ instances = get_instances('wok.plugins.kimchi.model.' + mod_name)
+ for instance in instances:
+ models.append(instance(**kargs))
return super(Model, self).__init__(models)
diff --git a/src/wok/plugins/kimchi/tests/test_host.py b/src/wok/plugins/kimchi/tests/test_host.py
index f3da49b..2940f48 100644
--- a/src/wok/plugins/kimchi/tests/test_host.py
+++ b/src/wok/plugins/kimchi/tests/test_host.py
@@ -128,12 +128,12 @@ class HostTests(unittest.TestCase):
task_params = [u'id', u'message', u'status', u'target_uri']
self.assertEquals(sorted(task_params), sorted(task.keys()))
- resp = self.request('/tasks/' + task[u'id'], None,
+ resp = self.request('/plugins/kimchi/tasks/' + task[u'id'], None,
'GET')
task_info = json.loads(resp.read())
self.assertEquals(task_info['status'], 'running')
wait_task(_task_lookup, task_info['id'])
- resp = self.request('/tasks/' + task[u'id'], None,
+ resp = self.request('/plugins/kimchi/tasks/' + task[u'id'], None,
'GET')
task_info = json.loads(resp.read())
self.assertEquals(task_info['status'], 'finished')
diff --git a/src/wok/plugins/kimchi/tests/test_mock_storagepool.py b/src/wok/plugins/kimchi/tests/test_mock_storagepool.py
index 5cf5b3e..ea9843b 100644
--- a/src/wok/plugins/kimchi/tests/test_mock_storagepool.py
+++ b/src/wok/plugins/kimchi/tests/test_mock_storagepool.py
@@ -61,7 +61,7 @@ class MockStoragepoolTests(unittest.TestCase):
def _task_lookup(self, taskid):
return json.loads(
- self.request('/tasks/%s' % taskid).read()
+ self.request('/plugins/kimchi/tasks/%s' % taskid).read()
)
def test_storagepool(self):
diff --git a/src/wok/plugins/kimchi/tests/test_model_storagevolume.py b/src/wok/plugins/kimchi/tests/test_model_storagevolume.py
index 8812e46..087dd7b 100644
--- a/src/wok/plugins/kimchi/tests/test_model_storagevolume.py
+++ b/src/wok/plugins/kimchi/tests/test_model_storagevolume.py
@@ -64,7 +64,7 @@ def tearDownModule():
def _do_volume_test(self, model, host, ssl_port, pool_name):
def _task_lookup(taskid):
return json.loads(
- self.request('/tasks/%s' % taskid).read()
+ self.request('/plugins/kimchi/tasks/%s' % taskid).read()
)
uri = '/plugins/kimchi/storagepools/%s/storagevolumes' \
@@ -91,7 +91,7 @@ def _do_volume_test(self, model, host, ssl_port, pool_name):
task_id = json.loads(resp.read())['id']
wait_task(_task_lookup, task_id)
status = json.loads(
- self.request('/tasks/%s' % task_id).read()
+ self.request('/plugins/kimchi/tasks/%s' % task_id).read()
)
self.assertEquals('finished', status['status'])
vol_info = json.loads(self.request(vol_uri).read())
@@ -137,7 +137,7 @@ def _do_volume_test(self, model, host, ssl_port, pool_name):
cloned_vol_name)
wait_task(_task_lookup, task['id'])
task = json.loads(
- self.request('/tasks/%s' % task['id']).read()
+ self.request('/plugins/kimchi/tasks/%s' % task['id']).read()
)
self.assertEquals('finished', task['status'])
resp = self.request(uri + '/' + cloned_vol_name.encode('utf-8'))
@@ -177,7 +177,7 @@ def _do_volume_test(self, model, host, ssl_port, pool_name):
self.assertEquals(202, resp.status)
task_id = json.loads(resp.read())['id']
wait_task(_task_lookup, task_id)
- status = json.loads(self.request('/tasks/%s' %
+ status = json.loads(self.request('/plugins/kimchi/tasks/%s' %
task_id).read())
self.assertEquals('ready for upload', status['message'])
diff --git a/src/wok/plugins/kimchi/tests/test_rest.py b/src/wok/plugins/kimchi/tests/test_rest.py
index 8cf4bd3..e1a2f54 100644
--- a/src/wok/plugins/kimchi/tests/test_rest.py
+++ b/src/wok/plugins/kimchi/tests/test_rest.py
@@ -335,7 +335,7 @@ class RestTests(unittest.TestCase):
task = json.loads(resp.read())
wait_task(self._task_lookup, task['id'])
task = json.loads(
- self.request('/tasks/%s' % task['id'], '{}').read()
+ self.request('/plugins/kimchi/tasks/%s' % task['id'], '{}').read()
)
self.assertEquals('finished', task['status'])
clone_vm_name = task['target_uri'].split('/')[-2]
@@ -366,7 +366,7 @@ class RestTests(unittest.TestCase):
task = json.loads(resp.read())
wait_task(self._task_lookup, task['id'])
task = json.loads(
- self.request('/tasks/%s' % task['id']).read()
+ self.request('/plugins/kimchi/tasks/%s' % task['id']).read()
)
self.assertEquals('finished', task['status'])
@@ -404,7 +404,7 @@ class RestTests(unittest.TestCase):
task = json.loads(resp.read())
snap_name = task['target_uri'].split('/')[-1]
wait_task(self._task_lookup, task['id'])
- resp = self.request('/tasks/%s' % task['id'], '{}',
+ resp = self.request('/plugins/kimchi/tasks/%s' % task['id'], '{}',
'GET')
task = json.loads(resp.read())
self.assertEquals('finished', task['status'])
@@ -1172,37 +1172,37 @@ class RestTests(unittest.TestCase):
def _task_lookup(self, taskid):
return json.loads(
- self.request('/tasks/%s' % taskid).read()
+ self.request('/plugins/kimchi/tasks/%s' % taskid).read()
)
def test_tasks(self):
- id1 = add_task('/tasks/1', self._async_op,
+ id1 = add_task('/plugins/kimchi/tasks/1', self._async_op,
model.objstore)
- id2 = add_task('/tasks/2', self._except_op,
+ id2 = add_task('/plugins/kimchi/tasks/2', self._except_op,
model.objstore)
- id3 = add_task('/tasks/3', self._intermid_op,
+ id3 = add_task('/plugins/kimchi/tasks/3', self._intermid_op,
model.objstore)
- target_uri = urllib2.quote('^/tasks/*', safe="")
+ target_uri = urllib2.quote('^/plugins/kimchi/tasks/*', safe="")
filter_data = 'status=running&target_uri=%s' % target_uri
tasks = json.loads(
- self.request('/tasks?%s' % filter_data).read()
+ self.request('/plugins/kimchi/tasks?%s' % filter_data).read()
)
self.assertEquals(3, len(tasks))
- tasks = json.loads(self.request('/tasks').read())
+ tasks = json.loads(self.request('/plugins/kimchi/tasks').read())
tasks_ids = [int(t['id']) for t in tasks]
self.assertEquals(set([id1, id2, id3]) - set(tasks_ids), set([]))
wait_task(self._task_lookup, id2)
foo2 = json.loads(
- self.request('/tasks/%s' % id2).read()
+ self.request('/plugins/kimchi/tasks/%s' % id2).read()
)
keys = ['id', 'status', 'message', 'target_uri']
self.assertEquals(sorted(keys), sorted(foo2.keys()))
self.assertEquals('failed', foo2['status'])
wait_task(self._task_lookup, id3)
foo3 = json.loads(
- self.request('/tasks/%s' % id3).read()
+ self.request('/plugins/kimchi/tasks/%s' % id3).read()
)
self.assertEquals('in progress', foo3['message'])
self.assertEquals('running', foo3['status'])
diff --git a/src/wok/plugins/kimchi/ui/js/src/kimchi.api.js b/src/wok/plugins/kimchi/ui/js/src/kimchi.api.js
index a16c95e..bb3a53d 100644
--- a/src/wok/plugins/kimchi/ui/js/src/kimchi.api.js
+++ b/src/wok/plugins/kimchi/ui/js/src/kimchi.api.js
@@ -525,7 +525,7 @@ var kimchi = {
getTask : function(taskId, suc, err) {
wok.requestJSON({
- url : 'tasks/' + encodeURIComponent(taskId),
+ url : 'plugins/kimchi/tasks/' + encodeURIComponent(taskId),
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -536,7 +536,7 @@ var kimchi = {
getTasksByFilter : function(filter, suc, err, sync) {
wok.requestJSON({
- url : 'tasks?' + filter,
+ url : 'plugins/kimchi/tasks?' + filter,
type : 'GET',
contentType : 'application/json',
dataType : 'json',
--
1.9.1
9 years, 2 months
[PATCH 0/2] Adding new-ui to Wok and Kimchi-Hosts (pre-gingerbase) v3
by sguimaraes943@gmail.com
From: samhenri <samuel.guimaraes(a)eldorado.org.br>
Refactored patches 5/6 and 6/6 from previous patchset to include some bug-fixes.
Kimchi/Hosts was updated with new-ui pre-gingerbase. Some CSS were left empty to avoid conflicts with git rm and git mv from other patches.
Please note that some styles, modal windows and buttons may stop working or display incorrectly since this patch includes the new-ui main template that ignores theme-default.min.css rules that were overriding Bootstrap styles in the new-ui.
v2:
Patch 1 - Separated wok.confirm.js from wok.message.js and fixed header icon when no title was given to confirm dialog
- Updated login page to not save user and password information (since we're dealing with O.S users I believe it is not a good idea to allow browsers to remember root username and password)
- Fixed minor bugs in wok.list.js. Added a button on top of the list if no debug report was previously generated. Disabled drop-down button when generating new report. Added loading icon to when generating report.
Patch 2 - Updated kimchi.hosts.js with necessary DOM manipulation after Patch 1 v2 changes in wok.list.js.
v3:
Patch 1 - Fixed wok.list.js Action button label.
Patch 2 - Updated kimchi.hosts.js after Hosts Monitor update from Friday. Also updated required DOM manipulation when Debug Reports or Repositories lists are not available. Updated the IDs from Debug Reports and Repositories elements.
samhenri (2):
Adding new-ui base templates and widgets
Adding new-ui to Hosts tab and modal windows
src/wok/plugins/kimchi/ui/config/tab-ext.xml | 10 +-
.../plugins/kimchi/ui/css/theme-default/host.css | 270 ---------
.../kimchi/ui/css/theme-default/report-add.css | 20 -
.../kimchi/ui/css/theme-default/report-rename.css | 22 -
.../kimchi/ui/css/theme-default/repository-add.css | 25 -
.../ui/css/theme-default/repository-edit.css | 62 ---
src/wok/plugins/kimchi/ui/js/src/kimchi.host.js | 615 +++++++++++----------
src/wok/plugins/kimchi/ui/pages/host.html.tmpl | 205 ++++----
.../plugins/kimchi/ui/pages/report-add.html.tmpl | 46 +-
.../kimchi/ui/pages/report-rename.html.tmpl | 42 +-
.../kimchi/ui/pages/repository-add.html.tmpl | 124 ++---
.../kimchi/ui/pages/repository-edit.html.tmpl | 138 ++---
ui/css/src/bootstrap-select.custom.scss | 1 +
ui/css/src/modules/_host.scss | 6 +-
ui/css/src/modules/_menu-flat.scss | 6 +-
ui/css/src/modules/_modal-flat.scss | 2 +-
ui/css/src/modules/_navbar-flat.scss | 4 +-
ui/css/src/modules/_toolbar.scss | 24 +-
ui/css/src/modules/_wok-confirm.scss | 42 ++
ui/css/src/wok.scss | 6 +-
ui/images/theme-default/Makefile.am | 2 +-
ui/images/theme-default/logo-flat.svg | 43 ++
ui/images/theme-default/logo-white.png | Bin 9879 -> 7583 bytes
ui/js/src/wok.grid.js | 416 ++++----------
ui/js/src/wok.line-chart.js | 74 ++-
ui/js/src/wok.list.js | 282 ++++++++++
ui/js/src/wok.login.js | 9 +-
ui/js/src/wok.main.js | 37 +-
ui/js/src/wok.message.js | 111 ++--
ui/js/src/wok.window.js | 38 +-
ui/pages/login.html.tmpl | 186 ++++---
ui/pages/wok-ui.html.tmpl | 219 ++++----
32 files changed, 1422 insertions(+), 1667 deletions(-)
create mode 100644 ui/css/src/modules/_wok-confirm.scss
create mode 100644 ui/images/theme-default/logo-flat.svg
create mode 100644 ui/js/src/wok.list.js
--
1.9.3
9 years, 2 months
[PATCH V2] Fix issue #738 - Part 2: Split Wok and Kimchi object stores
by Lucio Correia
Wok and Kimchi currently share the same object store. This
patch creates a specific store for Kimchi and uses it as
default location for Kimchi's model.
This patch depends on "Fix Kimchi Model V2" just sent, due to conflicts.
Signed-off-by: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
---
Makefile.am | 3 ++-
contrib/wok.spec.fedora.in | 3 ++-
contrib/wok.spec.suse.in | 3 ++-
src/wok/plugins/kimchi/Makefile.am | 2 --
src/wok/plugins/kimchi/config.py.in | 4 ++++
src/wok/plugins/kimchi/contrib/kimchi.spec.fedora.in | 2 +-
src/wok/plugins/kimchi/contrib/kimchi.spec.suse.in | 2 +-
src/wok/plugins/kimchi/model/model.py | 3 ++-
src/wok/plugins/kimchi/root.py | 1 +
src/wok/plugins/kimchi/tests/test_mockmodel.py | 2 +-
10 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 3d3b5d6..430d6bc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -81,6 +81,7 @@ install-deb: install
cp -R $(top_srcdir)/contrib/wokd-upstart.conf.debian \
$(DESTDIR)/etc/init/wokd.conf; \
fi
+ $(MKDIR_P) $(DESTDIR)/$(localstatedir)/lib/wok/
$(MKDIR_P) $(DESTDIR)/usr/lib/firewalld/services
cp -R $(top_srcdir)/src/firewalld.xml \
$(DESTDIR)/usr/lib/firewalld/services/wokd.xml
@@ -126,7 +127,7 @@ install-data-local:
mkdir -p $(DESTDIR)/etc/init.d/; \
$(INSTALL_DATA) contrib/wokd.sysvinit $(DESTDIR)/etc/init.d/wokd; \
chmod +x $(DESTDIR)/etc/init.d/wokd; \
- fi; \
+ fi; \
if test -d /usr/lib/firewalld/services/; then \
mkdir -p $(DESTDIR)/usr/lib/firewalld/services/; \
$(INSTALL_DATA) src/firewalld.xml $(DESTDIR)/usr/lib/firewalld/services/wokd.xml; \
diff --git a/contrib/wok.spec.fedora.in b/contrib/wok.spec.fedora.in
index 7987fa8..176bf05 100644
--- a/contrib/wok.spec.fedora.in
+++ b/contrib/wok.spec.fedora.in
@@ -122,6 +122,7 @@ rm -rf $RPM_BUILD_ROOT
%if 0%{?with_systemd}
%{_sysconfdir}/nginx/conf.d/wok.conf
%{_sharedstatedir}/wok/
+%{_sharedstatedir}/wok/objectstore
%{_localstatedir}/log/wok/*
%{_localstatedir}/log/wok/
%{_unitdir}/wokd.service
@@ -135,7 +136,7 @@ rm -rf $RPM_BUILD_ROOT
%endif
%changelog
-* Fri Jun 19 2015 Lucio Correia <luciojhc(a)linux.vnet.ibm.com> 1.6
+* Fri Jun 19 2015 Lucio Correia <luciojhc(a)linux.vnet.ibm.com> 2.0
- Rename to wokd
- Remove kimchi specifics
diff --git a/contrib/wok.spec.suse.in b/contrib/wok.spec.suse.in
index f749b9e..742ac72 100644
--- a/contrib/wok.spec.suse.in
+++ b/contrib/wok.spec.suse.in
@@ -95,6 +95,7 @@ rm -rf $RPM_BUILD_ROOT
%{_sysconfdir}/nginx/conf.d/wok.conf.in
%{_sysconfdir}/nginx/conf.d/wok.conf
%{_var}/lib/wok/
+%{_var}/lib/wok/objectstore
%{_localstatedir}/log/wok/*
%{_localstatedir}/log/wok/
%{_mandir}/man8/wokd.8.gz
@@ -115,7 +116,7 @@ rm -rf $RPM_BUILD_ROOT
%changelog
-* Fri Jun 19 2015 Lucio Correia <luciojhc(a)linux.vnet.ibm.com> 1.6
+* Fri Jun 19 2015 Lucio Correia <luciojhc(a)linux.vnet.ibm.com> 2.0
- Rename to wokd
- Remove kimchi specifics
diff --git a/src/wok/plugins/kimchi/Makefile.am b/src/wok/plugins/kimchi/Makefile.am
index 47212fe..82c4b19 100644
--- a/src/wok/plugins/kimchi/Makefile.am
+++ b/src/wok/plugins/kimchi/Makefile.am
@@ -99,7 +99,6 @@ config.py: config.py.in Makefile
install-deb: install
cp -R $(top_srcdir)/contrib/DEBIAN $(DESTDIR)/
mkdir -p $(DESTDIR)/$(localstatedir)/lib/kimchi
- touch $(DESTDIR)/$(localstatedir)/lib/wok/objectstore
mkdir -p $(DESTDIR)/$(localstatedir)/lib/kimchi/vnc-tokens
mkdir -p $(DESTDIR)/$(localstatedir)/lib/kimchi/debugreports
mkdir -p $(DESTDIR)/$(localstatedir)/lib/kimchi/screenshots
@@ -144,7 +143,6 @@ install-data-local:
$(INSTALL_DATA) contrib/kimchid.service.fedora $(DESTDIR)/etc/systemd/system/wokd.service.d/kimchi.conf; \
fi; \
$(MKDIR_P) $(DESTDIR)/$(localstatedir)/lib/kimchi/
- touch $(DESTDIR)/$(localstatedir)/lib/wok/objectstore
$(MKDIR_P) $(DESTDIR)$(kimchidir)
$(INSTALL_DATA) API.json $(DESTDIR)$(kimchidir)/API.json
mkdir -p $(DESTDIR)/$(localstatedir)/lib/kimchi/vnc-tokens
diff --git a/src/wok/plugins/kimchi/config.py.in b/src/wok/plugins/kimchi/config.py.in
index 6ae0ccd..43e94e1 100644
--- a/src/wok/plugins/kimchi/config.py.in
+++ b/src/wok/plugins/kimchi/config.py.in
@@ -42,6 +42,10 @@ def get_debugreports_path():
return os.path.join(PluginPaths('kimchi').state_dir, 'debugreports')
+def get_object_store():
+ return os.path.join(PluginPaths('kimchi').state_dir, 'objectstore')
+
+
def get_screenshot_path():
return os.path.join(PluginPaths('kimchi').state_dir, 'screenshots')
diff --git a/src/wok/plugins/kimchi/contrib/kimchi.spec.fedora.in b/src/wok/plugins/kimchi/contrib/kimchi.spec.fedora.in
index e4b7b6d..41a8a86 100644
--- a/src/wok/plugins/kimchi/contrib/kimchi.spec.fedora.in
+++ b/src/wok/plugins/kimchi/contrib/kimchi.spec.fedora.in
@@ -100,10 +100,10 @@ rm -rf $RPM_BUILD_ROOT
%{_sysconfdir}/kimchi/
%{_sharedstatedir}/kimchi/debugreports/
%{_sharedstatedir}/kimchi/isos/
+%{_sharedstatedir}/kimchi/objectstore
%{_sharedstatedir}/kimchi/screenshots/
%{_sharedstatedir}/kimchi/vnc-tokens/
%{_sharedstatedir}/kimchi/
-%{_sharedstatedir}/wok/objectstore
%changelog
diff --git a/src/wok/plugins/kimchi/contrib/kimchi.spec.suse.in b/src/wok/plugins/kimchi/contrib/kimchi.spec.suse.in
index 03dfa7b..6fbdb3e 100644
--- a/src/wok/plugins/kimchi/contrib/kimchi.spec.suse.in
+++ b/src/wok/plugins/kimchi/contrib/kimchi.spec.suse.in
@@ -87,10 +87,10 @@ rm -rf $RPM_BUILD_ROOT
%{_sysconfdir}/kimchi/
%{_var}/lib/kimchi/debugreports/
%{_var}/lib/kimchi/isos/
+%{_var}/lib/kimchi/objectstore
%{_var}/lib/kimchi/screenshots/
%{_var}/lib/kimchi/vnc-tokens/
%{_var}/lib/kimchi/
-%{_var}/lib/wok/objectstore
%changelog
diff --git a/src/wok/plugins/kimchi/model/model.py b/src/wok/plugins/kimchi/model/model.py
index 39097c4..95bd7f3 100644
--- a/src/wok/plugins/kimchi/model/model.py
+++ b/src/wok/plugins/kimchi/model/model.py
@@ -22,6 +22,7 @@ import os
from wok.basemodel import BaseModel
from wok.objectstore import ObjectStore
+from wok.plugins.kimchi import config
from wok.utils import import_module, listPathModules
from libvirtconnection import LibvirtConnection
@@ -41,7 +42,7 @@ class Model(BaseModel):
return instances
- self.objstore = ObjectStore(objstore_loc)
+ self.objstore = ObjectStore(objstore_loc or config.get_object_store())
self.conn = LibvirtConnection(libvirt_uri)
kargs = {'objstore': self.objstore, 'conn': self.conn}
models = []
diff --git a/src/wok/plugins/kimchi/root.py b/src/wok/plugins/kimchi/root.py
index 9cbc70f..c59f859 100644
--- a/src/wok/plugins/kimchi/root.py
+++ b/src/wok/plugins/kimchi/root.py
@@ -54,6 +54,7 @@ class KimchiRoot(WokRoot):
self.messages = messages
make_dirs = [
+ os.path.dirname(os.path.abspath(config.get_object_store())),
os.path.abspath(config.get_distros_store()),
os.path.abspath(config.get_debugreports_path()),
os.path.abspath(config.get_screenshot_path())
diff --git a/src/wok/plugins/kimchi/tests/test_mockmodel.py b/src/wok/plugins/kimchi/tests/test_mockmodel.py
index ffbf8d5..2e6b60f 100644
--- a/src/wok/plugins/kimchi/tests/test_mockmodel.py
+++ b/src/wok/plugins/kimchi/tests/test_mockmodel.py
@@ -135,7 +135,7 @@ class MockModelTests(unittest.TestCase):
self.assertEquals(get_template_default('old', 'memory'),
info['memory'])
self.assertEquals(1, info['cpus'])
- self.assertEquals('images/icon-vm.png', info['icon'])
+ self.assertEquals('plugins/kimchi/images/icon-vm.png', info['icon'])
self.assertEquals(stats_keys, set(info['stats'].keys()))
self.assertEquals('vnc', info['graphics']['type'])
self.assertEquals('127.0.0.1', info['graphics']['listen'])
--
1.9.1
9 years, 2 months
[PATCH] Kimchi: Fix some test cases on test_mockmodel.py
by Aline Manera
This patch depends on "[Kimchi-devel] [PATCH] Adjust Mockmodel to use the Task API from Wok"
Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
---
src/wok/plugins/kimchi/tests/test_mockmodel.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/wok/plugins/kimchi/tests/test_mockmodel.py b/src/wok/plugins/kimchi/tests/test_mockmodel.py
index ffbf8d5..7cbdbed 100644
--- a/src/wok/plugins/kimchi/tests/test_mockmodel.py
+++ b/src/wok/plugins/kimchi/tests/test_mockmodel.py
@@ -68,7 +68,7 @@ class MockModelTests(unittest.TestCase):
req = json.dumps({'name': 'test-vm', 'template': '/templates/test'})
resp = request(host, ssl_port, '/plugins/kimchi/vms', req, 'POST')
task = json.loads(resp.read())
- wait_task(model.task_lookup, task['id'])
+ wait_task(model.task.lookup, task['id'])
# Test screenshot refresh for running vm
request(host, ssl_port, '/plugins/kimchi/vms/test-vm/start', '{}',
@@ -101,7 +101,7 @@ class MockModelTests(unittest.TestCase):
'template': '/plugins/kimchi/templates/test'})
task = json.loads(request(host, ssl_port, '/plugins/kimchi/vms',
req, 'POST').read())
- wait_task(model.task_lookup, task['id'])
+ wait_task(model.task.lookup, task['id'])
vms = [u'abc', u'bca', u'cab', u'xba']
for vm in vms:
@@ -115,7 +115,7 @@ class MockModelTests(unittest.TestCase):
'cdrom': fake_iso})
task = model.vms_create({'name': u'test-vm',
'template': '/plugins/kimchi/templates/test'})
- wait_task(model.task_lookup, task['id'])
+ wait_task(model.task.lookup, task['id'])
vms = model.vms_get_list()
self.assertEquals(2, len(vms))
self.assertIn(u'test-vm', vms)
@@ -135,7 +135,7 @@ class MockModelTests(unittest.TestCase):
self.assertEquals(get_template_default('old', 'memory'),
info['memory'])
self.assertEquals(1, info['cpus'])
- self.assertEquals('images/icon-vm.png', info['icon'])
+ self.assertEquals('plugins/kimchi/images/icon-vm.png', info['icon'])
self.assertEquals(stats_keys, set(info['stats'].keys()))
self.assertEquals('vnc', info['graphics']['type'])
self.assertEquals('127.0.0.1', info['graphics']['listen'])
--
2.1.0
9 years, 2 months
[PATCH] bug fix: Allow user to get guest console (noVNC and spice)
by Aline Manera
While trying to access the guest console a Jquery error was displayed:
TypeError: $.base64 is undefined
return $.base64.btoa(str, true).replace(/\+/g, '-').replace(/\//g, '_');
It is because the base64/jquery.base64.js was conflicting with the new Jquery
version.
Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
---
ui/pages/wok-ui.html.tmpl | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/ui/pages/wok-ui.html.tmpl b/ui/pages/wok-ui.html.tmpl
index 669ae29..f2a09f5 100644
--- a/ui/pages/wok-ui.html.tmpl
+++ b/ui/pages/wok-ui.html.tmpl
@@ -53,10 +53,11 @@
<link rel="stylesheet" href="$href('libs/jquery-ui/themes/base/jquery-ui.min.css')">
<link rel="stylesheet" href="$href('css/jquery-ui.custom.css')">
<link rel="stylesheet" href="$href('css/theme-default.min.css')">
-<script src="$href('base64/jquery.base64.js')"></script>
+
<script src="$href('libs/jquery/jquery.min.js')"></script>
<script src="$href('libs/jquery-ui/jquery-ui.min.js')"></script>
<script src="$href('libs/jquery-ui/jquery-ui-i18n.min.js')"></script>
+<script src="$href('base64/jquery.base64.js')"></script>
<script src="$href('js/wok.min.js')"></script>
<!-- This is used for detecting if the UI needs to be built -->
--
2.1.0
9 years, 2 months
[PATCH V2] Fix Kimchi model
by Lucio Correia
With the Kimchi/Wok split, the Tasks model is now outside of
Kimchi's model tree and needs to be imported separately. This
patch does that and creates function get_instances() to
avoid code duplication.
It also fixes related documentation and URIs to use
/plugins/kimchi/tasks, which is now exported by Kimchi.
Signed-off-by: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
---
src/wok/plugins/kimchi/docs/API.md | 33 ++++++++++++++++++++++
src/wok/plugins/kimchi/model/model.py | 28 +++++++++++++-----
src/wok/plugins/kimchi/tests/test_host.py | 4 +--
.../plugins/kimchi/tests/test_mock_storagepool.py | 2 +-
.../kimchi/tests/test_model_storagevolume.py | 8 +++---
src/wok/plugins/kimchi/tests/test_rest.py | 24 ++++++++--------
src/wok/plugins/kimchi/ui/js/src/kimchi.api.js | 4 +--
7 files changed, 75 insertions(+), 28 deletions(-)
diff --git a/src/wok/plugins/kimchi/docs/API.md b/src/wok/plugins/kimchi/docs/API.md
index ccc843f..e7f399b 100644
--- a/src/wok/plugins/kimchi/docs/API.md
+++ b/src/wok/plugins/kimchi/docs/API.md
@@ -35,6 +35,39 @@ the following general conventions:
* Variable segments in the URI begin with a ':' and should replaced with the
appropriate resource identifier.
+
+### Collection: Tasks
+
+**URI:** /plugins/kimchi/tasks
+
+**Methods:**
+
+* **GET**: Retrieve a summarized list of current Kimchi specific Tasks (stored
+in Kimchi's object store)
+
+### Resource: Task
+
+**URI:** /plugins/kimchi/tasks/*:id*
+
+A task represents an asynchronous operation that is being performed by the
+server.
+
+**Methods:**
+
+* **GET**: Retrieve the full description of the Task
+ * id: The Task ID is used to identify this Task in the API.
+ * status: The current status of the Task
+ * running: The task is running
+ * finished: The task has finished successfully
+ * failed: The task failed
+ * message: Human-readable details about the Task status
+ * target_uri: Resource URI related to the Task
+* **POST**: *See Task Actions*
+
+**Actions (POST):**
+
+*No actions defined*
+
### Collection: Virtual Machines
**URI:** /plugins/kimchi/vms
diff --git a/src/wok/plugins/kimchi/model/model.py b/src/wok/plugins/kimchi/model/model.py
index 0c94f63..39097c4 100644
--- a/src/wok/plugins/kimchi/model/model.py
+++ b/src/wok/plugins/kimchi/model/model.py
@@ -30,23 +30,37 @@ from libvirtconnection import LibvirtConnection
class Model(BaseModel):
def __init__(self, libvirt_uri=None, objstore_loc=None):
+ def get_instances(module_name):
+ instances = []
+ module = import_module(module_name)
+ members = inspect.getmembers(module, inspect.isclass)
+ for cls_name, instance in members:
+ if inspect.getmodule(instance) == module and \
+ cls_name.endswith('Model'):
+ instances.append(instance)
+
+ return instances
+
self.objstore = ObjectStore(objstore_loc)
self.conn = LibvirtConnection(libvirt_uri)
kargs = {'objstore': self.objstore, 'conn': self.conn}
+ models = []
+ # Import task model from Wok
+ instances = get_instances('wok.model.tasks')
+ for instance in instances:
+ models.append(instance(**kargs))
+
+ # Import all Kimchi plugin models
this = os.path.basename(__file__)
this_mod = os.path.splitext(this)[0]
- models = []
for mod_name in listPathModules(os.path.dirname(__file__)):
if mod_name.startswith("_") or mod_name == this_mod:
continue
- module = import_module('plugins.kimchi.model.' + mod_name)
- members = inspect.getmembers(module, inspect.isclass)
- for cls_name, instance in members:
- if inspect.getmodule(instance) == module:
- if cls_name.endswith('Model'):
- models.append(instance(**kargs))
+ instances = get_instances('plugins.kimchi.model.' + mod_name)
+ for instance in instances:
+ models.append(instance(**kargs))
return super(Model, self).__init__(models)
diff --git a/src/wok/plugins/kimchi/tests/test_host.py b/src/wok/plugins/kimchi/tests/test_host.py
index f3da49b..2940f48 100644
--- a/src/wok/plugins/kimchi/tests/test_host.py
+++ b/src/wok/plugins/kimchi/tests/test_host.py
@@ -128,12 +128,12 @@ class HostTests(unittest.TestCase):
task_params = [u'id', u'message', u'status', u'target_uri']
self.assertEquals(sorted(task_params), sorted(task.keys()))
- resp = self.request('/tasks/' + task[u'id'], None,
+ resp = self.request('/plugins/kimchi/tasks/' + task[u'id'], None,
'GET')
task_info = json.loads(resp.read())
self.assertEquals(task_info['status'], 'running')
wait_task(_task_lookup, task_info['id'])
- resp = self.request('/tasks/' + task[u'id'], None,
+ resp = self.request('/plugins/kimchi/tasks/' + task[u'id'], None,
'GET')
task_info = json.loads(resp.read())
self.assertEquals(task_info['status'], 'finished')
diff --git a/src/wok/plugins/kimchi/tests/test_mock_storagepool.py b/src/wok/plugins/kimchi/tests/test_mock_storagepool.py
index 5cf5b3e..ea9843b 100644
--- a/src/wok/plugins/kimchi/tests/test_mock_storagepool.py
+++ b/src/wok/plugins/kimchi/tests/test_mock_storagepool.py
@@ -61,7 +61,7 @@ class MockStoragepoolTests(unittest.TestCase):
def _task_lookup(self, taskid):
return json.loads(
- self.request('/tasks/%s' % taskid).read()
+ self.request('/plugins/kimchi/tasks/%s' % taskid).read()
)
def test_storagepool(self):
diff --git a/src/wok/plugins/kimchi/tests/test_model_storagevolume.py b/src/wok/plugins/kimchi/tests/test_model_storagevolume.py
index 8812e46..087dd7b 100644
--- a/src/wok/plugins/kimchi/tests/test_model_storagevolume.py
+++ b/src/wok/plugins/kimchi/tests/test_model_storagevolume.py
@@ -64,7 +64,7 @@ def tearDownModule():
def _do_volume_test(self, model, host, ssl_port, pool_name):
def _task_lookup(taskid):
return json.loads(
- self.request('/tasks/%s' % taskid).read()
+ self.request('/plugins/kimchi/tasks/%s' % taskid).read()
)
uri = '/plugins/kimchi/storagepools/%s/storagevolumes' \
@@ -91,7 +91,7 @@ def _do_volume_test(self, model, host, ssl_port, pool_name):
task_id = json.loads(resp.read())['id']
wait_task(_task_lookup, task_id)
status = json.loads(
- self.request('/tasks/%s' % task_id).read()
+ self.request('/plugins/kimchi/tasks/%s' % task_id).read()
)
self.assertEquals('finished', status['status'])
vol_info = json.loads(self.request(vol_uri).read())
@@ -137,7 +137,7 @@ def _do_volume_test(self, model, host, ssl_port, pool_name):
cloned_vol_name)
wait_task(_task_lookup, task['id'])
task = json.loads(
- self.request('/tasks/%s' % task['id']).read()
+ self.request('/plugins/kimchi/tasks/%s' % task['id']).read()
)
self.assertEquals('finished', task['status'])
resp = self.request(uri + '/' + cloned_vol_name.encode('utf-8'))
@@ -177,7 +177,7 @@ def _do_volume_test(self, model, host, ssl_port, pool_name):
self.assertEquals(202, resp.status)
task_id = json.loads(resp.read())['id']
wait_task(_task_lookup, task_id)
- status = json.loads(self.request('/tasks/%s' %
+ status = json.loads(self.request('/plugins/kimchi/tasks/%s' %
task_id).read())
self.assertEquals('ready for upload', status['message'])
diff --git a/src/wok/plugins/kimchi/tests/test_rest.py b/src/wok/plugins/kimchi/tests/test_rest.py
index 8cf4bd3..e1a2f54 100644
--- a/src/wok/plugins/kimchi/tests/test_rest.py
+++ b/src/wok/plugins/kimchi/tests/test_rest.py
@@ -335,7 +335,7 @@ class RestTests(unittest.TestCase):
task = json.loads(resp.read())
wait_task(self._task_lookup, task['id'])
task = json.loads(
- self.request('/tasks/%s' % task['id'], '{}').read()
+ self.request('/plugins/kimchi/tasks/%s' % task['id'], '{}').read()
)
self.assertEquals('finished', task['status'])
clone_vm_name = task['target_uri'].split('/')[-2]
@@ -366,7 +366,7 @@ class RestTests(unittest.TestCase):
task = json.loads(resp.read())
wait_task(self._task_lookup, task['id'])
task = json.loads(
- self.request('/tasks/%s' % task['id']).read()
+ self.request('/plugins/kimchi/tasks/%s' % task['id']).read()
)
self.assertEquals('finished', task['status'])
@@ -404,7 +404,7 @@ class RestTests(unittest.TestCase):
task = json.loads(resp.read())
snap_name = task['target_uri'].split('/')[-1]
wait_task(self._task_lookup, task['id'])
- resp = self.request('/tasks/%s' % task['id'], '{}',
+ resp = self.request('/plugins/kimchi/tasks/%s' % task['id'], '{}',
'GET')
task = json.loads(resp.read())
self.assertEquals('finished', task['status'])
@@ -1172,37 +1172,37 @@ class RestTests(unittest.TestCase):
def _task_lookup(self, taskid):
return json.loads(
- self.request('/tasks/%s' % taskid).read()
+ self.request('/plugins/kimchi/tasks/%s' % taskid).read()
)
def test_tasks(self):
- id1 = add_task('/tasks/1', self._async_op,
+ id1 = add_task('/plugins/kimchi/tasks/1', self._async_op,
model.objstore)
- id2 = add_task('/tasks/2', self._except_op,
+ id2 = add_task('/plugins/kimchi/tasks/2', self._except_op,
model.objstore)
- id3 = add_task('/tasks/3', self._intermid_op,
+ id3 = add_task('/plugins/kimchi/tasks/3', self._intermid_op,
model.objstore)
- target_uri = urllib2.quote('^/tasks/*', safe="")
+ target_uri = urllib2.quote('^/plugins/kimchi/tasks/*', safe="")
filter_data = 'status=running&target_uri=%s' % target_uri
tasks = json.loads(
- self.request('/tasks?%s' % filter_data).read()
+ self.request('/plugins/kimchi/tasks?%s' % filter_data).read()
)
self.assertEquals(3, len(tasks))
- tasks = json.loads(self.request('/tasks').read())
+ tasks = json.loads(self.request('/plugins/kimchi/tasks').read())
tasks_ids = [int(t['id']) for t in tasks]
self.assertEquals(set([id1, id2, id3]) - set(tasks_ids), set([]))
wait_task(self._task_lookup, id2)
foo2 = json.loads(
- self.request('/tasks/%s' % id2).read()
+ self.request('/plugins/kimchi/tasks/%s' % id2).read()
)
keys = ['id', 'status', 'message', 'target_uri']
self.assertEquals(sorted(keys), sorted(foo2.keys()))
self.assertEquals('failed', foo2['status'])
wait_task(self._task_lookup, id3)
foo3 = json.loads(
- self.request('/tasks/%s' % id3).read()
+ self.request('/plugins/kimchi/tasks/%s' % id3).read()
)
self.assertEquals('in progress', foo3['message'])
self.assertEquals('running', foo3['status'])
diff --git a/src/wok/plugins/kimchi/ui/js/src/kimchi.api.js b/src/wok/plugins/kimchi/ui/js/src/kimchi.api.js
index a16c95e..bb3a53d 100644
--- a/src/wok/plugins/kimchi/ui/js/src/kimchi.api.js
+++ b/src/wok/plugins/kimchi/ui/js/src/kimchi.api.js
@@ -525,7 +525,7 @@ var kimchi = {
getTask : function(taskId, suc, err) {
wok.requestJSON({
- url : 'tasks/' + encodeURIComponent(taskId),
+ url : 'plugins/kimchi/tasks/' + encodeURIComponent(taskId),
type : 'GET',
contentType : 'application/json',
dataType : 'json',
@@ -536,7 +536,7 @@ var kimchi = {
getTasksByFilter : function(filter, suc, err, sync) {
wok.requestJSON({
- url : 'tasks?' + filter,
+ url : 'plugins/kimchi/tasks?' + filter,
type : 'GET',
contentType : 'application/json',
dataType : 'json',
--
1.9.1
9 years, 2 months
[PATCH] Adjust Mockmodel to use the Task API from Wok
by Aline Manera
Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
---
src/wok/plugins/kimchi/mockmodel.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/wok/plugins/kimchi/mockmodel.py b/src/wok/plugins/kimchi/mockmodel.py
index 0832b20..5b57bbd 100644
--- a/src/wok/plugins/kimchi/mockmodel.py
+++ b/src/wok/plugins/kimchi/mockmodel.py
@@ -26,6 +26,7 @@ from lxml import objectify
from lxml.builder import E
from wok.exception import NotFoundError, OperationFailed
+from wok.model.tasks import TaskModel
from wok.objectstore import ObjectStore
from wok.utils import add_task, get_next_clone_name, wok_log
from wok.xmlutils.utils import xml_item_update
@@ -99,6 +100,8 @@ class MockModel(Model):
super(MockModel, self).__init__('test:///default', objstore_loc)
self.objstore_loc = objstore_loc
self.objstore = ObjectStore(objstore_loc)
+ kargs = {'objstore': self.objstore}
+ self.task = TaskModel(**kargs)
# The MockModel methods are instantiated on runtime according to Model
# and BaseModel
@@ -371,7 +374,7 @@ class MockModel(Model):
def _mock_host_swupdate(self, args=None):
task_id = add_task('/plugins/kimchi/host/swupdate',
self._mock_swupdate.doUpdate, self.objstore)
- return self.task_lookup(task_id)
+ return self.task.lookup(task_id)
def _mock_repositories_get_list(self):
return self._mock_repositories.repos.keys()
@@ -424,7 +427,7 @@ class MockModel(Model):
taskid = add_task(u'/plugins/kimchi/vms/%s/snapshots/%s' %
(vm_name, name), self._vmsnapshots_create_task,
self.objstore, params)
- return self.task_lookup(taskid)
+ return self.task.lookup(taskid)
def _vmsnapshots_create_task(self, cb, params):
vm_name = params['vm_name']
--
2.1.0
9 years, 2 months
[PATCH] Fix Kimchi model
by Lucio Correia
With the Kimchi/Wok split, the Tasks model is now outside of
Kimchi's model tree and needs to be imported separately.
This patch does that and creates function get_instances() to
avoid code duplication.
With this fix Kimchi tests have about 7 errors less.
Signed-off-by: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
---
src/wok/plugins/kimchi/model/model.py | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/src/wok/plugins/kimchi/model/model.py b/src/wok/plugins/kimchi/model/model.py
index 0c94f63..39097c4 100644
--- a/src/wok/plugins/kimchi/model/model.py
+++ b/src/wok/plugins/kimchi/model/model.py
@@ -30,23 +30,37 @@ from libvirtconnection import LibvirtConnection
class Model(BaseModel):
def __init__(self, libvirt_uri=None, objstore_loc=None):
+ def get_instances(module_name):
+ instances = []
+ module = import_module(module_name)
+ members = inspect.getmembers(module, inspect.isclass)
+ for cls_name, instance in members:
+ if inspect.getmodule(instance) == module and \
+ cls_name.endswith('Model'):
+ instances.append(instance)
+
+ return instances
+
self.objstore = ObjectStore(objstore_loc)
self.conn = LibvirtConnection(libvirt_uri)
kargs = {'objstore': self.objstore, 'conn': self.conn}
+ models = []
+ # Import task model from Wok
+ instances = get_instances('wok.model.tasks')
+ for instance in instances:
+ models.append(instance(**kargs))
+
+ # Import all Kimchi plugin models
this = os.path.basename(__file__)
this_mod = os.path.splitext(this)[0]
- models = []
for mod_name in listPathModules(os.path.dirname(__file__)):
if mod_name.startswith("_") or mod_name == this_mod:
continue
- module = import_module('plugins.kimchi.model.' + mod_name)
- members = inspect.getmembers(module, inspect.isclass)
- for cls_name, instance in members:
- if inspect.getmodule(instance) == module:
- if cls_name.endswith('Model'):
- models.append(instance(**kargs))
+ instances = get_instances('plugins.kimchi.model.' + mod_name)
+ for instance in instances:
+ models.append(instance(**kargs))
return super(Model, self).__init__(models)
--
1.9.1
9 years, 2 months