[PATCH V2 0/6] VM supports interfaces
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
This patch set depends on this patch:
[PATCH V3 0/4] improve controller
V1 -> V2
use the "mac" to identify the iface and remove "name" parameter
$ curl -u user -H 'Accept: application/json' -H 'Content-type: application/json' \
http://localhost:800/vms/test-vm-8/ifaces/
[
{
"mac":"52:54:00:00:00:08",
"model":"virtio",
"type":"network",
"network":"default",
"name":"52:54:00:00:00:08"
}
]
$ curl -u user -H 'Accept: application/json' -H 'Content-type: application/json' \
http://localhost:800/vms/test-vm-8/ifaces/52:54:00:00:00:08
{
"mac":"52:54:00:00:00:08",
"model":"virtio",
"type":"network",
"network":"default",
"name":"52:54:00:00:00:08"
}
ShaoHe Feng (6):
Add a control.vm module
VM supports interfaces: update API
VM supports interfaces: update model
VM supports interfaces: update controller
VM supports interfaces: update mockmodel
VM supports interfaces: update testcase
Makefile.am | 1 +
configure.ac | 1 +
contrib/kimchi.spec.fedora.in | 1 +
contrib/kimchi.spec.suse.in | 1 +
docs/API.md | 46 +++++++++++++++++++++++++++++++++++++
src/kimchi/control/Makefile.am | 2 ++
src/kimchi/control/vm/Makefile.am | 32 ++++++++++++++++++++++++++
src/kimchi/control/vm/__init__.py | 30 ++++++++++++++++++++++++
src/kimchi/control/vm/ifaces.py | 48 +++++++++++++++++++++++++++++++++++++++
src/kimchi/control/vms.py | 3 +++
src/kimchi/mockmodel.py | 33 +++++++++++++++++++++++++++
src/kimchi/model.py | 36 +++++++++++++++++++++++++++++
tests/test_model.py | 19 ++++++++++++++++
tests/test_rest.py | 31 +++++++++++++++++++++++++
14 files changed, 284 insertions(+)
create mode 100644 src/kimchi/control/vm/Makefile.am
create mode 100644 src/kimchi/control/vm/__init__.py
create mode 100644 src/kimchi/control/vm/ifaces.py
--
1.8.4.2
10 years, 11 months
[PATCH] Remove 'encoding=iso-8859-1' from json.dumps()
by Mark Wu
The encoding option for json.dumps() is used to indicate the charsets
of the passed in str. Currently, we use the encoding of iso-8859-1,
but actually we don't have any data encoded in iso-8859-1. It doesn't
cause any problem because the strings in the data passed are ascii chars
or unicode. If we pass a utf-8 str, it will canse an expected result.
So we could remove the option, and after that it can accept utf-8 str too
because json.dumps use utf-8 as default encoding.
Signed-off-by: Mark Wu <wudxw(a)linux.vnet.ibm.com>
---
src/kimchi/template.py | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/kimchi/template.py b/src/kimchi/template.py
index 1f19c4a..f854657 100644
--- a/src/kimchi/template.py
+++ b/src/kimchi/template.py
@@ -84,9 +84,7 @@ def can_accept_html():
def render(resource, data):
if can_accept('application/json'):
cherrypy.response.headers['Content-Type'] = 'application/json;charset=utf-8'
- return json.dumps(data, indent=2,
- separators=(',', ':'),
- encoding='iso-8859-1')
+ return json.dumps(data, indent=2, separators=(',', ':'))
elif can_accept_html():
filename = config.get_template_path(resource)
try:
--
1.8.4.2
10 years, 11 months
[PATCH v2] Python: Do not allow lines longer than 79 characters
by Crístian Viana
This is the difference between this and the previous patchset (v1):
- Limit line length to 79 characters instead of 80, according to the PEP8
specification.
Crístian Viana (1):
Python: Do not allow lines longer than 79 characters
src/kimchi/__init__.py | 2 +-
src/kimchi/mockmodel.py | 26 ++++++++-----
src/kimchi/model.py | 99 ++++++++++++++++++++++++++++-------------------
src/kimchi/objectstore.py | 5 ++-
src/kimchi/osinfo.py | 20 ++++++----
src/kimchi/scan.py | 13 ++++---
src/kimchi/screenshot.py | 5 ++-
src/kimchi/sslcert.py | 2 +-
src/kimchi/template.py | 5 ++-
src/kimchi/utils.py | 2 +-
src/kimchi/vmtemplate.py | 12 ++++--
src/kimchi/vnc.py | 2 +-
tests/test_exception.py | 2 +-
tests/test_osinfo.py | 5 ++-
tests/test_server.py | 2 +-
tests/test_vmtemplate.py | 2 +-
16 files changed, 123 insertions(+), 81 deletions(-)
--
1.8.4.2
10 years, 11 months
[PATCH 0/4] support create/delete VMIface
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
This patch depends on "[PATCH V1 0/6] VM supports interfaces"
1. get all vms:
$ curl -u <user> -H 'Accept: application/json' -H 'Content-type: application/json' http://localhost:8000/vms
2. get all networks:
$ curl -u <user> -H 'Accept: application/json' -H 'Content-type: application/json' http://localhost:8000/networks
3. get all ifaces of a vm
$ curl -u <user> -H 'Accept: application/json' -H 'Content-type: application/json' http://localhost:8000/vms/test-vm-0/ifaces/
[
{
"mac":"52:54:00:00:00:01",
"model":"virtio",
"type":"network",
"network":"default"
}
]
4. attach a new iface to vm
$ curl -u <user> -H 'Accept: application/json' -H 'Content-type: application/json' http://localhost:8000/vms/test-vm-8/ifaces -X POST -d '
{
"type":"network",
"network":"test-network-0"
}
'
{
"mac":"52:54:00:00:00:0d",
"model":"virtio",
"type":"network",
"network":"test-network-0"
}
5. detach a iface from vm
$ curl -u <user> -H 'Accept: application/json' -H 'Content-type: application/json' http://localhost:8000/vms/test-vm-8/ifaces/52:54:00:00:00:0d -X DELETE
ShaoHe Feng (4):
support create/delete VMIface: update model
support create/delete VMIface: update mockmodel
support create/delete VMIface: update API.json
support create/delete VMIface: update testcase
src/kimchi/API.json | 21 ++++++++++++++++++++
src/kimchi/mockmodel.py | 21 ++++++++++++++++++++
src/kimchi/model.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++++-
tests/test_model.py | 22 +++++++++++++++++++++
tests/test_rest.py | 27 ++++++++++++++++++++++++++
5 files changed, 141 insertions(+), 1 deletion(-)
--
1.8.4.2
10 years, 11 months
[PATCHv9 0/8] storage servers and targets supprt
by lvroyce@linux.vnet.ibm.com
From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
v8>v9, split two types of filter params, fix nits
v7>v8, address model break, change xml construction to libxml
v6>v7, adopt lxml to parse xml, move parse params to get() to avoid duplicate code,
fix bugs when one server support multiple target type.
v5>v6, change GET param support to cover more scenario of filter collected results.
v4>v5, remove storage server list reload function,
merge storage server and targets
v3>v4, fix inconsistency between doc and json schema
v1>v3, fix racing problem, fix style.
Royce Lv (8):
Support params for GET method
Add testcase for GET param
Storage server: Update API.md
storage server: update controller.py
storage server: Update model and mockmodel
storage target: Update API.md
storage target: Update controller and json schema
storage target: Add model support
docs/API.md | 22 +++++++++++
src/kimchi/API.json | 22 +++++++++++
src/kimchi/control/base.py | 31 +++++++++++----
src/kimchi/control/storagepools.py | 4 +-
src/kimchi/control/storageserver.py | 55 ++++++++++++++++++++++++++
src/kimchi/control/storagevolumes.py | 2 +-
src/kimchi/mockmodel.py | 30 +++++++++++++++
src/kimchi/model.py | 75 ++++++++++++++++++++++++++++++++++++
src/kimchi/root.py | 2 +
tests/test_rest.py | 23 +++++++++++
10 files changed, 256 insertions(+), 10 deletions(-)
create mode 100644 src/kimchi/control/storageserver.py
--
1.8.1.2
10 years, 11 months
Process for Updating the API?
by Christy Perez
Hi guys,
I'm having trouble following the logic for adding a new resource to the
API. Could someone outline the general steps you'd need to cover? From
the patches on the mailing list, it looks like all anyone ever does is
new items to API.md -- but I'm getting a 404 not found error so I am
obviously missing something important.
Thanks!
- Christy
10 years, 11 months
[PATCH] Avoid useless libvirt error log produced by featuretests
by apporc
When running feature tests, we get bunch of error messages as below:
*** Running feature tests ***
libvirt: Domain Config error : internal error unknown protocol type 'http'
libvirt: Domain Config error : internal error unknown protocol type 'https'
libvirt: Domain Config error : internal error unknown protocol type 'ftp'
libvirt: Domain Config error : internal error unknown protocol type 'ftps'
libvirt: Domain Config error : internal error unknown protocol type 'tftp'
*** Feature tests completed ***
By replacing default error handler of libvirt, this patch succeeded to
avoid the error.
Signed-off-by: apporc <appleorchard2000(a)gmail.com>
---
src/kimchi/featuretests.py | 7 +++++++
src/kimchi/model.py | 2 --
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/featuretests.py b/src/kimchi/featuretests.py
index a5755a2..641ec5b 100644
--- a/src/kimchi/featuretests.py
+++ b/src/kimchi/featuretests.py
@@ -30,6 +30,11 @@ import threading
from kimchi import config
+def libvirt_errorhandler(userdata, error):
+ # A libvirt error handler to ignore annoying messages in stderr
+ pass
+
+
ISO_STREAM_XML = """
<domain type='kvm'>
<name>ISO_STREAMING</name>
@@ -60,6 +65,8 @@ class FeatureTests(object):
xml = ISO_STREAM_XML % {'protocol': protocol}
conn = None
try:
+ # Register the error handler to hide libvirt error in stderr
+ libvirt.registerErrorHandler(f=libvirt_errorhandler, ctx=None)
conn = libvirt.open('qemu:///system')
dom = conn.defineXML(xml)
dom.undefine()
diff --git a/src/kimchi/model.py b/src/kimchi/model.py
index 2c6d3a1..fe1ae5b 100644
--- a/src/kimchi/model.py
+++ b/src/kimchi/model.py
@@ -222,7 +222,6 @@ class Model(object):
sys.exit(1)
def _set_capabilities(self):
- kimchi_log.info("*** Running feature tests ***")
self.qemu_stream = FeatureTests.qemu_supports_iso_stream()
self.qemu_stream_dns = FeatureTests.qemu_iso_stream_dns()
@@ -231,7 +230,6 @@ class Model(object):
if FeatureTests.libvirt_supports_iso_stream(p):
self.libvirt_stream_protocols.append(p)
- kimchi_log.info("*** Feature tests completed ***")
_set_capabilities.priority = 90
def get_capabilities(self):
--
1.7.9.5
10 years, 11 months
[PATCH 00/13][WIP] Refactor model
by Aline Manera
From: Aline Manera <alinefm(a)br.ibm.com>
I am sending the first patch set to refactor model
It is not completed. I still need to do a lot of tests and so on.
But I would like to share it with you to get your suggestion.
Basically, the common code between model and mockmodel was placed into
model/<resource>.py and the specific code into model/libvirtbackend.py
and mockbackend.py
*** It still needs a lot of work ***
- Tests all functions
- Update Makefile and spec files
- Update test cases
Aline Manera (13):
refactor model: Create a separated model for task resource
refactor model: Create a separated model for debugreport resource
refactor model: Create a separated model for config resource
refactor model: Create a separated model for host resource
refactor model: Create a separated model for plugin resource
refactor model: Create a separated model for libvirt connection
refactor model: Move StoragePooldef from model to
libvirtstoragepools.py
refactor model: Create a separated model for storagepool resource
refactor model: Create a separated model for storagevolume resource
refactor model: Create a separated model for interface and network
resources
refactor model: Create a separated model for template resource
refactor model: Create a separated model for vm resource
refactor model: Update server.py and root.py to use new models
src/kimchi/control/base.py | 32 +-
src/kimchi/control/config.py | 30 +-
src/kimchi/control/debugreports.py | 18 +-
src/kimchi/control/host.py | 24 +-
src/kimchi/control/interfaces.py | 11 +-
src/kimchi/control/networks.py | 11 +-
src/kimchi/control/plugins.py | 13 +-
src/kimchi/control/storagepools.py | 32 +-
src/kimchi/control/storagevolumes.py | 24 +-
src/kimchi/control/tasks.py | 11 +-
src/kimchi/control/templates.py | 11 +-
src/kimchi/control/utils.py | 2 +-
src/kimchi/control/vms.py | 17 +-
src/kimchi/mockmodel.py | 784 --------------
src/kimchi/model.py | 1827 --------------------------------
src/kimchi/model/__init__.py | 21 +
src/kimchi/model/config.py | 52 +
src/kimchi/model/debugreports.py | 86 ++
src/kimchi/model/host.py | 49 +
src/kimchi/model/interfaces.py | 48 +
src/kimchi/model/libvirtbackend.py | 955 +++++++++++++++++
src/kimchi/model/libvirtconnection.py | 123 +++
src/kimchi/model/libvirtstoragepool.py | 225 ++++
src/kimchi/model/mockbackend.py | 338 ++++++
src/kimchi/model/networks.py | 115 ++
src/kimchi/model/plugins.py | 29 +
src/kimchi/model/storagepools.py | 86 ++
src/kimchi/model/storagevolumes.py | 95 ++
src/kimchi/model/tasks.py | 45 +
src/kimchi/model/templates.py | 89 ++
src/kimchi/model/vms.py | 164 +++
src/kimchi/networkxml.py | 6 +-
src/kimchi/root.py | 24 +-
src/kimchi/server.py | 16 +-
src/kimchi/vmtemplate.py | 18 +-
35 files changed, 2674 insertions(+), 2757 deletions(-)
delete mode 100644 src/kimchi/mockmodel.py
delete mode 100644 src/kimchi/model.py
create mode 100644 src/kimchi/model/__init__.py
create mode 100644 src/kimchi/model/config.py
create mode 100644 src/kimchi/model/debugreports.py
create mode 100644 src/kimchi/model/host.py
create mode 100644 src/kimchi/model/interfaces.py
create mode 100644 src/kimchi/model/libvirtbackend.py
create mode 100644 src/kimchi/model/libvirtconnection.py
create mode 100644 src/kimchi/model/libvirtstoragepool.py
create mode 100644 src/kimchi/model/mockbackend.py
create mode 100644 src/kimchi/model/networks.py
create mode 100644 src/kimchi/model/plugins.py
create mode 100644 src/kimchi/model/storagepools.py
create mode 100644 src/kimchi/model/storagevolumes.py
create mode 100644 src/kimchi/model/tasks.py
create mode 100644 src/kimchi/model/templates.py
create mode 100644 src/kimchi/model/vms.py
--
1.7.10.4
10 years, 11 months
[RFC] Authorization enhancement
by Shu Ming
Background
In Kimchi, now we have a basic authentication model based on PAM. In
this model, all the authenticated user get all of the privileges to
access the resources in Kimchi. However, it is too simple to cause some
security holes and classifying the user with different roles is a way to
address the holes. Roles with very fine grained privileges need huge
effort and time, so here we are trying to split the effort with several
steps. And we will discuss the first step of the effort in the below
which can be achieved in a certain time bound and reserve the forward
compatibility for future extensions.
First step of the effort
In this step, the goal is to authorize the user's action on a resource
by roles. The user action here is applied by the REST API exposed by
Kimchi. Every action on Kimchi resources should be checked based on the
user's role. In this step, we will not try to have roles in a very fine
granularity. Naturally, three permanent roles will be created by
default, the system administrator role, the infrastructure role and the
user role.
* The system administrator get the privileges to manage the roles for
the other users including assigning a role to a user, removing the role
from a user &etc. A default user "admink" will be created by default
with a system administrator role assigned to it. And the role of the
user "admink" can not be modified.
* The infrastructure role get the privileges to manage the physical
resources and virtual resources including network's creation and
deletion, create or delete storage storage pools or storage volumes'
creation and deletion, adding a user to the user list of storage storage
pool &etc.
* The user role get the privileges to apply action on VMs including VMs'
starting and stopping, viewing the VM console by VNC &etc.
* Some of the change can be enhanced on the existing REST API like
"DELETE /storagepools/poo1/vo1". But we need create new REST APIs for
actions like adding a role for a user like " PUT /users/user1 {role:
"user role"}"
* Database is needed to store the user information including roles and
resource user list
Beside the privileges inherited from the user's role, Kimchi will check
if a user get the permission to access a resource based on a tuple. The
tuple is composed from both the privileges of the user and the user list
of the resource. An example is, if a user try ti delete a storage volume
from the stroage pool, Kimchi will check if it is assigned a
infrastructure role and if it is in the user list of the storage pool.
Next step of the effort
* The roles are defined in a very fine granularity containing the
privileges precisely matching what the system administrator expects.
* Existing roles can by customized by the system administrator from a
set of previleges. The set of privileges should be pre-defined and
hierarchy.
* The system administrator can create new roles with customized privileges
10 years, 11 months
[PATCH v3 0/2] Change all CSS files indentation to 4 spaces
by Crístian Viana
This is the diff between this and the previous patchset (v2):
- Add a new patch (1) to split lines longer than 80 characters and align
the split lines consistently.
Crístian Viana (2):
CSS: Do not allow lines longer than 80 characters
CSS: Change all CSS files indentation to 4 spaces
ui/css/theme-default/button.css | 167 ++++++++++++++++++++----------
ui/css/theme-default/error.css | 15 ++-
ui/css/theme-default/grid.css | 36 ++++---
ui/css/theme-default/host.css | 6 +-
ui/css/theme-default/jquery-ui.custom.css | 27 +++--
ui/css/theme-default/line-chart.css | 6 +-
ui/css/theme-default/list.css | 15 ++-
ui/css/theme-default/nav-tree.css | 12 ++-
ui/css/theme-default/network.css | 12 ++-
ui/css/theme-default/popover.css | 39 ++++---
ui/css/theme-default/report-add.css | 3 +-
ui/css/theme-default/reset.css | 8 +-
ui/css/theme-default/storage.css | 18 ++--
ui/css/theme-default/template-edit.css | 9 +-
ui/css/theme-default/template_add.css | 20 ++--
ui/css/theme-default/template_list.css | 24 +++--
ui/css/theme-default/toolbar.css | 6 +-
ui/css/theme-default/topbar.css | 29 ++++--
ui/css/theme-default/window.css | 3 +-
19 files changed, 296 insertions(+), 159 deletions(-)
--
1.8.4.2
10 years, 11 months