Add libvirt config classes for handling capabilities XML doc
Libvirt exposes the host/hypervisor features using an XML schema known as "capabilities". Currently the libvirt driver code just parses this in an adhoc manner using xpath queries. This change provides a handful of classes LibvirtConfigCaps, LibvirtConfigCapsHost and LibvirtConfigCapsGuest for maintaining an object based representation of the capabilities. The LibvirtConfigCapsHost class also uses the existing LibvirtConfigCPU class Fixes: bug #1003373 Implements: blueprint libvirt-xml-cpu-model Change-Id: Ie962c6378b0da09eddc75983d4824a226ed1c25e Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
		| @@ -59,6 +59,41 @@ class LibvirtConfigTest(LibvirtConfigBaseTest): | |||||||
|         obj.parse_str(inxml) |         obj.parse_str(inxml) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class LibvirtConfigCapsTest(LibvirtConfigBaseTest): | ||||||
|  |  | ||||||
|  |     def test_config_host(self): | ||||||
|  |         xmlin = """ | ||||||
|  |         <capabilities> | ||||||
|  |           <host> | ||||||
|  |             <cpu> | ||||||
|  |               <arch>x86_64</arch> | ||||||
|  |               <model>Opteron_G3</model> | ||||||
|  |               <vendor>AMD</vendor> | ||||||
|  |               <topology sockets='1' cores='4' threads='1'/> | ||||||
|  |               <feature name='ibs'/> | ||||||
|  |               <feature name='osvw'/> | ||||||
|  |             </cpu> | ||||||
|  |           </host> | ||||||
|  |           <guest> | ||||||
|  |             <os_type>hvm</os_type> | ||||||
|  |             <arch name='x86_64'/> | ||||||
|  |           </guest> | ||||||
|  |           <guest> | ||||||
|  |             <os_type>hvm</os_type> | ||||||
|  |             <arch name='i686'/> | ||||||
|  |           </guest> | ||||||
|  |         </capabilities>""" | ||||||
|  |  | ||||||
|  |         obj = config.LibvirtConfigCaps() | ||||||
|  |         obj.parse_str(xmlin) | ||||||
|  |  | ||||||
|  |         self.assertEqual(type(obj.host), config.LibvirtConfigCapsHost) | ||||||
|  |  | ||||||
|  |         xmlout = obj.to_xml() | ||||||
|  |  | ||||||
|  |         self.assertXmlEqual(xmlin, xmlout) | ||||||
|  |  | ||||||
|  |  | ||||||
| class LibvirtConfigGuestTimerTest(LibvirtConfigBaseTest): | class LibvirtConfigGuestTimerTest(LibvirtConfigBaseTest): | ||||||
|     def test_config_platform(self): |     def test_config_platform(self): | ||||||
|         obj = config.LibvirtConfigGuestTimer() |         obj = config.LibvirtConfigGuestTimer() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Daniel P. Berrange
					Daniel P. Berrange