Merge "Fix libvirt Connection.get_disks method"
This commit is contained in:
		| @@ -693,6 +693,66 @@ class LibvirtConnTestCase(test.TestCase): | |||||||
|         devices = conn.get_all_block_devices() |         devices = conn.get_all_block_devices() | ||||||
|         self.assertEqual(devices, ['/path/to/dev/1', '/path/to/dev/3']) |         self.assertEqual(devices, ['/path/to/dev/1', '/path/to/dev/3']) | ||||||
|  |  | ||||||
|  |     def test_get_disks(self): | ||||||
|  |         xml = [ | ||||||
|  |             # NOTE(vish): id 0 is skipped | ||||||
|  |             None, | ||||||
|  |             """ | ||||||
|  |                 <domain type='kvm'> | ||||||
|  |                     <devices> | ||||||
|  |                         <disk type='file'> | ||||||
|  |                             <source file='filename'/> | ||||||
|  |                             <target dev='vda' bus='virtio'/> | ||||||
|  |                         </disk> | ||||||
|  |                         <disk type='block'> | ||||||
|  |                             <source dev='/path/to/dev/1'/> | ||||||
|  |                             <target dev='vdb' bus='virtio'/> | ||||||
|  |                         </disk> | ||||||
|  |                     </devices> | ||||||
|  |                 </domain> | ||||||
|  |             """, | ||||||
|  |             """ | ||||||
|  |                 <domain type='kvm'> | ||||||
|  |                     <devices> | ||||||
|  |                         <disk type='file'> | ||||||
|  |                             <source file='filename'/> | ||||||
|  |                             <target dev='vda' bus='virtio'/> | ||||||
|  |                         </disk> | ||||||
|  |                     </devices> | ||||||
|  |                 </domain> | ||||||
|  |             """, | ||||||
|  |             """ | ||||||
|  |                 <domain type='kvm'> | ||||||
|  |                     <devices> | ||||||
|  |                         <disk type='file'> | ||||||
|  |                             <source file='filename'/> | ||||||
|  |                             <target dev='vda' bus='virtio'/> | ||||||
|  |                         </disk> | ||||||
|  |                         <disk type='block'> | ||||||
|  |                             <source dev='/path/to/dev/3'/> | ||||||
|  |                             <target dev='vdb' bus='virtio'/> | ||||||
|  |                         </disk> | ||||||
|  |                     </devices> | ||||||
|  |                 </domain> | ||||||
|  |             """, | ||||||
|  |         ] | ||||||
|  |  | ||||||
|  |         def fake_lookup(id): | ||||||
|  |             return FakeVirtDomain(xml[id]) | ||||||
|  |  | ||||||
|  |         def fake_lookup_name(name): | ||||||
|  |             return FakeVirtDomain(xml[1]) | ||||||
|  |  | ||||||
|  |         self.mox.StubOutWithMock(connection.LibvirtConnection, '_conn') | ||||||
|  |         connection.LibvirtConnection._conn.listDomainsID = lambda: range(4) | ||||||
|  |         connection.LibvirtConnection._conn.lookupByID = fake_lookup | ||||||
|  |         connection.LibvirtConnection._conn.lookupByName = fake_lookup_name | ||||||
|  |  | ||||||
|  |         self.mox.ReplayAll() | ||||||
|  |         conn = connection.LibvirtConnection(False) | ||||||
|  |         devices = conn.get_disks(conn.list_instances()[0]) | ||||||
|  |         self.assertEqual(devices, ['vda', 'vdb']) | ||||||
|  |  | ||||||
|     @test.skip_if(missing_libvirt(), "Test requires libvirt") |     @test.skip_if(missing_libvirt(), "Test requires libvirt") | ||||||
|     def test_snapshot_in_ami_format(self): |     def test_snapshot_in_ami_format(self): | ||||||
|         self.flags(image_service='nova.image.fake.FakeImageService') |         self.flags(image_service='nova.image.fake.FakeImageService') | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jenkins
					Jenkins