summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/libvirt
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:22 +0000
commit38b7c80217c4e72b1d8988eb1e60bb6e77334114 (patch)
tree356e9fd3762877d07cde52d21e77070aeff7e789 /ansible_collections/community/libvirt
parentAdding upstream version 7.7.0+dfsg. (diff)
downloadansible-38b7c80217c4e72b1d8988eb1e60bb6e77334114.tar.xz
ansible-38b7c80217c4e72b1d8988eb1e60bb6e77334114.zip
Adding upstream version 9.4.0+dfsg.upstream/9.4.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/community/libvirt')
-rw-r--r--ansible_collections/community/libvirt/.azure-pipelines/azure-pipelines.yml265
-rw-r--r--ansible_collections/community/libvirt/CHANGELOG.rst25
-rw-r--r--ansible_collections/community/libvirt/CONTRIBUTING.md4
-rw-r--r--ansible_collections/community/libvirt/FILES.json53
-rw-r--r--ansible_collections/community/libvirt/MANIFEST.json4
-rw-r--r--ansible_collections/community/libvirt/REVIEW_CHECKLIST.md3
-rw-r--r--ansible_collections/community/libvirt/changelogs/changelog.yaml32
-rw-r--r--ansible_collections/community/libvirt/plugins/connection/libvirt_qemu.py8
-rw-r--r--ansible_collections/community/libvirt/plugins/doc_fragments/virt.py21
-rw-r--r--ansible_collections/community/libvirt/plugins/inventory/libvirt.py2
-rw-r--r--ansible_collections/community/libvirt/plugins/modules/virt.py352
-rw-r--r--ansible_collections/community/libvirt/plugins/modules/virt_net.py4
-rw-r--r--ansible_collections/community/libvirt/plugins/modules/virt_pool.py21
-rw-r--r--ansible_collections/community/libvirt/tests/sanity/ignore-2.10.txt10
-rw-r--r--ansible_collections/community/libvirt/tests/sanity/ignore-2.11.txt10
-rw-r--r--ansible_collections/community/libvirt/tests/sanity/ignore-2.15.txt3
-rw-r--r--ansible_collections/community/libvirt/tests/sanity/ignore-2.16.txt2
-rw-r--r--ansible_collections/community/libvirt/tests/sanity/ignore-2.17.txt2
-rw-r--r--ansible_collections/community/libvirt/tests/sanity/ignore-2.9.txt10
-rw-r--r--ansible_collections/community/libvirt/tests/unit/mock/loader.py2
-rwxr-xr-xansible_collections/community/libvirt/tests/utils/shippable/check_matrix.py2
21 files changed, 555 insertions, 280 deletions
diff --git a/ansible_collections/community/libvirt/.azure-pipelines/azure-pipelines.yml b/ansible_collections/community/libvirt/.azure-pipelines/azure-pipelines.yml
index f6912428a..71bab55d2 100644
--- a/ansible_collections/community/libvirt/.azure-pipelines/azure-pipelines.yml
+++ b/ansible_collections/community/libvirt/.azure-pipelines/azure-pipelines.yml
@@ -36,7 +36,7 @@ variables:
resources:
containers:
- container: default
- image: quay.io/ansible/azure-pipelines-test-container:3.0.0
+ image: quay.io/ansible/azure-pipelines-test-container:4.0.1
pool: Standard
@@ -56,65 +56,66 @@ stages:
- name: Units
test: 'devel/units/1'
- - stage: Ansible_2_13
- displayName: Sanity & Units 2.13
+ - stage: Ansible_2_16
+ displayName: Sanity & Units 2.16
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
targets:
- name: Sanity
- test: '2.13/sanity/1'
+ test: '2.16/sanity/1'
- name: Units
- test: '2.13/units/1'
+ test: '2.16/units/1'
- - stage: Ansible_2_12
- displayName: Sanity & Units 2.12
+ - stage: Ansible_2_15
+ displayName: Sanity & Units 2.15
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
targets:
- name: Sanity
- test: '2.12/sanity/1'
+ test: '2.15/sanity/1'
- name: Units
- test: '2.12/units/1'
+ test: '2.15/units/1'
- - stage: Ansible_2_11
- displayName: Sanity & Units 2.11
+ - stage: Ansible_2_14
+ displayName: Sanity & Units 2.14
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
targets:
- name: Sanity
- test: '2.11/sanity/1'
+ test: '2.14/sanity/1'
- name: Units
- test: '2.11/units/1'
+ test: '2.14/units/1'
- - stage: Ansible_2_10
- displayName: Sanity & Units 2.10
+ - stage: Ansible_2_13
+ displayName: Sanity & Units 2.13
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
targets:
- name: Sanity
- test: '2.10/sanity/1'
+ test: '2.13/sanity/1'
- name: Units
- test: '2.10/units/1'
+ test: '2.13/units/1'
- - stage: Ansible_2_9
- displayName: Sanity & Units 2.9
+ - stage: Ansible_2_12
+ displayName: Sanity & Units 2.12
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
targets:
- name: Sanity
- test: '2.9/sanity/1'
+ test: '2.12/sanity/1'
- name: Units
- test: '2.9/units/1'
+ test: '2.12/units/1'
+
### Docker
- stage: Docker_devel
displayName: Docker devel
@@ -126,10 +127,8 @@ stages:
targets:
- name: CentOS 7
test: centos7
- - name: Fedora 35
- test: fedora35
- - name: Fedora 36
- test: fedora36
+ - name: Fedora 38
+ test: fedora38
- name: openSUSE 15 py3
test: opensuse15
- name: Ubuntu 20.04
@@ -137,124 +136,104 @@ stages:
- name: Ubuntu 22.04
test: ubuntu2204
- - stage: Docker_2_13
- displayName: Docker 2.13
+ - stage: Docker_2_16
+ displayName: Docker 2.16
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
- testFormat: 2.13/linux/{0}/1
+ testFormat: 2.16/linux/{0}/1
targets:
- name: CentOS 7
test: centos7
- - name: Fedora 34
- test: fedora34
- - name: openSUSE 15 py2
- test: opensuse15py2
+ - name: Fedora 38
+ test: fedora38
- name: openSUSE 15 py3
test: opensuse15
- - name: Ubuntu 18.04
- test: ubuntu1804
- name: Ubuntu 20.04
test: ubuntu2004
+ - name: Ubuntu 22.04
+ test: ubuntu2204
- - stage: Docker_2_12
- displayName: Docker 2.12
+ - stage: Docker_2_15
+ displayName: Docker 2.15
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
- testFormat: 2.12/linux/{0}/1
+ testFormat: 2.15/linux/{0}/1
targets:
- name: CentOS 7
test: centos7
- - name: Fedora 33
- test: fedora33
- - name: Fedora 34
- test: fedora34
- - name: openSUSE 15 py2
- test: opensuse15py2
+ - name: Fedora 37
+ test: fedora37
- name: openSUSE 15 py3
test: opensuse15
- - name: Ubuntu 18.04
- test: ubuntu1804
- name: Ubuntu 20.04
test: ubuntu2004
- - stage: Docker_2_11
- displayName: Docker 2.11
+ - stage: Docker_2_14
+ displayName: Docker 2.14
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
- testFormat: 2.11/linux/{0}/1
+ testFormat: 2.14/linux/{0}/1
targets:
- - name: CentOS 6
- test: centos6
- name: CentOS 7
test: centos7
- - name: Fedora 32
- test: fedora32
- - name: Fedora 33
- test: fedora33
- - name: openSUSE 15 py2
- test: opensuse15py2
+ - name: Fedora 36
+ test: fedora36
- name: openSUSE 15 py3
test: opensuse15
- - name: Ubuntu 18.04
- test: ubuntu1804
- name: Ubuntu 20.04
test: ubuntu2004
- - stage: Docker_2_10
- displayName: Docker 2.10
+ - stage: Docker_2_13
+ displayName: Docker 2.13
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
- testFormat: 2.10/linux/{0}/1
+ testFormat: 2.13/linux/{0}/1
targets:
- - name: CentOS 6
- test: centos6
- name: CentOS 7
test: centos7
- - name: Fedora 31
- test: fedora31
- - name: Fedora 32
- test: fedora32
+ - name: Fedora 34
+ test: fedora34
+ - name: Fedora 35
+ test: fedora35
- name: openSUSE 15 py2
test: opensuse15py2
- name: openSUSE 15 py3
test: opensuse15
- - name: Ubuntu 16.04
- test: ubuntu1604
- name: Ubuntu 18.04
test: ubuntu1804
+ - name: Ubuntu 20.04
+ test: ubuntu2004
- - stage: Docker_2_9
- displayName: Docker 2.9
+ - stage: Docker_2_12
+ displayName: Docker 2.12
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
- testFormat: 2.9/linux/{0}/1
+ testFormat: 2.12/linux/{0}/1
targets:
- - name: CentOS 6
- test: centos6
- name: CentOS 7
test: centos7
- - name: Fedora 31
- test: fedora31
- - name: Fedora 32
- test: fedora32
+ - name: Fedora 33
+ test: fedora33
+ - name: Fedora 34
+ test: fedora34
- name: openSUSE 15 py2
test: opensuse15py2
- name: openSUSE 15 py3
test: opensuse15
- - name: Ubuntu 16.04
- test: ubuntu1604
- name: Ubuntu 18.04
test: ubuntu1804
+ - name: Ubuntu 20.04
+ test: ubuntu2004
### Remote
- stage: Remote_devel
@@ -267,12 +246,57 @@ stages:
targets:
- name: RHEL 7.9
test: rhel/7.9
- - name: RHEL 8.6
- test: rhel/8.6
+ - name: RHEL 8.8
+ test: rhel/8.8
+ - name: RHEL 9.2
+ test: rhel/9.2
+ - name: FreeBSD 13.2
+ test: freebsd/13.2
+
+ - stage: Remote_2_16
+ displayName: Remote 2.16
+ dependsOn: []
+ jobs:
+ - template: templates/matrix.yml
+ parameters:
+ testFormat: '2.16/{0}/1'
+ targets:
+ - name: RHEL 7.9
+ test: rhel/7.9
+ - name: RHEL 8.8
+ test: rhel/8.8
+ - name: RHEL 9.2
+ test: rhel/9.2
+ - name: FreeBSD 13.2
+ test: freebsd/13.2
+
+ - stage: Remote_2_15
+ displayName: Remote 2.15
+ dependsOn: []
+ jobs:
+ - template: templates/matrix.yml
+ parameters:
+ testFormat: '2.15/{0}/1'
+ targets:
+ - name: RHEL 9.1
+ test: rhel/9.1
+ - name: RHEL 8.7
+ test: rhel/8.7
+ - name: FreeBSD 13.1
+ test: freebsd/13.1
+
+ - stage: Remote_2_14
+ displayName: Remote 2.14
+ dependsOn: []
+ jobs:
+ - template: templates/matrix.yml
+ parameters:
+ testFormat: '2.14/{0}/1'
+ targets:
- name: RHEL 9.0
test: rhel/9.0
- - name: FreeBSD 12.3
- test: freebsd/12.3
+ - name: RHEL 8.6
+ test: rhel/8.6
- name: FreeBSD 13.1
test: freebsd/13.1
@@ -286,8 +310,8 @@ stages:
targets:
- name: RHEL 8.5
test: rhel/8.5
- - name: FreeBSD 13.0
- test: freebsd/13.0
+ - name: FreeBSD 13.1
+ test: freebsd/13.1
- stage: Remote_2_12
displayName: Remote 2.12
@@ -306,77 +330,26 @@ stages:
- name: FreeBSD 13.0
test: freebsd/13.0
- - stage: Remote_2_11
- displayName: Remote 2.11
- dependsOn: []
- jobs:
- - template: templates/matrix.yml
- parameters:
- testFormat: '2.11/{0}/1'
- targets:
- - name: RHEL 7.9
- test: rhel/7.9
- - name: RHEL 8.3
- test: rhel/8.3
- - name: FreeBSD 11.4
- test: freebsd/11.4
- - name: FreeBSD 12.2
- test: freebsd/12.2
-
- - stage: Remote_2_10
- displayName: Remote 2.10
- dependsOn: []
- jobs:
- - template: templates/matrix.yml
- parameters:
- testFormat: '2.10/{0}/1'
- targets:
- - name: RHEL 7.8
- test: rhel/7.8
- - name: RHEL 8.2
- test: rhel/8.2
- - name: FreeBSD 11.1
- test: freebsd/11.1
- - name: FreeBSD 12.1
- test: freebsd/12.1
-
- - stage: Remote_2_9
- displayName: Remote 2.9
- dependsOn: []
- jobs:
- - template: templates/matrix.yml
- parameters:
- testFormat: '2.9/{0}/1'
- targets:
- - name: RHEL 7.8
- test: rhel/7.8
- - name: RHEL 8.2
- test: rhel/8.2
- - name: FreeBSD 11.1
- test: freebsd/11.1
- - name: FreeBSD 12.1
- test: freebsd/12.1
-
- stage: Summary
condition: succeededOrFailed()
dependsOn:
- Ansible_devel
+ - Ansible_2_16
+ - Ansible_2_15
+ - Ansible_2_14
- Ansible_2_13
- Ansible_2_12
- - Ansible_2_11
- - Ansible_2_10
- - Ansible_2_9
- Docker_devel
+ - Docker_2_16
+ - Docker_2_15
+ - Docker_2_14
- Docker_2_13
- Docker_2_12
- - Docker_2_11
- - Docker_2_10
- - Docker_2_9
- Remote_devel
+ - Remote_2_16
+ - Remote_2_15
+ - Remote_2_14
- Remote_2_13
- Remote_2_12
- - Remote_2_11
- - Remote_2_10
- - Remote_2_9
jobs:
- template: templates/coverage.yml
diff --git a/ansible_collections/community/libvirt/CHANGELOG.rst b/ansible_collections/community/libvirt/CHANGELOG.rst
index 0452a4685..23ea5e554 100644
--- a/ansible_collections/community/libvirt/CHANGELOG.rst
+++ b/ansible_collections/community/libvirt/CHANGELOG.rst
@@ -5,6 +5,31 @@ Community.Libvirt Release Notes
.. contents:: Topics
+v1.3.0
+======
+
+Release Summary
+---------------
+
+This is a new release of the ``community.libvirt`` collection.
+This changelog contains all changes to the modules and plugins in this collection
+that have been made after the previous release.
+
+Minor Changes
+-------------
+
+- virt - add `mutate_flags` parameter to enable XML mutation (add UUID, MAC addresses from existing domain) (https://github.com/ansible-collections/community.libvirt/pull/142/).
+- virt - support ``--diff`` for ``define`` command (https://github.com/ansible-collections/community.libvirt/pull/142/).
+
+Bugfixes
+--------
+
+- libvirt_qemu - connection plugin threw a warning about an improperly configured remote target. Fix adds `inventory_hostname` to `options.remote_addr.vars` (https://github.com/ansible-collections/community.libvirt/pull/147).
+- libvirt_qemu - fix encoding errors on Windows guests for non-ASCII return values (https://github.com/ansible-collections/community.libvirt/pull/157)
+- virt - fix virt module to undefine a domain with nvram, managed_save, snapshot_metadata or checkpoints_metadata (https://github.com/ansible-collections/community.libvirt/issues/40).
+- virt_pool - replace discouraged function ``listAllVolumes`` with ``listAllVolumes`` to fix potential race conditions (https://github.com/ansible-collections/community.libvirt/pull/135).
+- virt_pool - replace discouraged functions ``listStoragePools`` and ``listDefinedStoragePools`` with ``listAllStoragePools`` to fix potential race conditions (https://github.com/ansible-collections/community.libvirt/pull/134).
+
v1.2.0
======
diff --git a/ansible_collections/community/libvirt/CONTRIBUTING.md b/ansible_collections/community/libvirt/CONTRIBUTING.md
index edcfe55bc..70cd5557e 100644
--- a/ansible_collections/community/libvirt/CONTRIBUTING.md
+++ b/ansible_collections/community/libvirt/CONTRIBUTING.md
@@ -1,3 +1,5 @@
# Contributing
-Refer to the [Ansible Contributing guidelines](https://github.com/ansible/community-docs/blob/main/contributing.rst) to learn how to contribute to this collection.
+Refer to the [Ansible Contributing guidelines](https://docs.ansible.com/ansible/devel/community/index.html) to learn how to contribute to this collection.
+
+Refer to the [review checklist](https://docs.ansible.com/ansible/devel/community/collection_contributors/collection_reviewing.html) when triaging issues or reviewing PRs.
diff --git a/ansible_collections/community/libvirt/FILES.json b/ansible_collections/community/libvirt/FILES.json
index f41264643..66c2b67eb 100644
--- a/ansible_collections/community/libvirt/FILES.json
+++ b/ansible_collections/community/libvirt/FILES.json
@@ -109,7 +109,7 @@
"name": ".azure-pipelines/azure-pipelines.yml",
"ftype": "file",
"chksum_type": "sha256",
- "chksum_sha256": "a549b47cd670d92e56c58995ee2854f176baccf8bbb7bc7a064829bae78034c2",
+ "chksum_sha256": "235743eb1257d9b918cb046c756557e2f7b262cb6b0e3ef63fc9fb3af48df454",
"format": 1
},
{
@@ -123,7 +123,7 @@
"name": "changelogs/changelog.yaml",
"ftype": "file",
"chksum_type": "sha256",
- "chksum_sha256": "4a77c0ce3b56db83490dbc6c9a159f7e65b9952b08ed66f7eb9c4e090c1fabe3",
+ "chksum_sha256": "e5e062c16c66fc3bb41f11b732b92b0e631198816c975805636088ae79c9cae8",
"format": 1
},
{
@@ -172,7 +172,7 @@
"name": "plugins/connection/libvirt_qemu.py",
"ftype": "file",
"chksum_type": "sha256",
- "chksum_sha256": "fe6ca9c7dc6e723ac2ac1f720b78767ef3ba6663ecf3bfca03d1a62bb6d4d202",
+ "chksum_sha256": "fb6c4f88d7568d223a55839789ee576b4de55d47ca83bdcb056ffadfe465a144",
"format": 1
},
{
@@ -200,7 +200,7 @@
"name": "plugins/doc_fragments/virt.py",
"ftype": "file",
"chksum_type": "sha256",
- "chksum_sha256": "d0b7a491bad2786203fe8111137a7d2cfb0853499dcb16bbef34e3ee170935bd",
+ "chksum_sha256": "63c76e4bef4bedacafba97e075c96eafefdaa4f04f92f9abc112a8236fa36593",
"format": 1
},
{
@@ -221,7 +221,7 @@
"name": "plugins/inventory/libvirt.py",
"ftype": "file",
"chksum_type": "sha256",
- "chksum_sha256": "71b0387fc55fca79ad138058e8105465e2f2c1a7f8d3ad0c48251232132cbedd",
+ "chksum_sha256": "b20e409ad3494b68427147d677b83f819b6a6ac9e061c7dd931662aee75c08d6",
"format": 1
},
{
@@ -235,21 +235,21 @@
"name": "plugins/modules/virt.py",
"ftype": "file",
"chksum_type": "sha256",
- "chksum_sha256": "e23a3804a7fef3b08708ef89b61d70d155b5da55c77cf77ce084d4320452d6f9",
+ "chksum_sha256": "7ea10809743250129360305f892f3c3b263a6b006552380f2dfd594228072164",
"format": 1
},
{
"name": "plugins/modules/virt_net.py",
"ftype": "file",
"chksum_type": "sha256",
- "chksum_sha256": "1f5f65ec1c7fb458f33d22c06b5157ff251f72b01a5b5f2d9d6620447f0a9fb8",
+ "chksum_sha256": "2eb089b25132eb862d502a375ed9727646de76eb245a8ab3c0a68b92ae30d9ef",
"format": 1
},
{
"name": "plugins/modules/virt_pool.py",
"ftype": "file",
"chksum_type": "sha256",
- "chksum_sha256": "5ab52e7d19324c40a072eb2172bb7f3995621da95872fa090e714e420e64dffa",
+ "chksum_sha256": "f6614a835ce63252b9f969c1dca5bff6114246c98ffeef4da452f6e2ed7226b9",
"format": 1
},
{
@@ -645,45 +645,45 @@
"format": 1
},
{
- "name": "tests/sanity/ignore-2.10.txt",
+ "name": "tests/sanity/ignore-2.12.txt",
"ftype": "file",
"chksum_type": "sha256",
- "chksum_sha256": "3dbe66b16a396e94940e595e59436b4b2ff9163e53e7d33904839d5b51f1e572",
+ "chksum_sha256": "a70097a1274b645cb1981448b0b17069dfe2bdfedcec83cf6ea12c9a2d9092c1",
"format": 1
},
{
- "name": "tests/sanity/ignore-2.11.txt",
+ "name": "tests/sanity/ignore-2.13.txt",
"ftype": "file",
"chksum_type": "sha256",
- "chksum_sha256": "3dbe66b16a396e94940e595e59436b4b2ff9163e53e7d33904839d5b51f1e572",
+ "chksum_sha256": "a70097a1274b645cb1981448b0b17069dfe2bdfedcec83cf6ea12c9a2d9092c1",
"format": 1
},
{
- "name": "tests/sanity/ignore-2.12.txt",
+ "name": "tests/sanity/ignore-2.14.txt",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "a70097a1274b645cb1981448b0b17069dfe2bdfedcec83cf6ea12c9a2d9092c1",
"format": 1
},
{
- "name": "tests/sanity/ignore-2.13.txt",
+ "name": "tests/sanity/ignore-2.15.txt",
"ftype": "file",
"chksum_type": "sha256",
- "chksum_sha256": "a70097a1274b645cb1981448b0b17069dfe2bdfedcec83cf6ea12c9a2d9092c1",
+ "chksum_sha256": "30b40efd581721fa90731bfe2ea3bb9fdbaba3ffcedf13366b5379b1fd244042",
"format": 1
},
{
- "name": "tests/sanity/ignore-2.14.txt",
+ "name": "tests/sanity/ignore-2.16.txt",
"ftype": "file",
"chksum_type": "sha256",
- "chksum_sha256": "a70097a1274b645cb1981448b0b17069dfe2bdfedcec83cf6ea12c9a2d9092c1",
+ "chksum_sha256": "03d3b402bb612840b82adb62a100dd4e2dbc82ca4189ab7c3d88694aa6979fff",
"format": 1
},
{
- "name": "tests/sanity/ignore-2.9.txt",
+ "name": "tests/sanity/ignore-2.17.txt",
"ftype": "file",
"chksum_type": "sha256",
- "chksum_sha256": "3dbe66b16a396e94940e595e59436b4b2ff9163e53e7d33904839d5b51f1e572",
+ "chksum_sha256": "03d3b402bb612840b82adb62a100dd4e2dbc82ca4189ab7c3d88694aa6979fff",
"format": 1
},
{
@@ -746,7 +746,7 @@
"name": "tests/unit/mock/loader.py",
"ftype": "file",
"chksum_type": "sha256",
- "chksum_sha256": "cfe3480f0eae6d3723ee62d01d00a0e9f58fcdc082ea1d8e4836157c56d4fa95",
+ "chksum_sha256": "aec7750aabec8f519349a0b0899efbcc4ceadb57ade3201914debe347f4b26a5",
"format": 1
},
{
@@ -865,7 +865,7 @@
"name": "tests/utils/shippable/check_matrix.py",
"ftype": "file",
"chksum_type": "sha256",
- "chksum_sha256": "4855ba1cb515a6b3a51e3ac26e00c34d853866d8a67ced189f8f733526ae3d8a",
+ "chksum_sha256": "475c5515e7951b5e204c17a33f053964f245d5bb08d55ec46eee4e6314ade53d",
"format": 1
},
{
@@ -935,14 +935,14 @@
"name": "CHANGELOG.rst",
"ftype": "file",
"chksum_type": "sha256",
- "chksum_sha256": "6a5ac5751344499d6238ee7dce91c1b787ca62b388cdc2b2d40c5179bf53874b",
+ "chksum_sha256": "9fea037270c0db73ae6f11c9450f43534cb6448f7c0fac01cae01bcb745b669c",
"format": 1
},
{
"name": "CONTRIBUTING.md",
"ftype": "file",
"chksum_type": "sha256",
- "chksum_sha256": "537598e3a4b1c7e00d763177f92a0b2a66b0c02747dd47f847bc6a03bcb50cc0",
+ "chksum_sha256": "b0c50cf3715d59964a341dc651a6f626322209ef9fa8c0d03047d3a2b2e420a4",
"format": 1
},
{
@@ -974,13 +974,6 @@
"format": 1
},
{
- "name": "REVIEW_CHECKLIST.md",
- "ftype": "file",
- "chksum_type": "sha256",
- "chksum_sha256": "91ad4aff2cc14b98f81fbe2d90609c5a69ed96b6d836387a9c697c1112e603c0",
- "format": 1
- },
- {
"name": "shippable.yml",
"ftype": "file",
"chksum_type": "sha256",
diff --git a/ansible_collections/community/libvirt/MANIFEST.json b/ansible_collections/community/libvirt/MANIFEST.json
index 6f9a9f4eb..4f494c826 100644
--- a/ansible_collections/community/libvirt/MANIFEST.json
+++ b/ansible_collections/community/libvirt/MANIFEST.json
@@ -2,7 +2,7 @@
"collection_info": {
"namespace": "community",
"name": "libvirt",
- "version": "1.2.0",
+ "version": "1.3.0",
"authors": [
"Ansible (https://github.com/ansible)",
"community.libvirt"
@@ -26,7 +26,7 @@
"name": "FILES.json",
"ftype": "file",
"chksum_type": "sha256",
- "chksum_sha256": "37ac18f37cae0fd2deb7d11e81c71b9c5d7a68b4a040ccd07c31976f563357ff",
+ "chksum_sha256": "5209c6a915eee7b459e3bd0275469132b95ac29a0e0a283e41605ccba0c93a87",
"format": 1
},
"format": 1
diff --git a/ansible_collections/community/libvirt/REVIEW_CHECKLIST.md b/ansible_collections/community/libvirt/REVIEW_CHECKLIST.md
deleted file mode 100644
index 9dccf7ef1..000000000
--- a/ansible_collections/community/libvirt/REVIEW_CHECKLIST.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Review Checklist
-
-Refer to the [Collection review checklist](https://github.com/ansible/community-docs/blob/main/review_checklist.rst).
diff --git a/ansible_collections/community/libvirt/changelogs/changelog.yaml b/ansible_collections/community/libvirt/changelogs/changelog.yaml
index 62a1b1a9e..4770781b6 100644
--- a/ansible_collections/community/libvirt/changelogs/changelog.yaml
+++ b/ansible_collections/community/libvirt/changelogs/changelog.yaml
@@ -83,3 +83,35 @@ releases:
- 117_find_vms_update_calls.yml
- virt_pool_no_path.yml
release_date: '2022-08-04'
+ 1.3.0:
+ changes:
+ bugfixes:
+ - libvirt_qemu - connection plugin threw a warning about an improperly configured
+ remote target. Fix adds `inventory_hostname` to `options.remote_addr.vars`
+ (https://github.com/ansible-collections/community.libvirt/pull/147).
+ - libvirt_qemu - fix encoding errors on Windows guests for non-ASCII return
+ values (https://github.com/ansible-collections/community.libvirt/pull/157)
+ - virt - fix virt module to undefine a domain with nvram, managed_save, snapshot_metadata
+ or checkpoints_metadata (https://github.com/ansible-collections/community.libvirt/issues/40).
+ - virt_pool - replace discouraged function ``listAllVolumes`` with ``listAllVolumes``
+ to fix potential race conditions (https://github.com/ansible-collections/community.libvirt/pull/135).
+ - virt_pool - replace discouraged functions ``listStoragePools`` and ``listDefinedStoragePools``
+ with ``listAllStoragePools`` to fix potential race conditions (https://github.com/ansible-collections/community.libvirt/pull/134).
+ minor_changes:
+ - virt - add `mutate_flags` parameter to enable XML mutation (add UUID, MAC
+ addresses from existing domain) (https://github.com/ansible-collections/community.libvirt/pull/142/).
+ - virt - support ``--diff`` for ``define`` command (https://github.com/ansible-collections/community.libvirt/pull/142/).
+ release_summary: 'This is a new release of the ``community.libvirt`` collection.
+
+ This changelog contains all changes to the modules and plugins in this collection
+
+ that have been made after the previous release.'
+ fragments:
+ - 1.3.0.yml
+ - 134_virt_pool_replace_functions_listStoragePools.yml
+ - 135_virt_pool_replace_function_listVolumes.yml
+ - 136_fix_undefine_nvram.yml
+ - 142_virt_define_improvements.yml
+ - 147_fix_qemu_remote_target_warning.yml
+ - 156_fix_windows_encoding.yml
+ release_date: '2023-09-19'
diff --git a/ansible_collections/community/libvirt/plugins/connection/libvirt_qemu.py b/ansible_collections/community/libvirt/plugins/connection/libvirt_qemu.py
index 220c02283..c9ed52fab 100644
--- a/ansible_collections/community/libvirt/plugins/connection/libvirt_qemu.py
+++ b/ansible_collections/community/libvirt/plugins/connection/libvirt_qemu.py
@@ -29,6 +29,7 @@ options:
default: inventory_hostname
vars:
- name: ansible_host
+ - name: inventory_hostname
executable:
description:
- Shell to use for execution inside container.
@@ -57,7 +58,6 @@ except ImportError as imp_exc:
else:
LIBVIRT_IMPORT_ERROR = None
-from ansible import constants as C
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNotFound
from ansible.module_utils._text import to_bytes, to_native, to_text
from ansible.module_utils.six import raise_from
@@ -65,7 +65,7 @@ from ansible.plugins.connection import ConnectionBase, BUFSIZE
from ansible.plugins.shell.powershell import _parse_clixml
from ansible.utils.display import Display
from functools import partial
-from os.path import exists, getsize
+from os.path import exists
display = Display()
@@ -160,6 +160,10 @@ class Connection(ConnectionBase):
# prompt that will not occur
sudoable = False
+ # Make sure our first command is to set the console encoding to
+ # utf-8, this must be done via chcp to get utf-8 (65001)
+ cmd = ' '.join(["chcp.com", "65001", self._shell._SHELL_REDIRECT_ALLNULL, self._shell._SHELL_AND, cmd])
+
# Generate powershell commands
cmd_args_list = self._shell._encode_script(cmd, as_list=True, strict_mode=False, preserve_rc=False)
diff --git a/ansible_collections/community/libvirt/plugins/doc_fragments/virt.py b/ansible_collections/community/libvirt/plugins/doc_fragments/virt.py
index a607299bf..6e4ec35a1 100644
--- a/ansible_collections/community/libvirt/plugins/doc_fragments/virt.py
+++ b/ansible_collections/community/libvirt/plugins/doc_fragments/virt.py
@@ -65,3 +65,24 @@ options:
- Must be raw XML content using C(lookup). XML cannot be reference to a file.
type: str
"""
+
+ OPTIONS_MUTATE_FLAGS = r"""
+options:
+ mutate_flags:
+ description:
+ - For each mutate_flag, we will modify the given XML in some way
+ - ADD_UUID will add an existing domain's UUID to the xml if it's missing
+ - ADD_MAC_ADDRESSES will look up interfaces in the existing domain with a
+ matching alias and copy the MAC address over. The matching interface
+ doesn't need to be of the same type or source network.
+ - ADD_MAC_ADDRESSES_FUZZY will try to match incoming interfaces with
+ interfaces of the existing domain sharing the same type and source
+ network/device. It may not always result in the expected outcome,
+ particularly if a domain has multiple interface attached to the same
+ host device and only some of those devices have <mac>s.
+ Use caution, do some testing for your particular use-case!
+ choices: [ ADD_UUID, ADD_MAC_ADDRESSES, ADD_MAC_ADDRESSES_FUZZY ]
+ type: list
+ elements: str
+ default: ['ADD_UUID']
+ """
diff --git a/ansible_collections/community/libvirt/plugins/inventory/libvirt.py b/ansible_collections/community/libvirt/plugins/inventory/libvirt.py
index 903870cc0..d0cd62f8a 100644
--- a/ansible_collections/community/libvirt/plugins/inventory/libvirt.py
+++ b/ansible_collections/community/libvirt/plugins/inventory/libvirt.py
@@ -160,6 +160,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
)
# This needs the guest powered on, 'qemu-guest-agent' installed and the org.qemu.guest_agent.0 channel configured.
+ domain_guestInfo = ''
try:
# type==0 returns all types (users, os, timezone, hostname, filesystem, disks, interfaces)
domain_guestInfo = domain.guestInfo(types=0)
@@ -173,6 +174,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
)
# This needs the guest powered on, 'qemu-guest-agent' installed and the org.qemu.guest_agent.0 channel configured.
+ domain_interfaceAddresses = ''
try:
domain_interfaceAddresses = domain.interfaceAddresses(source=libvirt.VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT)
except libvirt.libvirtError as e:
diff --git a/ansible_collections/community/libvirt/plugins/modules/virt.py b/ansible_collections/community/libvirt/plugins/modules/virt.py
index bbc2add06..529e6cd47 100644
--- a/ansible_collections/community/libvirt/plugins/modules/virt.py
+++ b/ansible_collections/community/libvirt/plugins/modules/virt.py
@@ -16,6 +16,29 @@ module: virt
short_description: Manages virtual machines supported by libvirt
description:
- Manages virtual machines supported by I(libvirt).
+options:
+ flags:
+ choices: [ 'managed_save', 'snapshots_metadata', 'nvram', 'keep_nvram', 'checkpoints_metadata']
+ description:
+ - Pass additional parameters.
+ - Currently only implemented with command C(undefine).
+ Specify which metadata should be removed with C(undefine).
+ Useful option to be able to C(undefine) guests with UEFI nvram.
+ C(nvram) and C(keep_nvram) are conflicting and mutually exclusive.
+ Consider option C(force) if all related metadata should be removed.
+ type: list
+ elements: str
+ force:
+ description:
+ - Enforce an action.
+ - Currently only implemented with command C(undefine).
+ This option can be used instead of providing all C(flags).
+ If C(true), C(undefine) removes also any related nvram or other metadata, if existing.
+ If C(false) or not set, C(undefine) executes only if there is no nvram or other metadata existing.
+ Otherwise the task fails and the guest is kept defined without change.
+ C(true) and option C(flags) should not be provided together. In this case
+ C(undefine) ignores C(true), considers only C(flags) and issues a warning.
+ type: bool
extends_documentation_fragment:
- community.libvirt.virt.options_uri
- community.libvirt.virt.options_xml
@@ -23,6 +46,7 @@ extends_documentation_fragment:
- community.libvirt.virt.options_autostart
- community.libvirt.virt.options_state
- community.libvirt.virt.options_command
+ - community.libvirt.virt.options_mutate_flags
- community.libvirt.requirements
author:
- Ansible Core Team
@@ -58,14 +82,38 @@ EXAMPLES = '''
- name: Set autostart for a VM
community.libvirt.virt:
name: foo
- autostart: yes
+ autostart: true
# Defining a VM and making is autostart with host. VM will be off after this task
- name: Define vm from xml and set autostart
community.libvirt.virt:
command: define
xml: "{{ lookup('template', 'vm_template.xml.j2') }}"
- autostart: yes
+ autostart: true
+
+# Undefine VM only, if it has no existing nvram or other metadata
+- name: Undefine qemu VM
+ community.libvirt.virt:
+ name: foo
+
+# Undefine VM and force remove all of its related metadata (nvram, snapshots, etc.)
+- name: "Undefine qemu VM with force"
+ community.libvirt.virt:
+ name: foo
+ force: true
+
+# Undefine VM and remove all of its specified metadata specified
+# Result would the same as with force=true
+- name: Undefine qemu VM with list of flags
+ community.libvirt.virt:
+ name: foo
+ flags: managed_save, snapshots_metadata, nvram, checkpoints_metadata
+
+# Undefine VM, but keep its nvram
+- name: Undefine qemu VM and keep its nvram
+ community.libvirt.virt:
+ name: foo
+ flags: keep_nvram
# Listing VMs
- name: List all VMs
@@ -108,7 +156,12 @@ except ImportError:
else:
HAS_VIRT = True
-import re
+try:
+ from lxml import etree
+except ImportError:
+ HAS_XML = False
+else:
+ HAS_XML = True
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils._text import to_native
@@ -134,6 +187,19 @@ VIRT_STATE_NAME_MAP = {
6: 'crashed',
}
+ENTRY_UNDEFINE_FLAGS_MAP = {
+ 'managed_save': 1,
+ 'snapshots_metadata': 2,
+ 'nvram': 4,
+ 'keep_nvram': 8,
+ 'checkpoints_metadata': 16,
+}
+
+MUTATE_FLAGS = ['ADD_UUID', 'ADD_MAC_ADDRESSES', 'ADD_MAC_ADDRESSES_FUZZY']
+
+ALL_FLAGS = []
+ALL_FLAGS.extend(ENTRY_UNDEFINE_FLAGS_MAP.keys())
+
class VMNotFound(Exception):
pass
@@ -198,8 +264,8 @@ class LibvirtConnection(object):
def destroy(self, vmid):
return self.find_vm(vmid).destroy()
- def undefine(self, vmid):
- return self.find_vm(vmid).undefine()
+ def undefine(self, vmid, flag):
+ return self.find_vm(vmid).undefineFlags(flag)
def get_status2(self, vm):
state = vm.info()[0]
@@ -367,11 +433,11 @@ class Virt(object):
self.__get_conn()
return self.conn.destroy(vmid)
- def undefine(self, vmid):
+ def undefine(self, vmid, flag):
""" Stop a domain, and then wipe it from the face of the earth. (delete disk/config file) """
self.__get_conn()
- return self.conn.undefine(vmid)
+ return self.conn.undefine(vmid, flag)
def status(self, vmid):
"""
@@ -413,14 +479,210 @@ class Virt(object):
return self.conn.define_from_xml(xml)
+# A dict of interface types (found in their `type` attribute) to the
+# corresponding "source" attribute name of their <source> elements
+# user networks don't have a <source> element
+#
+# We do not support fuzzy matching against any interface types
+# not defined here
+INTERFACE_SOURCE_ATTRS = {
+ 'network': 'network',
+ 'bridge': 'bridge',
+ 'direct': 'dev',
+ 'user': None,
+}
+
+
+def handle_define(module, v):
+ ''' handle `command: define` '''
+ xml = module.params.get('xml', None)
+ guest = module.params.get('name', None)
+ autostart = module.params.get('autostart', None)
+ mutate_flags = module.params.get('mutate_flags', [])
+
+ if not xml:
+ module.fail_json(msg="define requires 'xml' argument")
+ try:
+ incoming_xml = etree.fromstring(xml)
+ except etree.XMLSyntaxError:
+ # TODO: provide info from parser
+ module.fail_json(msg="given XML is invalid")
+
+ # We'll support supplying the domain's name either from 'name' parameter or xml
+ #
+ # But we will fail if both are defined and not equal.
+ domain_name = incoming_xml.findtext("./name")
+ if domain_name is not None:
+ if guest is not None and domain_name != guest:
+ module.fail_json("given 'name' parameter does not match name in XML")
+ else:
+ if guest is None:
+ module.fail_json("missing 'name' parameter and no name provided in XML")
+ domain_name = guest
+ # since there's no <name> in the xml, we'll add it
+ etree.SubElement(incoming_xml, 'name').text = domain_name
+
+ if domain_name == '':
+ module.fail_json(msg="domain name cannot be an empty string")
+
+ res = dict()
+
+ # From libvirt docs (https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainDefineXML):
+ # -- A previous definition for this domain with the same UUID and name would
+ # be overridden if it already exists.
+ #
+ # If a domain is defined without a <uuid>, libvirt will generate one for it.
+ # If an attempt is made to re-define the same xml (with the same <name> and
+ # no <uuid>), libvirt will complain with the following error:
+ #
+ # operation failed: domain '<name>' already exists with <uuid>
+ #
+ # If a domain with a similiar <name> but different <uuid> is defined,
+ # libvirt complains with the same error. However, if a domain is defined
+ # with the same <name> and <uuid> as an existing domain, then libvirt will
+ # update the domain with the new definition (automatically handling
+ # addition/removal of devices. some changes may require a boot).
+ try:
+ existing_domain = v.get_vm(domain_name)
+ existing_xml_raw = existing_domain.XMLDesc(libvirt.VIR_DOMAIN_XML_INACTIVE)
+ existing_xml = etree.fromstring(existing_xml_raw)
+ except VMNotFound:
+ existing_domain = None
+ existing_xml_raw = None
+ existing_xml = None
+
+ if existing_domain is not None:
+ # we are updating a domain's definition
+
+ incoming_uuid = incoming_xml.findtext('./uuid')
+ existing_uuid = existing_domain.UUIDString()
+
+ if incoming_uuid is not None and incoming_uuid != existing_uuid:
+ # A user should not try defining a domain with the same name but
+ # different UUID
+ module.fail_json(msg="attempting to re-define domain %s/%s with a different UUID: %s" % (
+ domain_name, existing_uuid, incoming_uuid
+ ))
+ else:
+ if 'ADD_UUID' in mutate_flags and incoming_uuid is None:
+ # Users will often want to define their domains without an explicit
+ # UUID, instead giving them a unique name - so we support bringing
+ # over the UUID from the existing domain
+ etree.SubElement(incoming_xml, 'uuid').text = existing_uuid
+
+ existing_devices = existing_xml.find('./devices')
+
+ if 'ADD_MAC_ADDRESSES' in mutate_flags:
+ for interface in incoming_xml.xpath('./devices/interface[not(mac) and alias]'):
+ search_alias = interface.find('alias').get('name')
+ xpath = "./interface[alias[@name='%s']]" % search_alias
+ try:
+ matched_interface = existing_devices.xpath(xpath)[0]
+ existing_devices.remove(matched_interface)
+ etree.SubElement(interface, 'mac', {
+ 'address': matched_interface.find('mac').get('address')
+ })
+ except IndexError:
+ module.warn("Could not match interface %i of incoming XML by alias %s." % (
+ interface.getparent().index(interface) + 1, search_alias
+ ))
+
+ if 'ADD_MAC_ADDRESSES_FUZZY' in mutate_flags:
+ # the counts of interfaces of a similar type/source
+ # key'd with tuple of (type, source)
+ similar_interface_counts = {}
+
+ def get_interface_count(_type, source=None):
+ key = (_type, source if _type != "user" else None)
+ if key not in similar_interface_counts:
+ similar_interface_counts[key] = 1
+ else:
+ similar_interface_counts[key] += 1
+ return similar_interface_counts[key]
+
+ # iterate user-defined interfaces
+ for interface in incoming_xml.xpath('./devices/interface'):
+ _type = interface.get('type')
+
+ if interface.find('mac') is not None and interface.find('alias') is not None:
+ continue
+
+ if _type not in INTERFACE_SOURCE_ATTRS:
+ module.warn("Skipping fuzzy MAC matching for interface %i of incoming XML: unsupported interface type '%s'." % (
+ interface.getparent().index(interface) + 1, _type
+ ))
+ continue
+
+ source_attr = INTERFACE_SOURCE_ATTRS[_type]
+ source = interface.find('source').get(source_attr) if source_attr else None
+ similar_count = get_interface_count(_type, source)
+
+ if interface.find('mac') is not None:
+ # we want to count these, but not try to change their MAC address
+ continue
+
+ if source:
+ xpath = "./interface[@type='%s' and source[@%s='%s']]" % (
+ _type, source_attr, source)
+ else:
+ xpath = "./interface[@type = '%s']" % source_attr
+
+ matching_interfaces = existing_devices.xpath(xpath)
+ try:
+ matched_interface = matching_interfaces[similar_count - 1]
+ etree.SubElement(interface, 'mac', {
+ 'address': matched_interface.find('./mac').get('address'),
+ })
+ except IndexError:
+ module.warn("Could not fuzzy match interface %i of incoming XML." % (
+ interface.getparent().index(interface) + 1
+ ))
+
+ try:
+ domain_xml = etree.tostring(incoming_xml).decode()
+
+ # TODO: support check mode
+ domain = v.define(domain_xml)
+
+ if existing_domain is not None:
+ # In this case, we may have updated the definition or it might be the same.
+ # We compare the domain's previous xml with its new state and diff
+ # the changes. This allows users to fix their xml if it results in
+ # non-idempotent behaviour (e.g. libvirt mutates it each time)
+ new_xml = domain.XMLDesc(libvirt.VIR_DOMAIN_XML_INACTIVE)
+ if existing_xml_raw != new_xml:
+ res.update({
+ 'changed': True,
+ 'change_reason': 'domain definition changed',
+ 'diff': {
+ 'before': existing_xml_raw,
+ 'after': new_xml
+ }
+ })
+ else:
+ # there was no existing XML, so this is a newly created domain
+ res.update({'changed': True, 'created': domain.name()})
+
+ except libvirtError as e:
+ module.fail_json(msg='libvirtError: %s' % e.get_error_message())
+ except Exception as e:
+ module.fail_json(msg='an unknown error occured: %s' % e)
+
+ if autostart is not None and v.autostart(domain_name, autostart):
+ res.update({'changed': True, 'change_reason': 'autostart'})
+
+ return res
+
+
def core(module):
state = module.params.get('state', None)
autostart = module.params.get('autostart', None)
guest = module.params.get('name', None)
command = module.params.get('command', None)
+ force = module.params.get('force', None)
+ flags = module.params.get('flags', None)
uri = module.params.get('uri', None)
- xml = module.params.get('xml', None)
v = Virt(uri, module)
res = dict()
@@ -473,46 +735,34 @@ def core(module):
if command:
if command in VM_COMMANDS:
if command == 'define':
- if not xml:
- module.fail_json(msg="define requires xml argument")
- if guest:
- # there might be a mismatch between quest 'name' in the module and in the xml
- module.warn("'xml' is given - ignoring 'name'")
- try:
- domain_name = re.search('<name>(.*)</name>', xml).groups()[0]
- except AttributeError:
- module.fail_json(msg="Could not find domain 'name' in xml")
-
- # From libvirt docs (https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainDefineXML):
- # -- A previous definition for this domain would be overridden if it already exists.
- #
- # In real world testing with libvirt versions 1.2.17-13, 2.0.0-10 and 3.9.0-14
- # on qemu and lxc domains results in:
- # operation failed: domain '<name>' already exists with <uuid>
- #
- # In case a domain would be indeed overwritten, we should protect idempotency:
- try:
- existing_domain_xml = v.get_vm(domain_name).XMLDesc(
- libvirt.VIR_DOMAIN_XML_INACTIVE
- )
- except VMNotFound:
- existing_domain_xml = None
- try:
- domain = v.define(xml)
- if existing_domain_xml:
- # if we are here, then libvirt redefined existing domain as the doc promised
- if existing_domain_xml != domain.XMLDesc(libvirt.VIR_DOMAIN_XML_INACTIVE):
- res = {'changed': True, 'change_reason': 'config changed'}
- else:
- res = {'changed': True, 'created': domain.name()}
- except libvirtError as e:
- if e.get_error_code() != 9: # 9 means 'domain already exists' error
- module.fail_json(msg='libvirtError: %s' % e.get_error_message())
- if autostart is not None and v.autostart(domain_name, autostart):
- res = {'changed': True, 'change_reason': 'autostart'}
+ res.update(handle_define(module, v))
elif not guest:
module.fail_json(msg="%s requires 1 argument: guest" % command)
+
+ elif command == 'undefine':
+ # Use the undefine function with flag to also handle various metadata.
+ # This is especially important for UEFI enabled guests with nvram.
+ # Provide flag as an integer of all desired bits, see 'ENTRY_UNDEFINE_FLAGS_MAP'.
+ # Integer 23 takes care of all cases (23 = 1 + 2 + 4 + 16).
+ flag = 0
+ if flags is not None:
+ if force is True:
+ module.warn("Ignoring 'force', because 'flags' are provided.")
+ nv = ['nvram', 'keep_nvram']
+ # Check mutually exclusive flags
+ if set(nv) <= set(flags):
+ raise ValueError("Flags '%s' are mutually exclusive" % "' and '".join(nv))
+ for item in flags:
+ # Get and add flag integer from mapping, otherwise 0.
+ flag += ENTRY_UNDEFINE_FLAGS_MAP.get(item, 0)
+ elif force is True:
+ flag = 23
+ # Finally, execute with flag
+ res = getattr(v, command)(guest, flag)
+ if not isinstance(res, dict):
+ res = {command: res}
+
else:
res = getattr(v, command)(guest)
if not isinstance(res, dict):
@@ -539,13 +789,23 @@ def main():
state=dict(type='str', choices=['destroyed', 'paused', 'running', 'shutdown']),
autostart=dict(type='bool'),
command=dict(type='str', choices=ALL_COMMANDS),
+ flags=dict(type='list', elements='str', choices=ALL_FLAGS),
+ force=dict(type='bool'),
uri=dict(type='str', default='qemu:///system'),
xml=dict(type='str'),
+ mutate_flags=dict(type='list', elements='str', choices=MUTATE_FLAGS, default=['ADD_UUID']),
),
)
if not HAS_VIRT:
- module.fail_json(msg='The `libvirt` module is not importable. Check the requirements.')
+ module.fail_json(
+ msg='The `libvirt` module is not importable. Check the requirements.'
+ )
+
+ if not HAS_XML:
+ module.fail_json(
+ msg='The `lxml` module is not importable. Check the requirements.'
+ )
rc = VIRT_SUCCESS
try:
diff --git a/ansible_collections/community/libvirt/plugins/modules/virt_net.py b/ansible_collections/community/libvirt/plugins/modules/virt_net.py
index 7492cac79..de8418a6f 100644
--- a/ansible_collections/community/libvirt/plugins/modules/virt_net.py
+++ b/ansible_collections/community/libvirt/plugins/modules/virt_net.py
@@ -109,12 +109,12 @@ EXAMPLES = '''
- name: Ensure that a given network will be started at boot
community.libvirt.virt_net:
- autostart: yes
+ autostart: true
name: br_nat
- name: Disable autostart for a given network
community.libvirt.virt_net:
- autostart: no
+ autostart: false
name: br_nat
- name: Add a new host in the dhcp pool
diff --git a/ansible_collections/community/libvirt/plugins/modules/virt_pool.py b/ansible_collections/community/libvirt/plugins/modules/virt_pool.py
index 70145c617..3b0117333 100644
--- a/ansible_collections/community/libvirt/plugins/modules/virt_pool.py
+++ b/ansible_collections/community/libvirt/plugins/modules/virt_pool.py
@@ -124,12 +124,12 @@ EXAMPLES = '''
- name: Ensure that a given pool will be started at boot
community.libvirt.virt_pool:
- autostart: yes
+ autostart: true
name: vms
- name: Disable autostart for a given pool
community.libvirt.virt_pool:
- autostart: no
+ autostart: false
name: vms
'''
@@ -222,17 +222,8 @@ class LibvirtConnection(object):
def find_entry(self, entryid):
# entryid = -1 returns a list of everything
- results = []
-
- # Get active entries
- for name in self.conn.listStoragePools():
- entry = self.conn.storagePoolLookupByName(name)
- results.append(entry)
-
- # Get inactive entries
- for name in self.conn.listDefinedStoragePools():
- entry = self.conn.storagePoolLookupByName(name)
- results.append(entry)
+ # Get all entries
+ results = self.conn.listAllStoragePools()
if entryid == -1:
return results
@@ -296,7 +287,7 @@ class LibvirtConnection(object):
return self.find_entry(entryid).numOfVolumes()
def get_volume_names(self, entryid):
- return self.find_entry(entryid).listVolumes()
+ return self.find_entry(entryid).listAllVolumes()
def get_devices(self, entryid):
xml = etree.fromstring(self.find_entry(entryid).XMLDesc(0))
@@ -506,7 +497,7 @@ class VirtStoragePool(object):
results[entry]["volume_count"] = self.conn.get_volume_count(entry)
results[entry]["volumes"] = list()
for volume in self.conn.get_volume_names(entry):
- results[entry]["volumes"].append(volume)
+ results[entry]["volumes"].append(volume.name())
else:
results[entry]["volume_count"] = -1
diff --git a/ansible_collections/community/libvirt/tests/sanity/ignore-2.10.txt b/ansible_collections/community/libvirt/tests/sanity/ignore-2.10.txt
deleted file mode 100644
index f6584fe11..000000000
--- a/ansible_collections/community/libvirt/tests/sanity/ignore-2.10.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-tests/unit/mock/path.py future-import-boilerplate
-tests/unit/mock/path.py metaclass-boilerplate
-tests/unit/mock/yaml_helper.py future-import-boilerplate
-tests/unit/mock/yaml_helper.py metaclass-boilerplate
-tests/unit/modules/cloud/misc/virt_net/conftest.py future-import-boilerplate
-tests/unit/modules/cloud/misc/virt_net/conftest.py metaclass-boilerplate
-tests/unit/modules/cloud/misc/virt_net/test_virt_net.py future-import-boilerplate
-tests/unit/modules/cloud/misc/virt_net/test_virt_net.py metaclass-boilerplate
-tests/utils/shippable/timing.py shebang
-tests/utils/shippable/check_matrix.py replace-urlopen
diff --git a/ansible_collections/community/libvirt/tests/sanity/ignore-2.11.txt b/ansible_collections/community/libvirt/tests/sanity/ignore-2.11.txt
deleted file mode 100644
index f6584fe11..000000000
--- a/ansible_collections/community/libvirt/tests/sanity/ignore-2.11.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-tests/unit/mock/path.py future-import-boilerplate
-tests/unit/mock/path.py metaclass-boilerplate
-tests/unit/mock/yaml_helper.py future-import-boilerplate
-tests/unit/mock/yaml_helper.py metaclass-boilerplate
-tests/unit/modules/cloud/misc/virt_net/conftest.py future-import-boilerplate
-tests/unit/modules/cloud/misc/virt_net/conftest.py metaclass-boilerplate
-tests/unit/modules/cloud/misc/virt_net/test_virt_net.py future-import-boilerplate
-tests/unit/modules/cloud/misc/virt_net/test_virt_net.py metaclass-boilerplate
-tests/utils/shippable/timing.py shebang
-tests/utils/shippable/check_matrix.py replace-urlopen
diff --git a/ansible_collections/community/libvirt/tests/sanity/ignore-2.15.txt b/ansible_collections/community/libvirt/tests/sanity/ignore-2.15.txt
new file mode 100644
index 000000000..889e71429
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/sanity/ignore-2.15.txt
@@ -0,0 +1,3 @@
+tests/utils/shippable/timing.py shebang
+tests/utils/shippable/check_matrix.py replace-urlopen
+tests/unit/compat/builtins.py pylint:unused-import
diff --git a/ansible_collections/community/libvirt/tests/sanity/ignore-2.16.txt b/ansible_collections/community/libvirt/tests/sanity/ignore-2.16.txt
new file mode 100644
index 000000000..3eb3aa615
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/sanity/ignore-2.16.txt
@@ -0,0 +1,2 @@
+tests/utils/shippable/timing.py shebang
+tests/unit/compat/builtins.py pylint:unused-import
diff --git a/ansible_collections/community/libvirt/tests/sanity/ignore-2.17.txt b/ansible_collections/community/libvirt/tests/sanity/ignore-2.17.txt
new file mode 100644
index 000000000..3eb3aa615
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/sanity/ignore-2.17.txt
@@ -0,0 +1,2 @@
+tests/utils/shippable/timing.py shebang
+tests/unit/compat/builtins.py pylint:unused-import
diff --git a/ansible_collections/community/libvirt/tests/sanity/ignore-2.9.txt b/ansible_collections/community/libvirt/tests/sanity/ignore-2.9.txt
deleted file mode 100644
index f6584fe11..000000000
--- a/ansible_collections/community/libvirt/tests/sanity/ignore-2.9.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-tests/unit/mock/path.py future-import-boilerplate
-tests/unit/mock/path.py metaclass-boilerplate
-tests/unit/mock/yaml_helper.py future-import-boilerplate
-tests/unit/mock/yaml_helper.py metaclass-boilerplate
-tests/unit/modules/cloud/misc/virt_net/conftest.py future-import-boilerplate
-tests/unit/modules/cloud/misc/virt_net/conftest.py metaclass-boilerplate
-tests/unit/modules/cloud/misc/virt_net/test_virt_net.py future-import-boilerplate
-tests/unit/modules/cloud/misc/virt_net/test_virt_net.py metaclass-boilerplate
-tests/utils/shippable/timing.py shebang
-tests/utils/shippable/check_matrix.py replace-urlopen
diff --git a/ansible_collections/community/libvirt/tests/unit/mock/loader.py b/ansible_collections/community/libvirt/tests/unit/mock/loader.py
index 00a584127..e5eb8b411 100644
--- a/ansible_collections/community/libvirt/tests/unit/mock/loader.py
+++ b/ansible_collections/community/libvirt/tests/unit/mock/loader.py
@@ -30,7 +30,7 @@ class DictDataLoader(DataLoader):
def __init__(self, file_mapping=None):
file_mapping = {} if file_mapping is None else file_mapping
- assert type(file_mapping) == dict
+ assert type(file_mapping) is dict
super(DictDataLoader, self).__init__()
diff --git a/ansible_collections/community/libvirt/tests/utils/shippable/check_matrix.py b/ansible_collections/community/libvirt/tests/utils/shippable/check_matrix.py
index 567181fc0..e670ed51d 100755
--- a/ansible_collections/community/libvirt/tests/utils/shippable/check_matrix.py
+++ b/ansible_collections/community/libvirt/tests/utils/shippable/check_matrix.py
@@ -10,8 +10,6 @@ import re
import sys
import time
-from ansible.module_utils.urls import open_url
-
try:
from typing import NoReturn
except ImportError: