Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove virt.pool_delete fast parameter #54475

Merged
merged 3 commits into from
Dec 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions salt/modules/virt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4838,13 +4838,11 @@ def pool_undefine(name, **kwargs):
conn.close()


def pool_delete(name, fast=True, **kwargs):
def pool_delete(name, **kwargs):
'''
Delete the resources of a defined libvirt storage pool.

:param name: libvirt storage pool name
:param fast: if set to False, zeroes out all the data.
Default value is True.
:param connection: libvirt connection URI, overriding defaults
:param username: username to connect with, overriding defaults
:param password: password to connect with, overriding defaults
Expand All @@ -4860,10 +4858,7 @@ def pool_delete(name, fast=True, **kwargs):
conn = __get_conn(**kwargs)
try:
pool = conn.storagePoolLookupByName(name)
flags = libvirt.VIR_STORAGE_POOL_DELETE_NORMAL
if fast:
flags = libvirt.VIR_STORAGE_POOL_DELETE_ZEROED
return not bool(pool.delete(flags))
return not bool(pool.delete(libvirt.VIR_STORAGE_POOL_DELETE_NORMAL))
finally:
conn.close()

Expand Down
17 changes: 17 additions & 0 deletions tests/unit/modules/test_virt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2676,3 +2676,20 @@ def test_get_hypervisor(self, isxen_mock, iskvm_mock):

isxen_mock.return_value = True
self.assertEqual('xen', virt.get_hypervisor())

def test_pool_delete(self):
'''
Test virt.pool_delete function
'''
mock_pool = MagicMock()
mock_pool.delete = MagicMock(return_value=0)
self.mock_conn.storagePoolLookupByName = MagicMock(return_value=mock_pool)

res = virt.pool_delete('test-pool')
self.assertTrue(res)

self.mock_conn.storagePoolLookupByName.assert_called_once_with('test-pool')

# Shouldn't be called with another parameter so far since those are not implemented
# and thus throwing exceptions.
mock_pool.delete.assert_called_once_with(self.mock_libvirt.VIR_STORAGE_POOL_DELETE_NORMAL)