[PATCH] Setup VM's input and output template for Power systems.
by Paulo Vital
Setup the bus for keyboard and mouse to 'usb' by default and prevent the
sound configuration to be added for new Power guests.
Signed-off-by: Paulo Vital <pvital(a)linux.vnet.ibm.com>
---
src/kimchi/osinfo.py | 13 ++++++++-----
src/kimchi/vmtemplate.py | 23 ++++++++++++++++++++++-
2 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/src/kimchi/osinfo.py b/src/kimchi/osinfo.py
index f92db3d..eff8070 100644
--- a/src/kimchi/osinfo.py
+++ b/src/kimchi/osinfo.py
@@ -32,21 +32,24 @@ SUPPORTED_ARCHS = {'x86': ('i386', 'x86_64'), 'power': ('ppc', 'ppc64')}
common_spec = {'cpus': 1, 'cpu_cores': 1, 'cpu_threads': 1, 'memory': 1024,
'disks': [{'index': 0, 'size': 10}], 'cdrom_bus': 'ide',
- 'cdrom_index': 2}
+ 'cdrom_index': 2, 'mouse_bus': 'ps2'}
modern_spec = dict(common_spec, disk_bus='virtio', nic_model='virtio')
template_specs = {'x86': {'old': dict(common_spec, disk_bus='ide',
- nic_model='e1000'),
+ nic_model='e1000', sound_model= 'ich6'),
'modern': dict(common_spec, disk_bus='virtio',
- nic_model='virtio')},
+ nic_model='virtio',
+ sound_model= 'ich6')},
'power': {'old': dict(common_spec, disk_bus='scsi',
- nic_model='rtl8139', cdrom_bus='scsi'),
+ nic_model='rtl8139', cdrom_bus='scsi',
+ kbd_bus='usb', mouse_bus='usb'),
'modern': dict(common_spec, disk_bus='virtio',
nic_model='virtio',
- cdrom_bus='scsi')}}
+ cdrom_bus='scsi', kbd_bus='usb',
+ mouse_bus='usb')}}
modern_version_bases = {'debian': '6.0', 'ubuntu': '7.10', 'opensuse': '10.3',
diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
index 999473c..de52f40 100644
--- a/src/kimchi/vmtemplate.py
+++ b/src/kimchi/vmtemplate.py
@@ -241,11 +241,32 @@ class VMTemplate(object):
networks += network % net_info
return networks
+ def _get_input_output_xml(self):
+ sound = """
+ <sound model='%(sound_model)s' />
+ """
+ mouse = """
+ <input type='mouse' bus='%(mouse_bus)s'/>
+ """
+ keyboard = """
+ <input type='kbd' bus='%(kbd_bus)s'> </input>
+ """
+
+ input_output = ""
+ if 'mouse_bus' in self.info.keys():
+ input_output += mouse % self.info
+ if 'kbd_bus' in self.info.keys():
+ input_output += keyboard % self.info
+ if 'sound_model' in self.info.keys():
+ input_output += sound % self.info
+ return input_output
+
def to_vm_xml(self, vm_name, vm_uuid, **kwargs):
params = dict(self.info)
params['name'] = vm_name
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'] = ''
@@ -294,7 +315,7 @@ class VMTemplate(object):
%(cdroms)s
%(networks)s
%(graphics)s
- <sound model='ich6' />
+ %(input_output)s
<memballoon model='virtio' />
</devices>
</domain>
--
1.8.3.1
10 years, 10 months
[PATCH] Fix exception for model test
by lvroyce@linux.vnet.ibm.com
From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
We don't start server in model test so cherrypy.request.app is None
and exception translation cannot be used.
Just do translation when server started.
Signed-off-by: ShaoHe Feng<shaohef(a)linux.vnet.ibm.com>
Signed-off-by: Royce Lv<lvroyce(a)linux.vnet.ibm.com>
---
src/kimchi/exception.py | 18 ++++++++++++++----
src/kimchi/i18n.py | 2 +-
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/kimchi/exception.py b/src/kimchi/exception.py
index 952e243..2d974a8 100644
--- a/src/kimchi/exception.py
+++ b/src/kimchi/exception.py
@@ -24,16 +24,28 @@ import cherrypy
import gettext
+from kimchi.i18n import messages as _messages
from kimchi.template import get_lang, validate_language
class KimchiException(Exception):
def __init__(self, code='', args={}):
+ self.code = code
+
+ if cherrypy.request.app:
+ msg = self._get_translation(args)
+ else:
+ msg = _messages.get(code, code) % args
+
+ pattern = "%s: %s" % (code, msg)
+ Exception.__init__(self, pattern)
+
+ def _get_translation(self, args):
lang = validate_language(get_lang())
paths = cherrypy.request.app.root.paths
domain = cherrypy.request.app.root.domain
messages = cherrypy.request.app.root.messages
- text = messages.get(code, code)
+ text = messages.get(self.code, self.code)
try:
translation = gettext.translation(domain, paths.mo_dir, [lang])
@@ -44,9 +56,7 @@ class KimchiException(Exception):
if not isinstance(value, unicode):
args[key] = unicode(value, 'utf-8')
- msg = unicode(translation.gettext(text), 'utf-8') % args
- pattern = "%s: %s" % (code, msg)
- Exception.__init__(self, pattern)
+ return unicode(translation.gettext(text), 'utf-8') % args
class NotFoundError(KimchiException):
diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index fd61d4e..e9c003e 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -57,7 +57,7 @@ messages = {
"KCHISO0006E": _("Unexpected volume type for primary volume in ISO %(filename)s"),
"KCHISO0007E": _("Bad format while reading volume descriptor in ISO %(filename)s"),
- "KCHVM0001E": _("Virtual machine $(name)s already exists"),
+ "KCHVM0001E": _("Virtual machine %(name)s already exists"),
"KCHVM0002E": _("Virtual machine %(name)s does not exist"),
"KCHVM0003E": _("Unable to rename virtual machine %(name)s. The name %(new_name)s already exists or it is not powered off."),
"KCHVM0004E": _("Unable to retrieve screenshot for stopped virtual machine %(name)s"),
--
1.8.1.2
10 years, 10 months
[PATCH V2] Implement integrity verification: don't disable network used by guest
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
do not allow to delete a network when the network is used by more than
one guest.
do not allow to deactivate a network when the network is used by more
than one guest with running state.
add a filter for _get_vms_attach_to_a_network
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
src/kimchi/i18n.py | 2 ++
src/kimchi/model/networks.py | 13 +++++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index fd61d4e..03b232d 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -163,6 +163,8 @@ messages = {
"KCHNET0014E": _("Network interface must be a string"),
"KCHNET0015E": _("Network VLAN ID must be an integer between 1 and 4094"),
"KCHNET0016E": _("Specify name and type to create a Network"),
+ "KCHNET0017E": _("Unable to delete network %(name)s. There are still some VMs linked to this network."),
+ "KCHNET0018E": _("Unable to deactivate network %(name)s. There are some VMs running linked to this network."),
"KCHDR0001E": _("Debug report %(name)s does not exist"),
"KCHDR0002E": _("Debug report tool not found in system"),
diff --git a/src/kimchi/model/networks.py b/src/kimchi/model/networks.py
index 05105df..9a88fe9 100644
--- a/src/kimchi/model/networks.py
+++ b/src/kimchi/model/networks.py
@@ -188,12 +188,17 @@ class NetworkModel(object):
'autostart': network.autostart() == 1,
'state': network.isActive() and "active" or "inactive"}
- def _get_vms_attach_to_a_network(self, network):
+ def _get_vms_attach_to_a_network(self, network, filter="all"):
+ DOM_STATE_MAP = {'nostate': 0, 'running': 1, 'blocked': 2,
+ 'paused':3, 'shutdown': 4, 'shutoff': 5,
+ 'crashed': 6}
+ state = DOM_STATE_MAP.get(filter)
vms = []
conn = self.conn.get()
for dom in conn.listAllDomains(0):
networks = self._vm_get_networks(dom)
- if network in networks:
+ if network in networks and (state == None or
+ state == dom.state()[0]):
vms.append(dom.name())
return vms
@@ -208,12 +213,16 @@ class NetworkModel(object):
def deactivate(self, name):
network = self._get_network(name)
+ if self._get_vms_attach_to_a_network(name, "running"):
+ raise InvalidOperation("KCHNET0018E", {'name': name})
network.destroy()
def delete(self, name):
network = self._get_network(name)
if network.isActive():
raise InvalidOperation("KCHNET0005E", {'name': name})
+ if self._get_vms_attach_to_a_network(name):
+ raise InvalidOperation("KCHNET0017E", {'name': name})
self._remove_vlan_tagged_bridge(network)
network.undefine()
--
1.8.4.2
10 years, 10 months
[WIP 0/4] Authorization utililty modules
by Shu Ming
The following patches provide modules to manage groups for the users
Also pam modules are provided to check if a user is in one specific
group
Shu Ming (4):
A module to manage the groups of the users
A module to do pam account managment
An example to demo how pam_members.so is used
Configuration files for pam services
src/kimchi/pam_members.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++
src/kimchi/pamauth_acc.py | 51 +++++++++++++++++++++++
src/kimchi/rolegroups.py | 36 ++++++++++++++++
src/kimchi/superadmin | 5 +++
src/kimchi/vmadmin | 5 +++
src/kimchi/vmuser | 5 +++
6 files changed, 205 insertions(+)
create mode 100644 src/kimchi/pam_members.c
create mode 100644 src/kimchi/pamauth_acc.py
create mode 100644 src/kimchi/rolegroups.py
create mode 100644 src/kimchi/superadmin
create mode 100644 src/kimchi/vmadmin
create mode 100644 src/kimchi/vmuser
--
1.8.1.4
10 years, 10 months
[V1 0/2] Fibre Channel SCSI Storage Pool UI
by huoyuxin@linux.vnet.ibm.com
From: Yu Xin Huo <huoyuxin(a)linux.vnet.ibm.com>
Yu Xin Huo (2):
Fibre Channel SCSI Storage Pool UI
Add translation for FC SCSI Storage Pool
po/en_US.po | 6 +++++
po/kimchi.pot | 6 +++++
po/pt_BR.po | 6 +++++
po/zh_CN.po | 6 +++++
ui/js/src/kimchi.api.js | 14 +++++++++++++
ui/js/src/kimchi.storagepool_add_main.js | 31 ++++++++++++++++++++++++++++-
ui/pages/i18n.html.tmpl | 1 +
ui/pages/storagepool-add.html.tmpl | 12 +++++++++++
8 files changed, 80 insertions(+), 2 deletions(-)
10 years, 10 months
[PATCH V2] Fix Software Update rebase issue.
by Paulo Vital
V1 -> V2:
SoftwareUpdate() executes an exception if there's no pkg manager in the host, so
I changed previous patch to use try/except while instantiating PackagesUpdateModel()
V1:
During the last merge/rebase to apply Software Update feature to the code,
an important line was removed. This fix is adding it again and enabling the
code to list all host's package updates.
Signed-off-by: Paulo Vital <pvital(a)linux.vnet.ibm.com>
Signed-off-by: Aline Manera <alinefm(a)br.ibm.com>
---
src/kimchi/model/host.py | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/kimchi/model/host.py b/src/kimchi/model/host.py
index 68028b2..ef40879 100644
--- a/src/kimchi/model/host.py
+++ b/src/kimchi/model/host.py
@@ -262,21 +262,25 @@ class DeviceModel(object):
class PackagesUpdateModel(object):
def __init__(self, **kargs):
-
+ try:
+ self.host_swupdate = SoftwareUpdate()
+ except:
+ self.host_swupdate = None
self.objstore = kargs['objstore']
self.task = TaskModel(**kargs)
def get_list(self):
+ if self.host_swupdate is None:
+ raise OperationFailed('KCHPKGUPD0004E')
+
return self.host_swupdate.getUpdates()
def update(self, **kargs):
- try:
- swupdate = SoftwareUpdate()
- except Exception:
+ if self.host_swupdate is None:
raise OperationFailed('KCHPKGUPD0004E')
try:
- pkgs = swupdate.getNumOfUpdates()
+ pkgs = self.host_swupdate.getNumOfUpdates()
except OperationFailed, e:
raise e
@@ -284,7 +288,7 @@ class PackagesUpdateModel(object):
raise OperationFailed('KCHPKGUPD0001E')
kimchi_log.debug('Host is going to be updated.')
- taskid = add_task('', swupdate.doUpdate, self.objstore, None)
+ taskid = add_task('', self.host_swupdate.doUpdate, self.objstore, None)
return self.task.lookup(taskid)
--
1.8.3.1
10 years, 10 months
[PATCH V3 0/5] template cloning
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
V2 -> V3
raise HTTPredirect in controller.
V1 -> V2
clone will just "duplicate the template" with all default in new template.
The user may clone a template from an existing template with different name.
Later he can customize some parts of the template to save the effort to
create a full new template.
For example, he can update the network of the template cloned to have a new
different template.
ShaoHe Feng (5):
clone template: update API.md
Enhance generate_action_handler to redirect a new resource
clone template: update controller
clone template: update model and mockmodel
clone template: update test case
docs/API.md | 4 +++-
src/kimchi/control/base.py | 14 +++++++++-----
src/kimchi/control/templates.py | 1 +
src/kimchi/mockmodel.py | 16 ++++++++++++++++
src/kimchi/model/templates.py | 16 ++++++++++++++++
tests/test_model.py | 16 ++++++++++++++++
tests/test_rest.py | 15 +++++++++++++++
7 files changed, 76 insertions(+), 6 deletions(-)
--
1.8.4.2
10 years, 10 months
[PATCH 0/6 V3] Host's repositories management support
by Paulo Vital
V2 -> V3:
* PEP8 compatibility
* Improved mockmodel.py and model/host.py
* Updated API.json and backend files to use new exception error system code
V1 -> V2:
* Removed the enable/disable from docs/API.md and src/kimchi/API.json
* fixed wrong URI on test_rest.py
* PEP8 compatibility
* Updated repositories.py to make consistent with docs/API.md
* Raised correct exceptions
* Changed model/host.py and mockmodel.py to generate repo_id if not provided
* Changed mockmodel.py to declare MockRepositories class
V1:
This patch set provides support to host's repositories management operations.
At this point, an agnostic class is providing support to backend and
REST API operations. In addition, YUM (for RHEL, Fedora, SLES and OpenSuse)
and APT (for Debian and Ubuntu) specific classes are provided to support the
operation os each software update system.
To test the backend execute the following commands:
$ cd tests
$ sudo ./run_tests.sh test_model.ModelTests.test_repository_create
$ sudo ./run_tests.sh test_model.ModelTests.test_repository_update
$ sudo ./run_tests.sh test_model.ModelTests.test_repository_disable_enable
To test the REST API, execute the following commands (all them are agnostic of the
host's distro):
1) Get list of all repositories enabled in the host:
$ curl -u <USER> -H 'Content-type: application/json' -H 'Accept: application/json' http://localhost:8000/host/repositories/ -X GET
2) Create a new repository:
$ curl -u <USER> -H 'Content-type: application/json' -H 'Accept: application/json' http://localhost:8000/host/repositories/ -X POST -d'
{
"repo_id": "fedora-fake",
"baseurl": "http://www.fedora.org",
"gpgkey": "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-fake-19"
}
'
3) Get information from a specific repository:
$ curl -u <USER> -H 'Content-type: application/json' -H 'Accept: application/json' http://localhost:8000/host/repositories/fedora-fake
4) Update a specific repository:
$ curl -u <USER> -H 'Content-type: application/json' -H 'Accept: application/json' http://localhost:8000/host/repositories/fedora-fake -X PUT -d'
{
"repo_id":"fedora-fake",
"repo_name":"Fedora 19 FAKEs",
"baseurl": "http://www.fedora.org/downloads"
}
'
5) Disable a specific repository:
$ curl -u <USER> -H 'Content-type: application/json' -H 'Accept: application/json' http://localhost:8000/host/repositories/fedora-fake/disable -X POST -d ''
6) Enable a specific repository:
$ curl -u <USER> -H 'Content-type: application/json' -H 'Accept: application/json' http://localhost:8000/host/repositories/fedora-fake/enable -X POST -d ''
7) Delete a specific repository:
$ curl -u <USER> -H 'Content-type: application/json' -H 'Accept: application/json' http://localhost:8000/host/repositories/fedora-fake -X DELETE
Paulo Vital (6):
Host's repositories management: Update API.md
Host's repositories management: Update REST API
Host's repositories management: Update backend.
Host's repositories management: Update Makefile
Host's repositories management: Update test-cases.
Host's repositories management: Update error exception messages.
Makefile.am | 1 +
docs/API.md | 77 ++++++
src/kimchi/API.json | 76 ++++++
src/kimchi/Makefile.am | 1 +
src/kimchi/control/host.py | 21 ++
src/kimchi/i18n.py | 19 ++
src/kimchi/mockmodel.py | 133 +++++++++++
src/kimchi/model/host.py | 54 ++++-
src/kimchi/repositories.py | 585 +++++++++++++++++++++++++++++++++++++++++++++
tests/test_model.py | 100 ++++++++
tests/test_rest.py | 33 +++
11 files changed, 1099 insertions(+), 1 deletion(-)
create mode 100644 src/kimchi/repositories.py
--
1.8.3.1
10 years, 10 months
[PATCH] Implement integrity verification: don't disable network used by guest
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
do not allow to delete a network when the network is used by more than
one guest.
do not allow to deactivate a network when the network is used by more
than one guest with running state.
add a filter for _get_vms_attach_to_a_network
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
src/kimchi/i18n.py | 2 ++
src/kimchi/model/networks.py | 9 +++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index fd61d4e..ee864f6 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -163,6 +163,8 @@ messages = {
"KCHNET0014E": _("Network interface must be a string"),
"KCHNET0015E": _("Network VLAN ID must be an integer between 1 and 4094"),
"KCHNET0016E": _("Specify name and type to create a Network"),
+ "KCHNET0017E": _("Unable to delete network %(name)s. There are still some VMs join this network."),
+ "KCHNET0018E": _("Unable to deactivate network %(name)s. There are some VMs join this network."),
"KCHDR0001E": _("Debug report %(name)s does not exist"),
"KCHDR0002E": _("Debug report tool not found in system"),
diff --git a/src/kimchi/model/networks.py b/src/kimchi/model/networks.py
index 05105df..96ed43c 100644
--- a/src/kimchi/model/networks.py
+++ b/src/kimchi/model/networks.py
@@ -188,12 +188,13 @@ class NetworkModel(object):
'autostart': network.autostart() == 1,
'state': network.isActive() and "active" or "inactive"}
- def _get_vms_attach_to_a_network(self, network):
+ def _get_vms_attach_to_a_network(self, network, state=None):
vms = []
conn = self.conn.get()
for dom in conn.listAllDomains(0):
networks = self._vm_get_networks(dom)
- if network in networks:
+ if network in networks and (state == None or
+ state == dom.state()[0]):
vms.append(dom.name())
return vms
@@ -208,12 +209,16 @@ class NetworkModel(object):
def deactivate(self, name):
network = self._get_network(name)
+ if self._get_vms_attach_to_a_network(name, 1):
+ raise InvalidOperation("KCHNET0018E", {'name': name})
network.destroy()
def delete(self, name):
network = self._get_network(name)
if network.isActive():
raise InvalidOperation("KCHNET0005E", {'name': name})
+ if self._get_vms_attach_to_a_network(name):
+ raise InvalidOperation("KCHNET0017E", {'name': name})
self._remove_vlan_tagged_bridge(network)
network.undefine()
--
1.8.4.2
10 years, 10 months
[RFC] About the way Kimchi deals with services (libvirt, nfs, etc)
by Daniel H Barboza
Hello all,
I am working in a nfs related bug where kimchi hungs up if the nfs
service stops for some reason while creating a NFS pool. I have a very
similar situation Power-only with another service.
My idea at first was to verify the service status every time we request
a specific service. This could work for actions that requires specific
services, such as NFS. However, for this approach make sense, we should
verify the status of libvirt for all the operations that depend of it.
We would flood the code with "if (libvirt.service is active) "
conditionals do to pretty much anything.
Thus, I am creating this RFC to ask you: how can we handle Kimchi
dependencies on external services in a neat, clean way? Mark suggested
to use systemd, for example.
Thanks!
10 years, 10 months