[Kimchi-devel] [PATCH] bug fix: add an icon distros list.

Sheldon shaohef at linux.vnet.ibm.com
Mon Mar 10 14:07:40 UTC 2014


On 03/10/2014 10:02 PM, Aline Manera wrote:
> On 03/10/2014 09:36 AM, shaohef at linux.vnet.ibm.com wrote:
>> From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>>
>> Now I create template with rhel iso, but when I create a VM from this
>> template, the template info displays differently with other templates.
>>
>> That's because icon-rhel is missing for it is RED HAT trademark.
>>
>> But this make us uncomfortable.
>> If the icon is missing we should display the default icon
>>
>> Now there are only 7 icons, include the default icon icon-vm.
>>
>> $ ls ui/images/*.png
>> ui/images/icon-centos.png ui/images/icon-gentoo.png
>> ui/images/icon-debian.png ui/images/icon-opensuse.png
>> ui/images/icon-fedora.png ui/images/icon-ubuntu.png
>> ui/images/icon-vm.png
>>
>> Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>> ---
>> src/kimchi/osinfo.py | 9 +++++++--
>> 1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/kimchi/osinfo.py b/src/kimchi/osinfo.py
>> index 106cc0e..2eac63e 100644
>> --- a/src/kimchi/osinfo.py
>> +++ b/src/kimchi/osinfo.py
>> @@ -55,6 +55,8 @@ modern_version_bases = {'x86': {'debian': '6.0', 
>> 'ubuntu': '7.10',
>> 'rhel': '6.0', 'fedora': '16', 'gentoo': '0'},
>> 'power': {'rhel': '7.0', 'fedora': '19'}}
>>
>> +icon_available_distros = ['debian', 'centos', 'fedora',
>> + 'gentoo', 'opensuse', 'ubuntu']
>
> I'd suggest to get this information dinamically.
>
> Something like:
>
> icon_available_distros = glob.glob("ui/images/*.png")
>
> That way we don't need to update the code when new images are added.
ACK
>
>
>> isolinks = {
>> 'debian': {
>> @@ -100,15 +102,18 @@ def lookup(distro, version):
>> arch = _get_arch()
>>
>> if distro in modern_version_bases[arch]:
>> - params['icon'] = 'images/icon-%s.png' % distro
>> if LooseVersion(version) >= LooseVersion(
>> modern_version_bases[arch][distro]):
>> params.update(template_specs[arch]['modern'])
>> else:
>> params.update(template_specs[arch]['old'])
>> else:
>> - params['icon'] = 'images/icon-vm.png'
>> params['os_distro'] = params['os_version'] = "unknown"
>> params.update(template_specs[arch]['old'])
>>
>> + if distro in icon_available_distros:
>> + params['icon'] = 'images/icon-%s.png' % distro
>> + else
>> + params['icon'] = 'images/icon-vm.png'
>> +
>> return params
>
>
>


-- 
Thanks and best regards!

Sheldon Feng(冯少合)<shaohef at linux.vnet.ibm.com>
IBM Linux Technology Center




More information about the Kimchi-devel mailing list