[PATCH 5/6] Create VMs Asynchronously: Tests
by Christy Perez
Signed-off-by: Christy Perez <christy(a)linux.vnet.ibm.com>
---
tests/test_authorization.py | 23 +++++++++++-------
tests/test_mockmodel.py | 12 +++++++---
tests/test_model.py | 46 +++++++++++++++++++++++++----------
tests/test_rest.py | 58 ++++++++++++++++++++++++++++++++++-----------
4 files changed, 100 insertions(+), 39 deletions(-)
diff --git a/tests/test_authorization.py b/tests/test_authorization.py
index 4fcc496..eae837c 100644
--- a/tests/test_authorization.py
+++ b/tests/test_authorization.py
@@ -26,7 +26,7 @@
import kimchi.mockmodel
from iso_gen import construct_fake_iso
from utils import get_free_port, patch_auth, request
-from utils import run_server
+from utils import run_server, wait_task
test_server = None
@@ -118,19 +118,24 @@ def test_nonroot_access(self):
# Non-root users can only get vms authorized to them
model.templates_create({'name': u'test', 'cdrom': fake_iso})
- model.vms_create({'name': u'test-me', 'template': '/templates/test'})
+ task_info = model.vms_create({'name': u'test-me',
+ 'template': '/templates/test'})
+ wait_task(model.task_lookup, task_info['id'])
+
model.vm_update(u'test-me',
{'users': [kimchi.mockmodel.fake_user.keys()[0]],
'groups': []})
- model.vms_create({'name': u'test-usera',
- 'template': '/templates/test'})
+ task_info = model.vms_create({'name': u'test-usera',
+ 'template': '/templates/test'})
+ wait_task(model.task_lookup, task_info['id'])
non_root = list(set(model.users_get_list()) - set(['root']))[0]
model.vm_update(u'test-usera', {'users': [non_root], 'groups': []})
- model.vms_create({'name': u'test-groupa',
- 'template': '/templates/test'})
+ task_info = model.vms_create({'name': u'test-groupa',
+ 'template': '/templates/test'})
+ wait_task(model.task_lookup, task_info['id'])
a_group = model.groups_get_list()[0]
model.vm_update(u'test-groupa', {'groups': [a_group]})
@@ -143,9 +148,9 @@ def test_nonroot_access(self):
self.assertEquals(403, resp.status)
# Create a vm using mockmodel directly to test Resource access
- model.vms_create({'name': 'kimchi-test',
- 'template': '/templates/test'})
-
+ task_info = model.vms_create({'name': 'kimchi-test',
+ 'template': '/templates/test'})
+ wait_task(model.task_lookup, task_info['id'])
resp = self.request('/vms/kimchi-test', '{}', 'PUT')
self.assertEquals(403, resp.status)
resp = self.request('/vms/kimchi-test', '{}', 'DELETE')
diff --git a/tests/test_mockmodel.py b/tests/test_mockmodel.py
index aa48dd1..a731579 100644
--- a/tests/test_mockmodel.py
+++ b/tests/test_mockmodel.py
@@ -66,7 +66,9 @@ def test_screenshot_refresh(self):
req = json.dumps({'name': 'test', 'cdrom': fake_iso})
request(host, ssl_port, '/templates', req, 'POST')
req = json.dumps({'name': 'test-vm', 'template': '/templates/test'})
- request(host, ssl_port, '/vms', req, 'POST')
+ resp = request(host, ssl_port, '/vms', req, 'POST')
+ task = json.loads(resp.read())
+ wait_task(model.task_lookup, task['id'])
# Test screenshot refresh for running vm
request(host, ssl_port, '/vms/test-vm/start', '{}', 'POST')
@@ -94,7 +96,9 @@ def test_vm_list_sorted(self):
def add_vm(name):
# Create a VM
req = json.dumps({'name': name, 'template': '/templates/test'})
- request(host, ssl_port, '/vms', req, 'POST')
+ task = json.loads(request(host, ssl_port, '/vms', req,
+ 'POST').read())
+ wait_task(model.task_lookup, task['id'])
vms = [u'abc', u'bca', u'cab', u'xba']
for vm in vms:
@@ -106,7 +110,9 @@ def add_vm(name):
def test_vm_info(self):
model.templates_create({'name': u'test',
'cdrom': fake_iso})
- model.vms_create({'name': u'test-vm', 'template': '/templates/test'})
+ task = model.vms_create({'name': u'test-vm',
+ 'template': '/templates/test'})
+ wait_task(model.task_lookup, task['id'])
vms = model.vms_get_list()
self.assertEquals(2, len(vms))
self.assertIn(u'test-vm', vms)
diff --git a/tests/test_model.py b/tests/test_model.py
index ad0dccd..7e6090e 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -129,8 +129,11 @@ def test_vm_lifecycle(self):
rollback.prependDefer(inst.template_delete, 'test')
params = {'name': 'kimchi-vm', 'template': '/templates/test'}
- inst.vms_create(params)
+ task = inst.vms_create(params)
rollback.prependDefer(inst.vm_delete, 'kimchi-vm')
+ inst.task_wait(task['id'], 10)
+ task = inst.task_lookup(task['id'])
+ self.assertEquals('finished', task['status'])
vms = inst.vms_get_list()
self.assertTrue('kimchi-vm' in vms)
@@ -267,7 +270,8 @@ def test_image_based_template(self):
session.store('template', tmpl_name, tmpl_info)
params = {'name': 'kimchi-vm', 'template': '/templates/img-tmpl'}
- inst.vms_create(params)
+ task = inst.vms_create(params)
+ inst.task_wait(task['id'])
rollback.prependDefer(inst.vm_delete, 'kimchi-vm')
vms = inst.vms_get_list()
@@ -286,7 +290,8 @@ def test_vm_graphics(self):
inst.templates_create(params)
with RollbackContext() as rollback:
params = {'name': 'kimchi-vnc', 'template': '/templates/test'}
- inst.vms_create(params)
+ task1 = inst.vms_create(params)
+ inst.task_wait(task1['id'])
rollback.prependDefer(inst.vm_delete, 'kimchi-vnc')
info = inst.vm_lookup('kimchi-vnc')
@@ -296,7 +301,8 @@ def test_vm_graphics(self):
graphics = {'type': 'spice', 'listen': '127.0.0.1'}
params = {'name': 'kimchi-spice', 'template': '/templates/test',
'graphics': graphics}
- inst.vms_create(params)
+ task2 = inst.vms_create(params)
+ inst.task_wait(task2['id'])
rollback.prependDefer(inst.vm_delete, 'kimchi-spice')
info = inst.vm_lookup('kimchi-spice')
@@ -312,6 +318,10 @@ def test_vm_ifaces(self):
params = {'name': 'test', 'disks': [], 'cdrom': UBUNTU_ISO}
inst.templates_create(params)
rollback.prependDefer(inst.template_delete, 'test')
+ params = {'name': 'kimchi-ifaces', 'template': '/templates/test'}
+ task = inst.vms_create(params)
+ inst.task_wait(task['id'])
+ rollback.prependDefer(inst.vm_delete, 'kimchi-ifaces')
# Create a network
net_name = 'test-network'
@@ -422,7 +432,8 @@ def _attach_disk(expect_bus=modern_disk_bus):
inst.templates_create(params)
rollback.prependDefer(inst.template_delete, 'test')
params = {'name': vm_name, 'template': '/templates/test'}
- inst.vms_create(params)
+ task1 = inst.vms_create(params)
+ inst.task_wait(task1['id'])
rollback.prependDefer(inst.vm_delete, vm_name)
prev_count = len(inst.vmstorages_get_list(vm_name))
@@ -465,7 +476,8 @@ def _attach_disk(expect_bus=modern_disk_bus):
rollback.prependDefer(inst.template_delete, 'old_distro_template')
params = {'name': vm_name,
'template': '/templates/old_distro_template'}
- inst.vms_create(params)
+ task2 = inst.vms_create(params)
+ inst.task_wait(task2['id'])
rollback.prependDefer(inst.vm_delete, vm_name)
# Need to check the right disk_bus for old distro
@@ -486,7 +498,8 @@ def test_vm_cdrom(self):
inst.templates_create(params)
rollback.prependDefer(inst.template_delete, 'test')
params = {'name': vm_name, 'template': '/templates/test'}
- inst.vms_create(params)
+ task = inst.vms_create(params)
+ inst.task_wait(task['id'])
rollback.prependDefer(inst.vm_delete, vm_name)
prev_count = len(inst.vmstorages_get_list(vm_name))
@@ -575,7 +588,8 @@ def test_vm_storage_provisioning(self):
rollback.prependDefer(inst.template_delete, 'test')
params = {'name': 'test-vm-1', 'template': '/templates/test'}
- inst.vms_create(params)
+ task = inst.vms_create(params)
+ inst.task_wait(task['id'])
rollback.prependDefer(inst.vm_delete, 'test-vm-1')
vm_info = inst.vm_lookup(params['name'])
@@ -596,10 +610,12 @@ def test_vm_edit(self):
with RollbackContext() as rollback:
params_1 = {'name': 'kimchi-vm1', 'template': '/templates/test'}
params_2 = {'name': 'kimchi-vm2', 'template': '/templates/test'}
- inst.vms_create(params_1)
+ task1 = inst.vms_create(params_1)
+ inst.task_wait(task1['id'])
rollback.prependDefer(utils.rollback_wrapper, inst.vm_delete,
'kimchi-vm1')
- inst.vms_create(params_2)
+ task2 = inst.vms_create(params_2)
+ inst.task_wait(task2['id'])
rollback.prependDefer(utils.rollback_wrapper, inst.vm_delete,
'kimchi-vm2')
@@ -778,11 +794,13 @@ def test_delete_running_vm(self):
rollback.prependDefer(inst.template_delete, 'test')
params = {'name': u'kīмсhī-∨м', 'template': u'/templates/test'}
- inst.vms_create(params)
+ task = inst.vms_create(params)
+ inst.task_wait(task['id'])
rollback.prependDefer(utils.rollback_wrapper, inst.vm_delete,
u'kīмсhī-∨м')
inst.vm_start(u'kīмсhī-∨м')
+ self.assertEquals(inst.vm_lookup(u'kīмсhī-∨м')['state'], 'running')
rollback.prependDefer(utils.rollback_wrapper, inst.vm_poweroff,
u'kīмсhī-∨м')
@@ -801,7 +819,8 @@ def test_vm_list_sorted(self):
rollback.prependDefer(inst.template_delete, 'test')
params = {'name': 'kimchi-vm', 'template': '/templates/test'}
- inst.vms_create(params)
+ task = inst.vms_create(params)
+ inst.task_wait(task['id'])
rollback.prependDefer(inst.vm_delete, 'kimchi-vm')
vms = inst.vms_get_list()
@@ -873,7 +892,8 @@ def test_use_test_host(self):
params = {'name': 'kimchi-vm',
'template': '/templates/test'}
- inst.vms_create(params)
+ task = inst.vms_create(params)
+ inst.task_wait(task['id'])
rollback.prependDefer(inst.vm_delete, 'kimchi-vm')
vms = inst.vms_get_list()
diff --git a/tests/test_rest.py b/tests/test_rest.py
index 65c3db5..8826424 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -112,7 +112,9 @@ def test_get_vms(self):
req = json.dumps({'name': name, 'template': '/templates/test',
'users': test_users, 'groups': test_groups})
resp = self.request('/vms', req, 'POST')
- self.assertEquals(201, resp.status)
+ self.assertEquals(202, resp.status)
+ task = json.loads(resp.read())
+ wait_task(self._task_lookup, task['id'])
vms = json.loads(self.request('/vms').read())
self.assertEquals(11, len(vms))
@@ -130,7 +132,9 @@ def test_edit_vm(self):
req = json.dumps({'name': 'vm-1', 'template': '/templates/test'})
resp = self.request('/vms', req, 'POST')
- self.assertEquals(201, resp.status)
+ self.assertEquals(202, resp.status)
+ task = json.loads(resp.read())
+ wait_task(self._task_lookup, task['id'])
vm = json.loads(self.request('/vms/vm-1').read())
self.assertEquals('vm-1', vm['name'])
@@ -247,7 +251,9 @@ def test_vm_lifecycle(self):
# Create a VM
req = json.dumps({'name': 'test-vm', 'template': '/templates/test'})
resp = self.request('/vms', req, 'POST')
- self.assertEquals(201, resp.status)
+ task = json.loads(resp.read())
+ wait_task(self._task_lookup, task['id'])
+ self.assertEquals(202, resp.status)
# Verify the VM
vm = json.loads(self.request('/vms/test-vm').read())
@@ -429,7 +435,9 @@ def test_vm_graphics(self):
# Create a VM with default args
req = json.dumps({'name': 'test-vm', 'template': '/templates/test'})
resp = self.request('/vms', req, 'POST')
- self.assertEquals(201, resp.status)
+ self.assertEquals(202, resp.status)
+ task = json.loads(resp.read())
+ wait_task(self._task_lookup, task['id'])
# Verify the VM
vm = json.loads(self.request('/vms/test-vm').read())
self.assertEquals('127.0.0.1', vm['graphics']['listen'])
@@ -443,7 +451,9 @@ def test_vm_graphics(self):
req = json.dumps({'name': 'test-vm', 'template': '/templates/test',
'graphics': graphics})
resp = self.request('/vms', req, 'POST')
- self.assertEquals(201, resp.status)
+ self.assertEquals(202, resp.status)
+ task = json.loads(resp.read())
+ wait_task(self._task_lookup, task['id'])
# Verify the VM
vm = json.loads(self.request('/vms/test-vm').read())
self.assertEquals('127.0.0.1', vm['graphics']['listen'])
@@ -457,7 +467,9 @@ def test_vm_graphics(self):
req = json.dumps({'name': 'test-vm', 'template': '/templates/test',
'graphics': graphics})
resp = self.request('/vms', req, 'POST')
- self.assertEquals(201, resp.status)
+ self.assertEquals(202, resp.status)
+ task = json.loads(resp.read())
+ wait_task(self._task_lookup, task['id'])
# Verify the VM
vm = json.loads(self.request('/vms/test-vm').read())
self.assertEquals('fe00::0', vm['graphics']['listen'])
@@ -471,7 +483,9 @@ def test_vm_graphics(self):
req = json.dumps({'name': 'test-vm', 'template': '/templates/test',
'graphics': graphics})
resp = self.request('/vms', req, 'POST')
- self.assertEquals(201, resp.status)
+ self.assertEquals(202, resp.status)
+ task = json.loads(resp.read())
+ wait_task(self._task_lookup, task['id'])
# Verify the VM
vm = json.loads(self.request('/vms/test-vm').read())
self.assertEquals('127.0.0.1', vm['graphics']['listen'])
@@ -513,7 +527,9 @@ def test_vm_storage_devices(self):
req = json.dumps({'name': 'test-vm',
'template': '/templates/test'})
resp = self.request('/vms', req, 'POST')
- self.assertEquals(201, resp.status)
+ self.assertEquals(202, resp.status)
+ task = json.loads(resp.read())
+ wait_task(self._task_lookup, task['id'])
# Delete the VM
rollback.prependDefer(self.request,
'/vms/test-vm', '{}', 'DELETE')
@@ -658,7 +674,9 @@ def test_vm_iface(self):
req = json.dumps({'name': 'test-vm',
'template': '/templates/test'})
resp = self.request('/vms', req, 'POST')
- self.assertEquals(201, resp.status)
+ self.assertEquals(202, resp.status)
+ task = json.loads(resp.read())
+ wait_task(self._task_lookup, task['id'])
# Delete the VM
rollback.prependDefer(self.request,
'/vms/test-vm', '{}', 'DELETE')
@@ -738,7 +756,10 @@ def test_vm_customise_storage(self):
req = json.dumps({'name': 'test-vm', 'template': '/templates/test',
'storagepool': '/storagepools/alt'})
resp = self.request('/vms', req, 'POST')
- self.assertEquals(201, resp.status)
+ self.assertEquals(202, resp.status)
+ task = json.loads(resp.read())
+ wait_task(self._task_lookup, task['id'])
+ resp = self.request('/vms/test-vm', {}, 'GET')
vm_info = json.loads(resp.read())
# Test template not changed after vm customise its pool
@@ -791,7 +812,9 @@ def test_scsi_fc_storage(self):
req = json.dumps({'name': 'test-vm',
'template': '/templates/test_fc_pool'})
resp = self.request('/vms', req, 'POST')
- self.assertEquals(201, resp.status)
+ self.assertEquals(202, resp.status)
+ task = json.loads(resp.read())
+ wait_task(self._task_lookup, task['id'])
# Start the VM
resp = self.request('/vms/test-vm/start', '{}', 'POST')
@@ -816,8 +839,10 @@ def test_unnamed_vms(self):
# Create 5 unnamed vms from this template
for i in xrange(1, 6):
req = json.dumps({'template': '/templates/test'})
- vm = json.loads(self.request('/vms', req, 'POST').read())
- self.assertEquals('test-vm-%i' % i, vm['name'])
+ task = json.loads(self.request('/vms', req, 'POST').read())
+ wait_task(self._task_lookup, task['id'])
+ resp = self.request('/vms/test-vm-%i' % i, {}, 'GET')
+ self.assertEquals(resp.status, 200)
count = len(json.loads(self.request('/vms').read()))
self.assertEquals(6, count)
@@ -849,7 +874,10 @@ def test_create_vm_with_img_based_template(self):
self.assertEquals(201, resp.status)
req = json.dumps({'template': '/templates/test'})
- json.loads(self.request('/vms', req, 'POST').read())
+ resp = self.request('/vms', req, 'POST')
+ self.assertEquals(202, resp.status)
+ task = json.loads(resp.read())
+ wait_task(self._task_lookup, task['id'])
# Test storage volume created with backing store of base file
resp = json.loads(
@@ -939,6 +967,8 @@ def test_screenshot_refresh(self):
resp = self.request('/templates', req, 'POST')
req = json.dumps({'name': 'test-vm', 'template': '/templates/test'})
resp = self.request('/vms', req, 'POST')
+ task = json.loads(resp.read())
+ wait_task(self._task_lookup, task['id'])
# Test screenshot for shut-off state vm
resp = self.request('/vms/test-vm/screenshot')
--
2.1.0
9 years, 7 months
[PATCH 1/6] Append clone to target_uri for vm clone task
by Christy Perez
So that we can differentiate between clone and create tasks for
VMs.
Signed-off-by: Christy Perez <christy(a)linux.vnet.ibm.com>
---
src/kimchi/model/vms.py | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
index a6ca27b..5f8c3da 100644
--- a/src/kimchi/model/vms.py
+++ b/src/kimchi/model/vms.py
@@ -229,9 +229,8 @@ def clone(self, name):
new_name = get_next_clone_name(current_vm_names, name)
# create a task with the actual clone function
- taskid = add_task(u'/vms/%s' % new_name, self._clone_task,
- self.objstore,
- {'name': name, 'new_name': new_name})
+ taskid = add_task(u'/vms/%s/clone' % new_name, self._clone_task,
+ self.objstore, {'name': name, 'new_name': new_name})
return self.task.lookup(taskid)
--
2.1.0
9 years, 7 months
[PATCH v6 0/6] Async VM Creation
by Christy Perez
v6 Changes:
- Rebase
v5 Changes:
- Rebase
- Remove all the unimperative target_uri changes (see below)
If a guest has a large disk, and uses a filesystem that requires
preallocation, it can take several minutes to create a VM. During that
time, kimchi is tied up by the VM creation.
This patch changes the VMs Collection to be an AsyncCollection.
Another change required for this was to create a more granular way to
query vm-related tasks. The original idea was to add another field to the
task database, but then Aline suggested just modifying the task_uri. Since
the task_uri cretation will be changed in a future patchset, this is
now only modified for the conflicting (clone) tasks.
Christy Perez (6):
Append clone to target_uri for vm clone task
Tests for new clone target_uri
UI changes for new clone target_uri
Create VMs asynchronously: Backend
Create VMs Asynchronously: Tests
Create VMs Asynchronously: UI
src/kimchi/control/vms.py | 4 +--
src/kimchi/model/vms.py | 32 +++++++++++++++++----
tests/test_authorization.py | 23 +++++++++------
tests/test_mockmodel.py | 12 ++++++--
tests/test_model.py | 50 ++++++++++++++++++++++----------
tests/test_model_storagevolume.py | 2 +-
tests/test_rest.py | 60 +++++++++++++++++++++++++++++----------
ui/css/theme-default/list.css | 18 ++++++++++++
ui/js/src/kimchi.guest_main.js | 29 +++++++++++++++----
ui/pages/guest.html.tmpl | 3 ++
10 files changed, 177 insertions(+), 56 deletions(-)
--
2.1.0
9 years, 7 months
[PATCH 6/6] Create VMs Asynchronously: UI
by Christy Perez
Signed-off-by: Christy Perez <christy(a)linux.vnet.ibm.com>
---
ui/css/theme-default/list.css | 18 ++++++++++++++++++
ui/js/src/kimchi.guest_main.js | 25 ++++++++++++++++++++++---
ui/pages/guest.html.tmpl | 3 +++
3 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/ui/css/theme-default/list.css b/ui/css/theme-default/list.css
index 7b32ea6..62d1539 100644
--- a/ui/css/theme-default/list.css
+++ b/ui/css/theme-default/list.css
@@ -306,3 +306,21 @@
margin-left: 5px;
text-shadow: -1px -1px 1px #CCCCCC, 1px 1px 1px #FFFFFF;
}
+
+.guest-create {
+ margin: 10px;
+}
+
+.guest-create .icon {
+ background: url('../../images/theme-default/kimchi-loading15x15.gif') no-repeat;
+ display: inline-block;
+ width: 20px;
+ height: 20px;
+ vertical-align: middle;
+}
+
+.guest-create .text {
+ color: #666666;
+ margin-left: 5px;
+ text-shadow: -1px -1px 1px #CCCCCC, 1px 1px 1px #FFFFFF;
+}
diff --git a/ui/js/src/kimchi.guest_main.js b/ui/js/src/kimchi.guest_main.js
index c712bb4..dbcc162 100644
--- a/ui/js/src/kimchi.guest_main.js
+++ b/ui/js/src/kimchi.guest_main.js
@@ -201,6 +201,21 @@ kimchi.listVmsAuto = function() {
if (kimchi.vmTimeout) {
clearTimeout(kimchi.vmTimeout);
}
+ var getCreatingGuests = function(){
+ var guests = [];
+ kimchi.getTasksByFilter('status=running&target_uri='+encodeURIComponent('^/vms/[^/]+$'), function(tasks) {
+ for(var i=0;i<tasks.length;i++){
+ var guestUri = tasks[i].target_uri;
+ var guestName = guestUri.split('/')[1]
+ guests.push($.extend({}, kimchi.sampleGuestObject, {name: guestName, isCreating: true}));
+ if(kimchi.trackingTasks.indexOf(tasks[i].id)==-1)
+ kimchi.trackTask(tasks[i].id, null, function(err){
+ kimchi.message.error(err.message);
+ }, null);
+ }
+ }, null, true);
+ return guests;
+ };
var getCloningGuests = function(){
var guests = [];
kimchi.getTasksByFilter('status=running&target_uri='+encodeURIComponent('^/vms/.+/clone'), function(tasks) {
@@ -219,6 +234,7 @@ kimchi.listVmsAuto = function() {
kimchi.listVMs(function(result, textStatus, jqXHR) {
if (result && textStatus=="success") {
result = getCloningGuests().concat(result);
+ result = getCreatingGuests().concat(result);
if(result.length) {
var listHtml = '';
var guestTemplate = kimchi.guestTemplate;
@@ -281,7 +297,7 @@ kimchi.createGuestLi = function(vmObject, prevScreenImage, openMenu) {
imgLoad.attr('src',load_src);
//Link the stopped tile to the start action, the running tile to open the console
- if(!vmObject.isCloning){
+ if(!(vmObject.isCloning || vmObject.isCreating)){
if (vmRunningBool) {
liveTile.off("click", kimchi.vmstart);
liveTile.on("click", kimchi.openVmConsole);
@@ -329,7 +345,7 @@ kimchi.createGuestLi = function(vmObject, prevScreenImage, openMenu) {
}
//Setup action event handlers
- if(!vmObject.isCloning){
+ if(!(vmObject.isCloning || vmObject.isCreating)){
guestActions.find("[name=vm-start]").on({click : kimchi.vmstart});
guestActions.find("[name=vm-poweroff]").on({click : kimchi.vmpoweroff});
if (vmRunningBool) { //If the guest is not running, do not enable reset
@@ -362,7 +378,10 @@ kimchi.createGuestLi = function(vmObject, prevScreenImage, openMenu) {
}else{
guestActions.find('.btn').attr('disabled', true);
- result.find('.guest-clone').removeClass('hide-content');
+ if(vmObject.isCloning)
+ result.find('.guest-clone').removeClass('hide-content');
+ else
+ result.find('.guest-create').removeClass('hide-content');
$('.popover', guestActions.find("div[name=actionmenu]")).remove();
}
diff --git a/ui/pages/guest.html.tmpl b/ui/pages/guest.html.tmpl
index 17d41ac..aaf41a2 100644
--- a/ui/pages/guest.html.tmpl
+++ b/ui/pages/guest.html.tmpl
@@ -29,6 +29,9 @@
<div class="guest-clone hide-content">
<span class="icon"></span><span class="text">$_("Cloning")...</span>
</div>
+ <div class="guest-create hide-content">
+ <span class="icon"></span><span class="text">$_("Creating")...</span>
+ </div>
</div>
<div name="cpu_utilization" class="sortable">
<div class="circleGauge"></div>
--
2.1.0
9 years, 7 months
[PATCH 4/6] Create VMs asynchronously: Backend
by Christy Perez
Signed-off-by: Christy Perez <christy(a)linux.vnet.ibm.com>
---
src/kimchi/control/vms.py | 4 ++--
src/kimchi/model/vms.py | 27 ++++++++++++++++++++++++---
2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/src/kimchi/control/vms.py b/src/kimchi/control/vms.py
index 6352a26..a40b56e 100644
--- a/src/kimchi/control/vms.py
+++ b/src/kimchi/control/vms.py
@@ -17,13 +17,13 @@
# 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 kimchi.control.base import Collection, Resource
+from kimchi.control.base import AsyncCollection, Resource
from kimchi.control.utils import internal_redirect, UrlSubNode
from kimchi.control.vm import sub_nodes
@UrlSubNode('vms', True)
-class VMs(Collection):
+class VMs(AsyncCollection):
def __init__(self, model):
super(VMs, self).__init__(model)
self.resource = VM
diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
index 5f8c3da..9786063 100644
--- a/src/kimchi/model/vms.py
+++ b/src/kimchi/model/vms.py
@@ -79,9 +79,9 @@ def __init__(self, **kargs):
self.conn = kargs['conn']
self.objstore = kargs['objstore']
self.caps = CapabilitiesModel(**kargs)
+ self.task = TaskModel(**kargs)
def create(self, params):
- conn = self.conn.get()
t_name = template_name_from_uri(params['template'])
vm_uuid = str(uuid.uuid4())
vm_list = self.get_list()
@@ -102,7 +102,26 @@ def create(self, params):
raise InvalidOperation("KCHVM0005E")
t.validate()
+ taskid = add_task(u'/vms/%s' % name,
+ self._create_task, self.objstore,
+ {'vm_uuid': vm_uuid, 'template': t, 'name': name})
+
+ return self.task.lookup(taskid)
+
+ def _create_task(self, cb, params):
+ """
+ params: A dict with the following values:
+ - vm_uuid: The UUID of the VM being created
+ - template: The template being used to create the VM
+ - name: The name for the new VM
+ """
+
+ vm_uuid = params['vm_uuid']
+ t = params['template']
+ name = params['name']
+ conn = self.conn.get()
+ cb('Storing VM icon')
# Store the icon for displaying later
icon = t.info.get('icon')
if icon:
@@ -117,6 +136,7 @@ def create(self, params):
# If storagepool is SCSI, volumes will be LUNs and must be passed by
# the user from UI or manually.
+ cb('Provisioning storage for new VM')
vol_list = []
if t._get_storage_type() not in ["iscsi", "scsi"]:
vol_list = t.fork_vm_storage(vm_uuid)
@@ -128,6 +148,7 @@ def create(self, params):
graphics=graphics,
volumes=vol_list)
+ cb('Defining new VM')
try:
conn.defineXML(xml.encode('utf-8'))
except libvirt.libvirtError as e:
@@ -138,10 +159,10 @@ def create(self, params):
raise OperationFailed("KCHVM0007E", {'name': name,
'err': e.get_error_message()})
+ cb('Updating VM metadata')
VMModel.vm_update_os_metadata(VMModel.get_vm(name, self.conn), t.info,
self.caps.metadata_support)
-
- return name
+ cb('OK', True)
def get_list(self):
return VMsModel.get_vms(self.conn)
--
2.1.0
9 years, 7 months
[PATCH 3/6] UI changes for new clone target_uri
by Christy Perez
Signed-off-by: Christy Perez <christy(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.guest_main.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ui/js/src/kimchi.guest_main.js b/ui/js/src/kimchi.guest_main.js
index b66177c..c712bb4 100644
--- a/ui/js/src/kimchi.guest_main.js
+++ b/ui/js/src/kimchi.guest_main.js
@@ -203,10 +203,10 @@ kimchi.listVmsAuto = function() {
}
var getCloningGuests = function(){
var guests = [];
- kimchi.getTasksByFilter('status=running&target_uri='+encodeURIComponent('^/vms/*'), function(tasks) {
+ kimchi.getTasksByFilter('status=running&target_uri='+encodeURIComponent('^/vms/.+/clone'), function(tasks) {
for(var i=0;i<tasks.length;i++){
var guestUri = tasks[i].target_uri;
- var guestName = guestUri.substring(guestUri.lastIndexOf('/')+1, guestUri.length);
+ var guestName = guestUri.split('/')[2]
guests.push($.extend({}, kimchi.sampleGuestObject, {name: guestName, isCloning: true}));
if(kimchi.trackingTasks.indexOf(tasks[i].id)==-1)
kimchi.trackTask(tasks[i].id, null, function(err){
--
2.1.0
9 years, 7 months
[PATCH v5 0/6] Async VM Creation
by Christy Perez
v5 Changes:
- Rebase
- Remove all the unimperative target_uri changes (see below)
If a guest has a large disk, and uses a filesystem that requires
preallocation, it can take several minutes to create a VM. During that
time, kimchi is tied up by the VM creation.
This patch changes the VMs Collection to be an AsyncCollection.
Another change required for this was to create a more granular way to
query vm-related tasks. The original idea was to add another field to the
task database, but then Aline suggested just modifying the task_uri. Since
the task_uri cretation will be changed in a future patchset, this is
now only modified for the conflicting (clone) tasks.
Christy Perez (6):
Append clone to target_uri for vm clone task
Tests for new clone target_uri
UI changes for new clone target_uri
Create VMs asynchronously: Backend
Create VMs Asynchronously: Tests
Create VMs Asynchronously: UI
src/kimchi/control/vms.py | 4 +--
src/kimchi/model/vms.py | 32 +++++++++++++++++----
tests/test_authorization.py | 23 +++++++++------
tests/test_mockmodel.py | 12 ++++++--
tests/test_model.py | 49 +++++++++++++++++++++-----------
tests/test_model_storagevolume.py | 2 +-
tests/test_rest.py | 60 +++++++++++++++++++++++++++++----------
ui/css/theme-default/list.css | 18 ++++++++++++
ui/js/src/kimchi.guest_main.js | 29 +++++++++++++++----
ui/pages/guest.html.tmpl | 3 ++
10 files changed, 175 insertions(+), 57 deletions(-)
--
2.1.0
9 years, 7 months
[PATCH] Improve code to retrieve the number of host CPUs
by Jose Ricardo Ziviani
- Retrieving the number of cpus using psinfo is unstable, there
are three (at least) different ways to do it that changes from
version to version. This code improves the way such functions
are called to avoid any surprise in future.
Signed-off-by: Jose Ricardo Ziviani <joserz(a)linux.vnet.ibm.com>
---
src/kimchi/model/host.py | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/kimchi/model/host.py b/src/kimchi/model/host.py
index 293c4ce..b2fa379 100644
--- a/src/kimchi/model/host.py
+++ b/src/kimchi/model/host.py
@@ -102,15 +102,20 @@ class HostModel(object):
return res
def lookup(self, *name):
- cpus = 0
+ cpus = psutil.NUM_CPUS
- # Only newer psutil versions have a portable method to get
- # the number of cpus
- try:
+ # psutil is unstable on how to get the number of
+ # cpus, different versions call it differently
+ if hasattr(psutil, 'cpu_count'):
cpus = psutil.cpu_count()
- except AttributeError:
- cpus = psutil._psplatform.get_num_cpus()
+ elif hasattr(psutil, '_psplatform'):
+ for method_name in ['_get_num_cpus', 'get_num_cpus']:
+
+ method = getattr(psutil._psplatform, method_name, None)
+ if method is not None:
+ cpus = method()
+ break
self.host_info['cpus'] = cpus
self.host_info['memory'] = psutil.phymem_usage().total
--
1.9.1
9 years, 7 months
[PATCH] Move kimchi nginx config file to nginx default directory.
by Jose Ricardo Ziviani
- Move Kimchi nginx config file to /etc/nginx/conf.d.
- Rename nginx_kimchi.conf to kimchi.conf.
---
.gitignore | 2 +-
configure.ac | 1 +
contrib/kimchi.spec.fedora.in | 6 ++--
contrib/kimchi.spec.suse.in | 7 ++--
src/Makefile.am | 5 ++-
src/kimchi/config.py.in | 2 ++
src/kimchi/proxy.py | 12 +++----
src/nginx.conf.in | 76 -------------------------------------------
src/nginx/Makefile.am | 23 +++++++++++++
src/nginx/kimchi.conf.in | 76 +++++++++++++++++++++++++++++++++++++++++++
10 files changed, 119 insertions(+), 91 deletions(-)
delete mode 100644 src/nginx.conf.in
create mode 100644 src/nginx/Makefile.am
create mode 100644 src/nginx/kimchi.conf.in
diff --git a/.gitignore b/.gitignore
index 4abfc0a..a318bd9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,7 +28,7 @@ stamp-po
kimchi-*.tar.gz
src/kimchid
src/kimchi.conf
-src/nginx_kimchi.conf
+src/nginx/kimchi.conf
src/kimchi/config.py
tests/run_tests.sh
tests/test_config.py
diff --git a/configure.ac b/configure.ac
index 1b476c3..5da3240 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,6 +80,7 @@ AC_CONFIG_FILES([
docs/Makefile
src/Makefile
src/distros.d/Makefile
+ src/nginx/Makefile
src/kimchi/Makefile
src/kimchi/control/Makefile
src/kimchi/control/vm/Makefile
diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in
index 750dada..a721a7f 100644
--- a/contrib/kimchi.spec.fedora.in
+++ b/contrib/kimchi.spec.fedora.in
@@ -94,7 +94,7 @@ touch %{buildroot}/%{_localstatedir}/log/kimchi/kimchi-error.log
# create /etc/kimchi structure
mkdir -p %{buildroot}/%{_sysconfdir}/kimchi/
-touch %{buildroot}/%{_sysconfdir}/kimchi/nginx_kimchi.conf
+touch %{buildroot}/%{_sysconfdir}/nginx/conf.d/kimchi.conf
# Install the systemd scripts
install -Dm 0644 contrib/kimchid.service.fedora %{buildroot}%{_unitdir}/kimchid.service
@@ -158,14 +158,14 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/kimchi/config/ui/*.xml
%{_datadir}/kimchi/ui/
%{_datadir}/kimchi
+%{_sysconfdir}/nginx/conf.d/kimchi.conf.in
+%{_sysconfdir}/nginx/conf.d/kimchi.conf
%{_sysconfdir}/kimchi/kimchi.conf
-%{_sysconfdir}/kimchi/nginx.conf.in
%{_sysconfdir}/kimchi/distros.d/debian.json
%{_sysconfdir}/kimchi/distros.d/fedora.json
%{_sysconfdir}/kimchi/distros.d/opensuse.json
%{_sysconfdir}/kimchi/distros.d/ubuntu.json
%{_sysconfdir}/kimchi/distros.d/gentoo.json
-%{_sysconfdir}/kimchi/nginx_kimchi.conf
%{_sysconfdir}/kimchi/
%{_sharedstatedir}/kimchi/debugreports/
%{_sharedstatedir}/kimchi/screenshots/
diff --git a/contrib/kimchi.spec.suse.in b/contrib/kimchi.spec.suse.in
index 7e4172d..5673ced 100644
--- a/contrib/kimchi.spec.suse.in
+++ b/contrib/kimchi.spec.suse.in
@@ -63,7 +63,9 @@ touch %{buildroot}/%{_localstatedir}/log/kimchi/kimchi-error.log
# create /etc/kimchi structure
mkdir -p %{buildroot}/%{_sysconfdir}/kimchi/
-touch %{buildroot}/%{_sysconfdir}/kimchi/nginx_kimchi.conf
+
+# create nginx configuration
+touch %{buildroot}/%{_sysconfdir}/nginx/conf.d/kimchi.conf
# Install the SysV init scripts
install -Dm 0755 contrib/kimchid.sysvinit %{buildroot}%{_initrddir}/kimchid
@@ -97,13 +99,14 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/kimchi/config/ui/*.xml
%{_datadir}/kimchi/ui/
%{_datadir}/kimchi
+%{_sysconfdir}/nginx/conf.d/kimchi.conf.in
+%{_sysconfdir}/nginx/conf.d/kimchi.conf
%{_sysconfdir}/kimchi/kimchi.conf
%{_sysconfdir}/kimchi/distros.d/debian.json
%{_sysconfdir}/kimchi/distros.d/fedora.json
%{_sysconfdir}/kimchi/distros.d/opensuse.json
%{_sysconfdir}/kimchi/distros.d/ubuntu.json
%{_sysconfdir}/kimchi/distros.d/gentoo.json
-%{_sysconfdir}/kimchi/nginx_kimchi.conf
%{_sysconfdir}/kimchi
%{_initrddir}/kimchid
%{_sysconfdir}/kimchi/
diff --git a/src/Makefile.am b/src/Makefile.am
index dfeb24e..edc163e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,18 +17,17 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-SUBDIRS = kimchi distros.d
+SUBDIRS = kimchi distros.d nginx
EXTRA_DIST = kimchid.in \
kimchi.conf.in \
- nginx.conf.in \
firewalld.xml \
$(NULL)
bin_SCRIPTS = kimchid
confdir = $(sysconfdir)/kimchi
-dist_conf_DATA = kimchi.conf nginx.conf.in
+dist_conf_DATA = kimchi.conf
BUILT_SOURCES = kimchi.conf
diff --git a/src/kimchi/config.py.in b/src/kimchi/config.py.in
index f2e1cac..f15d228 100644
--- a/src/kimchi/config.py.in
+++ b/src/kimchi/config.py.in
@@ -112,6 +112,7 @@ class Paths(object):
self.novnc_dir = '/usr/share/novnc'
if self.installed:
+ self.nginx_conf_dir = '@sysconfdir(a)/nginx/conf.d'
self.state_dir = '@localstatedir@/lib/kimchi'
self.log_dir = '@localstatedir@/log/kimchi'
self.conf_dir = '@sysconfdir@/kimchi'
@@ -120,6 +121,7 @@ class Paths(object):
self.mo_dir = '@prefix@/share/locale'
self.spice_css_file = os.path.join(self.spice_dir, 'spice.css')
else:
+ self.nginx_conf_dir = self.add_prefix('src/nginx')
self.state_dir = self.add_prefix('data')
self.log_dir = self.add_prefix('log')
self.conf_dir = self.add_prefix('src')
diff --git a/src/kimchi/proxy.py b/src/kimchi/proxy.py
index fafa5bc..1b70d5e 100644
--- a/src/kimchi/proxy.py
+++ b/src/kimchi/proxy.py
@@ -37,8 +37,7 @@ def _create_proxy_config(options):
To allow flexibility in which port kimchi runs, we need the same
flexibility with the nginx proxy. This method creates the config
file dynamically by using 'nginx.conf.in' as a template, creating
- the file 'nginx_kimchi.config' which will be used to launch the
- proxy.
+ the file 'kimchi.conf' which will be used to launch the proxy.
Arguments:
options - OptionParser object with Kimchi config options
@@ -53,6 +52,7 @@ def _create_proxy_config(options):
user_proxy = 'www-data'
config_dir = paths.conf_dir
+ nginx_config_dir = paths.nginx_conf_dir
cert = options.ssl_cert
key = options.ssl_key
@@ -70,7 +70,7 @@ def _create_proxy_config(options):
# Read template file and create a new config file
# with the specified parameters.
- with open(os.path.join(config_dir, "nginx.conf.in")) as template:
+ with open(os.path.join(nginx_config_dir, "kimchi.conf.in")) as template:
data = template.read()
data = Template(data)
data = data.safe_substitute(user=user_proxy,
@@ -81,7 +81,7 @@ def _create_proxy_config(options):
max_body_size=eval(options.max_body_size))
# Write file to be used for nginx.
- config_file = open(os.path.join(config_dir, "nginx_kimchi.conf"), "w")
+ config_file = open(os.path.join(nginx_config_dir, "kimchi.conf"), "w")
config_file.write(data)
config_file.close()
@@ -89,8 +89,8 @@ def _create_proxy_config(options):
def start_proxy(options):
"""Start nginx reverse proxy."""
_create_proxy_config(options)
- config_dir = paths.conf_dir
- config_file = "%s/nginx_kimchi.conf" % config_dir
+ nginx_config_dir = paths.nginx_conf_dir
+ config_file = "%s/kimchi.conf" % nginx_config_dir
cmd = ['nginx', '-c', config_file]
subprocess.call(cmd)
diff --git a/src/nginx.conf.in b/src/nginx.conf.in
deleted file mode 100644
index e308152..0000000
--- a/src/nginx.conf.in
+++ /dev/null
@@ -1,76 +0,0 @@
-# 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
-
-# This is a template file to be used to generate a nginx
-# proxy config file at kimchid script.
-
-user ${user};
-worker_processes 1;
-
-error_log /var/log/nginx/error.log;
-
-events {
- worker_connections 1024;
-}
-
-http {
-
- log_format main '$remote_addr - $remote_user [$time_local] "$request" '
- '$status $body_bytes_sent "$http_referer" '
- '"$http_user_agent" "$http_x_forwarded_for"';
-
- access_log /var/log/nginx/access.log main;
- sendfile on;
-
- client_max_body_size ${max_body_size}k;
-
- # Timeout set to 10 minutes to avoid the 504 Gateway Timeout
- # when Kimchi is processing a request.
- proxy_connect_timeout 600;
- proxy_send_timeout 600;
- proxy_read_timeout 600;
- send_timeout 600;
-
- server {
- listen ${proxy_ssl_port} ssl;
-
- ssl_certificate ${cert_pem};
- ssl_certificate_key ${cert_key};
- ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
- ssl_ciphers ECDH@STRENGTH:DH@STRENGTH:HIGH:!RC4:!MD5:!DES:!aNULL:!eNULL;
-
- add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
- add_header X-Frame-Options DENY;
- add_header X-Content-Type-Options nosniff;
- add_header X-XSS-Protection "1; mode=block";
-
- location / {
- proxy_pass http://127.0.0.1:${kimchid_port};
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_redirect http://127.0.0.1:${kimchid_port}/ https://$host:${proxy_ssl_port}/;
- }
- }
-
- server {
- listen ${proxy_port};
- rewrite ^/(.*)$ https://$host:${proxy_ssl_port}/$1 redirect;
- }
-}
diff --git a/src/nginx/Makefile.am b/src/nginx/Makefile.am
new file mode 100644
index 0000000..b240508
--- /dev/null
+++ b/src/nginx/Makefile.am
@@ -0,0 +1,23 @@
+#
+# Kimchi
+#
+# Copyright IBM Corp, 2013
+#
+# 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
+
+EXTRA_DIST = kimchi.conf.in
+
+confdir = $(sysconfdir)/nginx/conf.d
+dist_conf_DATA = kimchi.conf.in
diff --git a/src/nginx/kimchi.conf.in b/src/nginx/kimchi.conf.in
new file mode 100644
index 0000000..e308152
--- /dev/null
+++ b/src/nginx/kimchi.conf.in
@@ -0,0 +1,76 @@
+# 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
+
+# This is a template file to be used to generate a nginx
+# proxy config file at kimchid script.
+
+user ${user};
+worker_processes 1;
+
+error_log /var/log/nginx/error.log;
+
+events {
+ worker_connections 1024;
+}
+
+http {
+
+ log_format main '$remote_addr - $remote_user [$time_local] "$request" '
+ '$status $body_bytes_sent "$http_referer" '
+ '"$http_user_agent" "$http_x_forwarded_for"';
+
+ access_log /var/log/nginx/access.log main;
+ sendfile on;
+
+ client_max_body_size ${max_body_size}k;
+
+ # Timeout set to 10 minutes to avoid the 504 Gateway Timeout
+ # when Kimchi is processing a request.
+ proxy_connect_timeout 600;
+ proxy_send_timeout 600;
+ proxy_read_timeout 600;
+ send_timeout 600;
+
+ server {
+ listen ${proxy_ssl_port} ssl;
+
+ ssl_certificate ${cert_pem};
+ ssl_certificate_key ${cert_key};
+ ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
+ ssl_ciphers ECDH@STRENGTH:DH@STRENGTH:HIGH:!RC4:!MD5:!DES:!aNULL:!eNULL;
+
+ add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
+ add_header X-Frame-Options DENY;
+ add_header X-Content-Type-Options nosniff;
+ add_header X-XSS-Protection "1; mode=block";
+
+ location / {
+ proxy_pass http://127.0.0.1:${kimchid_port};
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_redirect http://127.0.0.1:${kimchid_port}/ https://$host:${proxy_ssl_port}/;
+ }
+ }
+
+ server {
+ listen ${proxy_port};
+ rewrite ^/(.*)$ https://$host:${proxy_ssl_port}/$1 redirect;
+ }
+}
--
1.9.1
9 years, 7 months
Re: [Kimchi-devel] [PATCH 3/5] Use get_vm() instead of conn.lookupByName
by Ramon Medeiros
Please ignore these patches
On 04/28/2015 10:16 AM, Ramon Medeiros wrote:
> Remove duplicated code of conn.lookupByName.
>
> Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
> ---
> src/kimchi/model/vms.py | 2 +-
> src/kimchi/model/vmstorages.py | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
> index 6792447..87d63c1 100644
> --- a/src/kimchi/model/vms.py
> +++ b/src/kimchi/model/vms.py
> @@ -266,7 +266,7 @@ class VMModel(object):
> # fetch base XML
> cb('reading source VM XML')
> try:
> - vir_dom = vir_conn.lookupByName(name)
> + vir_dom = self.get_vm(name)
> flags = libvirt.VIR_DOMAIN_XML_SECURE
> xml = vir_dom.XMLDesc(flags).decode('utf-8')
> except libvirt.libvirtError, e:
> diff --git a/src/kimchi/model/vmstorages.py b/src/kimchi/model/vmstorages.py
> index 37aca64..8dabae7 100644
> --- a/src/kimchi/model/vmstorages.py
> +++ b/src/kimchi/model/vmstorages.py
> @@ -138,7 +138,7 @@ class VMStoragesModel(object):
> dev, xml = get_disk_xml(params)
> try:
> conn = self.conn.get()
> - dom = conn.lookupByName(vm_name)
> + dom = VMModel.get_vm(vm_name, conn)
> dom.attachDeviceFlags(xml, get_vm_config_flag(dom, 'all'))
> except Exception as e:
> raise OperationFailed("KCHVMSTOR0008E", {'error': e.message})
> @@ -173,7 +173,7 @@ class VMStorageModel(object):
>
> try:
> bus_type = self.lookup(vm_name, dev_name)['bus']
> - dom = conn.lookupByName(vm_name)
> + dom = VMModel.get_vm(vm_name, conn)
> except NotFoundError:
> raise
>
--
Ramon Nunes Medeiros
Kimchi Developer
Linux Technology Center Brazil
IBM Systems & Technology Group
Phone : +55 19 2132 7878
ramonn(a)br.ibm.com
9 years, 7 months