From a8810c88a2879a8fdbeed9a686bbede717aec362ef7aaf5b869fa6801b31eef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?= Date: Tue, 10 Dec 2019 15:22:43 +0000 Subject: [PATCH 1/2] osc copypac from project:systemsmanagement:saltstack:testing package:salt revision:312 OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=157 --- _lastrevision | 2 +- ...rt-full-info-fixes-with-upstream-192.patch | 116 ++++++++++++++++++ fix-batch_async-obsolete-test.patch | 33 +++++ fix-virt.get_hypervisor-188.patch | 54 ++++++++ fixing-streamclosed-issue.patch | 33 +++++ ...-platform-python-binary-in-rhel8-191.patch | 32 +++++ salt.changes | 34 +++++ salt.spec | 26 +++- 8 files changed, 323 insertions(+), 7 deletions(-) create mode 100644 align-virt-full-info-fixes-with-upstream-192.patch create mode 100644 fix-batch_async-obsolete-test.patch create mode 100644 fix-virt.get_hypervisor-188.patch create mode 100644 fixing-streamclosed-issue.patch create mode 100644 let-salt-ssh-use-platform-python-binary-in-rhel8-191.patch diff --git a/_lastrevision b/_lastrevision index e63f25d..ba90586 100644 --- a/_lastrevision +++ b/_lastrevision @@ -1 +1 @@ -8ec046fadeba7bd58a5bf2a3f561c4bffd6c4510 \ No newline at end of file +f0c179a11cfb8bbbff31619eba7d716bc800704a \ No newline at end of file diff --git a/align-virt-full-info-fixes-with-upstream-192.patch b/align-virt-full-info-fixes-with-upstream-192.patch new file mode 100644 index 0000000..c059e3a --- /dev/null +++ b/align-virt-full-info-fixes-with-upstream-192.patch @@ -0,0 +1,116 @@ +From d569054ebc63718e62fe5799685b0623910f7e1f Mon Sep 17 00:00:00 2001 +From: Cedric Bosdonnat +Date: Mon, 9 Dec 2019 17:27:41 +0100 +Subject: [PATCH] Align virt full info fixes with upstream (#192) + +* Porting PR #52574 to 2019.2.1 + +* Partly revert 4ce0bc544174fdb00482db4653fb4b0ef411e78b to match upstream's fix +--- + salt/modules/virt.py | 12 +++++++----- + tests/unit/modules/test_virt.py | 23 ++++++++++++++++++++++- + 2 files changed, 29 insertions(+), 6 deletions(-) + +diff --git a/salt/modules/virt.py b/salt/modules/virt.py +index 3abc140a00..5e26964449 100644 +--- a/salt/modules/virt.py ++++ b/salt/modules/virt.py +@@ -331,7 +331,7 @@ def _get_uuid(dom): + + salt '*' virt.get_uuid + ''' +- return ElementTree.fromstring(dom.XMLDesc(0)).find('uuid').text ++ return ElementTree.fromstring(get_xml(dom)).find('uuid').text + + + def _get_on_poweroff(dom): +@@ -344,7 +344,7 @@ def _get_on_poweroff(dom): + + salt '*' virt.get_on_restart + ''' +- node = ElementTree.fromstring(dom.XMLDesc(0)).find('on_poweroff') ++ node = ElementTree.fromstring(get_xml(dom)).find('on_poweroff') + return node.text if node is not None else '' + + +@@ -358,7 +358,7 @@ def _get_on_reboot(dom): + + salt '*' virt.get_on_reboot + ''' +- node = ElementTree.fromstring(dom.XMLDesc(0)).find('on_reboot') ++ node = ElementTree.fromstring(get_xml(dom)).find('on_reboot') + return node.text if node is not None else '' + + +@@ -372,7 +372,7 @@ def _get_on_crash(dom): + + salt '*' virt.get_on_crash + ''' +- node = ElementTree.fromstring(dom.XMLDesc(0)).find('on_crash') ++ node = ElementTree.fromstring(get_xml(dom)).find('on_crash') + return node.text if node is not None else '' + + +@@ -2435,7 +2435,9 @@ def get_xml(vm_, **kwargs): + salt '*' virt.get_xml + ''' + conn = __get_conn(**kwargs) +- xml_desc = _get_domain(conn, vm_).XMLDesc(0) ++ xml_desc = vm_.XMLDesc(0) if isinstance( ++ vm_, libvirt.virDomain ++ ) else _get_domain(conn, vm_).XMLDesc(0) + conn.close() + return xml_desc + +diff --git a/tests/unit/modules/test_virt.py b/tests/unit/modules/test_virt.py +index b95f51807f..d8efafc063 100644 +--- a/tests/unit/modules/test_virt.py ++++ b/tests/unit/modules/test_virt.py +@@ -38,6 +38,10 @@ class LibvirtMock(MagicMock): # pylint: disable=too-many-ancestors + ''' + Libvirt library mock + ''' ++ class virDomain(MagicMock): ++ ''' ++ virDomain mock ++ ''' + + class libvirtError(Exception): + ''' +@@ -76,7 +80,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin): + Define VM to use in tests + ''' + self.mock_conn.listDefinedDomains.return_value = [name] # pylint: disable=no-member +- mock_domain = MagicMock() ++ mock_domain = self.mock_libvirt.virDomain() + self.mock_conn.lookupByName.return_value = mock_domain # pylint: disable=no-member + mock_domain.XMLDesc.return_value = xml # pylint: disable=no-member + +@@ -1396,6 +1400,23 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin): + re.match('^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$', + interface_attrs['mac'], re.I)) + ++ def test_get_xml(self): ++ ''' ++ Test virt.get_xml() ++ ''' ++ xml = ''' ++ test-vm ++ ++ ++ ++ ++ ++ ++ ''' ++ domain = self.set_mock_vm("test-vm", xml) ++ self.assertEqual(xml, virt.get_xml('test-vm')) ++ self.assertEqual(xml, virt.get_xml(domain)) ++ + def test_parse_qemu_img_info(self): + ''' + Make sure that qemu-img info output is properly parsed +-- +2.23.0 + + diff --git a/fix-batch_async-obsolete-test.patch b/fix-batch_async-obsolete-test.patch new file mode 100644 index 0000000..f41f596 --- /dev/null +++ b/fix-batch_async-obsolete-test.patch @@ -0,0 +1,33 @@ +From 78b466b0d45de8b7edace542dd3815ca852def40 Mon Sep 17 00:00:00 2001 +From: Mihai Dinca +Date: Tue, 3 Dec 2019 11:22:42 +0100 +Subject: [PATCH] Fix batch_async obsolete test + +--- + tests/unit/cli/test_batch_async.py | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/tests/unit/cli/test_batch_async.py b/tests/unit/cli/test_batch_async.py +index 12dfe543bc..f1d36a81fb 100644 +--- a/tests/unit/cli/test_batch_async.py ++++ b/tests/unit/cli/test_batch_async.py +@@ -140,8 +140,14 @@ class AsyncBatchTestCase(AsyncTestCase, TestCase): + "salt/batch/1235/done" + ) + ) ++ ++ def test_batch__del__(self): ++ batch = BatchAsync(MagicMock(), MagicMock(), MagicMock()) ++ event = MagicMock() ++ batch.event = event ++ batch.__del__() + self.assertEqual( +- len(self.batch.event.remove_event_handler.mock_calls), 1) ++ len(event.remove_event_handler.mock_calls), 1) + + @tornado.testing.gen_test + def test_batch_next(self): +-- +2.23.0 + + diff --git a/fix-virt.get_hypervisor-188.patch b/fix-virt.get_hypervisor-188.patch new file mode 100644 index 0000000..0690c11 --- /dev/null +++ b/fix-virt.get_hypervisor-188.patch @@ -0,0 +1,54 @@ +From 4e315730c1cf91c8c3efb1aad3c6370953c78459 Mon Sep 17 00:00:00 2001 +From: Cedric Bosdonnat +Date: Tue, 10 Dec 2019 10:27:26 +0100 +Subject: [PATCH] Fix virt.get_hypervisor() (#188) + +virt.get_hypervisor resulted in: + + AttributeError: module 'salt.loader.dev-srv.tf.local.int.module.virt' has no attribute '_is_{}_hyper' + +This was due to missplaced parenthese. +--- + salt/modules/virt.py | 2 +- + tests/unit/modules/test_virt.py | 14 ++++++++++++++ + 2 files changed, 15 insertions(+), 1 deletion(-) + +diff --git a/salt/modules/virt.py b/salt/modules/virt.py +index 5e26964449..dedcf8cb6f 100644 +--- a/salt/modules/virt.py ++++ b/salt/modules/virt.py +@@ -3309,7 +3309,7 @@ def get_hypervisor(): + # To add a new 'foo' hypervisor, add the _is_foo_hyper function, + # add 'foo' to the list below and add it to the docstring with a .. versionadded:: + hypervisors = ['kvm', 'xen'] +- result = [hyper for hyper in hypervisors if getattr(sys.modules[__name__], '_is_{}_hyper').format(hyper)()] ++ result = [hyper for hyper in hypervisors if getattr(sys.modules[__name__], '_is_{}_hyper'.format(hyper))()] + return result[0] if result else None + + +diff --git a/tests/unit/modules/test_virt.py b/tests/unit/modules/test_virt.py +index d8efafc063..6f594a8ff3 100644 +--- a/tests/unit/modules/test_virt.py ++++ b/tests/unit/modules/test_virt.py +@@ -3044,3 +3044,17 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin): + # 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) ++ ++ @patch('salt.modules.virt._is_kvm_hyper', return_value=True) ++ @patch('salt.modules.virt._is_xen_hyper', return_value=False) ++ def test_get_hypervisor(self, isxen_mock, iskvm_mock): ++ ''' ++ test the virt.get_hypervisor() function ++ ''' ++ self.assertEqual('kvm', virt.get_hypervisor()) ++ ++ iskvm_mock.return_value = False ++ self.assertIsNone(virt.get_hypervisor()) ++ ++ isxen_mock.return_value = True ++ self.assertEqual('xen', virt.get_hypervisor()) +-- +2.23.0 + + diff --git a/fixing-streamclosed-issue.patch b/fixing-streamclosed-issue.patch new file mode 100644 index 0000000..1a688ae --- /dev/null +++ b/fixing-streamclosed-issue.patch @@ -0,0 +1,33 @@ +From 11d5623a4b9b8ac40f29adb79f203ab8bbfdd8fc Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Mihai=20Dinc=C4=83?= +Date: Tue, 26 Nov 2019 18:26:31 +0100 +Subject: [PATCH] Fixing StreamClosed issue + +--- + salt/cli/batch_async.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/salt/cli/batch_async.py b/salt/cli/batch_async.py +index 754c257b36..c4545e3ebc 100644 +--- a/salt/cli/batch_async.py ++++ b/salt/cli/batch_async.py +@@ -221,7 +221,6 @@ class BatchAsync(object): + "metadata": self.metadata + } + self.event.fire_event(data, "salt/batch/{0}/done".format(self.batch_jid)) +- self.event.remove_event_handler(self.__event_handler) + for (pattern, label) in self.patterns: + if label in ["ping_return", "batch_run"]: + self.event.unsubscribe(pattern, match_type='glob') +@@ -265,6 +264,7 @@ class BatchAsync(object): + + def __del__(self): + self.local = None ++ self.event.remove_event_handler(self.__event_handler) + self.event = None + self.ioloop = None + gc.collect() +-- +2.23.0 + + diff --git a/let-salt-ssh-use-platform-python-binary-in-rhel8-191.patch b/let-salt-ssh-use-platform-python-binary-in-rhel8-191.patch new file mode 100644 index 0000000..ef336ed --- /dev/null +++ b/let-salt-ssh-use-platform-python-binary-in-rhel8-191.patch @@ -0,0 +1,32 @@ +From 43cdd24d035ff21c946f6de0a973f5db0e50c8a5 Mon Sep 17 00:00:00 2001 +From: Can Bulut Bayburt <1103552+cbbayburt@users.noreply.github.com> +Date: Wed, 4 Dec 2019 15:59:46 +0100 +Subject: [PATCH] Let salt-ssh use 'platform-python' binary in RHEL8 + (#191) + +RHEL/CentOS 8 has an internal Python interpreter called 'platform-python' +included in the base setup. + +Add this binary to the list of Python executables to look for when +creating the sh shim. +--- + salt/client/ssh/__init__.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/salt/client/ssh/__init__.py b/salt/client/ssh/__init__.py +index 0df918d634..d5bc6e5c27 100644 +--- a/salt/client/ssh/__init__.py ++++ b/salt/client/ssh/__init__.py +@@ -147,7 +147,7 @@ elif [ "$SUDO" ] && [ -n "$SUDO_USER" ] + then SUDO="sudo " + fi + EX_PYTHON_INVALID={EX_THIN_PYTHON_INVALID} +-PYTHON_CMDS="python3 python27 python2.7 python26 python2.6 python2 python" ++PYTHON_CMDS="python3 /usr/libexec/platform-python python27 python2.7 python26 python2.6 python2 python" + for py_cmd in $PYTHON_CMDS + do + if command -v "$py_cmd" >/dev/null 2>&1 && "$py_cmd" -c "import sys; sys.exit(not (sys.version_info >= (2, 6)));" +-- +2.23.0 + + diff --git a/salt.changes b/salt.changes index 9929cd2..0176997 100644 --- a/salt.changes +++ b/salt.changes @@ -1,3 +1,37 @@ +------------------------------------------------------------------- +Tue Dec 10 12:56:45 UTC 2019 - Pablo Suárez Hernández + +- Don't use __python indirection macros on spec file + %__python is no longer defined in RPM 4.15 (python2 is going EOL in Jan 2020); + additionally, python/python3 are just binaries in the path. + +------------------------------------------------------------------- +Tue Dec 10 09:35:15 UTC 2019 - Pablo Suárez Hernández + +- Fix errors when running virt.get_hypervisor function + +- Added: + * fix-virt.get_hypervisor-188.patch + +------------------------------------------------------------------- +Mon Dec 9 16:37:04 UTC 2019 - Pablo Suárez Hernández + +- Align virt.full_info fixes with upstream Salt +- Let salt-ssh use platform-python on RHEL8 (bsc#1158441) + +- Added: + * align-virt-full-info-fixes-with-upstream-192.patch + * let-salt-ssh-use-platform-python-binary-in-rhel8-191.patch + +------------------------------------------------------------------- +Tue Dec 3 12:22:55 UTC 2019 - Mihai Dincă + +- Fix StreamClosedError issue (bsc#1157479) + +- Added: + * fix-batch_async-obsolete-test.patch + * fixing-streamclosed-issue.patch + ------------------------------------------------------------------- Thu Nov 28 15:27:27 UTC 2019 - Mihai Dincă diff --git a/salt.spec b/salt.spec index c762c5c..2beb4d6 100644 --- a/salt.spec +++ b/salt.spec @@ -261,6 +261,15 @@ Patch90: read-repo-info-without-using-interpolation-bsc-11356.patch # PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/53293 Patch91: prevent-test_mod_del_repo_multiline_values-to-fail.patch Patch92: fix-for-log-checking-in-x509-test.patch +# PATCH_FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/190 +Patch93: fixing-streamclosed-issue.patch +Patch94: fix-batch_async-obsolete-test.patch +# PATCH_FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/191 +Patch95: let-salt-ssh-use-platform-python-binary-in-rhel8-191.patch +# PATCH_FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/192 +Patch96: align-virt-full-info-fixes-with-upstream-192.patch +# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/55351 +Patch97: fix-virt.get_hypervisor-188.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: logrotate @@ -869,15 +878,20 @@ cp %{S:5} ./.travis.yml %patch90 -p1 %patch91 -p1 %patch92 -p1 +%patch93 -p1 +%patch94 -p1 +%patch95 -p1 +%patch96 -p1 +%patch97 -p1 %build %if 0%{?build_py2} -%{__python} setup.py --with-salt-version=%{version} --salt-transport=both build +python setup.py --with-salt-version=%{version} --salt-transport=both build cp ./build/lib/salt/_version.py ./salt mv build _build.python2 %endif %if 0%{?build_py3} -%{__python3} setup.py --with-salt-version=%{version} --salt-transport=both build +python3 setup.py --with-salt-version=%{version} --salt-transport=both build cp ./build/lib/salt/_version.py ./salt mv build _build.python3 %endif @@ -898,12 +912,12 @@ cd doc && make html && rm _build/html/.buildinfo && rm _build/html/_images/proxy %install %if 0%{?build_py2} mv _build.python2 build -%{__python} setup.py --salt-transport=both install --prefix=%{_prefix} --root=%{buildroot} +python setup.py --salt-transport=both install --prefix=%{_prefix} --root=%{buildroot} mv build _build.python2 %endif %if 0%{?build_py3} mv _build.python3 build -%{__python3} setup.py --salt-transport=both install --prefix=%{_prefix} --root=%{buildroot} +python3 setup.py --salt-transport=both install --prefix=%{_prefix} --root=%{buildroot} mv build _build.python3 %endif @@ -1069,9 +1083,9 @@ install -Dpm 0640 conf/suse/standalone-formulas-configuration.conf %{buildroot}% %check %if %{with test} %if 0%{?default_py3} -%{__python3} setup.py test --runtests-opts=-u +python3 setup.py test --runtests-opts=-u %else -%{__python} setup.py test --runtests-opts=-u +python setup.py test --runtests-opts=-u %endif %endif From 4ead0d0098f93d6b479dc70add0a228a3883b1d14db24df1383b32630ec7b0e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?= Date: Thu, 12 Dec 2019 10:37:03 +0000 Subject: [PATCH 2/2] osc copypac from project:systemsmanagement:saltstack:testing package:salt revision:314 OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=158 --- _lastrevision | 2 +- salt.changes | 25 +++++ salt.spec | 3 + xfs-do-not-fails-if-type-is-not-present.patch | 92 +++++++++++++++++++ 4 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 xfs-do-not-fails-if-type-is-not-present.patch diff --git a/_lastrevision b/_lastrevision index ba90586..a4a9fc6 100644 --- a/_lastrevision +++ b/_lastrevision @@ -1 +1 @@ -f0c179a11cfb8bbbff31619eba7d716bc800704a \ No newline at end of file +119d230d13c22207b56ca0276f65a25692e8f4bf \ No newline at end of file diff --git a/salt.changes b/salt.changes index 0176997..a78c4c7 100644 --- a/salt.changes +++ b/salt.changes @@ -1,3 +1,28 @@ +------------------------------------------------------------------- +Thu Dec 12 10:21:15 UTC 2019 - Pablo Suárez Hernández + +- Add missing bugzilla references: + Properly handle colons in inline dicts with yamlloader (bsc#1095651) + Fix corrupt public key with m2crypto python3 (bsc#1099323) + Add missing dateutils import (bsc#1099945) + Fix UnicodeDecodeError using is_binary check (bsc#1100225) + Prevent payload crash on decoding binary data (bsc#1100697) + Fix file.blockreplace to avoid throwing IndexError (bsc#1101812) + Add API log rotation on SUSE package (bsc#1102218) + Fix wrong recurse behavior on for linux_acl.present (bsc#1106164) + Handle anycast IPv6 addresses on network.routes (bsc#1114474) + Crontab module fix: file attributes option missing (bsc#1114824) + Add metadata to accepted keyword arguments (bsc#1122680) + Bugfix: properly refresh pillars (bsc#1125015) + +------------------------------------------------------------------- +Wed Dec 11 14:27:24 UTC 2019 - Mihai Dincă + +- xfs: do not fail if type is not present (bsc#1153611) + +- Added: + * xfs-do-not-fails-if-type-is-not-present.patch + ------------------------------------------------------------------- Tue Dec 10 12:56:45 UTC 2019 - Pablo Suárez Hernández diff --git a/salt.spec b/salt.spec index 2beb4d6..90a4436 100644 --- a/salt.spec +++ b/salt.spec @@ -270,6 +270,8 @@ Patch95: let-salt-ssh-use-platform-python-binary-in-rhel8-191.patch Patch96: align-virt-full-info-fixes-with-upstream-192.patch # PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/55351 Patch97: fix-virt.get_hypervisor-188.patch +# PATCH_FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/193 +Patch98: xfs-do-not-fails-if-type-is-not-present.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: logrotate @@ -883,6 +885,7 @@ cp %{S:5} ./.travis.yml %patch95 -p1 %patch96 -p1 %patch97 -p1 +%patch98 -p1 %build %if 0%{?build_py2} diff --git a/xfs-do-not-fails-if-type-is-not-present.patch b/xfs-do-not-fails-if-type-is-not-present.patch new file mode 100644 index 0000000..c4e3224 --- /dev/null +++ b/xfs-do-not-fails-if-type-is-not-present.patch @@ -0,0 +1,92 @@ +From 4a922d62a899cacf15a80882b2d1aff7ab66097c Mon Sep 17 00:00:00 2001 +From: Alberto Planas +Date: Tue, 11 Jun 2019 17:21:05 +0200 +Subject: [PATCH] xfs: do not fails if type is not present + +The command `blkid -o export` not always provides a 'TYPE' output +for all the devices. One example is non-formatted partitions, like for +example the BIOS partition. + +This patch do not force the presence of this field in the blkid +output. + +(cherry picked from commit 88df6963470007aa4fe2adb09f000311f48226a8) +--- + salt/modules/xfs.py | 2 +- + tests/unit/modules/test_xfs.py | 50 ++++++++++++++++++++++++++++++++++ + 2 files changed, 51 insertions(+), 1 deletion(-) + create mode 100644 tests/unit/modules/test_xfs.py + +diff --git a/salt/modules/xfs.py b/salt/modules/xfs.py +index 6546603ed6..e133ec83e1 100644 +--- a/salt/modules/xfs.py ++++ b/salt/modules/xfs.py +@@ -329,7 +329,7 @@ def _blkid_output(out): + for items in flt(dev_meta.strip().split("\n")): + key, val = items.split("=", 1) + dev[key.lower()] = val +- if dev.pop("type") == "xfs": ++ if dev.pop("type", None) == "xfs": + dev['label'] = dev.get('label') + data[dev.pop("devname")] = dev + +diff --git a/tests/unit/modules/test_xfs.py b/tests/unit/modules/test_xfs.py +new file mode 100644 +index 0000000000..4b423d69d1 +--- /dev/null ++++ b/tests/unit/modules/test_xfs.py +@@ -0,0 +1,50 @@ ++# -*- coding: utf-8 -*- ++ ++# Import Python libs ++from __future__ import absolute_import, print_function, unicode_literals ++import textwrap ++ ++# Import Salt Testing Libs ++from tests.support.mixins import LoaderModuleMockMixin ++from tests.support.unit import skipIf, TestCase ++from tests.support.mock import ( ++ NO_MOCK, ++ NO_MOCK_REASON, ++ MagicMock, ++ patch) ++ ++# Import Salt Libs ++import salt.modules.xfs as xfs ++ ++ ++@skipIf(NO_MOCK, NO_MOCK_REASON) ++@patch('salt.modules.xfs._get_mounts', MagicMock(return_value={})) ++class XFSTestCase(TestCase, LoaderModuleMockMixin): ++ ''' ++ Test cases for salt.modules.xfs ++ ''' ++ def setup_loader_modules(self): ++ return {xfs: {}} ++ ++ def test__blkid_output(self): ++ ''' ++ Test xfs._blkid_output when there is data ++ ''' ++ blkid_export = textwrap.dedent(''' ++ DEVNAME=/dev/sda1 ++ UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX ++ TYPE=xfs ++ PARTUUID=YYYYYYYY-YY ++ ++ DEVNAME=/dev/sdb1 ++ PARTUUID=ZZZZZZZZ-ZZZZ-ZZZZ-ZZZZ-ZZZZZZZZZZZZ ++ ''') ++ # We expect to find only data from /dev/sda1, nothig from ++ # /dev/sdb1 ++ self.assertEqual(xfs._blkid_output(blkid_export), { ++ '/dev/sda1': { ++ 'label': None, ++ 'partuuid': 'YYYYYYYY-YY', ++ 'uuid': 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' ++ } ++ }) +-- +2.23.0 + +