[RFC] New API to create a random guest console password
by Aline Manera
Today user may set/change the guest console password and also its
expiration time through Kimchi API.
When passing an empty password, a random password is automatically
generated.
curl -u <user:password> -H "Content-Type: application/json" -H "Accept:
application/json"
http://localhost:8010/vms/blah -X PUT -d'{"graphics": {"passwd": ""}}'
That way is difficult to handle when user wants to reset the guest password.
We have a similar issue when we automatically change the passwdValidTo
when it is expired - increasing it in 30 seconds.
My proposal is simple: only change "passwd" and "passwdValidTo" when
user wants to do it.
curl -u <user:password> -H "Content-Type: application/json" -H "Accept:
application/json"
http://localhost:8010/vms/blah -X PUT -d'{"graphics": {"passwd":
"123456", "passwdValidTo": "<some datetime format>"}}'
curl -u <user:password> -H "Content-Type: application/json" -H "Accept:
application/json"
http://localhost:8010/vms/blah -X PUT -d'{"graphics":
{"passwdValidTo": "<some datetime format>"}}'
And make sure the passwdValidTo is only acceptable when there is a
passwd set.
And to reset those values, we only need to send an empty string:
curl -u <user:password> -H "Content-Type: application/json" -H "Accept:
application/json"
http://localhost:8010/vms/blah -X PUT -d'{"graphics": {"password":
"", "passwdValidTo": ""}}'
And create a new API: POST /vms/blah/ticket to automatically generate a
random password valid only for 30 seconds.
curl -u <user:password> -H "Content-Type: application/json" -H "Accept:
application/json"
http://localhost:8010/vms/blah/ticket -X POST -d'{}'
What do you think about it?
Regards,
Aline Manera
9 years, 8 months
CPU discussion (RE: psutil.NUM_CPUS)
by Christy Perez
After my confusion on Paulo's patch a few weeks ago, I thought I had
just gotten confused, and so I put psutil.NUM_CPUS in my SMT/HT patch.
However, testing now on x86, I'm noticing a difference in the way Power
and x86 report CPUS.
On my laptop:
<cpu>
<arch>x86_64</arch>
<model>SandyBridge</model>
<vendor>Intel</vendor>
<topology sockets='1' cores='2' threads='2'/>
psutil.NUM_CPUS returns 4
On a Power7 system with 16 cores, 4 threads/core (so 64 total threads),
psutil.NUM_CPUS returns 16.
And this is, it turns out, because (and this sounds odd) for *guests* to
be able to do SMT on Power, SMT has to be disabled. So, psutil.NUM_CPUS
will not report the number of vCPUs that are available to guests. The
same change would happen on x86 if you disabled HT, I assume.
So, revisiting this difference that I noticed but wasn't able to
articulate very well last time, do we want to make a change to the host
code to use ppc64_cpu if the arch is Power, instead of psutil.NUM_CPUS?
SMT *is* off, so, technically this isn't correct, but I think we should
provide this information with guests in mind since we are a
virtualization platform.
Regards,
- Christy
9 years, 11 months
[PATCH] UI: Use capabilities cached values on 'Host PCI Device' tab
by Aline Manera
Kimchi capabilities are cached on UI to avoid multiples request to it as
those values does not change with high frequency.
So use the cached values to check host has kernel_vfio capability.
Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.guest_edit_main.js | 132 ++++++++++++++++++------------------
1 file changed, 65 insertions(+), 67 deletions(-)
diff --git a/ui/js/src/kimchi.guest_edit_main.js b/ui/js/src/kimchi.guest_edit_main.js
index 9d87a73..359add8 100644
--- a/ui/js/src/kimchi.guest_edit_main.js
+++ b/ui/js/src/kimchi.guest_edit_main.js
@@ -360,77 +360,75 @@ kimchi.guest_edit_main = function() {
var setupPCIDevice = function(){
kimchi.getHostPCIDevices(function(hostPCIs){
kimchi.getVMPCIDevices(kimchi.selectedGuest, function(vmPCIs){
- kimchi.getCapabilities(function(result) {
- var pciEnabled = result.kernel_vfio;
- for(var i=0; i<hostPCIs.length; i++){
- var itemNode = $.parseHTML(kimchi.substitute($('#pci-tmpl').html(),{
- name: hostPCIs[i].name,
- product: hostPCIs[i].product.description,
- vendor: hostPCIs[i].vendor.description
- }));
- $(".body", "#form-guest-edit-pci").append(itemNode);
- var iconClass = "ui-icon-plus";
- for(var j=0; j<vmPCIs.length; j++){
- if(hostPCIs[i].name==vmPCIs[j].name){
- iconClass = "ui-icon-minus";
- break;
- }
+ var pciEnabled = kimchi.capabilities.kernel_vfio;
+ for(var i=0; i<hostPCIs.length; i++){
+ var itemNode = $.parseHTML(kimchi.substitute($('#pci-tmpl').html(),{
+ name: hostPCIs[i].name,
+ product: hostPCIs[i].product.description,
+ vendor: hostPCIs[i].vendor.description
+ }));
+ $(".body", "#form-guest-edit-pci").append(itemNode);
+ var iconClass = "ui-icon-plus";
+ for(var j=0; j<vmPCIs.length; j++){
+ if(hostPCIs[i].name==vmPCIs[j].name){
+ iconClass = "ui-icon-minus";
+ break;
}
- pciEnabled || $("button", itemNode).remove();
- $("button", itemNode).button({
- icons: { primary: iconClass },
- text: false
- }).click(function(){
- var obj = $(this);
- if(obj.button("option", "icons").primary == "ui-icon-minus"){
- kimchi.removeVMPCIDevice(kimchi.selectedGuest, obj.parent().prop("id"), function(){
- kimchi.getVMPCIDevices(kimchi.selectedGuest, function(vmPCIs1){
- for(var k=0; k<hostPCIs.length; k++) {
- $("button", "#" + hostPCIs[k].name).button("option", "icons", {primary: "ui-icon-plus"});
- }
- for(var k=0; k<vmPCIs1.length; k++) {
- $("button", "#" + vmPCIs1[k].name).button("option", "icons", {primary: "ui-icon-minus"});
- }
- });
- filterNodes($("select", "#form-guest-edit-pci").val(), $("input", "#form-guest-edit-pci").val());
+ }
+ pciEnabled || $("button", itemNode).remove();
+ $("button", itemNode).button({
+ icons: { primary: iconClass },
+ text: false
+ }).click(function(){
+ var obj = $(this);
+ if(obj.button("option", "icons").primary == "ui-icon-minus"){
+ kimchi.removeVMPCIDevice(kimchi.selectedGuest, obj.parent().prop("id"), function(){
+ kimchi.getVMPCIDevices(kimchi.selectedGuest, function(vmPCIs1){
+ for(var k=0; k<hostPCIs.length; k++) {
+ $("button", "#" + hostPCIs[k].name).button("option", "icons", {primary: "ui-icon-plus"});
+ }
+ for(var k=0; k<vmPCIs1.length; k++) {
+ $("button", "#" + vmPCIs1[k].name).button("option", "icons", {primary: "ui-icon-minus"});
+ }
});
- }else{
- kimchi.addVMPCIDevice(kimchi.selectedGuest, { name: obj.parent().prop("id") }, function(){
- kimchi.getVMPCIDevices(kimchi.selectedGuest, function(vmPCIs1){
- for(var k=0; k<vmPCIs1.length; k++) {
- $("button", "#" + vmPCIs1[k].name).button("option", "icons", {primary: "ui-icon-minus"});
- }
- });
- filterNodes($("select", "#form-guest-edit-pci").val(), $("input", "#form-guest-edit-pci").val());
+ filterNodes($("select", "#form-guest-edit-pci").val(), $("input", "#form-guest-edit-pci").val());
+ });
+ } else {
+ kimchi.addVMPCIDevice(kimchi.selectedGuest, { name: obj.parent().prop("id") }, function(){
+ kimchi.getVMPCIDevices(kimchi.selectedGuest, function(vmPCIs1){
+ for(var k=0; k<vmPCIs1.length; k++) {
+ $("button", "#" + vmPCIs1[k].name).button("option", "icons", {primary: "ui-icon-minus"});
+ }
});
+ filterNodes($("select", "#form-guest-edit-pci").val(), $("input", "#form-guest-edit-pci").val());
+ });
+ }
+ });
+ kimchi.getPCIDeviceCompanions(hostPCIs[i].name, function(infoData) {
+ var pciTitle = i18n["KCHVMED6007M"] + "\n";
+ var haveCompanions = false;
+ for(var p=0; p<infoData.length; p++) {
+ if(infoData[p].device_type === "net") {
+ haveCompanions = true;
+ pciTitle += " " + infoData[p].name + "\n";
+ pciTitle += " " + i18n["KCHVMED6001M"] + " " + infoData[p].interface;
+ pciTitle += ", " + i18n["KCHVMED6002M"] + " " + infoData[p].address;
+ pciTitle += ", " + i18n["KCHVMED6003M"] + " " + infoData[p].link_type + "\n";
+ } else if(infoData[p].device_type === "storage") {
+ haveCompanions = true;
+ pciTitle += " " + infoData[p].name + "\n";
+ pciTitle += " " + i18n["KCHVMED6004M"] + " " + infoData[p].block;
+ pciTitle += ", " + i18n["KCHVMED6005M"] + " " + infoData[p].drive_type;
+ pciTitle += ", " + i18n["KCHVMED6006M"] + " " + infoData[p].model + "\n";
}
- });
- kimchi.getPCIDeviceCompanions(hostPCIs[i].name, function(infoData) {
- var pciTitle = i18n["KCHVMED6007M"] + "\n";
- var haveCompanions = false;
- for(var p=0; p<infoData.length; p++) {
- if(infoData[p].device_type === "net") {
- haveCompanions = true;
- pciTitle += " " + infoData[p].name + "\n";
- pciTitle += " " + i18n["KCHVMED6001M"] + " " + infoData[p].interface;
- pciTitle += ", " + i18n["KCHVMED6002M"] + " " + infoData[p].address;
- pciTitle += ", " + i18n["KCHVMED6003M"] + " " + infoData[p].link_type + "\n";
- } else if(infoData[p].device_type === "storage") {
- haveCompanions = true;
- pciTitle += " " + infoData[p].name + "\n";
- pciTitle += " " + i18n["KCHVMED6004M"] + " " + infoData[p].block;
- pciTitle += ", " + i18n["KCHVMED6005M"] + " " + infoData[p].drive_type;
- pciTitle += ", " + i18n["KCHVMED6006M"] + " " + infoData[p].model + "\n";
- }
- }
- for(var q=0; q<infoData.length; q++) {
- haveCompanions && $(".name", "#" + infoData[q].parent).attr("title", pciTitle);
- haveCompanions && $(".product", "#" + infoData[q].parent).attr("title", pciTitle);
- haveCompanions && $(".vendor", "#" + infoData[q].parent).attr("title", pciTitle);
- }
- });
- }
- });
+ }
+ for(var q=0; q<infoData.length; q++) {
+ haveCompanions && $(".name", "#" + infoData[q].parent).attr("title", pciTitle);
+ haveCompanions && $(".product", "#" + infoData[q].parent).attr("title", pciTitle);
+ haveCompanions && $(".vendor", "#" + infoData[q].parent).attr("title", pciTitle);
+ }
+ });
+ }
});
});
var filterNodes = function(group, text){
--
1.9.3
10 years
[PATCH] Bugfix: Disable actions not supported by non-persistent VMs
by Wen Wang
1) Disable "Reset" and "Delete" buttons when using non-persistent VMs
2) Disable "Reset" button when VM is shutdown
Signed-off-by: Wen Wang <wenwang(a)linux.vnet.ibm.com>
---
ui/css/theme-default/list.css | 11 +++++++++++
ui/js/src/kimchi.guest_main.js | 7 +++++--
ui/pages/guest.html.tmpl | 10 +++++-----
3 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/ui/css/theme-default/list.css b/ui/css/theme-default/list.css
index ded18eb..52cccc4 100644
--- a/ui/css/theme-default/list.css
+++ b/ui/css/theme-default/list.css
@@ -228,6 +228,17 @@
padding: 7px 10px;
}
+.guest-actions .top button {
+ display: inline-block;
+ width: 42px;
+ height: 42px;
+}
+
+.guest-actions .top button span {
+ margin-left: -3px;
+ margin-top: -1px;
+}
+
.guest-actions .bottom {
padding: 0 10px;
}
diff --git a/ui/js/src/kimchi.guest_main.js b/ui/js/src/kimchi.guest_main.js
index 2fd5c55..21caf1b 100644
--- a/ui/js/src/kimchi.guest_main.js
+++ b/ui/js/src/kimchi.guest_main.js
@@ -252,6 +252,7 @@ kimchi.createGuestLi = function(vmObject, prevScreenImage, openMenu) {
//Setup the VM list entry
var vmRunningBool=(vmObject.state=="running");
+ var vmPersistent = (vmObject.persistent == true);
result.attr('id',vmObject.name);
result.data(vmObject);
@@ -302,8 +303,10 @@ kimchi.createGuestLi = function(vmObject, prevScreenImage, openMenu) {
//Setup the VM Actions
var guestActions=result.find("div[name=guest-actions]");
- guestActions.find(".shutoff-disabled").prop('disabled', !vmRunningBool );
- guestActions.find(".running-disabled").prop('disabled', vmRunningBool );
+ guestActions.find(".shutoff-disabled").prop("disabled", !vmRunningBool);
+ guestActions.find(".running-disabled").prop("disabled", vmRunningBool);
+ guestActions.find(".non-persistent-disabled").prop("disabled", !vmPersistent);
+ guestActions.find(".reset-disabled").prop("disabled", !vmRunningBool || !vmPersistent);
if (vmRunningBool) {
guestActions.find(".running-hidden").hide();
diff --git a/ui/pages/guest.html.tmpl b/ui/pages/guest.html.tmpl
index ebb5e86..3cc2fad 100644
--- a/ui/pages/guest.html.tmpl
+++ b/ui/pages/guest.html.tmpl
@@ -50,9 +50,9 @@
</div>
<div class="sortable guest-actions" name="guest-actions">
<div class="top">
- <a class="btn shutoff-disabled" name="vm-reset" href="javascript:void(0);" title="$_("Reset")"><span class="icon reset"></span></a>
- <a class="btn running-hidden" name="vm-start" href="javascript:void(0);" title="$_("Start")"><span class="icon power-down"></span></a>
- <a class="btn shutoff-hidden" name="vm-poweroff" href="javascript:void(0);" title="$_("Power Off")"><span class="icon power-up"></span></a>
+ <button class="btn reset-disabled" name="vm-reset" href="javascript:void(0);" title="$_("Reset")"><span class="icon reset"></span></button>
+ <button class="btn running-hidden" name="vm-start" href="javascript:void(0);" title="$_("Start")"><span class="icon power-down"></span></button>
+ <button class="btn shutoff-hidden" name="vm-poweroff" href="javascript:void(0);" title="$_("Power Off")"><span class="icon power-up"></span></button>
</div>
<div class="bottom">
<div name="actionmenu" class="btn dropdown popable vm-action" style="width: 70px">
@@ -61,11 +61,11 @@
<button class="button-big shutoff-disabled" name="vm-console" ><span class="text">$_("Connect")</span></button>
<button class="button-big running-disabled" name="vm-clone"><span class="text">$_("Clone")</span></button>
<button class="button-big" name="vm-edit"><span class="text">$_("Edit")</span></button>
- <button class="button-big shutoff-hidden" name="vm-reset"><span class="text">$_("Reset")</span></button>
+ <button class="button-big shutoff-hidden non-persistent-disabled" name="vm-reset"><span class="text">$_("Reset")</span></button>
<button class="button-big shutoff-hidden" name="vm-shutdown"><span class="text">$_("Shut Down")</span></button>
<button class="button-big running-hidden" name="vm-start"><span class="text">$_("Start")</span></button>
<button class="button-big shutoff-hidden" name="vm-poweroff"><span class="text">$_("Power Off")</span></button>
- <a class="button-big red " name="vm-delete">$_("Delete")</a>
+ <button class="button-big red non-persistent-disabled" name="vm-delete">$_("Delete")</button>
</div>
</div>
</div>
--
1.9.3
10 years
[PATCH] Change pattern match in pep8 filtering
by lvroyce@linux.vnet.ibm.com
From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
Files like "./src/kimchi/i18n.py" will be warned with error by pep8
because pep8 uses wildcard searching instead of interpreting path
of file.
So change pattern to fix this problem.
Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
---
Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am
index ec88787..62b10fc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -34,7 +34,7 @@ EXTRA_DIST = \
$(NULL)
-PEP8_BLACKLIST = src/kimchi/config.py,src/kimchi/i18n.py,tests/test_config.py
+PEP8_BLACKLIST = *src/kimchi/config.py,*src/kimchi/i18n.py,*tests/test_config.py
SKIP_PYFLAKES_ERR = "\./src/kimchi/websocket\.py"
--
1.8.3.2
10 years
[PATCH 0/2] More snapshot bugfixes
by Crístian Viana
Crístian Viana (2):
Only allow VM snapshots to be taken on 'qcow2' disks
Revert "snapshot: Clone snapshots when cloning a VM"
src/kimchi/i18n.py | 1 +
src/kimchi/model/vms.py | 29 +----------------------------
src/kimchi/model/vmsnapshots.py | 17 +++++++++++++++--
tests/test_model.py | 11 -----------
tests/test_rest.py | 19 ++-----------------
5 files changed, 19 insertions(+), 58 deletions(-)
--
1.9.3
10 years
[PATCH V2] Add sos (sosreport) plugin for kimchi
by Rodrigo Trujillo
This patches adds a sos plugin to collect kimchi's configuration,
log files and other information for diagnosis.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo(a)linux.vnet.ibm.com>
Signed-off-by: Mark Wu <wudxw(a)linux.vnet.ibm.com>
Signed-off-by: Eli Qiao <taget(a)linux.vnet.ibm.com>
Signed-off-by: Paulo Vital <pvital(a)linux.vnet.ibm.com>
---
Makefile.am | 3 +++
contrib/kimchi.spec.fedora.in | 3 +++
src/Makefile.am | 1 +
src/sos.py | 43 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 50 insertions(+)
create mode 100644 src/sos.py
diff --git a/Makefile.am b/Makefile.am
index ec88787..53b6b40 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -70,10 +70,13 @@ install-deb: install
cp -R $(top_srcdir)/contrib/DEBIAN $(DESTDIR)/
$(MKDIR_P) $(DESTDIR)/etc/init
$(MKDIR_P) $(DESTDIR)/usr/lib/firewalld/services
+ $(MKDIR_P) $(DESTDIR)/usr/share/sosreport/sos/plugins
cp -R $(top_srcdir)/contrib/kimchid-upstart.conf.debian \
$(DESTDIR)/etc/init/kimchid.conf
cp -R $(top_srcdir)/src/firewalld.xml \
$(DESTDIR)/usr/lib/firewalld/services/kimchid.xml
+ cp -R $(top_srcdir)/src/sos.py \
+ $(DESTDIR)/usr/share/sosreport/sos/plugins/kimchi.py
deb: contrib/make-deb.sh
diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in
index 236c862..4d23ad0 100644
--- a/contrib/kimchi.spec.fedora.in
+++ b/contrib/kimchi.spec.fedora.in
@@ -80,6 +80,8 @@ make
%install
rm -rf %{buildroot}
make DESTDIR=%{buildroot} install
+install -Dm 0644 src/sos.py \
+ %{buildroot}/%{python_sitelib}/sos/plugins/kimchi.py
%if 0%{?with_systemd}
# Install the systemd scripts
@@ -161,6 +163,7 @@ rm -rf $RPM_BUILD_ROOT
%{python_sitelib}/kimchi/xmlutils/*.py*
%{python_sitelib}/kimchi/API.json
%{python_sitelib}/kimchi/plugins/*.py*
+%{python_sitelib}/sos/plugins/kimchi.py*
%{_datadir}/kimchi/doc/API.md
%{_datadir}/kimchi/doc/README.md
%{_datadir}/kimchi/doc/README-federation.md
diff --git a/src/Makefile.am b/src/Makefile.am
index dfeb24e..46ca1ab 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -23,6 +23,7 @@ EXTRA_DIST = kimchid.in \
kimchi.conf.in \
nginx.conf.in \
firewalld.xml \
+ sos.py \
$(NULL)
bin_SCRIPTS = kimchid
diff --git a/src/sos.py b/src/sos.py
new file mode 100644
index 0000000..5d1fa3f
--- /dev/null
+++ b/src/sos.py
@@ -0,0 +1,43 @@
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2014
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+from sos.plugins import Plugin, RedHatPlugin, UbuntuPlugin, DebianPlugin
+from sos.utilities import sos_get_command_output
+
+
+class Kimchi(Plugin, RedHatPlugin, UbuntuPlugin, DebianPlugin):
+ """
+ kimchi-related information
+ """
+
+ plugin_name = 'kimchi'
+
+ def setup(self):
+ self.add_copy_specs([
+ "/etc/kimchi/",
+ "/var/log/kimchi*"
+ ])
+ self.add_cmd_output("virsh pool-list --details")
+ rc, out, _ = sos_get_command_output('virsh pool-list')
+ if rc == 0:
+ for pool in out.splitlines()[2:]:
+ if pool:
+ pool_name = pool.split()[0]
+ self.add_cmd_output("virsh vol-list --pool %s --details"
+ % pool_name)
--
1.9.3
10 years
[PATCH] RHEL7: Guide user to subscribe to "RHEL Server Optional" channel
by Aline Manera
python-cheetah requires python-pygments package that is only available
for RHEL7 system in the "RHEL Server Optional" channel at RHN Classic or
Red Hat Satellite. So guide user to subscribe to this channel in order
to install and run Kimchi.
Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
---
docs/README.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/docs/README.md b/docs/README.md
index 555ce89..ed3d489 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -74,6 +74,9 @@ EPEL repositories. See
[this FAQ](http://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_package...
for more information on how to configure your system to access this repository.
+And for RHEL7 systems, you also need to subscribe to the "RHEL Server Optional"
+channel at RHN Classic or Red Hat Satellite.
+
**For debian:**
$ sudo apt-get install gcc make autoconf automake gettext git \
--
1.9.3
10 years