[PATCH v5 1/3] Fix Key Error when editing CD ROM path
by Christy Perez
lxml only accepts strings as parameters when looking
up xml elements. The port for remote ISO was being
passed in as an int, and a KeyError was thrown.
This patch just casts the ints to strings for the
lookups.
Signed-off-by: Christy Perez <christy(a)linux.vnet.ibm.com>
---
src/kimchi/model/vmstorages.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/kimchi/model/vmstorages.py b/src/kimchi/model/vmstorages.py
index b5311db..e5be17c 100644
--- a/src/kimchi/model/vmstorages.py
+++ b/src/kimchi/model/vmstorages.py
@@ -67,7 +67,7 @@ def _get_storage_xml(params, ignore_source=False):
# Working with url paths
if src_type == 'network':
output = urlparse.urlparse(params.get('path'))
- port = output.port or socket.getservbyname(output.scheme)
+ port = str(output.port or socket.getservbyname(output.scheme))
host = E.host(name=output.hostname, port=port)
source = E.source(protocol=output.scheme, name=output.path)
source.append(host)
--
1.9.3
10 years, 4 months
[PATCH V3] UI enhancement: Request /config/capabilities as soon as possible
by Aline Manera
V2 - V3:
- Make host tab uses the cached capabilities values (Cristian)
V1 - V2:
- Make sure kimchi.capabilities is properly set before using its value (Cristian)
I prefered to do it this way because making a sync request will prevent the
full UI to load even for some seconds.
Aline Manera (1):
UI enhancement: Request /config/capabilities as soon as possible
ui/js/src/kimchi.host.js | 21 +++++++++++--------
ui/js/src/kimchi.main.js | 8 ++++++++
ui/js/src/kimchi.template_add_main.js | 37 ++++++++++++++++++++--------------
ui/js/src/kimchi.template_edit_main.js | 20 ++++++++++--------
4 files changed, 55 insertions(+), 31 deletions(-)
--
1.9.3
10 years, 4 months
[PATCH] Change default environment configuration to production mode.
by Paulo Vital
Changed the default environment configuration present in the final files
src/kimchi.conf and src/kimchi.config.py from 'development' to
'production' mode.
This modification will prevent that debugging traces be printed in the
front-end when something goes wrong.
Signed-off-by: Paulo Vital <pvital(a)linux.vnet.ibm.com>
---
src/kimchi.conf.in | 2 +-
src/kimchi/config.py.in | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/kimchi.conf.in b/src/kimchi.conf.in
index 369f2c3..ed0270d 100644
--- a/src/kimchi.conf.in
+++ b/src/kimchi.conf.in
@@ -24,7 +24,7 @@
#ssl_key =
# Running environment of the server
-#environment = development
+#environment = production
[logging]
# Log directory
diff --git a/src/kimchi/config.py.in b/src/kimchi/config.py.in
index 68c8a4d..fca32ee 100644
--- a/src/kimchi/config.py.in
+++ b/src/kimchi/config.py.in
@@ -253,7 +253,7 @@ def _get_config():
config.set("server", "cherrypy_port", "8010")
config.set("server", "ssl_cert", "")
config.set("server", "ssl_key", "")
- config.set("server", "environment", "development")
+ config.set("server", "environment", "production")
config.add_section("logging")
config.set("logging", "log_dir", paths.log_dir)
config.set("logging", "log_level", DEFAULT_LOG_LEVEL)
--
1.8.3.1
10 years, 4 months
[PATCH] Reject cdrom update when protocol is not supported by libvirt
by lvroyce@linux.vnet.ibm.com
From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
Based on Christy's patchset:
[Kimchi-devel] [PATCH v3 1/3] Fix Key Error when editing CD ROM path
When remote iso protocol is not supported by libvirt,
even if we work around by qemu command,
it will mess up device list logic.
So reject this use case.
Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
---
src/kimchi/i18n.py | 1 +
src/kimchi/model/vmstorages.py | 5 ++++-
tests/test_model.py | 13 +++++++++++++
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index 2eae7e8..f5ef275 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -255,6 +255,7 @@ messages = {
"KCHVMSTOR0015E": _("Cannot lookup disk path information by given pool/volume: %(error)s"),
"KCHVMSTOR0016E": _("Volume already been used by other vm"),
"KCHVMSTOR0017E": _("Only one of path or pool/volume can be specified to add a new virtual machine disk"),
+ "KCHVMSTOR0018E": _("Remote ISO update/attach is not supported by your libvirt version"),
"KCHREPOS0001E": _("YUM Repository ID must be one word only string."),
"KCHREPOS0002E": _("Repository URL must be an http://, ftp:// or file:// URL."),
diff --git a/src/kimchi/model/vmstorages.py b/src/kimchi/model/vmstorages.py
index e5be17c..7dc8800 100644
--- a/src/kimchi/model/vmstorages.py
+++ b/src/kimchi/model/vmstorages.py
@@ -29,6 +29,7 @@ from lxml.builder import E
from kimchi.exception import InvalidOperation, InvalidParameter, NotFoundError
from kimchi.exception import OperationFailed
+from kimchi.model.config import CapabilitiesModel
from kimchi.model.vms import DOM_STATE_MAP, VMModel
from kimchi.model.storagevolumes import StorageVolumeModel
from kimchi.model.utils import get_vm_config_flag
@@ -38,7 +39,7 @@ from kimchi.vmdisks import get_device_xml, get_vm_disk, get_vm_disk_list
from kimchi.vmdisks import DEV_TYPE_SRC_ATTR_MAP
HOTPLUG_TYPE = ['scsi', 'virtio']
-
+caps = CapabilitiesModel()
def _get_device_bus(dev_type, dom):
try:
@@ -69,6 +70,8 @@ def _get_storage_xml(params, ignore_source=False):
output = urlparse.urlparse(params.get('path'))
port = str(output.port or socket.getservbyname(output.scheme))
host = E.host(name=output.hostname, port=port)
+ if output.scheme not in caps.libvirt_stream_protocols:
+ raise InvalidOperation("KCHVMSTOR0018E")
source = E.source(protocol=output.scheme, name=output.path)
source.append(host)
disk.append(source)
diff --git a/tests/test_model.py b/tests/test_model.py
index 7fd0f00..dc56676 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -29,6 +29,7 @@ import tempfile
import threading
import time
import unittest
+import urlparse
import uuid
@@ -38,6 +39,7 @@ import utils
from kimchi import netinfo
from kimchi.exception import InvalidOperation, InvalidParameter
from kimchi.exception import NotFoundError, OperationFailed
+from kimchi.featuretests import FeatureTests
from kimchi.iscsi import TargetClient
from kimchi.model import model
from kimchi.rollbackcontext import RollbackContext
@@ -397,11 +399,22 @@ class ModelTests(unittest.TestCase):
valid_remote_iso_path = utils.get_remote_iso_path()
cdrom_args = {"type": "cdrom",
"path": valid_remote_iso_path}
+ protocol = urlparse.urlparse(valid_remote_iso_path).scheme
+ if not FeatureTests.libvirt_supports_iso_stream(protocol):
+ self.assertRaises(InvalidOperation, inst.vmstorages_create,
+ vm_name, cdrom_args)
+ return
+
cdrom_dev = inst.vmstorages_create(vm_name, cdrom_args)
storage_list = inst.vmstorages_get_list(vm_name)
self.assertEquals(prev_count + 1, len(storage_list))
# Update remote-backed cdrom with the same ISO
+ protocol = urlparse.urlparse(valid_remote_iso_path).scheme
+ if not FeatureTests.libvirt_supports_iso_stream(protocol):
+ self.assertRaises(InvalidOperation, inst.vmstorage_update,
+ vm_name, cdrom_dev, {'path': valid_remote_iso_path})
+ return
inst.vmstorage_update(vm_name, cdrom_dev,
{'path': valid_remote_iso_path})
cdrom_info = inst.vmstorage_lookup(vm_name, cdrom_dev)
--
1.8.3.2
10 years, 4 months
[PATCH] Nit: refactor vm xml format
by lvroyce@linux.vnet.ibm.com
From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
Move qemu namespace from xml top level to cdrom generation,
so that future cdrom update can just modify this part without
affect top level xml.
Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
---
src/kimchi/vmtemplate.py | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
index 761bac5..c2101db 100644
--- a/src/kimchi/vmtemplate.py
+++ b/src/kimchi/vmtemplate.py
@@ -150,7 +150,7 @@ class VMTemplate(object):
"""
qemu_stream_cmdline = """
- <qemu:commandline>
+ <qemu:commandline %(ns)s>
<qemu:arg value='-drive'/>
<qemu:arg value='file=%(url)s,if=none,id=drive-%(bus)s0-1-0,\
readonly=on,format=raw'/>
@@ -179,7 +179,7 @@ drive=drive-%(bus)s0-1-0,id=%(bus)s0-1-0'/>
url = protocol + "://" + hostname + ":" + str(port) + url_path
if protocol not in libvirt_stream_protocols:
- return qemu_stream_cmdline % {'url': url, 'bus': bus}
+ return qemu_stream_cmdline % {'url': url, 'bus': bus, 'ns': QEMU_NAMESPACE}
params = {'protocol': protocol, 'url_path': url_path,
'hostname': hostname, 'port': port, 'dev': dev, 'bus': bus}
@@ -365,7 +365,6 @@ drive=drive-%(bus)s0-1-0,id=%(bus)s0-1-0'/>
params['uuid'] = vm_uuid
params['networks'] = self._get_networks_xml()
params['input_output'] = self._get_input_output_xml()
- params['qemu-namespace'] = ''
params['cdroms'] = ''
params['qemu-stream-cmdline'] = ''
graphics = kwargs.get('graphics')
@@ -389,13 +388,12 @@ drive=drive-%(bus)s0-1-0,id=%(bus)s0-1-0'/>
if not urlparse.urlparse(self.info.get('cdrom', "")).scheme in \
libvirt_stream_protocols and \
params.get('iso_stream', False):
- params['qemu-namespace'] = QEMU_NAMESPACE
params['qemu-stream-cmdline'] = cdrom_xml
else:
params['cdroms'] = cdrom_xml
xml = """
- <domain type='%(domain)s' %(qemu-namespace)s>
+ <domain type='%(domain)s'>
%(qemu-stream-cmdline)s
<name>%(name)s</name>
<uuid>%(uuid)s</uuid>
--
1.8.3.2
10 years, 4 months
[PATCH] list host user names as less a possible
by shaohef@linux.vnet.ibm.com
From: Simon Jin <simonjin(a)linux.vnet.ibm.com>
The backend should fitler the user name who can not login the shell.
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
Signed-off-by: Simon Jin <simonjin(a)linux.vnet.ibm.com>
---
src/kimchi/model/host.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/kimchi/model/host.py b/src/kimchi/model/host.py
index a1f8944..39f45d8 100644
--- a/src/kimchi/model/host.py
+++ b/src/kimchi/model/host.py
@@ -419,7 +419,8 @@ def __init__(self, **kargs):
pass
def get_list(self):
- return [user.pw_name for user in pwd.getpwall()]
+ return [user.pw_name for user in pwd.getpwall()
+ if user.pw_shell.rsplit("/")[-1] not in ["nologin", "false"]]
class GroupsModel(object):
--
1.9.3
10 years, 4 months
[PATCH] bug fix: Properly list host partitions for Ubuntu 14.04 server
by Aline Manera
While trying to create a logical pool in a Ubuntu 14.04 server I got the
following error:
[08/Aug/2014:15:52:38] HTTP Traceback (most recent call last):
File "/home/alinefm/kimchi/src/kimchi/control/base.py", line 110, in lookup
self.info = lookup(*self.model_args)
File "/home/alinefm/kimchi/src/kimchi/model/host.py", line 274, in lookup
return disks.get_partition_details(name)
File "/home/alinefm/kimchi/src/kimchi/disks.py", line 180, in get_partition_details
dev_path = _get_dev_node_path(majmin)
File "/home/alinefm/kimchi/src/kimchi/disks.py", line 41, in _get_dev_node_path
return _get_friendly_dm_path(maj_min)
File "/home/alinefm/kimchi/src/kimchi/disks.py", line 33, in _get_friendly_dm_path
with open(dm_name) as dm_f:
IOError: [Errno 2] No such file or directory: '/sys/dev/block/253:5/dm/name'
It is because, even the maj_min starts with '253:', the file does not
exist.
So check this file exists in order to use it, otherwise get the dev path
from uevent file.
Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
---
src/kimchi/disks.py | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/src/kimchi/disks.py b/src/kimchi/disks.py
index 65d3a1d..a092c17 100644
--- a/src/kimchi/disks.py
+++ b/src/kimchi/disks.py
@@ -17,6 +17,7 @@
# 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 os.path
import re
import subprocess
@@ -27,18 +28,14 @@ from kimchi.exception import OperationFailed
from kimchi.utils import kimchi_log
-def _get_friendly_dm_path(maj_min):
- """ Returns user friendly dm path given the device number 'major:min' """
- dm_name = "/sys/dev/block/%s/dm/name" % maj_min
- with open(dm_name) as dm_f:
- content = dm_f.read().rstrip('\n')
- return "/dev/mapper/" + content
-
-
def _get_dev_node_path(maj_min):
""" Returns device node path given the device number 'major:min' """
- if maj_min.startswith('253:'):
- return _get_friendly_dm_path(maj_min)
+
+ dm_name = "/sys/dev/block/%s/dm/name" % maj_min
+ if os.path.exists(dm_name):
+ with open(dm_name) as dm_f:
+ content = dm_f.read().rstrip('\n')
+ return "/dev/mapper/" + content
uevent = "/sys/dev/block/%s/uevent" % maj_min
with open(uevent) as ueventf:
--
1.9.3
10 years, 4 months
[PATCH] bug fix: Allow user updates the cdrom from local to remote file
by Aline Manera
It depends on:
- [Kimchi-devel] [PATCH v3 1/3] Fix Key Error when editing CD ROM path
- [Kimchi-devel] [PATCH v3 2/3] Fix verification of remote ISO
- [Kimchi-devel] [PATCH v3 3/3] Add unit tests for remote-backed CD ROM updates.
And I still need to update the test cases accordingly.
Aline Manera (1):
bug fix: Allow user updates the cdrom from local to remote file
src/kimchi/model/vmstorages.py | 15 +++++++++++++++
1 file changed, 15 insertions(+)
--
1.9.3
10 years, 4 months
[PATCH v3 1/3] Fix Key Error when editing CD ROM path
by Christy Perez
lxml only accepts strings as parameters when looking
up xml elements. The port for remote ISO was being
passed in as an int, and a KeyError was thrown.
This patch just casts the ints to strings for the
lookups.
Signed-off-by: Christy Perez <christy(a)linux.vnet.ibm.com>
---
src/kimchi/model/vmstorages.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/kimchi/model/vmstorages.py b/src/kimchi/model/vmstorages.py
index b5311db..e5be17c 100644
--- a/src/kimchi/model/vmstorages.py
+++ b/src/kimchi/model/vmstorages.py
@@ -67,7 +67,7 @@ def _get_storage_xml(params, ignore_source=False):
# Working with url paths
if src_type == 'network':
output = urlparse.urlparse(params.get('path'))
- port = output.port or socket.getservbyname(output.scheme)
+ port = str(output.port or socket.getservbyname(output.scheme))
host = E.host(name=output.hostname, port=port)
source = E.source(protocol=output.scheme, name=output.path)
source.append(host)
--
1.9.3
10 years, 4 months
[PATCH] UI enhancement: Request /config/capabilities as soon as possible
by Aline Manera
/config/capabilities was requested twice for the templates tab: one
request to identify if qemu has spice support and other one to identify
if the qemu has ISO streaming support.
Those requests were made right before using the information, causing a
delay on UI until get the server response.
For example, for distant servers, while creating a new template the
"Remote ISO" option was disabled at the first time and after some time it was
enabled.
The same behavior was identified while editing a template, as the graphics
options blinked to add the spice on it.
To fix it, request /config/capabilities when loading the templates tab to have
this information prior to edit or create a new template.
Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.template_add_main.js | 27 ++++++++++++---------------
ui/js/src/kimchi.template_edit_main.js | 12 ++++--------
ui/js/src/kimchi.template_main.js | 6 ++++++
3 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/ui/js/src/kimchi.template_add_main.js b/ui/js/src/kimchi.template_add_main.js
index a24a306..a7421d7 100644
--- a/ui/js/src/kimchi.template_add_main.js
+++ b/ui/js/src/kimchi.template_add_main.js
@@ -222,22 +222,19 @@ kimchi.template_add_main = function() {
//1-2 remote iso
$('#iso-remote').css('opacity', 0.3).css('cursor', 'not-allowed');
- kimchi.getCapabilities(function(result) {
- if (result.qemu_stream == true) {
- $('#iso-remote').css('opacity', 1).css('cursor', 'pointer');
-
- $('#iso-remote').click(function() {
- kimchi.switchPage('iso-type-box', 'iso-remote-box');
- initRemoteIsoField();
- initIsoUrlField();
- kimchi.listDistros(function(isos) {
- showRemoteIsoField(isos);
- }, function() {
- });
+ if (kimchi.capabilities.qemu_stream == true) {
+ $('#iso-remote').css('opacity', 1).css('cursor', 'pointer');
+
+ $('#iso-remote').click(function() {
+ kimchi.switchPage('iso-type-box', 'iso-remote-box');
+ initRemoteIsoField();
+ initIsoUrlField();
+ kimchi.listDistros(function(isos) {
+ showRemoteIsoField(isos);
+ }, function() {
});
- }
- }, function() {
- });
+ });
+ }
$('#iso-remote-box-back').click(function() {
kimchi.switchPage('iso-remote-box', 'iso-type-box', 'right');
diff --git a/ui/js/src/kimchi.template_edit_main.js b/ui/js/src/kimchi.template_edit_main.js
index d42108c..281154a 100644
--- a/ui/js/src/kimchi.template_edit_main.js
+++ b/ui/js/src/kimchi.template_edit_main.js
@@ -39,14 +39,10 @@ kimchi.template_edit_main = function() {
}
var options = [{label: 'VNC', value: 'vnc'}];
- kimchi.getCapabilities(function(result) {
- if (result.qemu_spice == true) {
- options.push({label: 'Spice', value: 'spice'})
- }
- }, function() {
- }, function() {
- kimchi.select('template-edit-graphics-list', options);
- });
+ if (kimchi.capabilities.qemu_spice == true) {
+ options.push({label: 'Spice', value: 'spice'})
+ }
+ kimchi.select('template-edit-graphics-list', options);
var scsipools = {};
kimchi.listStoragePools(function(result) {
diff --git a/ui/js/src/kimchi.template_main.js b/ui/js/src/kimchi.template_main.js
index 3c8421d..8a783c3 100644
--- a/ui/js/src/kimchi.template_main.js
+++ b/ui/js/src/kimchi.template_main.js
@@ -83,6 +83,12 @@ kimchi.hideTitle = function() {
};
kimchi.template_main = function() {
+ kimchi.getCapabilities(function(result) {
+ kimchi.capabilities = result;
+ }, function() {
+ kimchi.capabilities = {};
+ });
+
if(kimchi.tabMode['templates'] === 'admin') {
$('.tools').attr('style','display');
$("#template-add").on("click", function(event) {
--
1.9.3
10 years, 4 months