Skip to content

Commit

Permalink
Add virt.pool_get_xml function
Browse files Browse the repository at this point in the history
Users may want to see the full XML definition of a virtual storage pool.
  • Loading branch information
cbosdo committed Jan 7, 2020
1 parent 03d912c commit b688ec8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
24 changes: 24 additions & 0 deletions salt/modules/virt.py
Original file line number Diff line number Diff line change
Expand Up @@ -5352,6 +5352,30 @@ def _pool_extract_infos(pool):
return result


def pool_get_xml(name, **kwargs):
'''
Return the XML definition of a virtual storage pool
:param name: libvirt storage pool name
:param connection: libvirt connection URI, overriding defaults
:param username: username to connect with, overriding defaults
:param password: password to connect with, overriding defaults
.. versionadded:: Neon
CLI Example:
.. code-block:: bash
salt '*' virt.pool_get_xml default
'''
conn = __get_conn(**kwargs)
try:
return conn.storagePoolLookupByName(name).XMLDesc()
finally:
conn.close()


def pool_start(name, **kwargs):
'''
Start a defined libvirt storage pool.
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/modules/test_virt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2760,6 +2760,16 @@ def test_pool_info_all(self):
}
}, pool)

def test_pool_get_xml(self):
'''
Test virt.pool_get_xml
'''
pool_mock = MagicMock()
pool_mock.XMLDesc.return_value = '<pool>Raw XML</pool>'
self.mock_conn.storagePoolLookupByName.return_value = pool_mock

self.assertEqual('<pool>Raw XML</pool>', virt.pool_get_xml('default'))

def test_pool_list_volumes(self):
'''
Test virt.pool_list_volumes
Expand Down

0 comments on commit b688ec8

Please sign in to comment.