[PATCH V2] pass params to create method of all Collections.
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
We can pass params as an argument to create method, do not need call
parse_request in every create method.
create means the HTTP POST method, and POST requires body.
So every create needs params parsed from body.
But we do not need to parse params in every create.
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
src/kimchi/control/base.py | 8 +++-----
src/kimchi/control/storagepools.py | 5 ++---
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/kimchi/control/base.py b/src/kimchi/control/base.py
index 5c8ee82..6ce8113 100644
--- a/src/kimchi/control/base.py
+++ b/src/kimchi/control/base.py
@@ -196,14 +196,13 @@ class Collection(object):
self.resource_args = []
self.model_args = []
- def create(self, *args):
+ def create(self, params, *args):
try:
create = getattr(self.model, model_fn(self, 'create'))
except AttributeError:
error = 'Create is not allowed for %s' % get_class_name(self)
raise cherrypy.HTTPError(405, error)
- params = parse_request()
validate_params(params, self, 'create')
args = self.model_args + [params]
name = create(*args)
@@ -273,7 +272,7 @@ class Collection(object):
elif method == 'POST':
try:
- return self.create(*args)
+ return self.create(parse_request(), *args)
except MissingParameter, param:
error = "Missing parameter: '%s'" % param
raise cherrypy.HTTPError(400, error)
@@ -296,14 +295,13 @@ class AsyncCollection(Collection):
def __init__(self, model):
super(AsyncCollection, self).__init__(model)
- def create(self, *args):
+ def create(self, params, *args):
try:
create = getattr(self.model, model_fn(self, 'create'))
except AttributeError:
error = 'Create is not allowed for %s' % get_class_name(self)
raise cherrypy.HTTPError(405, error)
- params = parse_request()
args = self.model_args + [params]
task = create(*args)
cherrypy.response.status = 202
diff --git a/src/kimchi/control/storagepools.py b/src/kimchi/control/storagepools.py
index af10acd..ea19609 100644
--- a/src/kimchi/control/storagepools.py
+++ b/src/kimchi/control/storagepools.py
@@ -28,7 +28,7 @@ import cherrypy
from kimchi.control.base import Collection, Resource
from kimchi.control.storagevolumes import IsoVolumes, StorageVolumes
-from kimchi.control.utils import get_class_name, model_fn, parse_request
+from kimchi.control.utils import get_class_name, model_fn
from kimchi.control.utils import validate_params
from kimchi.model.storagepools import ISO_POOL_NAME
from kimchi.control.utils import UrlSubNode
@@ -42,14 +42,13 @@ class StoragePools(Collection):
isos = IsoPool(model)
setattr(self, ISO_POOL_NAME, isos)
- def create(self, *args):
+ def create(self, params, *args):
try:
create = getattr(self.model, model_fn(self, 'create'))
except AttributeError:
error = 'Create is not allowed for %s' % get_class_name(self)
raise cherrypy.HTTPError(405, error)
- params = parse_request()
validate_params(params, self, 'create')
args = self.model_args + [params]
name = create(*args)
--
1.8.4.2
10 years, 10 months
[PATCH] Fix path of plugins dir
by Mark Wu
Fix the wrong path of plugins dir introduced in commit 44be0d2d.
Signed-off-by: Mark Wu <wudxw(a)linux.vnet.ibm.com>
---
src/kimchi/config.py.in | 2 +-
tests/test_config.py.in | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/config.py.in b/src/kimchi/config.py.in
index 9f73d65..32d61c6 100644
--- a/src/kimchi/config.py.in
+++ b/src/kimchi/config.py.in
@@ -85,7 +85,7 @@ class Paths(object):
self.log_dir = '@localstatedir@/log/kimchi'
self.conf_dir = '@sysconfdir@/kimchi'
self.src_dir = '@kimchidir@'
- self.plugins_dir = '@kimchidir@'
+ self.plugins_dir = '@kimchidir@/plugins'
else:
self.state_dir = self.add_prefix('data')
self.log_dir = self.add_prefix('log')
diff --git a/tests/test_config.py.in b/tests/test_config.py.in
index 19a6cfe..3b9ebdc 100644
--- a/tests/test_config.py.in
+++ b/tests/test_config.py.in
@@ -41,7 +41,7 @@ class ConfigTests(unittest.TestCase):
self.assertInstalledPath(paths.log_dir, '/var/log/kimchi')
self.assertInstalledPath(paths.conf_dir, '/etc/kimchi')
self.assertInstalledPath(paths.src_dir, '@kimchidir@')
- self.assertInstalledPath(paths.plugins_dir, '@kimchidir@')
+ self.assertInstalledPath(paths.plugins_dir, '@kimchidir@/plugins')
self.assertInstalledPath(paths.ui_dir, '@pkgdatadir@/ui')
self.assertInstalledPath(paths.mo_dir, '@pkgdatadir@/mo')
--
1.8.4.2
10 years, 10 months
[PATCH] Fix wrong "Failed to list guest" message
by Rodrigo Trujillo
The module vmscreenshot is preventing this error using Image.load
function inside a try/except. However right after the except block,
the code calls Image.thumbnail() function, which calls the same
load() function internally. Then the error could happen again.
This patch fixes this possible problem.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo(a)linux.vnet.ibm.com>
---
src/kimchi/screenshot.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/kimchi/screenshot.py b/src/kimchi/screenshot.py
index 5cfea96..91c14a6 100644
--- a/src/kimchi/screenshot.py
+++ b/src/kimchi/screenshot.py
@@ -177,10 +177,9 @@ class VMScreenshot(object):
try:
# Prevent Image lib from lazy load,
# work around pic truncate validation in thumbnail generation
- im.load()
+ im.thumbnail(self.THUMBNAIL_SIZE)
except Exception as e:
kimchi_log.warning("Image load with warning: %s." % e)
- im.thumbnail(self.THUMBNAIL_SIZE)
im.save(thumbnail, "PNG")
self.info['thumbnail'] = thumbnail
--
1.8.5.3
10 years, 10 months
Re: [Kimchi-devel] [PATCH] : Dir Storagepool path: Git hub issue:316
by Crístian Viana
Am 12-02-2014 13:12, schrieb Pradeep K Surisetty:
> For ex: If user try to create directory "/home/sp/&", it never
> proceeds, Since this directory cannont be created. So i feel we need
> to have path checker.
Yes, that directory can be created. And also a storage pool using that
directory.
Take a look at the output below.
And even if the character '&' was not allowed we should block that
character only. Checking for a wrong '&' is very different than allowing
a few characters (like [A-Za-z0-9-_\.]).
vianac@kitkat ~ $ mkdir -v ~/\&
mkdir: created directory '/home/vianac/&'
vianac@kitkat ~ $ cat pool.xml
<pool type="dir">
<name>test</name>
<target>
<path>/home/vianac/&/</path>
</target>
</pool>
vianac@kitkat ~ $ sudo virsh pool-list
Name State Autostart
-----------------------------------------
default active yes
home active yes
vianac@kitkat ~ $ sudo virsh pool-create pool.xml
Pool test created from pool.xml
vianac@kitkat ~ $ sudo virsh pool-list
Name State Autostart
-----------------------------------------
default active yes
home active yes
test active no
vianac@kitkat ~ $ sudo virsh pool-dumpxml test
<pool type='dir'>
<name>test</name>
<uuid>176b8579-002d-4ed9-95aa-5875840cc56b</uuid>
<capacity unit='bytes'>253606490112</capacity>
<allocation unit='bytes'>80020393984</allocation>
<available unit='bytes'>173586096128</available>
<source>
</source>
<target>
<path>/home/vianac/&</path>
<permissions>
<mode>0755</mode>
<owner>-1</owner>
<group>-1</group>
</permissions>
</target>
</pool>
10 years, 10 months
[PATCH 0/5 V3] Host's software update support
by Paulo Vital
This patch set provides support to host's software update operations.
To test the backend (ONLY mockmodel) execute the following commands:
$ cd tests
$ sudo ./run_tests.sh test_mockmodel.MockModelTests.test_packages_update
To test the REST API, execute the following commands (all them are agnostic
of the host's distro):
1) Get list of all packages to be updated in the host:
$ curl -H 'Content-type: application/json' -H 'Accept: application/json' http://localhost:8000/host/packagesupdate/ -X GET
2) Update the host system:
$ curl -H 'Content-type: application/json' -H 'Accept: application/json' http://localhost:8000/host/packagesupdate/update -X POST -d ''
V2 -> V3:
* Fixed indent and wrong bullets on docs/API.md
* Changed to use Collection and Resource
* Removed unnecessary 'exposed'
* PEP8 compatibility on mockmodel.py
* Removed debug prints from swupdate.py
* Fixed indent in swupdate.py
* Usage of utils.run_command() to execute Zypper update
* Updated swupdate.py and mockmodel.py to make consistent with docs/API.md
* Usage of Task element in mockmodel.py
* Created test case in test_mockmodel.py
V1 -> V2:
* rebased to use new model framework
* added SLES as Zypper supported distro
* PEP8 compatibility
* changed import sentences
* use of run_command() from utils.py to execute shell commands
* usage of Task element to return update status
V1:
At this point, an agnostic class is providing support to backend and
REST API operations. In addition, YUM (for RHEL and Fedora), APT (for
Debian and Ubuntu) and ZYPPER (for OpenSuse) specific classes are provided
to support the operation os each software update system.
There's no test case to check backend once the software update information
is volatile to each system/box.
Paulo Vital (5):
Host's software update: Update API.md
Host's software update: Update REST API
Host's software update: Update backend.
Host's software update: Update Makefile
Host's software update: Update test cases.
Makefile.am | 1 +
docs/API.md | 30 +++++
src/kimchi/Makefile.am | 1 +
src/kimchi/control/host.py | 17 +++
src/kimchi/mockmodel.py | 45 ++++++++
src/kimchi/model/host.py | 28 ++++-
src/kimchi/swupdate.py | 269 +++++++++++++++++++++++++++++++++++++++++++++
tests/test_mockmodel.py | 11 ++
8 files changed, 401 insertions(+), 1 deletion(-)
create mode 100644 src/kimchi/swupdate.py
--
1.8.3.1
10 years, 10 months
[PATCH V4 0/5] Storagepool SCSI/FC
by Rodrigo Trujillo
V4:
- Implements mockmodel and tests
- Fix UI
- Fix other minor issues
V3:
- Changed API to only receive the scsi host name when creating new pool
- Changed API to require LUN when creating new VM on SCSI pool
- Created feature test and removed libvirt test function
- Rebased with new model structure
- Added error function handlers to UIs
- Fixed LUN selection window
V2:
- Implements Fibre Channel devices discover in the host
- Allow vms_create receive a volume to create the disk (if pool is SCSI)
- Create basic UI to select SCSI Host when creating SCSI FC pool
- Draft of UI to select LUN to create new VM when template has a SCSI
pool configured. (Need help of UI guys here!)
Rodrigo Trujillo (5):
Storagepool SCSI/FC: Implement node devices API backend
Storagepool SCSI/FC: Backend implementation
Storagepool SCSI/FC: Implement UI for FC scsi_host pool
Storagepool SCSI/FC: Modifies UI flow to select a LUN to new VM
Storagepool SCSI/FC: Modifies mockmodel and implements tests for FC
pool
docs/API.md | 5 ++-
src/kimchi/API.json | 14 +++++-
src/kimchi/control/host.py | 16 +++++++
src/kimchi/featuretests.py | 27 ++++++++++++
src/kimchi/mockmodel.py | 53 ++++++++++++++++++++---
src/kimchi/model/config.py | 5 ++-
src/kimchi/model/host.py | 54 +++++++++++++++++++++++
src/kimchi/model/libvirtstoragepool.py | 48 ++++++++++++++++++++-
src/kimchi/model/storagepools.py | 22 ++++++++--
src/kimchi/model/templates.py | 5 +++
src/kimchi/model/vms.py | 25 ++++++++++-
src/kimchi/vmtemplate.py | 31 +++++++++++++-
tests/test_rest.py | 47 ++++++++++++++++++++
tests/test_storagepool.py | 21 +++++++++
ui/js/src/kimchi.api.js | 24 +++++++++++
ui/js/src/kimchi.guest_add_main.js | 73 ++++++++++++++++++++++++++++++--
ui/js/src/kimchi.storagepool_add_main.js | 46 +++++++++++++++++++-
ui/pages/i18n.html.tmpl | 5 +++
ui/pages/storagepool-add.html.tmpl | 12 ++++++
19 files changed, 510 insertions(+), 23 deletions(-)
--
1.8.5.3
10 years, 10 months
[PATCH] pass params to create method of all Collections.
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
We can pass params as an argument to create method, do not need call
parse_request in every create method.
create means the HTTP POST method, and POST require body.
So very create needs params parsed from body.
But we do not call parsed params in every create.
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
src/kimchi/control/base.py | 8 +++-----
src/kimchi/control/storagepools.py | 5 ++---
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/kimchi/control/base.py b/src/kimchi/control/base.py
index 5c8ee82..6ce8113 100644
--- a/src/kimchi/control/base.py
+++ b/src/kimchi/control/base.py
@@ -196,14 +196,13 @@ class Collection(object):
self.resource_args = []
self.model_args = []
- def create(self, *args):
+ def create(self, params, *args):
try:
create = getattr(self.model, model_fn(self, 'create'))
except AttributeError:
error = 'Create is not allowed for %s' % get_class_name(self)
raise cherrypy.HTTPError(405, error)
- params = parse_request()
validate_params(params, self, 'create')
args = self.model_args + [params]
name = create(*args)
@@ -273,7 +272,7 @@ class Collection(object):
elif method == 'POST':
try:
- return self.create(*args)
+ return self.create(parse_request(), *args)
except MissingParameter, param:
error = "Missing parameter: '%s'" % param
raise cherrypy.HTTPError(400, error)
@@ -296,14 +295,13 @@ class AsyncCollection(Collection):
def __init__(self, model):
super(AsyncCollection, self).__init__(model)
- def create(self, *args):
+ def create(self, params, *args):
try:
create = getattr(self.model, model_fn(self, 'create'))
except AttributeError:
error = 'Create is not allowed for %s' % get_class_name(self)
raise cherrypy.HTTPError(405, error)
- params = parse_request()
args = self.model_args + [params]
task = create(*args)
cherrypy.response.status = 202
diff --git a/src/kimchi/control/storagepools.py b/src/kimchi/control/storagepools.py
index af10acd..ea19609 100644
--- a/src/kimchi/control/storagepools.py
+++ b/src/kimchi/control/storagepools.py
@@ -28,7 +28,7 @@ import cherrypy
from kimchi.control.base import Collection, Resource
from kimchi.control.storagevolumes import IsoVolumes, StorageVolumes
-from kimchi.control.utils import get_class_name, model_fn, parse_request
+from kimchi.control.utils import get_class_name, model_fn
from kimchi.control.utils import validate_params
from kimchi.model.storagepools import ISO_POOL_NAME
from kimchi.control.utils import UrlSubNode
@@ -42,14 +42,13 @@ class StoragePools(Collection):
isos = IsoPool(model)
setattr(self, ISO_POOL_NAME, isos)
- def create(self, *args):
+ def create(self, params, *args):
try:
create = getattr(self.model, model_fn(self, 'create'))
except AttributeError:
error = 'Create is not allowed for %s' % get_class_name(self)
raise cherrypy.HTTPError(405, error)
- params = parse_request()
validate_params(params, self, 'create')
args = self.model_args + [params]
name = create(*args)
--
1.8.4.2
10 years, 10 months
Fwd: [project-kimchi] NFS img permission problem
by Royce Lv
Guys,
When testing with kimchi nfs feature, I filed two issues related to
nfs image permission problem:
1. volume creation failure: Because of storage pool permission is
not configured to make write
permission.(https://github.com/kimchi-project/kimchi/issues/261)
2. vm with volume cannot be started: Root users are mapped to
nobody, so img it created cannot be accessed by libvirt-qemu(on ubuntu)
user.(https://github.com/kimchi-project/kimchi/issues/267)
After discussed with Mark Wu, we would like to propose the
following to resolve these two problem:
1. To allow creation: export with all_squash(gid = kimchi_guid) and
group allow write permission. Also with planned nfs-pool prevalidation
(a timeout try mount in a process), we can check if the gid and
permission is right. This will save us from future trouble.
2. To allow qemu process(started by libvirt) to access img, we add
uid ('qemu' under fedora and 'libvirt-qemu' under ubuntu) which running
qemu process to 'kimchi' group to allow the write access of the img.
I am also investigating other possibilities like using storage pool
permissions and so on.
Welcome thoughts on it!
--
project-kimchi mailing list <project-kimchi(a)googlegroups.com>
https://groups.google.com/forum/#!forum/project-kimchi
---
You received this message because you are subscribed to the Google Groups "project-kimchi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-kimchi+unsubscribe(a)googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
10 years, 10 months
[PATCH] bug fix: return empty dict when the request body is empty
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
in test mode, you can user curl or HttpRequester to try as follow.
$ curl -u <user> -H 'Accept: application/json' -H 'Content-type:
application/json' http://localhost:8000/templates/test-template-4 -X
PUT -d ''
kimchi will throw HTTPError: (400, 'Unable to parse JSON request')
Now remove the check Content-Length in request headers.
No Content-Length in request headers means this request without body.
GET and DELETE methods allow a request without body.
But PUT and POST methods require body in request.
After remove this check, new check for the length of body.
And also now we have decide not to pass parameters by body for GET method.
That means GET will not call parse_request.
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
src/kimchi/control/utils.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/kimchi/control/utils.py b/src/kimchi/control/utils.py
index 9c6878b..21a6ce8 100644
--- a/src/kimchi/control/utils.py
+++ b/src/kimchi/control/utils.py
@@ -69,13 +69,14 @@ def mime_in_header(header, mime):
def parse_request():
- if 'Content-Length' not in cherrypy.request.headers:
- return {}
rawbody = cherrypy.request.body.read()
if mime_in_header('Content-Type', 'application/json'):
try:
- return json.loads(rawbody)
+ if cherrypy.request.body.length:
+ return json.loads(rawbody)
+ else:
+ return {}
except ValueError:
raise cherrypy.HTTPError(400, "Unable to parse JSON request")
else:
--
1.8.4.2
10 years, 10 months
[PATCH v2 0/4] Add disks to LVM pool backend
by Daniel Barboza
From: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
Changes in v2:
- added API.json parameter verification
- added disk verification
- added mockmodel improvements
- other improvements based on feedback
This patch series implements the backend changes to allow disks/partitions to
be added to an existing LVM (logical) pool.
The process, as discussed previously in kimchi mailing list, is to use
'vgextend' and 'virsh pool-refresh' commands to add the disks and then
refresh the pool.
It is also worth noticing that the existing data from the disks/partitions
being added to the pool will be erased/lost.
To test the patch:
$ curl -u root -H 'Content-type: application/json' -H 'Accept: application/json' -X PUT localhost:8000/storagepools/<pool_name> -d '{"disks": ["/path/to/disk1", "/path/to/disk2"] }'
Tip: to test the patch over and over with the same pool and disks
without the need to destroy/create the pool:
$ vgreduce <pool_name> disk1 disk2
$ virsh pool-refresh <pool_name>
The above commands will restore the logical pool to its previous state,
before adding disks 'disk1' and 'disk2'
Daniel Henrique Barboza (4):
Add disks to LVM pool: control and model changes
Add disks to LVM pool: API.md changes
Add disks to LVM pool: mockmodel changes
Add disks to LVM pool: API.json changes
docs/API.md | 5 ++++-
src/kimchi/API.json | 16 +++++++++++++
src/kimchi/control/storagepools.py | 2 +-
src/kimchi/mockmodel.py | 36 +++++++++++++++++++++++------
src/kimchi/model/storagepools.py | 46 +++++++++++++++++++++++++++++++-------
5 files changed, 88 insertions(+), 17 deletions(-)
--
1.8.3.1
10 years, 10 months