mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Fix virt.pool_info usage in virt.update
pool_info was changed to return a dict of pool infos even for a single pool search. Adapt calls of it in the virt module.
This commit is contained in:
parent
333a133f83
commit
040bf4a39c
@ -928,7 +928,8 @@ def _fill_disk_filename(vm_name, disk, hypervisor, **kwargs):
|
||||
else:
|
||||
if not base_dir.startswith('/'):
|
||||
# The pool seems not to be a path, lookup for pool infos
|
||||
pool = pool_info(base_dir, **kwargs)
|
||||
infos = pool_info(base_dir, **kwargs)
|
||||
pool = infos[base_dir] if base_dir in infos else None
|
||||
if not pool or not pool['target_path'] or pool['target_path'].startswith('/dev'):
|
||||
raise CommandExecutionError(
|
||||
'Unable to create new disk {0}, specified pool {1} does not exist '
|
||||
|
@ -636,32 +636,32 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
|
||||
self.assertTrue(len(root.findall('.//interface')) == 2)
|
||||
|
||||
@patch('salt.modules.virt.pool_info',
|
||||
return_value={'target_path': os.path.join(salt.syspaths.ROOT_DIR,
|
||||
'pools',
|
||||
'default')})
|
||||
return_value={'mypool': {'target_path': os.path.join(salt.syspaths.ROOT_DIR, 'pools', 'mypool')}})
|
||||
def test_disk_profile_kvm_disk_pool(self, mock_poolinfo):
|
||||
'''
|
||||
Test virt._gen_xml(), KVM case with pools defined.
|
||||
'''
|
||||
disks = {
|
||||
'noeffect': [
|
||||
{'first': {'size': 8192, 'pool': 'default'}},
|
||||
{'first': {'size': 8192, 'pool': 'mypool'}},
|
||||
{'second': {'size': 4096}}
|
||||
]
|
||||
}
|
||||
|
||||
# pylint: disable=no-member
|
||||
with patch.dict(virt.__salt__, {'config.get': MagicMock(side_effect=[
|
||||
disks,
|
||||
os.path.join(salt.syspaths.ROOT_DIR, 'default', 'path')])}):
|
||||
|
||||
diskp = virt._disk_profile('noeffect', 'kvm', [], 'hello')
|
||||
|
||||
pools_path = os.path.join(
|
||||
salt.syspaths.ROOT_DIR, 'pools', 'default') + os.sep
|
||||
default_path = os.path.join(
|
||||
salt.syspaths.ROOT_DIR, 'default', 'path') + os.sep
|
||||
pools_path = os.path.join(salt.syspaths.ROOT_DIR, 'pools', 'mypool') + os.sep
|
||||
default_path = os.path.join(salt.syspaths.ROOT_DIR, 'default', 'path') + os.sep
|
||||
|
||||
self.assertEqual(len(diskp), 2)
|
||||
self.assertTrue(diskp[0]['source_file'].startswith(pools_path))
|
||||
self.assertTrue(diskp[1]['source_file'].startswith(default_path))
|
||||
# pylint: enable=no-member
|
||||
|
||||
def test_disk_profile_kvm_disk_external_image(self):
|
||||
'''
|
||||
|
Loading…
Reference in New Issue
Block a user