diff --git a/salt/modules/virt.py b/salt/modules/virt.py
index d3e7666b8232..460a0e0507bc 100644
--- a/salt/modules/virt.py
+++ b/salt/modules/virt.py
@@ -4584,6 +4584,30 @@ def _net_get_leases(net):
return result
+def network_get_xml(name, **kwargs):
+ '''
+ Return the XML definition of a virtual network
+
+ :param name: libvirt network 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.network_get_xml default
+ '''
+ conn = __get_conn(**kwargs)
+ try:
+ return conn.networkLookupByName(name).XMLDesc()
+ finally:
+ conn.close()
+
+
def network_start(name, **kwargs):
'''
Start a defined virtual network.
@@ -5328,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.
diff --git a/tests/unit/modules/test_virt.py b/tests/unit/modules/test_virt.py
index 6f472c656cd6..32f4302e5f59 100644
--- a/tests/unit/modules/test_virt.py
+++ b/tests/unit/modules/test_virt.py
@@ -2348,6 +2348,16 @@ def test_network_info_notfound(self):
net = virt.network_info('foo')
self.assertEqual({}, net)
+ def test_network_get_xml(self):
+ '''
+ Test virt.network_get_xml
+ '''
+ network_mock = MagicMock()
+ network_mock.XMLDesc.return_value = 'Raw XML'
+ self.mock_conn.networkLookupByName.return_value = network_mock
+
+ self.assertEqual('Raw XML', virt.network_get_xml('default'))
+
def test_pool(self):
'''
Test virt._gen_pool_xml()
@@ -2750,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 = 'Raw XML'
+ self.mock_conn.storagePoolLookupByName.return_value = pool_mock
+
+ self.assertEqual('Raw XML', virt.pool_get_xml('default'))
+
def test_pool_list_volumes(self):
'''
Test virt.pool_list_volumes