Why do we use mockmodel?
by Crístian Viana
Hi!
After creating a few patches for Kimchi, it occurred to me that the
mockmodel design has more cons than pros. So I started wondering why we
still use it.
I understand - and totally agree - that we should have an extensive test
infrastructure to make sure the code runs as designed and to make it
very easy to find regression bugs on every new feature we implement. And
as Kimchi works very integrated to its host system, it may not be easy
to create expected/failed situations for things we don't always have
control.
But for every new feature we implement, we currently have to:
1) Implement the feature itself
2) Create tests for (1)
3) Implement the feature in a mock environment
4) Create tests for (3)
And by looking at some existing code, many of the mock tests don't
actually test anything. They're just there so we can say we have a mock
implementation and a test for it. Why create a mock function and a test
for the mock function if what we need is to test the real code? And a
lot of times, the mock implementation (and the tests) are just
copy/paste of the original feature. For me, that seems very tedious and
useless.
Why don't we get rid of the mockmodel and keep only the "real" model? I
understand that it's not so simple to remove it right away, that's why
I'm starting this discussion so we could see how to do it better - if
we're actually going to do it. What would we miss if we didn't have the
mockmodel anymore? I believe we'll need to be more careful when writing
tests which run on a real environment (i.e. we can't "leak" VMs,
networks, templates, or anything else) but at least we'll always test
real code and we won't be writing code that won't be used.
Please share your opinion with us.
Best regards,
Crístian.
10 years, 2 months
[PATCH] Display "README" with markdown style on Github
by Crístian Viana
The file "README" is a markdown file but as it doesn't have the suffix
".md", Github doesn't render it with markdown style.
Rename the symlink "README" in order to be displayed with markdown style
on Github.
Signed-off-by: Crístian Viana <vianac(a)linux.vnet.ibm.com>
---
README | 1 -
README.md | 1 +
2 files changed, 1 insertion(+), 1 deletion(-)
delete mode 120000 README
create mode 120000 README.md
diff --git a/README b/README
deleted file mode 120000
index 0e01b43..0000000
--- a/README
+++ /dev/null
@@ -1 +0,0 @@
-docs/README.md
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 120000
index 0000000..0e01b43
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+docs/README.md
\ No newline at end of file
--
1.9.3
10 years, 2 months
[PATCH] Backend support for templates with sockets, cores, and threads
by Christy Perez
In order to allow a guest to use SMT/hyperthreading, we should
enable passing in of the sockets, cores, and threads values when
creating a template.
All three values must be specified, as per the topology descr at
http://libvirt.org/formatdomain.html#elementsCPU
Signed-off-by: Christy Perez <christy(a)linux.vnet.ibm.com>
---
docs/API.md | 7 +++++++
src/kimchi/API.json | 28 ++++++++++++++++++++++++++--
src/kimchi/control/templates.py | 11 ++++++++---
src/kimchi/osinfo.py | 2 +-
src/kimchi/vmtemplate.py | 22 ++++++++++++++++++++++
5 files changed, 64 insertions(+), 6 deletions(-)
diff --git a/docs/API.md b/docs/API.md
index d75c55f..cb4d541 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -200,6 +200,13 @@ Represents a snapshot of the Virtual Machine's primary monitor.
Independent Computing Environments
* null: Graphics is disabled or type not supported
* listen: The network which the vnc/spice server listens on.
+ * cpu_info *(optional)*: CPU-specific information.
+ * topology: Specify sockets, threads, and cores to run the virtual CPU
+ threads on.
+ All three are required in order to specify cpu topology.
+ * sockets - The number of sockets to use.
+ * cores - The number of cores per socket.
+ * threads - The number of threads per core.
### Sub-Collection: Virtual Machine Network Interfaces
diff --git a/src/kimchi/API.json b/src/kimchi/API.json
index c3fc5e3..d510634 100644
--- a/src/kimchi/API.json
+++ b/src/kimchi/API.json
@@ -26,6 +26,28 @@
]
}
}
+ },
+ "cpu_info": {
+ "description": "Configure CPU specifics for a VM.",
+ "type": "object",
+ "properties": {
+ "topology": {
+ "description": "Configure the guest CPU topology.",
+ "type": "object",
+ "properties": {
+ "sockets": {
+ "type": "number"
+ },
+ "cores": {
+ "type": "number"
+ },
+ "threads": {
+ "type": "number"
+ }
+ },
+ "required": [ "sockets", "cores", "threads" ]
+ }
+ }
}
},
"properties": {
@@ -438,7 +460,8 @@
"type": "array",
"items": { "type": "string" }
},
- "graphics": { "$ref": "#/kimchitype/graphics" }
+ "graphics": { "$ref": "#/kimchitype/graphics" },
+ "cpu_info": { "$ref": "#/kimchitype/cpu_info" }
},
"additionalProperties": false,
"error": "KCHAPI0001E"
@@ -608,7 +631,8 @@
"type": "array",
"items": { "type": "string" }
},
- "graphics": { "$ref": "#/kimchitype/graphics" }
+ "graphics": { "$ref": "#/kimchitype/graphics" },
+ "cpu_info": { "$ref": "#/kimchitype/cpu_info" }
},
"additionalProperties": false,
"error": "KCHAPI0001E"
diff --git a/src/kimchi/control/templates.py b/src/kimchi/control/templates.py
index e17fa54..5ef35ce 100644
--- a/src/kimchi/control/templates.py
+++ b/src/kimchi/control/templates.py
@@ -38,13 +38,14 @@ def __init__(self, model, ident):
self.update_params = ["name", "folder", "icon", "os_distro",
"storagepool", "os_version", "cpus",
"memory", "cdrom", "disks", "networks",
- "graphics"]
+ "graphics", "cpu_info"]
self.uri_fmt = "/templates/%s"
self.clone = self.generate_action_handler('clone')
@property
def data(self):
- return {'name': self.ident,
+ return_data = {
+ 'name': self.ident,
'icon': self.info['icon'],
'invalid': self.info['invalid'],
'os_distro': self.info['os_distro'],
@@ -56,4 +57,8 @@ def data(self):
'storagepool': self.info['storagepool'],
'networks': self.info['networks'],
'folder': self.info.get('folder', []),
- 'graphics': self.info['graphics']}
+ 'graphics': self.info['graphics']
+ }
+ if (self.info.get('cpu_info')):
+ return_data['cpu_info'] = self.info['cpu_info']
+ return return_data
diff --git a/src/kimchi/osinfo.py b/src/kimchi/osinfo.py
index 1ad353c..8492bb7 100644
--- a/src/kimchi/osinfo.py
+++ b/src/kimchi/osinfo.py
@@ -32,7 +32,7 @@
'power': ('ppc', 'ppc64')}
-common_spec = {'cpus': 1, 'cpu_cores': 1, 'cpu_threads': 1, 'memory': 1024,
+common_spec = {'cpus': 1, 'cpu_sockets': '1', 'cpu_cores': 1, 'cpu_threads': 1, 'memory': 1024,
'disks': [{'index': 0, 'size': 10}], 'cdrom_bus': 'ide',
'cdrom_index': 2, 'mouse_bus': 'ps2'}
diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
index 761bac5..c64e61d 100644
--- a/src/kimchi/vmtemplate.py
+++ b/src/kimchi/vmtemplate.py
@@ -359,6 +359,22 @@ def _get_input_output_xml(self):
input_output += sound % self.info
return input_output
+ def _get_cpu_xml(self):
+
+ cpu_info = self.info.get('cpu_info')
+ if cpu_info is not None:
+ cpu_topo = cpu_info.get('topology')
+ if cpu_topo is not None:
+ return """
+ <cpu>
+ <topology sockets='%(sockets)s'
+ cores='%(cores)s'
+ threads='%(threads)s'/>
+ </cpu>
+ """ % cpu_topo
+
+ return ""
+
def to_vm_xml(self, vm_name, vm_uuid, **kwargs):
params = dict(self.info)
params['name'] = vm_name
@@ -371,6 +387,11 @@ def to_vm_xml(self, vm_name, vm_uuid, **kwargs):
graphics = kwargs.get('graphics')
params['graphics'] = self._get_graphics_xml(graphics)
+ if params.get('cpu_info') is not None:
+ params['cpu_info'] = self._get_cpu_xml()
+ else:
+ params['cpu_info'] = ''
+
# Current implementation just allows to create disk in one single
# storage pool, so we cannot mix the types (scsi volumes vs img file)
storage_type = self._get_storage_type()
@@ -401,6 +422,7 @@ def to_vm_xml(self, vm_name, vm_uuid, **kwargs):
<uuid>%(uuid)s</uuid>
<memory unit='MiB'>%(memory)s</memory>
<vcpu>%(cpus)s</vcpu>
+ %(cpu_info)s
<os>
<type arch='%(arch)s'>hvm</type>
<boot dev='hd'/>
--
1.9.3
10 years, 2 months
A question about iSCSI storage pool
by Yu Xin Huo
I got a iSCSI target to work on my redhat with a USB disk to test iSCSI
storage pool and found below:
1. When create a iSCSI storage pool, I selected a target in dropdown list.
2. Once the pool is created, I see a volume named 'unit:0:0:1'.
3. When edit template, in the 'storage pool' dropdown, 'unit:0:0:1' is
listed there.
So 'unit:0:0:1' which indeed is a *volume* but listed as a *pool* in
template? or something I am misunderstanding?
10 years, 2 months
Kimchi UI design proposals
by Don S. Spangler
I recently created a page on the Kimchi wiki (UI Design Proposals
<https://github.com/kimchi-project/kimchi/wiki/UI-Design-Proposals>)
around developing a set of UI design proposals with the following goals:
* Provide a complete user interface and visual style for all major
tabs and tasks
* Maintain clean design and interactions in keeping with Kimchi directions
* Design flexible framework to allow for consistency when adding new
capabilities
* Enable design to support responsiveness and touch / mobile (tablet /
phone) interactions
We plan on making iterative updates to the screens and would like to
open it up to feedback. The initial focus has been the major content
areas (host, guest, template, storage, and networks) and will be working
on details of the interactions, including page level blueprints. The
layouts to support responsiveness are particularly important and would
be part of the next updates.
We look forward to your feedback, including areas that may need more
clarification and issues around implementation.
Thanks!
Don Spangler
10 years, 2 months
[PATCHv2] Fix: accelerate mockmodel for file upload
by lvroyce@linux.vnet.ibm.com
From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
v1>v2, use wait task rather than adding sleep time (Cristian)
File upload fails with error 404 because of small read is time consuming,
change read size and wait in test to guarentee storage volume
created when query URI.
Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
---
src/kimchi/mockmodel.py | 2 +-
tests/test_rest.py | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index ab4357d..cbbdba3 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -534,7 +534,7 @@ class MockModel(object):
size = 0
try:
while True:
- data = upload_file.file.read(8192)
+ data = upload_file.file.read(8192*32)
if not data:
break
size += len(data)
diff --git a/tests/test_rest.py b/tests/test_rest.py
index 7eb6233..99f2176 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -1947,9 +1947,10 @@ class RestTests(unittest.TestCase):
self.assertEquals(r.status_code, 202)
task = r.json()
- self._wait_task(task['id'])
+ self._wait_task(task['id'], 15)
resp = self.request('/storagepools/default/storagevolumes/%s' %
task['target_uri'].split('/')[-1])
+
self.assertEquals(200, resp.status)
# Create a file with 5M to upload
--
1.8.3.2
10 years, 2 months
[PATCH] Bug Fix: Correct select menu to handle empty input
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/js/widgets/select-menu.js | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/ui/js/widgets/select-menu.js b/ui/js/widgets/select-menu.js
index ad53200..c4b0209 100644
--- a/ui/js/widgets/select-menu.js
+++ b/ui/js/widgets/select-menu.js
@@ -36,8 +36,10 @@
var selectedClass = 'active';
var itemTag = 'li';
var item;
+ that.listControl.find('li').remove();
+ that.label.text("");
+ that.target.val("");
if (options.length > 0) {
- that.listControl.find('li').remove();
$.each(options, function(index, option) {
item = $('<' + itemTag + '>' + option.label +'</' + itemTag + '>');
item.data('value', option.value);
@@ -58,8 +60,6 @@
that.target.change();
}
});
- } else {
- kimchi.message.error.code('KCHAPI6006E');
}
},
--
1.7.1
10 years, 2 months
[PATCH V4] Bugfix: Cancel option not working properly in New Storage Define
by Wen Wang
From: Wen Wang <wenwang(a)linux.vnet.ibm.com>
V3 -> V4:
Move the duplicate part to a function that reduce the duplication.
V2 -> V3:
Make the button style change properly with different storage pool types.
V1 -> V2:
Make the "Create" button change style and disable the input box only
when clicked on "ok" in "confirm" diaguage. The button and the input
style stay the same if user cancel the creating job.
This bug fix the defect that when adding a new logical storage pool, a
confrim message box show up and when canceling it, the inputbox as well
as button "Create" is still disabled.
Signed-off-by: Wen Wang <wenwang(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.storagepool_add_main.js | 37 +++++++++++++-----------------
1 files changed, 16 insertions(+), 21 deletions(-)
diff --git a/ui/js/src/kimchi.storagepool_add_main.js b/ui/js/src/kimchi.storagepool_add_main.js
index 4f1f943..ffe8fb6 100644
--- a/ui/js/src/kimchi.storagepool_add_main.js
+++ b/ui/js/src/kimchi.storagepool_add_main.js
@@ -352,8 +352,6 @@ kimchi.validateLogicalForm = function () {
kimchi.addPool = function(event) {
if (kimchi.validateForm()) {
- $('#pool-doAdd').hide();
- $('#pool-loading').show();
var formData = $('#form-pool-add').serializeObject();
delete formData.authname;
var poolType = $('#poolTypeId').selectMenu('value');
@@ -390,16 +388,11 @@ kimchi.addPool = function(event) {
} else if (poolType === 'scsi'){
formData.source = { adapter_name: $('#scsiAdapter').selectMenu('value') };
}
- $('input', '#form-pool-add').attr('disabled','disabled');
- if (poolType === 'logical') {
- var settings = {
- title : i18n['KCHAPI6001M'],
- content : i18n['KCHPOOL6003M'],
- confirm : i18n['KCHAPI6002M'],
- cancel : i18n['KCHAPI6003M']
- };
- kimchi.confirm(settings, function() {
- kimchi.createStoragePool(formData, function() {
+ var storagePoolAddingFunc = function() {
+ $('input', '#form-pool-add').attr('disabled','disabled');
+ $('#pool-doAdd').hide();
+ $('#pool-loading').show();
+ kimchi.createStoragePool(formData, function() {
kimchi.doListStoragePools();
kimchi.window.close();
}, function(err) {
@@ -408,18 +401,20 @@ kimchi.addPool = function(event) {
$('#pool-loading').hide();
$('#pool-doAdd').show();
});
+ };
+ if (poolType === 'logical') {
+ var settings = {
+ title : i18n['KCHAPI6001M'],
+ content : i18n['KCHPOOL6003M'],
+ confirm : i18n['KCHAPI6002M'],
+ cancel : i18n['KCHAPI6003M']
+ };
+ kimchi.confirm(settings, function() {
+ storagePoolAddingFunc();
}, function() {
});
} else {
- kimchi.createStoragePool(formData, function() {
- kimchi.doListStoragePools();
- kimchi.window.close();
- }, function(err) {
- kimchi.message.error(err.responseJSON.reason);
- $('input', '#form-pool-add').removeAttr('disabled');
- $('#pool-loading').hide();
- $('#pool-doAdd').show();
- });
+ storagePoolAddingFunc();
}
}
};
--
1.7.1
10 years, 2 months
[PATCH V2] Bug Fix: Correct select menu to handle empty input
by Wen Wang
From: Yu Xin Huo <huoyuxin(a)linux.vnet.ibm.com>
V1 -> V2:
Have the message item "Options needed." deleted from
"ui/pages/i18n.json.tmpl" and make the proper change with each po file.
Signed-off-by: Yu Xin Huo <huoyuxin(a)linux.vnet.ibm.com>
Signed-off-by: Wen Wang <wenwang(a)linux.vnet.ibm.com>
---
po/de_DE.po | 3 ---
po/en_US.po | 3 ---
po/es_ES.po | 3 ---
po/fr_FR.po | 3 ---
po/it_IT.po | 3 ---
po/ja_JP.po | 3 ---
po/kimchi.pot | 3 ---
po/ko_KR.po | 3 ---
po/pt_BR.po | 3 ---
po/ru_RU.po | 3 ---
po/zh_CN.po | 3 ---
po/zh_TW.po | 3 ---
ui/js/widgets/select-menu.js | 6 +++---
ui/pages/i18n.json.tmpl | 1 -
14 files changed, 3 insertions(+), 40 deletions(-)
diff --git a/po/de_DE.po b/po/de_DE.po
index 9d25e20..98bde90 100644
--- a/po/de_DE.po
+++ b/po/de_DE.po
@@ -1256,9 +1256,6 @@ msgstr "Dies ist kein gültiger URL."
msgid "No such data available."
msgstr "Keine solchen Daten verfügbar."
-msgid "Options needed."
-msgstr ""
-
msgid ""
"Can not contact the host system. Verify the host system is up and that you "
"have network connectivity to it. HTTP request response %1. "
diff --git a/po/en_US.po b/po/en_US.po
index e36c88d..eb571ca 100644
--- a/po/en_US.po
+++ b/po/en_US.po
@@ -1128,9 +1128,6 @@ msgstr ""
msgid "No such data available."
msgstr ""
-msgid "Options needed."
-msgstr ""
-
msgid ""
"Can not contact the host system. Verify the host system is up and that you "
"have network connectivity to it. HTTP request response %1. "
diff --git a/po/es_ES.po b/po/es_ES.po
index 1279969..5a3fa46 100644
--- a/po/es_ES.po
+++ b/po/es_ES.po
@@ -1274,9 +1274,6 @@ msgstr "No es un URL válido."
msgid "No such data available."
msgstr "No hay datos de ese tipo disponibles."
-msgid "Options needed."
-msgstr ""
-
msgid ""
"Can not contact the host system. Verify the host system is up and that you "
"have network connectivity to it. HTTP request response %1. "
diff --git a/po/fr_FR.po b/po/fr_FR.po
index a13ef9f..414dd4a 100644
--- a/po/fr_FR.po
+++ b/po/fr_FR.po
@@ -1263,9 +1263,6 @@ msgstr "Ce n'est pas une URL valide."
msgid "No such data available."
msgstr "De telles données ne sont pas disponibles."
-msgid "Options needed."
-msgstr ""
-
msgid ""
"Can not contact the host system. Verify the host system is up and that you "
"have network connectivity to it. HTTP request response %1. "
diff --git a/po/it_IT.po b/po/it_IT.po
index d710a66..4a6c919 100644
--- a/po/it_IT.po
+++ b/po/it_IT.po
@@ -1243,9 +1243,6 @@ msgstr "Non è un URL valido."
msgid "No such data available."
msgstr "Dati indicati non disponibili."
-msgid "Options needed."
-msgstr ""
-
msgid ""
"Can not contact the host system. Verify the host system is up and that you "
"have network connectivity to it. HTTP request response %1. "
diff --git a/po/ja_JP.po b/po/ja_JP.po
index d8d20f7..af00487 100644
--- a/po/ja_JP.po
+++ b/po/ja_JP.po
@@ -1253,9 +1253,6 @@ msgstr "有効な URL ではありません。"
msgid "No such data available."
msgstr "そのようなデータはありません。"
-msgid "Options needed."
-msgstr ""
-
msgid ""
"Can not contact the host system. Verify the host system is up and that you "
"have network connectivity to it. HTTP request response %1. "
diff --git a/po/kimchi.pot b/po/kimchi.pot
index e72ddcd..685802e 100755
--- a/po/kimchi.pot
+++ b/po/kimchi.pot
@@ -1128,9 +1128,6 @@ msgstr ""
msgid "No such data available."
msgstr ""
-msgid "Options needed."
-msgstr ""
-
msgid ""
"Can not contact the host system. Verify the host system is up and that you "
"have network connectivity to it. HTTP request response %1. "
diff --git a/po/ko_KR.po b/po/ko_KR.po
index 7946cb2..a9f82e4 100644
--- a/po/ko_KR.po
+++ b/po/ko_KR.po
@@ -1185,9 +1185,6 @@ msgstr "올바른 URL이 아닙니다."
msgid "No such data available."
msgstr "해당 데이터가 없습니다."
-msgid "Options needed."
-msgstr ""
-
msgid ""
"Can not contact the host system. Verify the host system is up and that you "
"have network connectivity to it. HTTP request response %1. "
diff --git a/po/pt_BR.po b/po/pt_BR.po
index a86567d..f2fba64 100644
--- a/po/pt_BR.po
+++ b/po/pt_BR.po
@@ -1265,9 +1265,6 @@ msgstr "Essa não é uma URL válida."
msgid "No such data available."
msgstr "Não há dados disponíveis."
-msgid "Options needed."
-msgstr "Opções necessárias."
-
msgid ""
"Can not contact the host system. Verify the host system is up and that you "
"have network connectivity to it. HTTP request response %1. "
diff --git a/po/ru_RU.po b/po/ru_RU.po
index f17f9bc..059b999 100644
--- a/po/ru_RU.po
+++ b/po/ru_RU.po
@@ -1184,9 +1184,6 @@ msgstr "Это недопустимый URL."
msgid "No such data available."
msgstr "Нет таких данных."
-msgid "Options needed."
-msgstr ""
-
msgid ""
"Can not contact the host system. Verify the host system is up and that you "
"have network connectivity to it. HTTP request response %1. "
diff --git a/po/zh_CN.po b/po/zh_CN.po
index 5bf59ca..f77e405 100644
--- a/po/zh_CN.po
+++ b/po/zh_CN.po
@@ -1151,9 +1151,6 @@ msgstr "这不是一个有效的URL"
msgid "No such data available."
msgstr "没有可用的数据"
-msgid "Options needed."
-msgstr "需要选项。"
-
msgid ""
"Can not contact the host system. Verify the host system is up and that you "
"have network connectivity to it. HTTP request response %1. "
diff --git a/po/zh_TW.po b/po/zh_TW.po
index 9db4edf..4040b2a 100644
--- a/po/zh_TW.po
+++ b/po/zh_TW.po
@@ -1131,9 +1131,6 @@ msgstr "這是無效的 URL。"
msgid "No such data available."
msgstr "沒有此類可用資料。"
-msgid "Options needed."
-msgstr ""
-
msgid ""
"Can not contact the host system. Verify the host system is up and that you "
"have network connectivity to it. HTTP request response %1. "
diff --git a/ui/js/widgets/select-menu.js b/ui/js/widgets/select-menu.js
index ad53200..c4b0209 100644
--- a/ui/js/widgets/select-menu.js
+++ b/ui/js/widgets/select-menu.js
@@ -36,8 +36,10 @@
var selectedClass = 'active';
var itemTag = 'li';
var item;
+ that.listControl.find('li').remove();
+ that.label.text("");
+ that.target.val("");
if (options.length > 0) {
- that.listControl.find('li').remove();
$.each(options, function(index, option) {
item = $('<' + itemTag + '>' + option.label +'</' + itemTag + '>');
item.data('value', option.value);
@@ -58,8 +60,6 @@
that.target.change();
}
});
- } else {
- kimchi.message.error.code('KCHAPI6006E');
}
},
diff --git a/ui/pages/i18n.json.tmpl b/ui/pages/i18n.json.tmpl
index c52b175..75f1e43 100644
--- a/ui/pages/i18n.json.tmpl
+++ b/ui/pages/i18n.json.tmpl
@@ -39,7 +39,6 @@
"KCHAPI6003E": "$_("This is not a valid Linux path")",
"KCHAPI6004E": "$_("This is not a valid URL.")",
"KCHAPI6005E": "$_("No such data available.")",
- "KCHAPI6006E": "$_("Options needed.")",
"KCHAPI6007E": "$_("Can not contact the host system. Verify the host system is up and that you have network connectivity to it. HTTP request response %1. ")",
"KCHAPI6001M": "$_("Delete Confirmation")",
--
1.7.1
10 years, 2 months
[PATCHv6] Fix wrong config param of repository creation
by lvroyce@linux.vnet.ibm.com
From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
Wrong config param for repository creation needs to be rejected,
also fix correspoding testcases.
Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
---
src/kimchi/i18n.py | 1 +
src/kimchi/repositories.py | 11 ++++++++++-
tests/test_model.py | 13 +++++++++++--
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index d402dde..1b543ce 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -288,4 +288,5 @@ messages = {
"KCHREPOS0025E": _("Unable to retrieve repository information. Details: '%(err)s'"),
"KCHREPOS0026E": _("Unable to add repository. Details: '%(err)s'"),
"KCHREPOS0027E": _("Unable to remove repository. Details: '%(err)s'"),
+ "KCHREPOS0028E": _("Configuration items: '%(items)s' are not supported by repository manager"),
}
diff --git a/src/kimchi/repositories.py b/src/kimchi/repositories.py
index 19edc22..f826ac9 100644
--- a/src/kimchi/repositories.py
+++ b/src/kimchi/repositories.py
@@ -26,7 +26,7 @@ from ConfigParser import ConfigParser
from kimchi.basemodel import Singleton
from kimchi.config import kimchiLock
-from kimchi.exception import InvalidOperation
+from kimchi.exception import InvalidOperation, InvalidParameter
from kimchi.exception import OperationFailed, NotFoundError, MissingParameter
from kimchi.utils import validate_repo_url
@@ -52,6 +52,13 @@ class Repositories(object):
"""
Add and enable a new repository
"""
+ config = params.get('config', {})
+ extra_keys = list(
+ set(config.keys()).difference(set(self._pkg_mnger.CONFIG_ENTRY)))
+ if len(extra_keys) > 0:
+ raise InvalidParameter("KCHREPOS0028E",
+ {'items': ",".join(extra_keys)})
+
return self._pkg_mnger.addRepo(params)
def getRepositories(self):
@@ -105,6 +112,7 @@ class YumRepo(object):
"""
TYPE = 'yum'
DEFAULT_CONF_DIR = "/etc/yum.repos.d"
+ CONFIG_ENTRY = ('repo_name', 'mirrorlist')
def __init__(self):
self._yb = getattr(__import__('yum'), 'YumBase')
@@ -319,6 +327,7 @@ class AptRepo(object):
"""
TYPE = 'deb'
KIMCHI_LIST = "kimchi-source.list"
+ CONFIG_ENTRY = ('dist', 'comps')
def __init__(self):
getattr(__import__('apt_pkg'), 'init_config')()
diff --git a/tests/test_model.py b/tests/test_model.py
index 63032f5..1f2e79c 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -1309,8 +1309,7 @@ class ModelTests(unittest.TestCase):
'baseurl': 'http://www.fedora.org'},
{'repo_id': 'fedora-updates-fake',
'config':
- {'mirrorlist': 'http://www.fedoraproject.org',
- 'gpgkey': 'file:///tmp/KEY-fedora-updates-fake-19'}}]
+ {'mirrorlist': 'http://www.fedoraproject.org'}}]
deb_repos = [{'baseurl': 'http://archive.ubuntu.com/ubuntu/',
'config': {'dist': 'quantal'}},
@@ -1325,12 +1324,22 @@ class ModelTests(unittest.TestCase):
wrong_mirrorlist = {'repo_id': 'wrong-id',
'baseurl': 'www.example.com',
'config': {'mirrorlist': url}}
+ wrong_config_item = {
+ 'repo_id': 'wrong-id',
+ 'baseurl': 'www.example.com',
+ 'config': {
+ 'gpgkey': 'file:///tmp/KEY-fedora-updates-fake-19'}}
yum_invalid_repos.append(wrong_baseurl)
yum_invalid_repos.append(wrong_mirrorlist)
+ yum_invalid_repos.append(wrong_config_item)
wrong_baseurl['config'] = {'dist': 'tasty'}
+ wrong_config = {'baseurl': deb_repos[0]['baseurl'],
+ 'config': {
+ 'unsupported_item': "a_unsupported_item"}}
deb_invalid_repos.append(wrong_baseurl)
+ deb_invalid_repos.append(wrong_config)
repo_type = inst.capabilities_lookup()['repo_mngt_tool']
if repo_type == 'yum':
--
1.8.3.2
10 years, 2 months