[PATCH 0/2 V2] Fix VM's network model template for Power systems.

This patchset setup the network model to 'spapr-vlan' by default in those old distro vesions for new Power guests, creates a new format to modern distro versions dictionary and setup the modern distro version for Power guests: RHEL7.0 and Fedora 19. Also, fix the testcase that checks osinfo information to use the new modern distro versions dictionary and fixed PEP8 to this file. Paulo Vital (2): Fix VM's network model template for Power systems. Fix test_osinfo.py to use new modern distro version dict. Makefile.am | 1 + src/kimchi/osinfo.py | 14 ++++++++------ tests/test_osinfo.py | 9 +++++---- 3 files changed, 14 insertions(+), 10 deletions(-) -- 1.8.3.1

Setup the network model to 'spapr-vlan' by default in those old distro vesions for new Power guests. Also, setup the modern distro version for Power guests: RHEL7.0 and Fedora 19. Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com> --- src/kimchi/osinfo.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/kimchi/osinfo.py b/src/kimchi/osinfo.py index 8ce4110..a50daae 100644 --- a/src/kimchi/osinfo.py +++ b/src/kimchi/osinfo.py @@ -41,7 +41,7 @@ template_specs = {'x86': {'old': dict(common_spec, disk_bus='ide', nic_model='virtio', sound_model= 'ich6')}, 'power': {'old': dict(common_spec, disk_bus='scsi', - nic_model='rtl8139', cdrom_bus='scsi', + nic_model='spapr-vlan', cdrom_bus='scsi', kbd_bus='usb', mouse_bus='usb'), 'modern': dict(common_spec, disk_bus='virtio', nic_model='virtio', @@ -49,9 +49,10 @@ template_specs = {'x86': {'old': dict(common_spec, disk_bus='ide', mouse_bus='usb')}} -modern_version_bases = {'debian': '6.0', 'ubuntu': '7.10', 'opensuse': '10.3', - 'centos': '5.3', 'rhel': '6.0', 'fedora': '16', - 'gentoo': '0'} +modern_version_bases = {'x86': {'debian': '6.0', 'ubuntu': '7.10', + 'opensuse': '10.3', 'centos': '5.3', + 'rhel': '6.0', 'fedora': '16', 'gentoo': '0'}, + 'power': {'rhel': '7.0', 'fedora': '19'}} isolinks = { @@ -97,9 +98,10 @@ def lookup(distro, version): params['cdrom'] = isolinks.get(distro, {}).get(version, '') arch = _get_arch() - if distro in modern_version_bases: + if distro in modern_version_bases[arch]: params['icon'] = 'images/icon-%s.png' % distro - if LooseVersion(version) >= LooseVersion(modern_version_bases[distro]): + if LooseVersion(version) >= LooseVersion( + modern_version_bases[arch][distro]): params.update(template_specs[arch]['modern']) else: params.update(template_specs[arch]['old']) -- 1.8.3.1

Reviewed-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> On 03/01/2014 03:52 AM, Paulo Vital wrote:
Setup the network model to 'spapr-vlan' by default in those old distro vesions for new Power guests.
Also, setup the modern distro version for Power guests: RHEL7.0 and Fedora 19.
Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com> --- src/kimchi/osinfo.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/kimchi/osinfo.py b/src/kimchi/osinfo.py index 8ce4110..a50daae 100644 --- a/src/kimchi/osinfo.py +++ b/src/kimchi/osinfo.py @@ -41,7 +41,7 @@ template_specs = {'x86': {'old': dict(common_spec, disk_bus='ide', nic_model='virtio', sound_model= 'ich6')}, 'power': {'old': dict(common_spec, disk_bus='scsi', - nic_model='rtl8139', cdrom_bus='scsi', + nic_model='spapr-vlan', cdrom_bus='scsi', kbd_bus='usb', mouse_bus='usb'), 'modern': dict(common_spec, disk_bus='virtio', nic_model='virtio', @@ -49,9 +49,10 @@ template_specs = {'x86': {'old': dict(common_spec, disk_bus='ide', mouse_bus='usb')}}
-modern_version_bases = {'debian': '6.0', 'ubuntu': '7.10', 'opensuse': '10.3', - 'centos': '5.3', 'rhel': '6.0', 'fedora': '16', - 'gentoo': '0'} +modern_version_bases = {'x86': {'debian': '6.0', 'ubuntu': '7.10', + 'opensuse': '10.3', 'centos': '5.3', + 'rhel': '6.0', 'fedora': '16', 'gentoo': '0'}, + 'power': {'rhel': '7.0', 'fedora': '19'}}
isolinks = { @@ -97,9 +98,10 @@ def lookup(distro, version): params['cdrom'] = isolinks.get(distro, {}).get(version, '') arch = _get_arch()
- if distro in modern_version_bases: + if distro in modern_version_bases[arch]: params['icon'] = 'images/icon-%s.png' % distro - if LooseVersion(version) >= LooseVersion(modern_version_bases[distro]): + if LooseVersion(version) >= LooseVersion( + modern_version_bases[arch][distro]): params.update(template_specs[arch]['modern']) else: params.update(template_specs[arch]['old'])
-- Thanks and best regards! Sheldon Feng(冯少合)<shaohef@linux.vnet.ibm.com> IBM Linux Technology Center

Fix the testcase to use the new format of the modern distro version dictionary. In addition, fixed PEP8 issues and added this file to Makefile.am Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com> --- Makefile.am | 1 + tests/test_osinfo.py | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index 22944d5..0fd019e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -61,6 +61,7 @@ PEP8_WHITELIST = \ tests/test_config.py.in \ tests/test_mockmodel.py \ tests/test_model.py \ + tests/test_osinfo.py \ tests/test_plugin.py \ tests/test_rest.py \ tests/test_rollbackcontext.py \ diff --git a/tests/test_osinfo.py b/tests/test_osinfo.py index 8020895..104e7b8 100644 --- a/tests/test_osinfo.py +++ b/tests/test_osinfo.py @@ -15,12 +15,12 @@ # # 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 +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA import unittest -from kimchi.osinfo import lookup, modern_version_bases +from kimchi.osinfo import lookup, modern_version_bases, _get_arch class OSInfoTests(unittest.TestCase): @@ -31,7 +31,8 @@ class OSInfoTests(unittest.TestCase): self.assertEquals(['default'], entry['networks']) def test_fedora_lookup(self): - cd = 'http://fedora.mirrors.tds.net/pub/fedora/releases/17/Live/x86_64/Fedora-17-x...' + cd = ('http://fedora.mirrors.tds.net/pub/fedora/releases/17/Live/' + 'x86_64/Fedora-17-x86_64-Live-Desktop.iso') entry = lookup('fedora', '17') self.assertEquals(10, entry['disks'][0]['size']) self.assertEquals(cd, entry['cdrom']) @@ -46,7 +47,7 @@ class OSInfoTests(unittest.TestCase): self.assertEquals(entry['nic_model'], 'e1000') def test_modern_bases(self): - for distro, version in modern_version_bases.iteritems(): + for distro, version in modern_version_bases[_get_arch()].iteritems(): entry = lookup(distro, version) self.assertEquals(entry['disk_bus'], 'virtio') self.assertEquals(entry['nic_model'], 'virtio') -- 1.8.3.1

Reviewed-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> On 03/01/2014 03:52 AM, Paulo Vital wrote:
Fix the testcase to use the new format of the modern distro version dictionary.
In addition, fixed PEP8 issues and added this file to Makefile.am
Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com> --- Makefile.am | 1 + tests/test_osinfo.py | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/Makefile.am b/Makefile.am index 22944d5..0fd019e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -61,6 +61,7 @@ PEP8_WHITELIST = \ tests/test_config.py.in \ tests/test_mockmodel.py \ tests/test_model.py \ + tests/test_osinfo.py \ tests/test_plugin.py \ tests/test_rest.py \ tests/test_rollbackcontext.py \ diff --git a/tests/test_osinfo.py b/tests/test_osinfo.py index 8020895..104e7b8 100644 --- a/tests/test_osinfo.py +++ b/tests/test_osinfo.py @@ -15,12 +15,12 @@ # # 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 +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import unittest
-from kimchi.osinfo import lookup, modern_version_bases +from kimchi.osinfo import lookup, modern_version_bases, _get_arch
class OSInfoTests(unittest.TestCase): @@ -31,7 +31,8 @@ class OSInfoTests(unittest.TestCase): self.assertEquals(['default'], entry['networks'])
def test_fedora_lookup(self): - cd = 'http://fedora.mirrors.tds.net/pub/fedora/releases/17/Live/x86_64/Fedora-17-x...' + cd = ('http://fedora.mirrors.tds.net/pub/fedora/releases/17/Live/' + 'x86_64/Fedora-17-x86_64-Live-Desktop.iso') entry = lookup('fedora', '17') self.assertEquals(10, entry['disks'][0]['size']) self.assertEquals(cd, entry['cdrom']) @@ -46,7 +47,7 @@ class OSInfoTests(unittest.TestCase): self.assertEquals(entry['nic_model'], 'e1000')
def test_modern_bases(self): - for distro, version in modern_version_bases.iteritems(): + for distro, version in modern_version_bases[_get_arch()].iteritems(): entry = lookup(distro, version) self.assertEquals(entry['disk_bus'], 'virtio') self.assertEquals(entry['nic_model'], 'virtio')
-- Thanks and best regards! Sheldon Feng(冯少合)<shaohef@linux.vnet.ibm.com> IBM Linux Technology Center
participants (3)
-
Aline Manera
-
Paulo Vital
-
Sheldon