[PATCH v7][Kimchi 0/4] Use a single field to create a template
by Ramon Medeiros
Changes:
v2:
Remove libvirt connection from VMtemplate
Fix incorrect changes on tests
Fix return status when source_media not passed
v3:
Fix pep8 issues
Remove/add some constants
Rewrite API message
v4:
Remove cdrom verification on model
Use disk info from osinfo when adding disk based template
v6:
Add all logic to model
Create tests to verify source_media functionally
Add source_media as required
Update tests
v7:
Update tests
Stop using osinfo on model/templates
Change when template name duplication is verified
Ramon Medeiros (4):
Create a single field to pass the installation media
Identify installation media while creating template
Update tests
Add new tests to verify source_media feature
API.json | 16 ++++------
i18n.py | 2 +-
model/templates.py | 72 +++++++++++++++++++++++++++++++--------------
tests/test_authorization.py | 4 +--
tests/test_livemigration.py | 7 +++--
tests/test_mockmodel.py | 13 ++++----
tests/test_model.py | 71 ++++++++++++++++++++++----------------------
tests/test_rest.py | 36 +++++++++++------------
tests/test_template.py | 39 ++++++++++++------------
tests/test_vmtemplate.py | 3 +-
10 files changed, 144 insertions(+), 119 deletions(-)
--
2.5.5
8 years, 8 months
[PATCH] [Kimchi 0/3] Fixes on template issues
by Jose Ricardo Ziviani
This patchset fixes a problem to create a template from existing image
plus more 2 issues: 919/920.
Jose Ricardo Ziviani (3):
Fix template creation from image file
Issue #919: Deactivate a storagepool makes the list of templates blank
Issue #920: Template is removed if an ISO doesn't exist anymore
model/templates.py | 28 +++++++++++++++++++++++-----
vmtemplate.py | 6 +++++-
2 files changed, 28 insertions(+), 6 deletions(-)
--
1.9.1
8 years, 8 months
[PATCH v2] [Kimchi] Fix template creation from image file
by Jose Ricardo Ziviani
- When using an existing image as base for creating templates we cannot
rely on its pool because it's undefined. This commit sets the default
pool for this case.
Signed-off-by: Jose Ricardo Ziviani <joserz(a)linux.vnet.ibm.com>
---
vmtemplate.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/vmtemplate.py b/vmtemplate.py
index 653ad02..3270749 100644
--- a/vmtemplate.py
+++ b/vmtemplate.py
@@ -96,7 +96,9 @@ class VMTemplate(object):
for index, disk in enumerate(disks):
disk_info = dict(default_disk)
- pool_type = self._get_storage_type(disk['pool']['name'])
+ pool = disk.get('pool', default_disk['pool'])
+ pool_type = self._get_storage_type(pool['name'])
+
if pool_type in ['iscsi', 'scsi']:
disk_info = {'index': 0, 'format': 'raw', 'volume': None}
--
1.9.1
8 years, 8 months
[PATCH v6][Kimchi 0/4] Use a single field to create a template
by Ramon Medeiros
Changes:
v2:
Remove libvirt connection from VMtemplate
Fix incorrect changes on tests
Fix return status when source_media not passed
v3:
Fix pep8 issues
Remove/add some constants
Rewrite API message
v4:
Remove cdrom verification on model
Use disk info from osinfo when adding disk based template
v6:
Add all logic to model
Create tests to verify source_media functionally
Add source_media as required
Update tests
Ramon Medeiros (4):
Create a single field to pass the installation media
Identify installation media while creating template
Update tests
Add new tests to verify source_media feature
API.json | 16 +++-------
i18n.py | 2 +-
model/templates.py | 75 ++++++++++++++++++++++++++++++++-------------
tests/test_authorization.py | 4 +--
tests/test_livemigration.py | 7 +++--
tests/test_mockmodel.py | 13 ++++----
tests/test_model.py | 71 +++++++++++++++++++-----------------------
tests/test_rest.py | 35 ++++++++++-----------
tests/test_template.py | 41 ++++++++++++-------------
tests/test_vmtemplate.py | 3 +-
10 files changed, 142 insertions(+), 125 deletions(-)
--
2.5.5
8 years, 8 months
[PATCH][Kimchi] Test if CPU value is higher than Max CPU before request
by Rodrigo Trujillo
This patch does two modifications in Kimchi UI behavior:
- Change "CPUs" by "Current CPUs" in Guest edit window in order to make
it similar to other windows and widgets, like Template edit;
- Add a CPU checking in the UI before send server request to update the
guest. We know that CPU cannot be higher than Max CPU and backend is
going to raise an error, so, to avoid waste of resources, warn the user
when he/she clicks on Save button and do not perform the request.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.guest_edit_main.js | 7 +++++++
ui/pages/guest-edit.html.tmpl | 2 +-
ui/pages/i18n.json.tmpl | 1 +
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/ui/js/src/kimchi.guest_edit_main.js b/ui/js/src/kimchi.guest_edit_main.js
index 7a9c754..ef6d650 100644
--- a/ui/js/src/kimchi.guest_edit_main.js
+++ b/ui/js/src/kimchi.guest_edit_main.js
@@ -752,6 +752,13 @@ kimchi.guest_edit_main = function() {
return;
}
+ // Test CPU values before submit. Avoid requests we know are going to fail
+ if ($('#guest-edit-cores-textbox').val() > $('#guest-edit-max-processor-textbox').val()) {
+ wok.message.error(i18n['KCHVM0003E'], '#alert-modal-container');
+ $(saveButton).prop('disabled', false);
+ return;
+ }
+
if (data['vcpus'] !== undefined) {
var cpu = Number(data['vcpus']);
var maxCpu = Number(data['max-processor']);
diff --git a/ui/pages/guest-edit.html.tmpl b/ui/pages/guest-edit.html.tmpl
index 05d0b14..5b7155a 100644
--- a/ui/pages/guest-edit.html.tmpl
+++ b/ui/pages/guest-edit.html.tmpl
@@ -45,7 +45,7 @@
<input id="guest-edit-id-textbox" class="form-control" name="name" type="text" />
</div>
<div class="form-group">
- <label for="guest-edit-cores-textbox">$_("CPUs")</label>
+ <label for="guest-edit-cores-textbox">$_("Current CPUs")</label>
<div id="guest-processor">
<input id="guest-edit-cores-textbox" class="form-control" name="vcpus" type="number" min="1" />
<button id="guest-show-max-processor" class="btn btn-primary" type="button"><i class="fa fa-plus-circle"></i> <span class="cputext">$_("More")</span></button>
diff --git a/ui/pages/i18n.json.tmpl b/ui/pages/i18n.json.tmpl
index 153d7c2..24abeb6 100644
--- a/ui/pages/i18n.json.tmpl
+++ b/ui/pages/i18n.json.tmpl
@@ -67,6 +67,7 @@
"KCHVM0001E": "$_("Input is not a number")",
"KCHVM0002E": "$_("Memory value cannot be higher then Max Memory value")",
+ "KCHVM0003E": "$_("Current CPUs value cannot be higher then Max CPU value")",
"KCHVMCD6001M": "$_("This CDROM will be detached permanently and you can re-attach it. Continue to detach it?")",
"KCHVMCD6003M": "$_("Attaching...")",
--
2.1.0
8 years, 8 months
[PATCH] [Kimchi] Fix template creation from image file
by Jose Ricardo Ziviani
- When using an existing image as base for creating templates we cannot
rely on its pool because it's undefined. This commit sets the default
pool for this case.
Signed-off-by: Jose Ricardo Ziviani <joserz(a)linux.vnet.ibm.com>
---
vmtemplate.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/vmtemplate.py b/vmtemplate.py
index 653ad02..b71cf23 100644
--- a/vmtemplate.py
+++ b/vmtemplate.py
@@ -96,7 +96,12 @@ class VMTemplate(object):
for index, disk in enumerate(disks):
disk_info = dict(default_disk)
- pool_type = self._get_storage_type(disk['pool']['name'])
+ if 'pool' in disk and 'name' in disk['pool']:
+ pool_type = self._get_storage_type(disk['pool']['name'])
+ else:
+ pool_type = self._get_storage_type(
+ default_disk['pool']['name'])
+
if pool_type in ['iscsi', 'scsi']:
disk_info = {'index': 0, 'format': 'raw', 'volume': None}
--
1.9.1
8 years, 8 months
[PATCH] [Wok] Implement update methods for object store
by Jose Ricardo Ziviani
- This commit implements two new methods for object store, update_data
and update_id. Now it's possible to update an existing data
instead of delete/create.
Signed-off-by: Jose Ricardo Ziviani <joserz(a)linux.vnet.ibm.com>
---
src/wok/objectstore.py | 13 +++++++++++++
tests/test_objectstore.py | 11 +++++++++++
2 files changed, 24 insertions(+)
diff --git a/src/wok/objectstore.py b/src/wok/objectstore.py
index ff3796c..5ec87eb 100644
--- a/src/wok/objectstore.py
+++ b/src/wok/objectstore.py
@@ -94,6 +94,19 @@ class ObjectStoreSession(object):
(ident, obj_type, jsonstr, version))
self.conn.commit()
+ def update_data(self, obj_type, ident, data):
+ jsonstr = json.dumps(data)
+ c = self.conn.cursor()
+ c.execute('UPDATE objects SET json=? WHERE id=? AND type=?',
+ (jsonstr, ident, obj_type))
+ self.conn.commit()
+
+ def update_id(self, obj_type, ident, new_ident):
+ c = self.conn.cursor()
+ c.execute('UPDATE objects SET id=? WHERE id=? AND type=?',
+ (new_ident, ident, obj_type))
+ self.conn.commit()
+
class ObjectStore(object):
def __init__(self, location=None):
diff --git a/tests/test_objectstore.py b/tests/test_objectstore.py
index 3ea7b70..d6ea434 100644
--- a/tests/test_objectstore.py
+++ b/tests/test_objectstore.py
@@ -82,6 +82,17 @@ class ObjectStoreTests(unittest.TestCase):
item = session.get_object_version('f����', 't��st1')
self.assertEquals(get_version().split('-')[0], item[0])
+ # test update data
+ session.update_data('f����', 't��st1', {'��': 5})
+ item = session.get('f����', 't��st1')
+ self.assertEquals(5, item[u'��'])
+
+ # test update id
+ session.update_id('f����', 't��st1', 't��st2')
+ item = session.get('f����', 't��st2')
+ self.assertEquals(5, item[u'��'])
+
+
def test_object_store_threaded(self):
def worker(ident):
with store as session:
--
1.9.1
8 years, 8 months
[PATCH v5][Kimchi 0/4] Use a single field to create a template
by Ramon Medeiros
Changes:
v2:
Remove libvirt connection from VMtemplate
Fix incorrect changes on tests
Fix return status when source_media not passed
v3:
Fix pep8 issues
Remove/add some constants
Rewrite API message
v4:
Remove cdrom verification on model
Use disk info from osinfo when adding disk based template
Ramon Medeiros (4):
Create a single field to pass the installation media
Fix checking duplicate template before creating it
Identify installation media while creating template
Update tests
API.json | 9 ++--
i18n.py | 2 +-
model/templates.py | 26 +++++------
tests/test_authorization.py | 4 +-
tests/test_livemigration.py | 7 +--
tests/test_mockmodel.py | 13 +++---
tests/test_model.py | 94 +++++++++++++++++++++------------------
tests/test_rest.py | 36 ++++++++-------
tests/test_template.py | 47 +++++++++-----------
tests/test_vmtemplate.py | 40 +++++++++--------
vmtemplate.py | 104 +++++++++++++++++++++++++++++++++++++-------
11 files changed, 227 insertions(+), 155 deletions(-)
--
2.5.5
8 years, 8 months
[PATCH V2] [Kimchi] Add support to Libvirt Events.
by pvital@linux.vnet.ibm.com
From: Paulo Vital <pvital(a)linux.vnet.ibm.com>
This patch adds support to handle in Kimchi any Libvirt Event, just by adding
a callback to process the event and register the event with the callback.
A method called register_common_events() is responsible to register the common
domain events to use a generic callback that logs into error log, the event
happened and it's details.
This patch is part of the solution for Kimchi Issue #817
Signed-off-by: Paulo Vital <pvital(a)linux.vnet.ibm.com>
---
i18n.py | 4 +++
model/libvirtevents.py | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++
model/model.py | 6 +++-
3 files changed, 106 insertions(+), 1 deletion(-)
create mode 100644 model/libvirtevents.py
diff --git a/i18n.py b/i18n.py
index 6214687..3939aba 100644
--- a/i18n.py
+++ b/i18n.py
@@ -326,4 +326,8 @@ messages = {
"KCHLVMS0001E": _("Invalid volume group name parameter: %(name)s."),
+ "KCHEVENT0001E": _("Failed to register the default event implementation."),
+ "KCHEVENT0002E": _("Failed to register timeout event."),
+ "KCHEVENT0003E": _("Failed to Run the default event implementation."),
+
}
diff --git a/model/libvirtevents.py b/model/libvirtevents.py
new file mode 100644
index 0000000..2775476
--- /dev/null
+++ b/model/libvirtevents.py
@@ -0,0 +1,97 @@
+#
+# Project Kimchi
+#
+# 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
+
+import cherrypy
+import libvirt
+import time
+
+from wok.exception import OperationFailed
+from wok.utils import wok_log
+
+
+class LibvirtEvents(object):
+ def __init__(self):
+ # Register default implementation of event handlers
+ if libvirt.virEventRegisterDefaultImpl() < 0:
+ raise OperationFailed('KCHEVENT0001E')
+
+ # Run a background thread with the event loop. Using cherrypy
+ # BackgroundTask class due to issues when using threading module with
+ # cherrypy.
+ self.event_loop_thread = cherrypy.process.plugins.BackgroundTask(
+ 2,
+ self._event_loop_run
+ )
+ self.event_loop_thread.setName('KimchiLibvirtEventLoop')
+ self.event_loop_thread.setDaemon(True)
+ self.event_loop_thread.start()
+
+ # Set an event timeout to control the self._event_loop_run
+ if libvirt.virEventAddTimeout(0, self._kimchi_EventTimeout, None) < 0:
+ raise OperationFailed('KCHEVENT0002E')
+
+ # Event loop method to be executed in background as thread
+ def _event_loop_run(self):
+ while True:
+ if libvirt.virEventRunDefaultImpl() < 0:
+ raise OperationFailed('KCHEVENT0003E')
+
+ def is_event_loop_alive(self):
+ return self.event_loop_thread.isAlive()
+
+ # Event loop handler used to limit length of waiting for any other event.
+ def _kimchi_EventTimeout(self, timer, opaque):
+ time.sleep(1)
+
+ def domain_event_generic_cb(self, conn, dom, event, detail, *args):
+ """
+ Generic callback to handle Domain (VMs) events.
+ """
+ evStrings = ("Defined", "Undefined", "Started", "Suspended", "Resumed",
+ "Stopped", "Shutdown", "PMSuspended", "Crashed")
+ evDetails = (("Added", "Updated"),
+ ("Removed", ),
+ ("Booted", "Migrated", "Restored", "Snapshot", "Wakeup"),
+ ("Paused", "Migrated", "IOError", "Watchdog", "Restored",
+ "Snapshot", "API error"),
+ ("Unpaused", "Migrated", "Snapshot"),
+ ("Shutdown", "Destroyed", "Crashed", "Migrated", "Saved",
+ "Failed", "Snapshot"),
+ ("Finished", ),
+ ("Memory", "Disk"),
+ ("Panicked"))
+ msg = "Libvirt Event: Domain %s %s %s" % (dom.name(), evStrings[event],
+ evDetails[event][detail])
+
+ wok_log.error(msg)
+
+ def register_common_domain_events(self, conn):
+ """
+ Register the most common Libvirt domain events to be handled.
+ """
+ conn = conn.get()
+ for ev in (libvirt.VIR_DOMAIN_EVENT_ID_LIFECYCLE,
+ libvirt.VIR_DOMAIN_EVENT_ID_REBOOT,
+ libvirt.VIR_DOMAIN_EVENT_ID_RTC_CHANGE,
+ libvirt.VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON,
+ libvirt.VIR_DOMAIN_EVENT_ID_GRAPHICS,
+ libvirt.VIR_DOMAIN_EVENT_ID_BLOCK_JOB,
+ libvirt.VIR_DOMAIN_EVENT_ID_WATCHDOG):
+ conn.domainEventRegisterAny(None, ev, self.domain_event_generic_cb,
+ ev)
diff --git a/model/model.py b/model/model.py
index e44f804..aeb8b7d 100644
--- a/model/model.py
+++ b/model/model.py
@@ -26,6 +26,7 @@ from wok.plugins.kimchi import config
from wok.utils import import_module, listPathModules
from wok.plugins.kimchi.model.libvirtconnection import LibvirtConnection
+from wok.plugins.kimchi.model.libvirtevents import LibvirtEvents
class Model(BaseModel):
@@ -43,8 +44,11 @@ class Model(BaseModel):
return instances
self.objstore = ObjectStore(objstore_loc or config.get_object_store())
+ self.events = LibvirtEvents()
self.conn = LibvirtConnection(libvirt_uri)
- kargs = {'objstore': self.objstore, 'conn': self.conn}
+ self.events.register_common_domain_events(self.conn)
+ kargs = {'objstore': self.objstore, 'conn': self.conn,
+ 'eventsloop': self.events}
models = []
# Import task model from Wok
--
2.5.5
8 years, 8 months
[PATCH v4][Kimchi 0/4] Use a single field to create a template
by Ramon Medeiros
Instead of specify if the media is cdrom or disk, use source_media to create a template
Changes:
v2:
Remove libvirt connection from VMtemplate
Fix incorrect changes on tests
Fix return status when source_media not passed
v3:
Fix pep8 issues
Remove/add some constants
Rewrite API message
Ramon Medeiros (4):
Create a single field to pass the installation media
Fix checking duplicate template before creating it
Identify installation media while creating template
Update tests
API.json | 5 ++
i18n.py | 2 +-
model/templates.py | 15 ++++--
tests/test_authorization.py | 4 +-
tests/test_livemigration.py | 7 +--
tests/test_mockmodel.py | 13 +++---
tests/test_model.py | 94 ++++++++++++++++++++-----------------
tests/test_rest.py | 36 +++++++--------
tests/test_template.py | 47 +++++++++----------
tests/test_vmtemplate.py | 40 ++++++++--------
vmtemplate.py | 110 +++++++++++++++++++++++++++++++++++++-------
11 files changed, 235 insertions(+), 138 deletions(-)
--
2.5.5
8 years, 8 months