[PATCH] Clarify the meaning of an empty vm user or group list
by Christy Perez
The API doc said that the default list returned is an empty list
of users and groups, but that could have been interpreted as no
restrictions, or nothing at all had access. Adding two lines
to clarify who can access a vm by default.
Signed-off-by: Christy Perez <christy(a)linux.vnet.ibm.com>
---
docs/API.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/API.md b/docs/API.md
index 716c983..51a84e2 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -95,9 +95,9 @@ the following general conventions:
can use this port to connect to the vm with general vnc/spice
clients.
* users: A list of system users who have permission to access the VM.
- Default is: empty.
+ Default is: empty (i.e. only root-users may access).
* groups: A list of system groups whose users have permission to access
- the VM. Default is: empty.
+ the VM. Default is: empty (i.e. no groups given access).
* **DELETE**: Remove the Virtual Machine
* **PUT**: update the parameters of existed VM
* name: New name for this VM (only applied for shutoff VM)
--
1.9.0
10 years, 8 months
[PATCH] VMEdit of CPU and Memory
by Adam King
Patch assumes VM edit API already updated to accept cpu and memory
Patch depends on [PATCH 0/3] Create and use jQuery form extensions
Adam King (1):
VM Edit: CPU and memory
ui/js/src/kimchi.guest_edit_main.js | 10 ++--------
ui/pages/guest-edit.html.tmpl | 12 +++++-------
2 files changed, 7 insertions(+), 15 deletions(-)
--
1.8.1.4
10 years, 8 months
[PATCH v2] VM Edit: CPU and memory
by Adam King
Update the edit VM form to use the new form extensions.
Enable the cpu and memory fields to be edited.
Signed-off-by: Adam King <rak(a)linux.vnet.ibm.com>
---
ui/css/theme-default/guest-edit.css | 2 +-
ui/js/src/kimchi.guest_edit_main.js | 18 ++++++++++--------
ui/pages/guest-edit.html.tmpl | 14 ++++++--------
3 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/ui/css/theme-default/guest-edit.css b/ui/css/theme-default/guest-edit.css
index 0b7ba21..bf5ae5f 100644
--- a/ui/css/theme-default/guest-edit.css
+++ b/ui/css/theme-default/guest-edit.css
@@ -46,7 +46,7 @@
line-height: 38px;
margin-top: 5px;
vertical-align: top;
- width: 80px;
+ width: 90px;
}
#form-guest-edit-storage .guest-edit-wrapper-label {
diff --git a/ui/js/src/kimchi.guest_edit_main.js b/ui/js/src/kimchi.guest_edit_main.js
index 9375c51..ded8c07 100644
--- a/ui/js/src/kimchi.guest_edit_main.js
+++ b/ui/js/src/kimchi.guest_edit_main.js
@@ -80,9 +80,7 @@ kimchi.guest_edit_main = function() {
var initContent = function(guest) {
guest['icon'] = guest['icon'] || 'images/icon-vm.png';
- for ( var prop in guest) {
- $('input[name="' + prop + '"]', guestEditForm).val(guest[prop]);
- }
+ $('#form-guest-edit-general').fillWithObject(guest);
refreshCDROMs();
@@ -116,16 +114,20 @@ kimchi.guest_edit_main = function() {
var submitForm = function(event) {
$(saveButton).prop('disabled', true);
- var editableFields = [ 'name' ];
- var data = {};
- $.each(editableFields, function(i, field) {
- data[field] = $('#form-guest-edit [name="' + field + '"]').val();
- });
+ var data=$('#form-guest-edit-general').serializeObject();
+ if(data['memory']!=undefined) {
+ data['memory'] = Number(data['memory']);
+ }
+ if(data['cpus']!=undefined) {
+ data['cpus'] = Number(data['cpus']);
+ }
+
kimchi.updateVM(kimchi.selectedGuest, data, function() {
kimchi.listVmsAuto();
kimchi.window.close();
}, function(err) {
kimchi.message.error(err.responseJSON.reason);
+ $(saveButton).prop('disabled', false);
});
event.preventDefault();
diff --git a/ui/pages/guest-edit.html.tmpl b/ui/pages/guest-edit.html.tmpl
index 804fc39..aae9694 100644
--- a/ui/pages/guest-edit.html.tmpl
+++ b/ui/pages/guest-edit.html.tmpl
@@ -59,21 +59,19 @@
<input
id="guest-edit-cores-textbox"
name="cpus"
- type="text"
- disabled="disabled" />
+ type="text" />
</div>
</div>
<div>
<div class="guest-edit-wrapper-label">
<label for="guest-edit-memory-textbox">
- $_("Memory")
+ $_("Memory (MB)")
</label>
</div>
<div class="guest-edit-wrapper-controls">
<input id="guest-edit-memory-textbox"
name="memory"
- type="text"
- disabled="disabled" />
+ type="text" />
</div>
</div>
<div>
@@ -98,7 +96,7 @@
<div>
<button id="guest-edit-attach-cdrom-button"
class="guest-edit-cdrom-button attach"
- title="$_("Attach")">
+ title='$_("Attach")'>
</button>
</div>
</fieldset>
@@ -124,11 +122,11 @@
value="{path}" readonly="readonly" />
<button class="guest-edit-cdrom-button replace"
data-vm="{vm}" data-dev="{dev}"
- title="$_("Replace")">
+ title='$_("Replace")'>
</button>
<button class="guest-edit-cdrom-button detach"
data-vm="{vm}" data-dev="{dev}"
- title="$_("Detach")">
+ title='$_("Detach")'>
</button>
</div>
</div>
--
1.9.0
10 years, 8 months
[PATCH V5 0/3] VM Edit CPU/Memory: (Backend)
by Rodrigo Trujillo
V5:
- Fix API documentation
V4:
- Address Aline's comments
- Rebase with latest user/groups patches
V3:
- Fix PEP8 issues
V2:
- Rebased with latest Kimchi master
V1:
- This patch set implements backend side of feature "Edit VM CPU/Memory".
You can use curl to test:
curl -X PUT -u <USER> -H 'Content-type: application/json'
-H 'Accept: application/json' http://localhost:8000/vms/<VM_NAME>
-d '{ "cpus": <NUM>, "memory": <NUM>}'
Rodrigo Trujillo (3):
VM Edit CPU/Memory: (Backend) Changes API.md, API.json and i18n.py
VM Edit CPU/Memory: (Backend) Changes VM control and model
VM Edit CPU/Memory: (Backend) Changes mockmodel and tests
docs/API.md | 4 ++++
src/kimchi/API.json | 12 ++++++++++++
src/kimchi/control/vms.py | 17 ++---------------
src/kimchi/i18n.py | 2 +-
src/kimchi/mockmodel.py | 27 +++++++++++++++------------
src/kimchi/model/vms.py | 24 +++++++++++++++---------
tests/test_mockmodel.py | 6 ++++--
tests/test_model.py | 14 ++++++++++----
tests/test_rest.py | 32 +++++++++++++++++++++++++++++---
9 files changed, 92 insertions(+), 46 deletions(-)
--
1.9.0
10 years, 8 months
[V1 0/2] Edit Guest Network Interface
by huoyuxin@linux.vnet.ibm.com
From: Yu Xin Huo <huoyuxin(a)linux.vnet.ibm.com>
Edit guest network interface UI and translations
Yu Xin Huo (2):
Edit Guest Network Inteface UI
Edit Guest Network Interface PO
po/en_US.po | 3 +
po/kimchi.pot | 3 +
po/pt_BR.po | 3 +
po/zh_CN.po | 3 +
ui/css/theme-default/guest-edit.css | 43 +++++++++++++++
ui/js/src/kimchi.api.js | 55 +++++++++++++++++++
ui/js/src/kimchi.guest_edit_main.js | 103 +++++++++++++++++++++++++++++++++++
ui/pages/guest-edit.html.tmpl | 53 ++++++++++++++++++
8 files changed, 266 insertions(+), 0 deletions(-)
10 years, 8 months
[V2] UI: Edit Guest Network Interface
by huoyuxin@linux.vnet.ibm.com
From: Yu Xin Huo <huoyuxin(a)linux.vnet.ibm.com>
Signed-off-by: Yu Xin Huo <huoyuxin(a)linux.vnet.ibm.com>
---
ui/css/theme-default/guest-edit.css | 43 +++++++++++++++++
ui/js/src/kimchi.api.js | 55 +++++++++++++++++++++
ui/js/src/kimchi.guest_edit_main.js | 90 +++++++++++++++++++++++++++++++++++
ui/pages/guest-edit.html.tmpl | 28 +++++++++++
4 files changed, 216 insertions(+), 0 deletions(-)
diff --git a/ui/css/theme-default/guest-edit.css b/ui/css/theme-default/guest-edit.css
index 0b7ba21..39bf1fb 100644
--- a/ui/css/theme-default/guest-edit.css
+++ b/ui/css/theme-default/guest-edit.css
@@ -156,3 +156,46 @@
.guest-edit-cdrom-button.detach[disabled] {
background-position: -54px -108px;
}
+
+.guest-edit-interface .header {
+ margin-bottom: 8px;
+ padding-bottom: 2px;
+ font-weight: bold;
+ border-bottom: 1px solid #999999;
+ overflow: hidden;
+}
+
+.guest-edit-interface .body .item {
+ margin: 5px 0;
+}
+
+.guest-edit-interface .cell {
+ display: inline-block;
+ width: 250px;
+}
+
+.guest-edit-interface .body select {
+ width: 180px;
+ padding: 0px;
+}
+
+.guest-edit-interface .action-area {
+ float: right;
+}
+
+.guest-edit-interface button {
+ width: 20px;
+ height: 20px;
+}
+
+.guest-edit-interface .header button {
+ margin-bottom: 1px;
+}
+
+.guest-edit-interface .body button:not(:last-child) {
+ margin-right: 2px;
+}
+
+.guest-edit-interface .hide {
+ display: none;
+}
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index e96a67a..71b552f 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -959,5 +959,60 @@ var kimchi = {
kimchi.message.error(data.responseJSON.reason);
}
});
+ },
+
+ getGuestInterfaces: function(name, suc, err) {
+ var url = kimchi.url+'vms/'+encodeURIComponent(name)+'/ifaces';
+ kimchi.requestJSON({
+ url : url,
+ type : 'GET',
+ contentType : 'application/json',
+ dataType : 'json',
+ success : suc,
+ error : err || function(data) {
+ kimchi.message.error(data.responseJSON.reason);
+ }
+ });
+ },
+
+ createGuestInterface : function(name, interface, suc, err) {
+ kimchi.requestJSON({
+ url : kimchi.url+'vms/'+encodeURIComponent(name)+'/ifaces',
+ type : 'POST',
+ contentType : 'application/json',
+ dataType : 'json',
+ data : JSON.stringify(interface),
+ success : suc,
+ error : err || function(data) {
+ kimchi.message.error(data.responseJSON.reason);
+ }
+ });
+ },
+
+ deleteGuestInterface : function(vm, mac, suc, err) {
+ kimchi.requestJSON({
+ url : kimchi.url+'vms/'+encodeURIComponent(vm)+'/ifaces/'+encodeURIComponent(mac),
+ type : 'DELETE',
+ contentType : 'application/json',
+ dataType : 'json',
+ success : suc,
+ error : err ? err : function(data) {
+ kimchi.message.error(data.responseJSON.reason);
+ }
+ });
+ },
+
+ updateGuestInterface : function(vm, mac, interface, suc, err) {
+ $.ajax({
+ url : kimchi.url+'vms/'+encodeURIComponent(vm)+'/ifaces/'+encodeURIComponent(mac),
+ type : 'PUT',
+ contentType : 'application/json',
+ data : JSON.stringify(interface),
+ dataType : 'json',
+ success: suc,
+ error: err ? err : function(data) {
+ kimchi.message.error(data.responseJSON.reason);
+ }
+ });
}
};
diff --git a/ui/js/src/kimchi.guest_edit_main.js b/ui/js/src/kimchi.guest_edit_main.js
index 9375c51..4337150 100644
--- a/ui/js/src/kimchi.guest_edit_main.js
+++ b/ui/js/src/kimchi.guest_edit_main.js
@@ -78,6 +78,94 @@ kimchi.guest_edit_main = function() {
});
};
+ var setupInterface = function() {
+ $(".add", "#form-guest-edit-interface").button({
+ icons: { primary: "ui-icon-plusthick" },
+ text: false
+ }).click(function(){
+ addItem({
+ mac: "",
+ network: "",
+ type: "network",
+ viewMode: "hide",
+ editMode: ""
+ });
+ });
+ var toggleEdit = function(item, on){
+ $("label", item).toggleClass("hide", on);
+ $("select", item).toggleClass("hide", !on);
+ $(".action-area", item).toggleClass("hide");
+ };
+ var addItem = function(data) {
+ var itemNode = $.parseHTML(kimchi.template($('#interface-tmpl').html(),data));
+ $(".body", "#form-guest-edit-interface").append(itemNode);
+ $("select", itemNode).append(networkOptions);
+ if(data.network!==""){
+ $("select", itemNode).val(data.network);
+ }
+ $(".edit", itemNode).button({
+ icons: { primary: "ui-icon-pencil" },
+ text: false
+ }).click(function(){
+ toggleEdit($(this).parent().parent(), true);
+ });
+ $(".delete", itemNode).button({
+ icons: { primary: "ui-icon-trash" },
+ text: false
+ }).click(function(){
+ var item = $(this).parent().parent();
+ kimchi.deleteGuestInterface(kimchi.selectedGuest, item.prop("id"), function(){
+ item.remove();
+ });
+ });
+ $(".save", itemNode).button({
+ icons: { primary: "ui-icon-disk" },
+ text: false
+ }).click(function(){
+ var item = $(this).parent().parent();
+ var interface = {
+ network: $("select", item).val(),
+ type: "network"
+ };
+ var postUpdate = function(){
+ $("label", item).text(interface.network);
+ toggleEdit(item, false);
+ };
+ if(item.prop("id")==""){
+ kimchi.createGuestInterface(kimchi.selectedGuest, interface, function(data){
+ item.prop("id", data.mac);
+ postUpdate();
+ });
+ }else{
+ kimchi.updateGuestInterface(kimchi.selectedGuest, item.prop("id"), interface, function(){
+ postUpdate();
+ });
+ }
+ });
+ $(".cancel", itemNode).button({
+ icons: { primary: "ui-icon-arrowreturnthick-1-w" },
+ text: false
+ }).click(function(){
+ var item = $(this).parent().parent();
+ $("label", item).text()==="" ? item.remove() : toggleEdit(item, false);
+ });
+ };
+ var networkOptions = "";
+ kimchi.listNetworks(function(data){
+ for(var i=0;i<data.length;i++){
+ var isSlected = i==0 ? " selected" : "";
+ networkOptions += "<option"+isSlected+">"+data[i].name+"</option>";
+ }
+ kimchi.getGuestInterfaces(kimchi.selectedGuest, function(data){
+ for(var i=0;i<data.length;i++){
+ data[i].viewMode = "";
+ data[i].editMode = "hide";
+ addItem(data[i]);
+ }
+ });
+ });
+ };
+
var initContent = function(guest) {
guest['icon'] = guest['icon'] || 'images/icon-vm.png';
for ( var prop in guest) {
@@ -101,6 +189,8 @@ kimchi.guest_edit_main = function() {
refreshCDROMs();
};
+ setupInterface();
+
kimchi.topic('kimchi/vmCDROMAttached').subscribe(onAttached);
kimchi.topic('kimchi/vmCDROMReplaced').subscribe(onReplaced);
kimchi.topic('kimchi/vmCDROMDetached').subscribe(onDetached);
diff --git a/ui/pages/guest-edit.html.tmpl b/ui/pages/guest-edit.html.tmpl
index 804fc39..d54b3ab 100644
--- a/ui/pages/guest-edit.html.tmpl
+++ b/ui/pages/guest-edit.html.tmpl
@@ -35,6 +35,9 @@
<li>
<a href="#form-guest-edit-storage">$_("Storage")</a>
</li>
+ <li>
+ <a href="#form-guest-edit-interface">$_("Interface")</a>
+ </li>
</ul>
<form id="form-guest-edit-general">
<fieldset class="guest-edit-fieldset">
@@ -103,6 +106,14 @@
</div>
</fieldset>
</form>
+ <form id="form-guest-edit-interface" class="guest-edit-interface">
+ <div class="header">
+ <span class="cell">$_("Network")</span>
+ <span class="cell">$_("Type")</span>
+ <button class="add action-area"></button>
+ </div>
+ <div class="body"></div>
+ </form>
</div>
</div>
<footer>
@@ -133,6 +144,23 @@
</div>
</div>
</script>
+<script id="interface-tmpl" type="text/html">
+ <div class="item" id="{mac}">
+ <span class="cell">
+ <label class="{viewMode}">{network}</label>
+ <select class="{editMode}"></select>
+ </span>
+ <span class="cell">
+ <span>{type}</span>
+ </span>
+ <span class="action-area {editMode}">
+ <button class="save"></button><button class="cancel"></button>
+ </span>
+ <span class="action-area {viewMode}">
+ <button class="edit"></button><button class="delete"></button>
+ </span>
+ <div>
+</script>
<script type="text/javascript">
kimchi.guest_edit_main();
--
1.7.1
10 years, 8 months
[PATCH V3 0/3] 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>
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 (3):
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
src/kimchi/i18n.py | 1 +
src/kimchi/model/utils.py | 41 ++++++++++++++++++++++++++++++
src/kimchi/model/vms.py | 65 +++++++++++++++++++++++------------------------
tests/test_model.py | 13 ++++++++++
4 files changed, 87 insertions(+), 33 deletions(-)
--
1.9.0
10 years, 8 months
[PATCH 0/2] add a smart way to get interface model
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
this patch depends on
[PATCH V3 0/3] bug fix: get user and group when VM is running
Also we should set the interface model into metadata when the user
change the model of interface.
not implement, for it depends on:
[PATCH 1/4] vmiface update support: update API.md
ShaoHe Feng (2):
add two moethod to get/set vm iface model in metadata
add a smart way to get interface model
src/kimchi/model/vmifaces.py | 47 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 45 insertions(+), 2 deletions(-)
--
1.9.0
10 years, 8 months
[PATCH V2 0/2] add a smart way to get interface model
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
V1 -> V2
fist choose model from iface metadata.
this patch depends on
[PATCH V5 0/3] bug fix: get user and group when VM is running
Also we should set the interface model into metadata when the user
change the model of interface.
not implement, for it depends on:
[PATCH V2 1/4] vmiface update support: update API.md
ShaoHe Feng (2):
add two moethod to get/set vm iface model in metadata
add a smart way to get interface model
src/kimchi/model/vmifaces.py | 50 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 48 insertions(+), 2 deletions(-)
--
1.9.0
10 years, 8 months
[PATCH 1/4] vmiface update support: update API.md
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
update API.md and API.json
Test this patch by:
$ curl -u <user>:<password> -H "Content-Type: application/json" \
> -H "Accept: application/json"
> http://localhost:8000/vms/<vmname>/ifaces/<mac> \
> -X PUT -d '
> {
> "model":"virtio",
> "network":"default"
> }'
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
docs/API.md | 8 ++++++++
src/kimchi/API.json | 17 +++++++++++++++++
src/kimchi/i18n.py | 1 +
3 files changed, 26 insertions(+)
diff --git a/docs/API.md b/docs/API.md
index 716c983..26a4937 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -220,6 +220,14 @@ A interface represents available network interface on VM.
* **DELETE**: detach the network interface from VM
+* **PUT**: update the parameters of existed VM interface.
+ * model *(optional)*: model of emulated network interface card. It will be one of these models:
+ ne2k_pci, i82551, i82557b, i82559er, rtl8139, e1000, pcnet and virtio.
+ This change is only on the persisted VM configuration.
+ * network *(optional)*: the name of resource network, only be available when the
+ interface type is network.
+ This change is on the active VM instance and persisted VM configuration.
+
**Actions (POST):**
*No actions defined*
diff --git a/src/kimchi/API.json b/src/kimchi/API.json
index 3360a9c..9ad8e9d 100644
--- a/src/kimchi/API.json
+++ b/src/kimchi/API.json
@@ -288,6 +288,23 @@
}
}
},
+ "vmiface_update": {
+ "type": "object",
+ "error": "KCHVMIF0008E",
+ "properties": {
+ "network": {
+ "description": "the name of one available network",
+ "minLength": 1,
+ "type": "string",
+ "error": "KCHVMIF0005E"
+ },
+ "model": {
+ "description": "model of emulated network interface card",
+ "enum": ["ne2k_pci", "i82551", "i82557b", "i82559er", "rtl8139", "e1000", "pcnet", "virtio", "spapr-vlan"],
+ "error": "KCHVMIF0006E"
+ }
+ }
+ },
"templates_create": {
"type": "object",
"error": "KCHTMPL0016E",
diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index 3fc3013..1a57bfd 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -94,6 +94,7 @@ messages = {
"KCHVMIF0005E": _("Network name for virtual machine interface must be a string"),
"KCHVMIF0006E": _("Invalid network model card specified for virtual machine interface"),
"KCHVMIF0007E": _("Specify type and network to add a new virtual machine interface"),
+ "KCHVMIF0008E": _("Specify type and network to update a virtual machine interface"),
"KCHTMPL0001E": _("Template %(name)s already exists"),
"KCHTMPL0002E": _("Template %(name)s does not exist"),
--
1.9.0
10 years, 8 months