[PATCH V3 1/3] VM shutdown support in backend
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
Shutdown command stop guest graceful.
Guest os will react to a shutdown request after the the request is issued.
The differences from power off are that the guests disk storage will
be in a stable state rather than having the (virtual) power cord pulled.
Note that the guest OS may ignore the request, so the vm is not stopped.
Additionally, the hypervisor may check and support the VM 'on_poweroff'
XML setting resulting in a domain that reboots instead of shutting down.
For kimchi will not set 'on_poweroff' for VM XML configure.
So kimchi will not check the 'on_poweroff' setting of VM.
So if VM is create by other management tool and set 'on_poweroff' as
reboot, kimchi still will call this shutdown command.
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
Signed-off-by: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
Conflicts:
src/kimchi/i18n.py
---
docs/API.md | 3 +++
src/kimchi/control/vms.py | 1 +
src/kimchi/i18n.py | 1 +
src/kimchi/mockmodel.py | 3 +++
src/kimchi/model/vms.py | 8 ++++++++
5 files changed, 16 insertions(+)
diff --git a/docs/API.md b/docs/API.md
index 716c983..0394824 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -110,6 +110,9 @@ the following general conventions:
* start: Power on a VM
* poweroff: Power off a VM forcefully. Note this action may produce undesirable
results, for example unflushed disk cache in the guest.
+* shutdown: Shut down a VM graceful. This action issue shutdown request to guest.
+ And the guest will react this request. Note the guest OS may ignore
+ the request.
* reset: Reset a VM immediately without the guest OS shutdown.
It emulates the power reset button on a machine. Note that there is a
risk of data loss caused by reset without the guest OS shutdown.
diff --git a/src/kimchi/control/vms.py b/src/kimchi/control/vms.py
index ea810e4..c7a1ff7 100644
--- a/src/kimchi/control/vms.py
+++ b/src/kimchi/control/vms.py
@@ -39,6 +39,7 @@ class VM(Resource):
setattr(self, ident, node(model, self.ident))
self.start = self.generate_action_handler('start')
self.poweroff = self.generate_action_handler('poweroff')
+ self.shutdown = self.generate_action_handler('shutdown')
self.reset = self.generate_action_handler('reset')
self.connect = self.generate_action_handler('connect')
diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index 89bcd02..2d701c3 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -86,6 +86,7 @@ messages = {
"KCHVM0026E": _("Group name must be a string"),
"KCHVM0027E": _("User(s) '%(users)s' do not exist"),
"KCHVM0028E": _("Group(s) '%(groups)s' do not exist"),
+ "KCHVM0029E": _("Unable to shutdown virtual machine %(name)s. Details: %(err)s"),
"KCHVMIF0001E": _("Interface %(iface)s does not exist in virtual machine %(name)s"),
"KCHVMIF0002E": _("Network %(network)s specified for virtual machine %(name)s does not exist"),
diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index 866ad2c..a9bd57f 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -144,6 +144,9 @@ class MockModel(object):
def vm_poweroff(self, name):
self._get_vm(name).info['state'] = 'shutoff'
+ def vm_shutdown(self, name):
+ self._get_vm(name).info['state'] = 'shutoff'
+
def vm_reset(self, name):
pass
diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
index ede54a3..dd5f081 100644
--- a/src/kimchi/model/vms.py
+++ b/src/kimchi/model/vms.py
@@ -443,6 +443,14 @@ class VMModel(object):
raise OperationFailed("KCHVM0020E",
{'name': name, 'err': e.get_error_message()})
+ def shutdown(self, name):
+ dom = self.get_vm(name, self.conn)
+ try:
+ dom.shutdown()
+ except libvirt.libvirtError as e:
+ raise OperationFailed("KCHVM0029E",
+ {'name': name, 'err': e.get_error_message()})
+
def reset(self, name):
dom = self.get_vm(name, self.conn)
try:
--
1.9.0
10 years, 8 months
[PATCH V4 0/5] bug fix: get user and group when VM is running
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
V3 -> V4:
work around if virDomain.metadata and virDomain.setMetadata do not work
in all livirt versions used in the supported distros.
V2 -> V3:
move the virDomain.metadata and virDomain.setMetadata to model/utils.py
add testcase
V1 -> V2:
libvirt also support virDomain.metadata and virDomain.setMetadata two api.
use virDomain.metadata to get the user and group.
use virDomain.setMetadata to set the user and group.
ShaoHe Feng (5):
Add two function to set and get domain xml metadata
bug fix: get user and group when vm is living.
update test case to set/get user and group when VM is running
write the template OS info to vm metadata
manually manage the metadata element
src/kimchi/i18n.py | 1 +
src/kimchi/model/utils.py | 73 ++++++++++++++++++++++++++++++++++++++++
src/kimchi/model/vms.py | 86 +++++++++++++++++++++++++++--------------------
tests/test_model.py | 13 +++++++
4 files changed, 137 insertions(+), 36 deletions(-)
--
1.9.0
10 years, 8 months
[PATCHv2 0/3] UI: Manage guest disk
by lvroyce@linux.vnet.ibm.com
From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
This patchset fix bug relating to select menu,
Add guest disk attach/detach ui support,
choose reasonable bus as default for disk/cdrom,
refresh the disk display view.
Royce Lv (3):
Fix select menu data append
UI: Support add guest disk
Display all disk types in storage edit view
ui/css/theme-default/guest-storage-add.css | 16 +++++
ui/js/src/kimchi.guest_edit_main.js | 5 +-
ui/js/src/kimchi.guest_storage_add.main.js | 110 +++++++++++++++++++++++++++--
ui/js/widgets/select-menu.js | 3 +-
ui/pages/guest-edit.html.tmpl | 17 ++++-
ui/pages/guest-storage-add.html.tmpl | 50 ++++++++++++-
6 files changed, 188 insertions(+), 13 deletions(-)
--
1.8.3.2
10 years, 8 months
[PATCH] bug fix: from persistent xml get user and group
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
define domain just edit the persistent xml.
So we should get user and group from persistent xml instead of live xml
when domain is living.
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
---
src/kimchi/model/vms.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
index 90e9537..2b9bf56 100644
--- a/src/kimchi/model/vms.py
+++ b/src/kimchi/model/vms.py
@@ -258,9 +258,11 @@ class VMModel(object):
old_xml = new_xml = dom.XMLDesc(0)
+ meta_xml = (dom.XMLDesc(libvirt.VIR_DOMAIN_XML_INACTIVE)
+ if dom.isPersistent() else old_xml)
metadata_xpath = "/domain/metadata/kimchi/access/%s"
- users = xpath_get_text(old_xml, metadata_xpath % "user")
- groups = xpath_get_text(old_xml, metadata_xpath % "group")
+ users = xpath_get_text(meta_xml, metadata_xpath % "user")
+ groups = xpath_get_text(meta_xml, metadata_xpath % "group")
for key, val in params.items():
if key == 'users':
--
1.9.0
10 years, 8 months
[PATCH 0/5] Add users and groups to VMs
by Aline Manera
From: Aline Manera <alinefm(a)br.ibm.com>
This patch set is based on Cristian's patches.
It uses the <metadata> tag to store users and groups to the VM XML.
It does not uses virDomain.setMetadata() as it does not well in some libvirt
versions.
Aline Manera (4):
Use proper term "user name" instead of "user id"
Add functions to check if a user/group exists
Return users and groups when fetching VM info
Add/remove users and groups to VMs
Crístian Viana (1):
Override only the updated "User" methods in "patch_auth"
docs/API.md | 6 ++++
po/en_US.po | 55 ++++++++++++++++++++++++++++--
po/kimchi.pot | 55 ++++++++++++++++++++++++++++--
po/pt_BR.po | 63 ++++++++++++++++++++++++++++++++---
po/zh_CN.po | 62 +++++++++++++++++++++++++++++++---
src/kimchi/API.json | 22 ++++++++++++
src/kimchi/auth.py | 60 ++++++++++++++++++++++-----------
src/kimchi/control/vms.py | 6 ++--
src/kimchi/i18n.py | 10 ++++--
src/kimchi/mockmodel.py | 7 ++--
src/kimchi/model/vms.py | 68 ++++++++++++++++++++++++++++++++------
src/kimchi/root.py | 4 +--
tests/test_authorization.py | 19 +++++++++++
tests/test_mockmodel.py | 2 +-
tests/test_model.py | 44 +++++++++++++++++++++++-
tests/test_rest.py | 10 +++---
tests/utils.py | 26 ++++-----------
ui/js/src/kimchi.login_window.js | 16 ++++-----
ui/js/src/kimchi.user.js | 14 ++++----
ui/pages/login-window.html.tmpl | 4 +--
20 files changed, 457 insertions(+), 96 deletions(-)
--
1.7.10.4
10 years, 8 months
[PATCH V2 0/3] VM shutdown support in backend
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
V1 -> V2
update a new domain state pmsuspended
ShaoHe Feng (3):
VM shutdown support in backend
VM shutdown support in UI
New domain state pmsuspended
docs/API.md | 3 +++
src/kimchi/control/vms.py | 1 +
src/kimchi/i18n.py | 1 +
src/kimchi/mockmodel.py | 3 +++
src/kimchi/model/vms.py | 11 ++++++++++-
ui/js/src/kimchi.api.js | 11 +++++++++++
ui/js/src/kimchi.guest_main.js | 23 +++++++++++++++++++++++
ui/pages/guest.html.tmpl | 1 +
ui/pages/i18n.html.tmpl | 2 ++
9 files changed, 55 insertions(+), 1 deletion(-)
--
1.9.0
10 years, 8 months
[PATCH 0/5] API to list system users and groups
by Aline Manera
From: Aline Manera <alinefm(a)br.ibm.com>
While setting users and groups to a VM the user needs to know what
are the available values.
So add the following API:
- /host/users: to list system users
- /host/groups: to list system groups
Aline Manera (5):
Create a new common collection named SimpleCollection
Add API to list system users and groups
Update users/groups verification based on new API
Remove unused code
Update test cases
src/kimchi/auth.py | 22 ----------------------
src/kimchi/control/base.py | 17 +++++++++++++++++
src/kimchi/control/host.py | 14 +++++++++++++-
src/kimchi/control/plugins.py | 19 ++-----------------
src/kimchi/i18n.py | 4 ++--
src/kimchi/mockmodel.py | 30 ++++++++++++++++++++++++------
src/kimchi/model/host.py | 18 ++++++++++++++++++
src/kimchi/model/vms.py | 20 ++++++++++++--------
tests/test_authorization.py | 19 -------------------
tests/test_model.py | 8 ++++----
tests/test_rest.py | 24 ++++++++++++++++++++----
11 files changed, 112 insertions(+), 83 deletions(-)
--
1.7.10.4
10 years, 8 months
[PATCH] Bug fix: add PYTHONPATH for contrib/check_i18n.py
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
for plugin i18n.py, it will import the base i18n.py
The i18n.py may from install directory install of source directory.
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
Signed-off-by: Mark Wu <wudxw(a)linux.vnet.ibm.com>
Signed-off-by: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
---
Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am
index ca5623d..85949d8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -81,7 +81,7 @@ I18N_FILES = plugins/*/i18n.py \
$(NULL)
check-local:
- contrib/check_i18n.py $(I18N_FILES)
+ PYTHONPATH=src contrib/check_i18n.py $(I18N_FILES)
find . -path './.git' -prune -type f -o \
-name '*.py' -o -name '*.py.in' | xargs $(PYFLAKES) | \
grep -w -v $(SKIP_PYFLAKES_ERR) | \
--
1.9.0
10 years, 8 months
[PATCH] packaging: ship kimchi with plugins/__init__.py
by zhshzhou@linux.vnet.ibm.com
From: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
If we do not package and install plugins/__init__.py, plugins can not be
imported as "import kimchi.plugins.pluginXYZ". The plugins also can not
be discovered and imported dynamically. This patch fixes the problem.
Signed-off-by: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
---
contrib/kimchi.spec.fedora.in | 1 +
contrib/kimchi.spec.suse.in | 1 +
plugins/Makefile.am | 5 ++++-
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in
index 1cd99b0..62d3000 100644
--- a/contrib/kimchi.spec.fedora.in
+++ b/contrib/kimchi.spec.fedora.in
@@ -141,6 +141,7 @@ rm -rf $RPM_BUILD_ROOT
%{python_sitelib}/kimchi/control/vm/*.py*
%{python_sitelib}/kimchi/model/*.py*
%{python_sitelib}/kimchi/API.json
+%{python_sitelib}/kimchi/plugins/*.py*
%{_datadir}/kimchi/doc/API.md
%{_datadir}/kimchi/doc/README.md
%{_datadir}/kimchi/doc/kimchi-guest.png
diff --git a/contrib/kimchi.spec.suse.in b/contrib/kimchi.spec.suse.in
index efb2c08..524a000 100644
--- a/contrib/kimchi.spec.suse.in
+++ b/contrib/kimchi.spec.suse.in
@@ -67,6 +67,7 @@ rm -rf $RPM_BUILD_ROOT
%{python_sitelib}/kimchi/control/vm/*.py*
%{python_sitelib}/kimchi/model/*.py*
%{python_sitelib}/kimchi/API.json
+%{python_sitelib}/kimchi/plugins/*.py*
%{_datadir}/kimchi/doc/API.md
%{_datadir}/kimchi/doc/README.md
%{_datadir}/kimchi/doc/kimchi-guest.png
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 2ceedae..894d28e 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -19,4 +19,7 @@
SUBDIRS = sample
-EXTRA_DIST = __init__.py
+plugins_PYTHON = \
+ __init__.py
+
+pluginsdir = $(pythondir)/kimchi/plugins
--
1.9.0
10 years, 8 months
[PATCH V2 0/2] bug fix: from persistent xml get user and group
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
V1 -> V2:
libvirt also support virDomain.metadata and virDomain.setMetadata two api.
use virDomain.metadata to get the user and group.
use virDomain.setMetadata to set the user and group.
ShaoHe Feng (2):
bug fix: get user and group metadata by libvirt virDomain.metadata API
use libvirt api to set user and group metadata by
virDomain.setMetadata API
src/kimchi/i18n.py | 1 +
src/kimchi/model/vms.py | 52 ++++++++++++++++++++++++++++++++++++++-----------
2 files changed, 42 insertions(+), 11 deletions(-)
--
1.9.0
10 years, 8 months