[PATCH V3] [Kimchi 0/4] Issue #817 - PCI attach/detach improvements.
by pvital@linux.vnet.ibm.com
From: Paulo Vital <pvital(a)linux.vnet.ibm.com>
V3:
* Fixed copyright line of new files.
V2:
This is the backend part of the solution to Issue #817. In this solution the
support for handle Libvirt events is added, as well, the attach and detach
functions were modified to return AsyncTasks (then frontend can be informed
when a device is really attached/detached).
Patch "Add support to Libvirt Events." is the third version of previous
submitted patch.
Patch "Make detach device return an AsyncTask" needs submitted Wok patch
"Update AsyncResource class with delete method." to work.
Paulo Vital (4):
Add support to Libvirt Events.
Add Events support to VM's Devices attach/detach.
Make attach device return an AsyncTask
Make detach device return an AsyncTask
control/vm/hostdevs.py | 6 +--
i18n.py | 4 ++
model/libvirtevents.py | 124 +++++++++++++++++++++++++++++++++++++++++++++
model/model.py | 6 ++-
model/vmhostdevs.py | 135 ++++++++++++++++++++++++++++++++++++++++++-------
5 files changed, 254 insertions(+), 21 deletions(-)
create mode 100644 model/libvirtevents.py
--
2.5.5
8 years, 8 months
[PATCH V2] [Kimchi 0/4] Issue #817 - PCI attach/detach improvements.
by pvital@linux.vnet.ibm.com
From: Paulo Vital <pvital(a)linux.vnet.ibm.com>
This is the backend part of the solution to Issue #817. In this solution the
support for handle Libvirt events is added, as well, the attach and detach
functions were modified to return AsyncTasks (then frontend can be informed
when a device is really attached/detached).
Patch "Add support to Libvirt Events." is the third version of previous
submitted patch.
Patch "Make detach device return an AsyncTask" needs submitted Wok patch
"Update AsyncResource class with delete method." to work.
Paulo Vital (4):
Add support to Libvirt Events.
Add Events support to VM's Devices attach/detach.
Make attach device return an AsyncTask
Make detach device return an AsyncTask
control/vm/hostdevs.py | 6 +--
i18n.py | 4 ++
model/libvirtevents.py | 124 +++++++++++++++++++++++++++++++++++++++++++++
model/model.py | 6 ++-
model/vmhostdevs.py | 135 ++++++++++++++++++++++++++++++++++++++++++-------
5 files changed, 254 insertions(+), 21 deletions(-)
create mode 100644 model/libvirtevents.py
--
2.5.5
8 years, 8 months
[PATCH v2] [Kimchi] Issue #920: Template is removed if an ISO doesn't exist
by Jose Ricardo Ziviani
- This commit changes the way the template update works. Now, it
really updates the existing template instead of creating a new
one (and deleting the old one)
Signed-off-by: Jose Ricardo Ziviani <joserz(a)linux.vnet.ibm.com>
---
i18n.py | 3 +++
model/templates.py | 55 ++++++++++++++++++++++++++++++++++--------------------
2 files changed, 38 insertions(+), 20 deletions(-)
diff --git a/i18n.py b/i18n.py
index 7cce796..e4656cb 100644
--- a/i18n.py
+++ b/i18n.py
@@ -155,8 +155,10 @@ messages = {
"KCHVMIF0011E": _("Cannot change MAC address of a running virtual machine"),
"KCHTMPL0001E": _("Template %(name)s already exists"),
+ "KCHTMPL0002E": _("Source media %(path)s not found"),
"KCHTMPL0003E": _("Network '%(network)s' specified for template %(template)s does not exist"),
"KCHTMPL0004E": _("Storage pool %(pool)s specified for template %(template)s does not exist"),
+ "KCHTMPL0005E": _("Template %(name)s does not exist."),
"KCHTMPL0006E": _("Invalid parameter '%(param)s' specified for CDROM."),
"KCHTMPL0007E": _("Network %(network)s specified for template %(template)s is not active"),
"KCHTMPL0008E": _("Template name must be a string"),
@@ -181,6 +183,7 @@ messages = {
"KCHTMPL0029E": _("Disk format must be 'raw', for logical, iscsi, and scsi pools."),
"KCHTMPL0030E": _("Memory expects an object with one or both parameters: 'current' and 'maxmemory'"),
"KCHTMPL0031E": _("Memory value (%(mem)sMiB) must be equal or lesser than maximum memory value (%(maxmem)sMiB)"),
+ "KCHTMPL0032E": _("Unable to update template due error: %(err)s"),
"KCHPOOL0001E": _("Storage pool %(name)s already exists"),
"KCHPOOL0002E": _("Storage pool %(name)s does not exist"),
diff --git a/model/templates.py b/model/templates.py
index a02099c..e240317 100644
--- a/model/templates.py
+++ b/model/templates.py
@@ -51,7 +51,7 @@ class TemplatesModel(object):
self.objstore = kargs['objstore']
self.conn = kargs['conn']
- def create(self, params):
+ def _validate_template_params(self, params):
name = params.get('name', '').strip()
conn = self.conn.get()
@@ -72,8 +72,7 @@ class TemplatesModel(object):
# image does not exists: raise error
elif not os.path.exists(path):
- raise InvalidParameter("Unable to find file %(path)s" %
- {"path": path})
+ raise InvalidParameter("KCHTMPL0002E", {'path': path})
# create magic object to discover file type
file_type = magic.open(magic.MAGIC_NONE)
@@ -119,16 +118,18 @@ class TemplatesModel(object):
if 'volume' in disk.keys():
self.template_volume_validate(volume, disk['pool'])
- # template with the same name already exists: raise exception
- name = params['name']
- with self.objstore as session:
- if name in session.get_list('template'):
- raise InvalidOperation("KCHTMPL0001E", {'name': name})
+ return t
+
+ def create(self, params):
+ template = self._validate_template_params(params)
# Store template on objectstore
+ name = params['name']
try:
with self.objstore as session:
- session.store('template', name, t.info,
+ if name in session.get_list('template'):
+ raise InvalidOperation("KCHTMPL0001E", {'name': name})
+ session.store('template', name, template.info,
get_kimchi_version())
except InvalidOperation:
raise
@@ -204,31 +205,33 @@ class TemplateModel(object):
raise OperationFailed('KCHTMPL0021E', {'err': e.message})
def update(self, name, params):
- old_t = self.lookup(name)
- new_t = copy.copy(old_t)
+ edit_template = self.lookup(name)
+
+ edit_template['source_media'] = edit_template.get(
+ 'base', edit_template['cdrom'])
# Merge graphics settings
graph_args = params.get('graphics')
if graph_args:
- graphics = dict(new_t['graphics'])
+ graphics = dict(edit_template['graphics'])
graphics.update(graph_args)
params['graphics'] = graphics
# Merge cpu_info settings
new_cpu_info = params.get('cpu_info')
if new_cpu_info:
- cpu_info = dict(new_t['cpu_info'])
+ cpu_info = dict(edit_template['cpu_info'])
cpu_info.update(new_cpu_info)
params['cpu_info'] = cpu_info
# Fix memory values, because method update does not work recursively
new_mem = params.get('memory')
if new_mem is not None:
- params['memory'] = copy.copy(old_t.get('memory'))
+ params['memory'] = copy.copy(edit_template.get('memory'))
params['memory'].update(new_mem)
validate_memory(params['memory'])
- new_t.update(params)
+ edit_template.update(params)
for net_name in params.get(u'networks', []):
try:
@@ -238,13 +241,25 @@ class TemplateModel(object):
raise InvalidParameter("KCHTMPL0003E", {'network': net_name,
'template': name})
- self.delete(name)
+ template = self.templates._validate_template_params(edit_template)
+
try:
- ident = self.templates.save_template(new_t)
- except:
- ident = self.templates.save_template(old_t)
+ with self.objstore as session:
+ if name not in session.get_list('template'):
+ raise InvalidOperation("KCHTMPL0005E", {'name': name})
+
+ if template.info['name'] != name:
+ session.delete('template', name)
+
+ session.store('template', template.info['name'],
+ template.info, get_kimchi_version())
+
+ except InvalidOperation:
raise
- return ident
+ except Exception, e:
+ raise OperationFailed('KCHTMPL0032E', {'err': e.message})
+
+ return template.info['name']
def validate_memory(memory):
--
1.9.1
8 years, 8 months
[PATCH] [Kimchi 0/4] Issue #817 - PCI attach/detach improvements.
by pvital@linux.vnet.ibm.com
From: Paulo Vital <pvital(a)linux.vnet.ibm.com>
This is the backend part of the solution to Issue #817. In this solution the
support for handle Libvirt events is added, as well, the attach and detach
functions were modified to return AsyncTasks (then frontend can be informed
when a device is really attached/detached).
Patch "Add support to Libvirt Events." is the third version of previous
submitted patch.
Patch "Make detach device return an AsyncTask" needs submitted Wok patch
"Update AsyncResource class with delete method." to work.
Paulo Vital (4):
Add support to Libvirt Events.
Add Events support to VM's Devices attach/detach.
Make attach device return an AsyncTask
Make detach device return an AsyncTask
control/vm/hostdevs.py | 6 +--
i18n.py | 4 ++
model/libvirtevents.py | 124 +++++++++++++++++++++++++++++++++++++++++++++
model/model.py | 6 ++-
model/vmhostdevs.py | 135 ++++++++++++++++++++++++++++++++++++++++++-------
5 files changed, 254 insertions(+), 21 deletions(-)
create mode 100644 model/libvirtevents.py
--
2.5.5
8 years, 8 months
[PATCH] [Wok] Wok utils method for converting String to Unicode and vice versa.
by archus@linux.vnet.ibm.com
From: Archana Singh <archus(a)linux.vnet.ibm.com>
Added two utils methods which can be used to convert
String to Unicode and Unicode to String.
This method does the checking of instance of value passed
and accordingly used the encode, decode, str methods.
Signed-off-by: Archana Singh <archus(a)linux.vnet.ibm.com>
---
src/wok/utils.py | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/src/wok/utils.py b/src/wok/utils.py
index 175cf25..0e8ec05 100644
--- a/src/wok/utils.py
+++ b/src/wok/utils.py
@@ -622,3 +622,27 @@ def upgrade_objectstore_schema(objstore=None, field=None):
wok_log.error("Cannot upgrade objectstore schema: %s" % e.args[0])
return False
return True
+
+
+def encode_value(val):
+ """
+ Convert the value to string.
+ If its unicode, use encode otherwise str.
+ """
+ if isinstance(val, unicode):
+ return val.encode('utf-8')
+ return str(val)
+
+
+def decode_value(val):
+ """
+ Converts value to unicode,
+ if its not an instance of unicode.
+ For doing so convert the val to string,
+ if its not instance of basestring.
+ """
+ if not isinstance(val, basestring):
+ val = str(val)
+ if not isinstance(val, unicode):
+ val = val.decode('utf-8')
+ return val
--
2.5.0
8 years, 8 months
[PATCH] [Wok] Wok utils method for converting String to Unicode and vice versa.
by archus@linux.vnet.ibm.com
From: Archana Singh <archus(a)linux.vnet.ibm.com>
Added two utils methods which can be used to convert
String to Unicode and Unicode to String.
This method does the checking of instance of value passed
and accordingly used the encode, decode, str methods.
Signed-off-by: Archana Singh <archus(a)linux.vnet.ibm.com>
---
src/wok/utils.py | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/src/wok/utils.py b/src/wok/utils.py
index 175cf25..0e8ec05 100644
--- a/src/wok/utils.py
+++ b/src/wok/utils.py
@@ -622,3 +622,27 @@ def upgrade_objectstore_schema(objstore=None, field=None):
wok_log.error("Cannot upgrade objectstore schema: %s" % e.args[0])
return False
return True
+
+
+def encode_value(val):
+ """
+ Convert the value to string.
+ If its unicode, use encode otherwise str.
+ """
+ if isinstance(val, unicode):
+ return val.encode('utf-8')
+ return str(val)
+
+
+def decode_value(val):
+ """
+ Converts value to unicode,
+ if its not an instance of unicode.
+ For doing so convert the val to string,
+ if its not instance of basestring.
+ """
+ if not isinstance(val, basestring):
+ val = str(val)
+ if not isinstance(val, unicode):
+ val = val.decode('utf-8')
+ return val
--
2.5.0
8 years, 8 months
[PATCH] [Kimchi] Create template (UI part) without specifying media type
by Socorro Stoppler
Rather than specifying whether local file is an img or an ISO, all the
user has to do is to input the file including the path of its location.
Kimchi will handle the rest on the backend. Rather than originally having 3
radio buttons, it is now 2 radio buttons -- one for local and the other
for remote.
This patch needs to work in conjunction w/Ramon's latest patch set sent
today - Use a single field to create a template - (backend)
Socorro Stoppler (1):
Create template without specifying media type
ui/css/kimchi.css | 2 +-
ui/css/src/modules/_templates.scss | 2 +-
ui/js/src/kimchi.template_add_main.js | 378 +++++-----------------------------
ui/pages/template-add.html.tmpl | 73 +------
4 files changed, 55 insertions(+), 400 deletions(-)
--
2.5.0
8 years, 8 months
Duplicate Wok Modal windows
by Samuel Henrique De Oliveira Guimaraes
Hey team,
I'm not sure if this is still happening randomly with Ginger, Gingerbase or Kimchi because after the latest changes to wok.window.js it was supposed to be fixed but I was able to reproduce it once again when developing Ginger OVS Bridge UI.
The problem is not related to wok.window.js at all, but in majority if a function that builds the UI has a wok.window.open() line inside of any block and the same parent function is called again, the modal content is hidden from the DOM tree but not removed. This will create windows with different IDs but with the same content inside the modal dialog. The ideal fix would be isolating all click handlers in a different function.
For instance, suppose we have a function like this:
ginger.buildTableUi = function() {
// Some lines
$('button').on('click',function(){
wok.window.open('url');
});
// Some lines
};
ginger.buildTableUi();
And then ginger.buildTableUi() is called again once a new element is added or removed from/to a table or list, this will make the modal content append inside the modal window at N times that this function was called.
Instead we have to isolate the click events like this:
ginger.someTabclickHandler = function() {
$('container').on('click','button',function(){
wok.window.open('url');
});
}
And then we can call it like this:
ginger.buildTableUi();
ginger.someTabclickHandler();
Call ginger.buildTableUi() many times as you want and it won't duplicate the click handlers :)
Please pay attention the changes in the click event differences from the examples above.
Since the UI will dynamically generate the buttons or links that we'll bind new events, we have to add a static container that is not generated by JS or ensure that the container, button or link element was in the DOM tree before someTabclickHandler() was called.
If you find any duplicate modal windows, please let me know or follow the instructions above and send a patch :)
Regards,
Samuel
8 years, 8 months
[PATCH] [Kimchi] Fixed some issues with SCSS after adding compact() mixin to Wok
by sguimaraes943@gmail.com
From: Samuel Guimarães <sguimaraes943(a)gmail.com>
Patch "Added compact Sass function that was removed from libsass" is required in order to compile the correct CSS output from kimchi.scss.
Samuel Guimarães (1):
Fixed some issues with SCSS after adding compact() mixin to Wok
ui/css/kimchi.css | 38 ++++++++++++++++++------------------
ui/css/src/kimchi.scss | 2 ++
ui/css/src/modules/_edit-guests.scss | 25 +++++++++++++++---------
3 files changed, 37 insertions(+), 28 deletions(-)
--
1.9.3
8 years, 8 months
[WOK][PATCH] Added method to validate ASCII value
by pkulkark@linux.vnet.ibm.com
From: Pooja Kulkarni <pkulkark(a)linux.vnet.ibm.com>
Added a method to utils to check
if a given field value is ASCII
Signed-off-by: Pooja Kulkarni <pkulkark(a)linux.vnet.ibm.com>
---
ui/js/src/wok.utils.js | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/ui/js/src/wok.utils.js b/ui/js/src/wok.utils.js
index e5701e6..d7dd8a3 100644
--- a/ui/js/src/wok.utils.js
+++ b/ui/js/src/wok.utils.js
@@ -193,3 +193,7 @@ wok.urlSafeB64Decode = function(str) {
wok.urlSafeB64Encode = function(str) {
return $.base64.btoa(str, true).replace(/\+/g, '-').replace(/\//g, '_');
}
+
+wok.isASCII = function(field) {
+ return /^[\x00-\x7F]*$/.test(field);
+}
--
2.1.0
8 years, 8 months