diff --git a/_lastrevision b/_lastrevision index 7aac985..801f4ce 100644 --- a/_lastrevision +++ b/_lastrevision @@ -1 +1 @@ -0ae10b837a49c10246690aabc972d2cb02bb75de \ No newline at end of file +760cec648ef1960ceba0c6f265dc821a2aa1f536 \ No newline at end of file diff --git a/prevent-ansiblegate-unit-tests-to-fail-on-ubuntu.patch b/prevent-ansiblegate-unit-tests-to-fail-on-ubuntu.patch new file mode 100644 index 0000000..bab0f21 --- /dev/null +++ b/prevent-ansiblegate-unit-tests-to-fail-on-ubuntu.patch @@ -0,0 +1,32 @@ +From 84e9371399b50618765038bcec2e313a006eadf9 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?= + +Date: Mon, 8 Jul 2019 14:46:10 +0100 +Subject: [PATCH] Prevent ansiblegate unit tests to fail on Ubuntu + +--- + tests/unit/modules/test_ansiblegate.py | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/tests/unit/modules/test_ansiblegate.py b/tests/unit/modules/test_ansiblegate.py +index 70b47f8bc2..2a24d6f147 100644 +--- a/tests/unit/modules/test_ansiblegate.py ++++ b/tests/unit/modules/test_ansiblegate.py +@@ -172,9 +172,11 @@ description: + with patch('salt.utils.timed_subprocess.TimedProc', proc): + ret = _ansible_module_caller.call("one.two.three", "arg_1", kwarg1="foobar") + if six.PY3: +- proc.assert_any_call(['echo', '{"ANSIBLE_MODULE_ARGS": {"kwarg1": "foobar", "_raw_params": "arg_1"}}'], stdout=-1, timeout=1200) + proc.assert_any_call(['python3', 'foofile'], stdin=ANSIBLE_MODULE_ARGS, stdout=-1, timeout=1200) + else: +- proc.assert_any_call(['echo', '{"ANSIBLE_MODULE_ARGS": {"_raw_params": "arg_1", "kwarg1": "foobar"}}'], stdout=-1, timeout=1200) + proc.assert_any_call(['python', 'foofile'], stdin=ANSIBLE_MODULE_ARGS, stdout=-1, timeout=1200) ++ try: ++ proc.assert_any_call(['echo', '{"ANSIBLE_MODULE_ARGS": {"kwarg1": "foobar", "_raw_params": "arg_1"}}'], stdout=-1, timeout=1200) ++ except AssertionError: ++ proc.assert_any_call(['echo', '{"ANSIBLE_MODULE_ARGS": {"_raw_params": "arg_1", "kwarg1": "foobar"}}'], stdout=-1, timeout=1200) + assert ret == {"completed": True, "timeout": 1200} +-- +2.21.0 + + diff --git a/salt.changes b/salt.changes index eca3c0b..56ac2ab 100644 --- a/salt.changes +++ b/salt.changes @@ -1,3 +1,19 @@ +------------------------------------------------------------------- +Wed Jul 10 08:54:28 UTC 2019 - Pablo Suárez Hernández + +- virt.volume_infos: don't raise an error if there is no VM + +- Added: + * virt-1.volume_infos-fix-for-single-vm.patch + +------------------------------------------------------------------- +Mon Jul 8 14:22:58 UTC 2019 - Pablo Suárez Hernández + +- Prevent ansiblegate unit tests to fail on Ubuntu + +- Added: + * prevent-ansiblegate-unit-tests-to-fail-on-ubuntu.patch + ------------------------------------------------------------------- Wed Jul 3 08:53:13 UTC 2019 - Pablo Suárez Hernández diff --git a/salt.spec b/salt.spec index 6e171f8..873c54e 100644 --- a/salt.spec +++ b/salt.spec @@ -202,6 +202,10 @@ Patch66: provide-the-missing-features-required-for-yomi-yet-o.patch Patch67: do-not-make-ansiblegate-to-crash-on-python3-minions.patch # PATCH_FIX_UPSTREAM: https://github.com/saltstack/salt/pull/53693 Patch68: allow-passing-kwargs-to-pkg.list_downloaded-bsc-1140.patch +# PATCH_FIX_UPSTREAM: https://github.com/saltstack/salt/pull/53661 +Patch69: prevent-ansiblegate-unit-tests-to-fail-on-ubuntu.patch +# PATCH_FIX_UPSTREAM: https://github.com/saltstack/salt/pull/53755 +Patch70: virt-1.volume_infos-fix-for-single-vm.patch # BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -740,6 +744,8 @@ cp %{S:5} ./.travis.yml %patch66 -p1 %patch67 -p1 %patch68 -p1 +%patch69 -p1 +%patch70 -p1 %build %if 0%{?build_py2} diff --git a/virt-1.volume_infos-fix-for-single-vm.patch b/virt-1.volume_infos-fix-for-single-vm.patch new file mode 100644 index 0000000..7d95686 --- /dev/null +++ b/virt-1.volume_infos-fix-for-single-vm.patch @@ -0,0 +1,91 @@ +From 9fcf9a768d0f11e04e145612cc5b2c05cfbf5378 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= +Date: Thu, 4 Apr 2019 16:18:58 +0200 +Subject: [PATCH] virt.volume_infos fix for single VM + +virt.volume_infos: don't raise an error if there is no VM +--- + salt/modules/virt.py | 8 ++++-- + tests/unit/modules/test_virt.py | 46 +++++++++++++++++++++++++++++++++ + 2 files changed, 52 insertions(+), 2 deletions(-) + +diff --git a/salt/modules/virt.py b/salt/modules/virt.py +index d160f0905f..953064cc2c 100644 +--- a/salt/modules/virt.py ++++ b/salt/modules/virt.py +@@ -5050,8 +5050,12 @@ def volume_infos(pool=None, volume=None, **kwargs): + conn = __get_conn(**kwargs) + try: + backing_stores = _get_all_volumes_paths(conn) +- domains = _get_domain(conn) +- domains_list = domains if isinstance(domains, list) else [domains] ++ try: ++ domains = _get_domain(conn) ++ domains_list = domains if isinstance(domains, list) else [domains] ++ except CommandExecutionError: ++ # Having no VM is not an error here. ++ domains_list = [] + disks = {domain.name(): + {node.get('file') for node + in ElementTree.fromstring(domain.XMLDesc(0)).findall('.//disk/source/[@file]')} +diff --git a/tests/unit/modules/test_virt.py b/tests/unit/modules/test_virt.py +index cc62b67918..b343b9bc31 100644 +--- a/tests/unit/modules/test_virt.py ++++ b/tests/unit/modules/test_virt.py +@@ -2910,6 +2910,52 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin): + } + }) + ++ # No VM test ++ with patch('salt.modules.virt._get_domain', MagicMock(side_effect=CommandExecutionError('no VM'))): ++ actual = virt.volume_infos('pool0', 'vol0') ++ self.assertEqual(1, len(actual.keys())) ++ self.assertEqual(1, len(actual['pool0'].keys())) ++ self.assertEqual([], sorted(actual['pool0']['vol0']['used_by'])) ++ self.assertEqual('/path/to/vol0.qcow2', actual['pool0']['vol0']['path']) ++ self.assertEqual('file', actual['pool0']['vol0']['type']) ++ self.assertEqual('/key/of/vol0', actual['pool0']['vol0']['key']) ++ self.assertEqual(123456789, actual['pool0']['vol0']['capacity']) ++ self.assertEqual(123456, actual['pool0']['vol0']['allocation']) ++ ++ self.assertEqual(virt.volume_infos('pool1', None), { ++ 'pool1': { ++ 'vol1': { ++ 'type': 'file', ++ 'key': '/key/of/vol1', ++ 'path': '/path/to/vol1.qcow2', ++ 'capacity': 12345, ++ 'allocation': 1234, ++ 'used_by': [], ++ }, ++ 'vol2': { ++ 'type': 'file', ++ 'key': '/key/of/vol2', ++ 'path': '/path/to/vol2.qcow2', ++ 'capacity': 12345, ++ 'allocation': 1234, ++ 'used_by': [], ++ } ++ } ++ }) ++ ++ self.assertEqual(virt.volume_infos(None, 'vol2'), { ++ 'pool1': { ++ 'vol2': { ++ 'type': 'file', ++ 'key': '/key/of/vol2', ++ 'path': '/path/to/vol2.qcow2', ++ 'capacity': 12345, ++ 'allocation': 1234, ++ 'used_by': [], ++ } ++ } ++ }) ++ + def test_volume_delete(self): + ''' + Test virt.volume_delete +-- +2.21.0 + +