[PATCH] Fix disk format lock and checking during template creation
by Rodrigo Trujillo
Users are able to pass the disk format (qcow, raw, etc) in disk Template
information. However, Kimchi was ignoring this information and always
creating QCOW2 disk images (if the storagepool is not 'LOGICAL') when it
creates a VM based on a given Template.
This patch fixes this problem and also moves the checking and disk
format auto assignment to Template creation phase, in VMTemplate class
init.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo(a)linux.vnet.ibm.com>
---
src/kimchi/i18n.py | 1 +
src/kimchi/vmtemplate.py | 15 +++++++++++----
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index 18e84bc..0651032 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -154,6 +154,7 @@ messages = {
"KCHTMPL0025E": _("When specifying CPU topology, VCPUs must be a product of sockets, cores, and threads."),
"KCHTMPL0026E": _("When specifying CPU topology, each element must be an integer greater than zero."),
"KCHTMPL0027E": _("Invalid disk image format. Valid formats: bochs, cloop, cow, dmg, qcow, qcow2, qed, raw, vmdk, vpc."),
+ "KCHTMPL0028E": _("Invalid disk image format. Logical, SCSI and iSCSI storage pools must use disk image format 'raw'."),
"KCHPOOL0001E": _("Storage pool %(name)s already exists"),
"KCHPOOL0002E": _("Storage pool %(name)s does not exist"),
diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
index ef97d83..84e877b 100644
--- a/src/kimchi/vmtemplate.py
+++ b/src/kimchi/vmtemplate.py
@@ -75,8 +75,16 @@ class VMTemplate(object):
args['graphics'] = graphics
self.info.update(args)
- # Assign right disk format to logical and [i]scsi storagepools
+ # Check disk image format passed and pool type
if self._get_storage_type() in ['logical', 'iscsi', 'scsi']:
+ paramdisks = args.get('disks')
+ if paramdisks is not None:
+ for disk in paramdisks:
+ fmt = disk.get('format')
+ if fmt is not None and fmt != 'raw':
+ raise InvalidParameter('KCHTMPL0028E')
+ # Finally add disk image format when not passed or
+ # using default
for i, disk in enumerate(self.info['disks']):
self.info['disks'][i]['format'] = 'raw'
@@ -198,7 +206,6 @@ class VMTemplate(object):
def to_volume_list(self, vm_uuid):
storage_path = self._get_storage_path()
- fmt = 'raw' if self._get_storage_type() in ['logical'] else 'qcow2'
ret = []
for i, d in enumerate(self.info['disks']):
index = d.get('index', i)
@@ -206,11 +213,11 @@ class VMTemplate(object):
info = {'name': volume,
'capacity': d['size'],
- 'format': fmt,
+ 'format': d['format'],
'path': '%s/%s' % (storage_path, volume)}
if 'logical' == self._get_storage_type() or \
- fmt not in ['qcow2', 'raw']:
+ info['format'] not in ['qcow2', 'raw']:
info['allocation'] = info['capacity']
else:
info['allocation'] = 0
--
2.1.0
9 years, 7 months
[PATCH V2] UI-Template Edit: Enable user to change disk format
by Rodrigo Trujillo
This patch adds a new field (Disk Format) in Storage tab in Template
edit window. Users will then be allowed to select any disk format
supported by Libvirt and Kimchi backend.
The default disk format is qcow2 (first option), so, for compatibility,
if the template register in objecstore does not contain the disk format
information, the new field is going to set 'qcow2' automatically.
For iscsi storagepools, the new field is going to be disabled and the
format is going to be set automatically as 'raw', just like the backend
behaves currently, avoiding errors.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo(a)linux.vnet.ibm.com>
---
ui/css/theme-default/template-edit.css | 8 ++++--
ui/js/src/kimchi.template_edit_main.js | 52 ++++++++++++++++++++++++++++++----
ui/pages/template-edit.html.tmpl | 16 +++++++++++
3 files changed, 68 insertions(+), 8 deletions(-)
diff --git a/ui/css/theme-default/template-edit.css b/ui/css/theme-default/template-edit.css
index 7abee7c..ed9f02c 100644
--- a/ui/css/theme-default/template-edit.css
+++ b/ui/css/theme-default/template-edit.css
@@ -95,7 +95,7 @@
#edit-template-tabs .template-storage-cell{
display: inline-block;
- width: 230px;
+ width: 180px;
}
#edit-template-tabs .template-storage-cell label {
@@ -114,7 +114,11 @@
}
#form-template-storage .template-tab-body .template-storage-name {
- width: 220px;
+ width: 170px;
+}
+
+#form-template-storage .template-tab-body .template-storage-disk-format {
+ width: 160px;
}
#edit-template-tabs .template-tab-body input[readonly] {
diff --git a/ui/js/src/kimchi.template_edit_main.js b/ui/js/src/kimchi.template_edit_main.js
index 85f76cd..6029a95 100644
--- a/ui/js/src/kimchi.template_edit_main.js
+++ b/ui/js/src/kimchi.template_edit_main.js
@@ -67,7 +67,7 @@ kimchi.template_edit_main = function() {
$('.template-tab-body', '#form-template-storage').append(nodeStorage);
var storageOptions = '';
var scsiOptions = '';
- $('select', '#form-template-storage').find('option').remove();
+ $('select:first', '#form-template-storage').find('option').remove();
$.each(result, function(index, storageEntities) {
if((storageEntities.state === 'active') && (storageEntities.type != 'kimchi-iso')) {
if(storageEntities.type === 'iscsi' || storageEntities.type === 'scsi') {
@@ -77,7 +77,7 @@ kimchi.template_edit_main = function() {
var isSlected = tmpPath === thisName ? ' selected' : '';
scsiOptions += '<option' + isSlected + '>' + tmpPath + '</option>';
});
- $('select', '#form-template-storage').append(scsiOptions);
+ $('select:first', '#form-template-storage').append(scsiOptions);
}, function() {});
} else {
var isSlected = storageEntities.name === thisName ? ' selected' : '';
@@ -85,8 +85,20 @@ kimchi.template_edit_main = function() {
}
}
});
- $('select', '#form-template-storage').append(storageOptions);
- $('select', '#form-template-storage').change(function() {
+ $('select:first', '#form-template-storage').append(storageOptions);
+
+ // Set disk format
+ $('select:last option', '#form-template-storage').each(function() {
+ if ($(this).text() == storageData.storageDiskFormat) {
+ $(this).prop('selected', true);
+ }
+ });
+
+ $('select:last', '#form-template-storage').change(function() {
+ $('.template-storage-disk-format').val($(this).val());
+ });
+
+ $('select:first', '#form-template-storage').change(function() {
var selectedItem = $(this).parent().parent();
var tempStorageNameFull = $(this).val();
var tempName = tempStorageNameFull.split('/');
@@ -99,9 +111,25 @@ kimchi.template_edit_main = function() {
kimchi.getStoragePoolVolume(tempStorageName, tempName[tempName.length-1], function(info) {
volSize = info.capacity / Math.pow(1024, 3);
$('.template-storage-disk', selectedItem).attr('readonly', true).val(volSize);
+ $('select:last option', selectedItem).each(function() {
+ this.selected = (this.text == 'raw');
+ });
+ $('select:last', selectedItem).prop('disabled', true).change();
});
+ } else if (tempType === 'logical') {
+ $('.template-storage-disk', selectedItem).attr('readonly', false);
+ $('select:last option', selectedItem).each(function() {
+ this.selected = (this.text == 'raw');
+ });
+ $('select:last', selectedItem).prop('disabled', true).change();
} else {
$('.template-storage-disk', selectedItem).attr('readonly', false);
+ if ($('select:last', selectedItem).prop('disabled') == true) {
+ $('select:last option', selectedItem).each(function() {
+ this.selected = (this.text == 'qcow2');
+ });
+ $('select:last', selectedItem).prop('disabled', false).change();
+ }
}
});
});
@@ -120,7 +148,8 @@ kimchi.template_edit_main = function() {
editMode : 'hide',
storageName : defaultPool,
storageType : defaultType,
- storageDisk : diskEntities.size
+ storageDisk : diskEntities.size,
+ storageDiskFormat : diskEntities.format ? diskEntities.format : 'qcow2'
}
if (diskEntities.volume) {
@@ -131,7 +160,17 @@ kimchi.template_edit_main = function() {
nodeData.storageDisk = volSize;
addStorageItem(nodeData);
$('.template-storage-disk').attr('readonly', true);
+ $('select:last option', '#form-template-storage').each(function() {
+ this.selected = (this.text == 'raw');
+ });
+ $('select:last', '#form-template-storage').prop('disabled', true).change();
+ });
+ } else if (defaultType === 'logical') {
+ addStorageItem(storageNodeData);
+ $('select:last option', '#form-template-storage').each(function() {
+ this.selected = (this.text == 'raw');
});
+ $('select:last', '#form-template-storage').prop('disabled', true).change();
} else {
addStorageItem(storageNodeData);
}
@@ -271,7 +310,8 @@ kimchi.template_edit_main = function() {
origDisks[0]['volume'] && delete origDisks[0]['volume'];
origDisks[0].size = Number($('.template-storage-disk', tmpItem).val());
}
- data[field] = origDisks;
+ origDisks[0].format = $('.template-storage-disk-format', tmpItem).val();
+ data[field] = origDisks;
}
else if (field == 'graphics') {
var type = $('#form-template-general [name="' + field + '"]').val();
diff --git a/ui/pages/template-edit.html.tmpl b/ui/pages/template-edit.html.tmpl
index c7832c9..e64a30f 100644
--- a/ui/pages/template-edit.html.tmpl
+++ b/ui/pages/template-edit.html.tmpl
@@ -104,6 +104,7 @@
<span class="template-storage-cell">$_("Storage Pool")</span>
<span class="template-storage-cell">$_("Type")</span>
<span class="template-storage-cell">$_("Disk(GB)")</span>
+ <span class="template-storage-cell">$_("Disk Format")</span>
<button type="button" id="template-edit-storage-add-button" class="action-area"></button>
</div>
<div class="template-tab-body">
@@ -160,6 +161,21 @@
<span class="template-storage-cell">
<input class="template-storage-disk" value={storageDisk} type="text" />
</span>
+ <span class="template-storage-cell">
+ <input class="template-storage-disk-format" value={storageDiskFormat} type="text" style="display:none" />
+ <select>
+ <option>qcow2</option>
+ <option>raw</option>
+ <option>bochs</option>
+ <option>cloop</option>
+ <option>cow</option>
+ <option>dmg</option>
+ <option>qcow</option>
+ <option>qed</option>
+ <option>vmdk</option>
+ <option>vpc</option>
+ </select>
+ </span>
</div>
</script>
<script id="template-interface-tmpl" type="text/html">
--
2.1.0
9 years, 7 months
[PATCH V3 0/2] Warn users about NetworkManager instability
by Jose Ricardo Ziviani
V3:
- Use cached capability value.
V2:
- Change is_nm_running to use a 'cross distro' command.
- Update the warning message
NetworkManager might have some instability when managing the bridges created by libvirt. There some bugs against NM about it and there is no much we can do more than warn the users about it. So, this patchset checks if NM is running and, if so, will display a message to users.
Jose Ricardo Ziviani (2):
Implement function to check if NM is running.
Add a warn about NM running in the system.
src/kimchi/model/config.py | 1 +
src/kimchi/model/featuretests.py | 10 ++++++++++
tests/test_rest.py | 3 ++-
ui/js/src/kimchi.network.js | 3 +++
ui/pages/i18n.json.tmpl | 1 +
5 files changed, 17 insertions(+), 1 deletion(-)
--
1.9.1
9 years, 7 months
[PATCH] Allow creating VM storages with ref_cnt > 0
by Crístian Deives
As discussed in an e-mail thread
(http://lists.ovirt.org/pipermail/kimchi-devel/2015-March/010154.html),
we should stop blocking the user from creating VM storages when the
storage has already been added to some VM. The UI may display a warning
when that cases happens so the user should decide what to do.
Remove check on ref_cnt when creating a VM storage.
Signed-off-by: Crístian Deives <cristiandeives(a)gmail.com>
---
src/kimchi/i18n.py | 1 -
src/kimchi/model/vmstorages.py | 2 --
2 files changed, 3 deletions(-)
diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index 18e84bc..6b4726c 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -285,7 +285,6 @@ messages = {
"KCHVMSTOR0013E": _("Specify path to update virtual machine disk"),
"KCHVMSTOR0014E": _("Controller type %(type)s limitation of %(limit)s devices reached"),
"KCHVMSTOR0015E": _("Cannot retrieve disk path information for given pool/volume: %(error)s"),
- "KCHVMSTOR0016E": _("Volume already in use by other virtual machine."),
"KCHVMSTOR0017E": _("Only one of path or pool/volume can be specified to add a new virtual machine disk"),
"KCHVMSTOR0018E": _("Volume chosen with format %(format)s does not fit in the storage type %(type)s"),
diff --git a/src/kimchi/model/vmstorages.py b/src/kimchi/model/vmstorages.py
index 37aca64..0375772 100644
--- a/src/kimchi/model/vmstorages.py
+++ b/src/kimchi/model/vmstorages.py
@@ -111,8 +111,6 @@ class VMStoragesModel(object):
raise InvalidParameter("KCHVMSTOR0012E")
except Exception as e:
raise InvalidParameter("KCHVMSTOR0015E", {'error': e})
- if vol_info['ref_cnt'] != 0:
- raise InvalidParameter("KCHVMSTOR0016E")
valid_format = {
"disk": ["raw", "bochs", "qcow", "qcow2", "qed", "vmdk"],
--
2.1.0
9 years, 7 months
[PATCH 0/3] Warn users about NetworkManager instability
by Jose Ricardo Ziviani
NetworkManager might have some instability when managing the bridges created by libvirt. There some bugs against NM about it and there is no much we can do more than warn the users about it. So, this patchset checks if NM is running and, if so, will display a message to users.
Jose Ricardo Ziviani (3):
Add the env parameter to run_command.
Implement function to check if NM is running.
Add a warn about NM running in the system.
src/kimchi/model/config.py | 1 +
src/kimchi/model/featuretests.py | 28 ++++++++++++++++++++++++++++
src/kimchi/utils.py | 6 ++++--
tests/test_rest.py | 3 ++-
ui/js/src/kimchi.network.js | 5 +++++
ui/pages/i18n.json.tmpl | 1 +
6 files changed, 41 insertions(+), 3 deletions(-)
--
1.9.1
9 years, 7 months
[PATCH] Supress error messages while checking vm metadata
by Ramon Medeiros
From: Ramon Medeiros <ramonn(a)jarvis.br.ibm.com>
The function FeatureTests.disable_libvirt_error_logging only removes the
error message that will be displayed on the console. Libvirt also logs
errors on messages log. To avoid flood messages log with metadata
errors, it will be verified manually if the xml has the tag.
Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
---
src/kimchi/model/utils.py | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/kimchi/model/utils.py b/src/kimchi/model/utils.py
index b2739b2..749be93 100644
--- a/src/kimchi/model/utils.py
+++ b/src/kimchi/model/utils.py
@@ -22,6 +22,7 @@ import socket
import urlparse
from lxml import etree, objectify
from lxml.builder import E, ElementMaker
+from xml.dom import minidom
from kimchi.exception import OperationFailed
from kimchi.model.featuretests import FeatureTests
@@ -95,6 +96,13 @@ def _kimchi_set_metadata_node(dom, node):
def libvirt_get_kimchi_metadata_node(dom, mode="current"):
+ # check xml for metadata tag
+ xml = minidom.parseString(dom.XMLDesc(0))
+
+ # no metadata: return
+ if not xml.getElementsByTagName('metadata'):
+ return None
+
FeatureTests.disable_libvirt_error_logging()
try:
xml = dom.metadata(libvirt.VIR_DOMAIN_METADATA_ELEMENT,
--
2.1.0
9 years, 7 months
[PATCH v4 0/7] Async VM Creation
by Christy Perez
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 tasks. Currently it is not possible (using the API) to query tasks
for the same collection or resource type that may have different operations.
For example, VM cloning is also an asynchronous operation. For the guests tab,
the UI was querying all running tasks and displaying them with the Cloning
label. This picked up VMs that were being created as well. For more information
about how the tasks can be queried, see the updated API doc and the UI change.
Christy Perez (7):
Granular Task Queries: Backend
Granular task query test updates
Granular Task Queries: UI
Create guests asynchronously: Backend
Async vm creation test updates
VMs Async Create: UI
Translation update to add 'Creating'
docs/API.md | 16 ++++++
po/de_DE.po | 103 ++++++++++++++++++++-----------------
po/en_US.po | 83 +++++++++++++++++-------------
po/es_ES.po | 102 +++++++++++++++++++-----------------
po/fr_FR.po | 102 +++++++++++++++++++-----------------
po/it_IT.po | 102 +++++++++++++++++++-----------------
po/ja_JP.po | 102 +++++++++++++++++++-----------------
po/kimchi.pot | 84 +++++++++++++++++-------------
po/ko_KR.po | 102 +++++++++++++++++++-----------------
po/pt_BR.po | 102 +++++++++++++++++++-----------------
po/ru_RU.po | 102 +++++++++++++++++++-----------------
po/zh_CN.po | 102 +++++++++++++++++++-----------------
po/zh_TW.po | 102 +++++++++++++++++++-----------------
src/kimchi/control/vms.py | 4 +-
src/kimchi/mockmodel.py | 7 +--
src/kimchi/model/debugreports.py | 4 +-
src/kimchi/model/host.py | 4 +-
src/kimchi/model/storagepools.py | 2 +-
src/kimchi/model/storagevolumes.py | 12 +++--
src/kimchi/model/vms.py | 33 +++++++++---
src/kimchi/model/vmsnapshots.py | 5 +-
tests/test_authorization.py | 23 +++++----
tests/test_mockmodel.py | 12 +++--
tests/test_model.py | 60 ++++++++++++++-------
tests/test_model_storagevolume.py | 2 +-
tests/test_rest.py | 77 ++++++++++++++++++++-------
ui/css/theme-default/list.css | 18 +++++++
ui/js/src/kimchi.guest_main.js | 29 +++++++++--
ui/pages/guest.html.tmpl | 3 ++
29 files changed, 886 insertions(+), 613 deletions(-)
--
2.1.0
9 years, 7 months
[PATCH V2 0/2] Warn users about NetworkManager instability
by Jose Ricardo Ziviani
V2:
- Change is_nm_running to use a 'cross distro' command.
- Update the warning message
NetworkManager might have some instability when managing the bridges created by libvirt. There some bugs against NM about it and there is no much we can do more than warn the users about it. So, this patchset checks if NM is running and, if so, will display a message to users.
Jose Ricardo Ziviani (2):
Implement function to check if NM is running.
Add a warn about NM running in the system.
src/kimchi/model/config.py | 1 +
src/kimchi/model/featuretests.py | 10 ++++++++++
tests/test_rest.py | 3 ++-
ui/js/src/kimchi.network.js | 5 +++++
ui/pages/i18n.json.tmpl | 1 +
5 files changed, 19 insertions(+), 1 deletion(-)
--
1.9.1
9 years, 7 months
[PATCH] Host tests
by Aline Manera
This patch creates a new test file (test_host.py) to handle all the Host
Resource related tests.
It also updates the docs/API.md to reflect the right data set returned
for /host/partitions API.
Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
---
docs/API.md | 1 +
src/kimchi/mockmodel.py | 8 +-
tests/test_host.py | 192 ++++++++++++++++++++++++++++++++++++++++++++++++
tests/test_mockmodel.py | 17 -----
tests/test_model.py | 73 ------------------
tests/test_rest.py | 72 ------------------
6 files changed, 200 insertions(+), 163 deletions(-)
create mode 100644 tests/test_host.py
diff --git a/docs/API.md b/docs/API.md
index 3f7925f..922ded1 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -985,6 +985,7 @@ stats history
* size: The total size of the partition, in bytes
* mountpoint: If the partition is mounted, represents the mountpoint.
Otherwise blank.
+ * available: false, if the partition is in use by system; true, otherwise.
### Collection: Devices
diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index 413ac5d..3ebddca 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -42,7 +42,7 @@ from kimchi.model.templates import LibvirtVMTemplate
from kimchi.model.users import PAMUsersModel
from kimchi.model.groups import PAMGroupsModel
from kimchi.objectstore import ObjectStore
-from kimchi.utils import add_task, get_next_clone_name
+from kimchi.utils import add_task, get_next_clone_name, kimchi_log
from kimchi.vmtemplate import VMTemplate
from kimchi.xmlutils.utils import xml_item_update
@@ -273,6 +273,12 @@ class MockModel(Model):
conn.storagePoolDefineXML(ET.tostring(root), 0)
+ def _mock_host_shutdown(self, *name):
+ kimchi_log.info("The host system will be shutted down")
+
+ def _mock_host_reboot(self, *name):
+ kimchi_log.info("The host system will be rebooted")
+
def _mock_storagevolumes_create(self, pool, params):
vol_source = ['file', 'url', 'capacity']
index_list = list(i for i in range(len(vol_source))
diff --git a/tests/test_host.py b/tests/test_host.py
new file mode 100644
index 0000000..1273457
--- /dev/null
+++ b/tests/test_host.py
@@ -0,0 +1,192 @@
+# -*- coding: utf-8 -*-
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2015
+#
+# 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
+
+import json
+import os
+import platform
+import psutil
+import tempfile
+import time
+import unittest
+
+from functools import partial
+
+from kimchi.mockmodel import MockModel
+from utils import get_free_port, patch_auth, request, run_server, wait_task
+
+test_server = None
+model = None
+host = None
+ssl_port = None
+tmpfile = None
+
+
+def setUpModule():
+ global test_server, model, host, ssl_port, tmpfile
+
+ patch_auth()
+ tmpfile = tempfile.mktemp()
+ model = MockModel(tmpfile)
+ host = '127.0.0.1'
+ port = get_free_port('http')
+ ssl_port = get_free_port('https')
+ cherrypy_port = get_free_port('cherrypy_port')
+ test_server = run_server(host, port, ssl_port, test_mode=True,
+ cherrypy_port=cherrypy_port, model=model)
+
+
+def tearDownModule():
+ test_server.stop()
+ os.unlink(tmpfile)
+
+
+class HostTests(unittest.TestCase):
+ def setUp(self):
+ self.request = partial(request, host, ssl_port)
+
+ def test_hostinfo(self):
+ resp = self.request('/host').read()
+ info = json.loads(resp)
+ keys = ['os_distro', 'os_version', 'os_codename', 'cpu_model',
+ 'memory', 'cpus']
+ self.assertEquals(sorted(keys), sorted(info.keys()))
+
+ distro, version, codename = platform.linux_distribution()
+ self.assertEquals(distro, info['os_distro'])
+ self.assertEquals(version, info['os_version'])
+ self.assertEquals(unicode(codename, "utf-8"), info['os_codename'])
+ self.assertEquals(psutil.TOTAL_PHYMEM, info['memory'])
+
+ def test_hoststats(self):
+ time.sleep(1)
+ stats_keys = ['cpu_utilization', 'memory', 'disk_read_rate',
+ 'disk_write_rate', 'net_recv_rate', 'net_sent_rate']
+ resp = self.request('/host/stats').read()
+ stats = json.loads(resp)
+ self.assertEquals(sorted(stats_keys), sorted(stats.keys()))
+
+ cpu_utilization = stats['cpu_utilization']
+ self.assertIsInstance(cpu_utilization, float)
+ self.assertGreaterEqual(cpu_utilization, 0.0)
+ self.assertTrue(cpu_utilization <= 100.0)
+
+ memory_stats = stats['memory']
+ self.assertIn('total', memory_stats)
+ self.assertIn('free', memory_stats)
+ self.assertIn('cached', memory_stats)
+ self.assertIn('buffers', memory_stats)
+ self.assertIn('avail', memory_stats)
+
+ resp = self.request('/host/stats/history').read()
+ history = json.loads(resp)
+ self.assertEquals(sorted(stats_keys), sorted(history.keys()))
+
+ def test_host_actions(self):
+ def _task_lookup(taskid):
+ return json.loads(self.request('/tasks/%s' % taskid).read())
+
+ resp = self.request('/host/shutdown', '{}', 'POST')
+ self.assertEquals(200, resp.status)
+ resp = self.request('/host/reboot', '{}', 'POST')
+ self.assertEquals(200, resp.status)
+
+ # Test system update
+ resp = self.request('/host/packagesupdate', None, 'GET')
+ pkgs = json.loads(resp.read())
+ self.assertEquals(3, len(pkgs))
+
+ pkg_keys = ['package_name', 'repository', 'arch', 'version']
+ for p in pkgs:
+ name = p['package_name']
+ resp = self.request('/host/packagesupdate/' + name, None, 'GET')
+ info = json.loads(resp.read())
+ self.assertEquals(sorted(pkg_keys), sorted(info.keys()))
+
+ resp = self.request('/host/swupdate', '{}', 'POST')
+ task = json.loads(resp.read())
+ task_params = [u'id', u'message', u'status', u'target_uri']
+ self.assertEquals(sorted(task_params), sorted(task.keys()))
+
+ resp = self.request('/tasks/' + task[u'id'], None, 'GET')
+ task_info = json.loads(resp.read())
+ self.assertEquals(task_info['status'], 'running')
+ wait_task(_task_lookup, task_info['id'])
+ resp = self.request('/tasks/' + task[u'id'], None, 'GET')
+ task_info = json.loads(resp.read())
+ self.assertEquals(task_info['status'], 'finished')
+ self.assertIn(u'All packages updated', task_info['message'])
+ pkgs = model.packagesupdate_get_list()
+ self.assertEquals(0, len(pkgs))
+
+ def test_host_partitions(self):
+ resp = self.request('/host/partitions')
+ self.assertEquals(200, resp.status)
+ partitions = json.loads(resp.read())
+
+ keys = ['name', 'path', 'type', 'fstype', 'size', 'mountpoint',
+ 'available']
+ for item in partitions:
+ resp = self.request('/host/partitions/%s' % item['name'])
+ info = json.loads(resp.read())
+ self.assertEquals(sorted(info.keys()), sorted(keys))
+
+ def test_host_devices(self):
+ def asset_devices_type(devices, dev_type):
+ for dev in devices:
+ self.assertEquals(dev['device_type'], dev_type)
+
+ resp = self.request('/host/devices?_cap=scsi_host')
+ nodedevs = json.loads(resp.read())
+ # Mockmodel brings 3 preconfigured scsi fc_host
+ self.assertEquals(3, len(nodedevs))
+
+ nodedev = json.loads(self.request('/host/devices/scsi_host2').read())
+ # Mockmodel generates random wwpn and wwnn
+ self.assertEquals('scsi_host2', nodedev['name'])
+ self.assertEquals('fc_host', nodedev['adapter']['type'])
+ self.assertEquals(16, len(nodedev['adapter']['wwpn']))
+ self.assertEquals(16, len(nodedev['adapter']['wwnn']))
+
+ devs = json.loads(self.request('/host/devices').read())
+ dev_names = [dev['name'] for dev in devs]
+ for dev_type in ('pci', 'usb_device', 'scsi'):
+ resp = self.request('/host/devices?_cap=%s' % dev_type)
+ devsByType = json.loads(resp.read())
+ names = [dev['name'] for dev in devsByType]
+ self.assertTrue(set(names) <= set(dev_names))
+ asset_devices_type(devsByType, dev_type)
+
+ resp = self.request('/host/devices?_passthrough=true')
+ passthru_devs = [dev['name'] for dev in json.loads(resp.read())]
+ self.assertTrue(set(passthru_devs) <= set(dev_names))
+
+ for dev_type in ('pci', 'usb_device', 'scsi'):
+ resp = self.request('/host/devices?_cap=%s&_passthrough=true' %
+ dev_type)
+ filteredDevs = json.loads(resp.read())
+ filteredNames = [dev['name'] for dev in filteredDevs]
+ self.assertTrue(set(filteredNames) <= set(dev_names))
+ asset_devices_type(filteredDevs, dev_type)
+
+ for dev in passthru_devs:
+ resp = self.request('/host/devices?_passthrough_affected_by=%s' %
+ dev)
+ affected_devs = [dev['name'] for dev in json.loads(resp.read())]
+ self.assertTrue(set(affected_devs) <= set(dev_names))
diff --git a/tests/test_mockmodel.py b/tests/test_mockmodel.py
index c7e733e..aa48dd1 100644
--- a/tests/test_mockmodel.py
+++ b/tests/test_mockmodel.py
@@ -26,7 +26,6 @@ import unittest
import kimchi.mockmodel
from utils import get_free_port, patch_auth, request, run_server
-from utils import wait_task
from kimchi.osinfo import get_template_default
@@ -131,19 +130,3 @@ class MockModelTests(unittest.TestCase):
self.assertEquals(stats_keys, set(info['stats'].keys()))
self.assertEquals('vnc', info['graphics']['type'])
self.assertEquals('127.0.0.1', info['graphics']['listen'])
-
- def test_packages_update(self):
- pkgs = model.packagesupdate_get_list()
- self.assertEquals(3, len(pkgs))
-
- for pkg_name in pkgs:
- pkgupdate = model.packageupdate_lookup(pkg_name)
- self.assertIn('package_name', pkgupdate.keys())
- self.assertIn('repository', pkgupdate.keys())
- self.assertIn('arch', pkgupdate.keys())
- self.assertIn('version', pkgupdate.keys())
-
- task = model.host_swupdate()
- task_params = [u'id', u'message', u'status', u'target_uri']
- self.assertEquals(sorted(task_params), sorted(task.keys()))
- wait_task(model.task_lookup, task['id'])
diff --git a/tests/test_model.py b/tests/test_model.py
index c25929f..210adfd 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -20,8 +20,6 @@
import grp
import os
-import platform
-import psutil
import pwd
import re
import shutil
@@ -725,37 +723,6 @@ class ModelTests(unittest.TestCase):
self.assertIn('ipaddr', iface)
self.assertIn('netmask', iface)
- @unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
- def test_get_devices(self):
- def asset_devices_type(devices, dev_type):
- for dev in devices:
- self.assertEquals(dev['device_type'], dev_type)
-
- inst = model.Model('qemu:///system',
- objstore_loc=self.tmp_store)
-
- devs = inst.devices_get_list()
-
- for dev_type in ('pci', 'usb_device', 'scsi'):
- names = inst.devices_get_list(_cap=dev_type)
- self.assertTrue(set(names) <= set(devs))
- infos = [inst.device_lookup(name) for name in names]
- asset_devices_type(infos, dev_type)
-
- passthru_devs = inst.devices_get_list(_passthrough='true')
- self.assertTrue(set(passthru_devs) <= set(devs))
-
- for dev_type in ('pci', 'usb_device', 'scsi'):
- names = inst.devices_get_list(_cap=dev_type, _passthrough='true')
- self.assertTrue(set(names) <= set(devs))
- infos = [inst.device_lookup(name) for name in names]
- asset_devices_type(infos, dev_type)
-
- for dev_name in passthru_devs:
- affected_devs = inst.devices_get_list(
- _passthrough_affected_by=dev_name)
- self.assertTrue(set(affected_devs) <= set(devs))
-
def test_async_tasks(self):
class task_except(Exception):
pass
@@ -983,46 +950,6 @@ class ModelTests(unittest.TestCase):
self.assertIn('path', distro)
@unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
- def test_get_hostinfo(self):
- inst = model.Model(None,
- objstore_loc=self.tmp_store)
- info = inst.host_lookup()
- distro, version, codename = platform.linux_distribution()
- self.assertIn('cpu_model', info)
- self.assertIn('cpus', info)
- self.assertEquals(distro, info['os_distro'])
- self.assertEquals(version, info['os_version'])
- self.assertEquals(unicode(codename, "utf-8"), info['os_codename'])
- self.assertEquals(psutil.TOTAL_PHYMEM, info['memory'])
-
- def test_get_hoststats(self):
- inst = model.Model('test:///default',
- objstore_loc=self.tmp_store)
- time.sleep(1.5)
- stats = inst.hoststats_lookup()
- stats_keys = ['cpu_utilization', 'memory', 'disk_read_rate',
- 'disk_write_rate', 'net_recv_rate', 'net_sent_rate']
- self.assertEquals(sorted(stats_keys), sorted(stats.keys()))
- cpu_utilization = stats['cpu_utilization']
- # cpu_utilization is set int 0, after first stats sample
- # the cpu_utilization is float in range [0.0, 100.0]
- self.assertIsInstance(cpu_utilization, float)
- self.assertGreaterEqual(cpu_utilization, 0.0)
- self.assertTrue(cpu_utilization <= 100.0)
-
- memory_stats = stats['memory']
- self.assertIn('total', memory_stats)
- self.assertIn('free', memory_stats)
- self.assertIn('cached', memory_stats)
- self.assertIn('buffers', memory_stats)
- self.assertIn('avail', memory_stats)
-
- history = inst.hoststatshistory_lookup()
- self.assertEquals(sorted(stats_keys), sorted(history.keys()))
- for key, value in history.iteritems():
- self.assertEquals(type(value), list)
-
- @unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
def test_deep_scan(self):
inst = model.Model(None,
objstore_loc=self.tmp_store)
diff --git a/tests/test_rest.py b/tests/test_rest.py
index ee350b2..4ade722 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -93,19 +93,6 @@ class RestTests(unittest.TestCase):
resp = self.request(*args)
self.assertEquals(code, resp.status)
- def test_host_devices(self):
- resp = self.request('/host/devices?_cap=scsi_host')
- nodedevs = json.loads(resp.read())
- # Mockmodel brings 3 preconfigured scsi fc_host
- self.assertEquals(3, len(nodedevs))
-
- nodedev = json.loads(self.request('/host/devices/scsi_host2').read())
- # Mockmodel generates random wwpn and wwnn
- self.assertEquals('scsi_host2', nodedev['name'])
- self.assertEquals('fc_host', nodedev['adapter']['type'])
- self.assertEquals(16, len(nodedev['adapter']['wwpn']))
- self.assertEquals(16, len(nodedev['adapter']['wwnn']))
-
def test_get_vms(self):
vms = json.loads(self.request('/vms').read())
# test_rest.py uses MockModel() which connects to libvirt URI
@@ -1129,65 +1116,6 @@ class RestTests(unittest.TestCase):
resp = request(host, ssl_port, debugre['uri'])
self.assertEquals(200, resp.status)
- def test_host(self):
- resp = self.request('/host').read()
- info = json.loads(resp)
-
- keys = ['os_distro', 'os_version', 'os_codename', 'cpu_model',
- 'memory', 'cpus']
- self.assertEquals(sorted(keys), sorted(info.keys()))
-
- def test_hoststats(self):
- stats_keys = ['cpu_utilization', 'memory', 'disk_read_rate',
- 'disk_write_rate', 'net_recv_rate', 'net_sent_rate']
- resp = self.request('/host/stats').read()
- stats = json.loads(resp)
- self.assertEquals(sorted(stats_keys), sorted(stats.keys()))
-
- cpu_utilization = stats['cpu_utilization']
- self.assertIsInstance(cpu_utilization, float)
- self.assertGreaterEqual(cpu_utilization, 0.0)
- self.assertTrue(cpu_utilization <= 100.0)
-
- memory_stats = stats['memory']
- self.assertIn('total', memory_stats)
- self.assertIn('free', memory_stats)
- self.assertIn('cached', memory_stats)
- self.assertIn('buffers', memory_stats)
- self.assertIn('avail', memory_stats)
-
- resp = self.request('/host/stats/history').read()
- history = json.loads(resp)
- self.assertEquals(sorted(stats_keys), sorted(history.keys()))
-
- def test_packages_update(self):
- resp = self.request('/host/packagesupdate', None, 'GET')
- pkgs = json.loads(resp.read())
- self.assertEquals(3, len(pkgs))
-
- for p in pkgs:
- name = p['package_name']
- resp = self.request('/host/packagesupdate/' + name, None, 'GET')
- info = json.loads(resp.read())
- self.assertIn('package_name', info.keys())
- self.assertIn('repository', info.keys())
- self.assertIn('arch', info.keys())
- self.assertIn('version', info.keys())
-
- resp = self.request('/host/swupdate', '{}', 'POST')
- task = json.loads(resp.read())
- task_params = [u'id', u'message', u'status', u'target_uri']
- self.assertEquals(sorted(task_params), sorted(task.keys()))
-
- resp = self.request('/tasks/' + task[u'id'], None, 'GET')
- task_info = json.loads(resp.read())
- self.assertEquals(task_info['status'], 'running')
- wait_task(self._task_lookup, task_info['id'])
- resp = self.request('/tasks/' + task[u'id'], None, 'GET')
- task_info = json.loads(resp.read())
- self.assertEquals(task_info['status'], 'finished')
- self.assertIn(u'All packages updated', task_info['message'])
-
def test_repositories(self):
def verify_repo(t, res):
for field in ('repo_id', 'enabled', 'baseurl', 'config'):
--
2.1.0
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.
Signed-off-by: Jose Ricardo Ziviani <joserz(a)linux.vnet.ibm.com>
---
.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