Accepting request 819714 from systemsmanagement:saltstack
- Fix the registration of libvirt pool and nodedev events - Accept nested namespaces in spacewalk.api runner function. (bsc#1172211) - info_installed works without status attr now (bsc#1171461) - Added: * info_installed-works-without-status-attr-now.patch * opensuse-3000.3-spacewalk-runner-parse-command-250.patch * opensuse-3000-libvirt-engine-fixes-251.patch - Avoid traceback on debug logging for swarm module (bsc#1172075) - Added: * avoid-has_docker-true-if-import-messes-with-salt.uti.patch OBS-URL: https://build.opensuse.org/request/show/819714 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/salt?expand=0&rev=106
This commit is contained in:
commit
9ee450bc18
@ -1 +1 @@
|
|||||||
fb1212e6b081322ac0e32bb841293b347bcb4b62
|
82be64a05e54109be6af70998d154fe62150ce9c
|
34
avoid-has_docker-true-if-import-messes-with-salt.uti.patch
Normal file
34
avoid-has_docker-true-if-import-messes-with-salt.uti.patch
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
From f942aeb3eb64b99cd9432bebf021835ade46df74 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
|
||||||
|
<psuarezhernandez@suse.com>
|
||||||
|
Date: Thu, 28 May 2020 16:38:04 +0100
|
||||||
|
Subject: [PATCH] Avoid HAS_DOCKER true if import messes with
|
||||||
|
salt.utils.docker (bsc#1172075)
|
||||||
|
|
||||||
|
---
|
||||||
|
salt/modules/swarm.py | 6 +++++-
|
||||||
|
1 file changed, 5 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/salt/modules/swarm.py b/salt/modules/swarm.py
|
||||||
|
index ea327ce640040bdbd7e7077bc6bbb59a9f0ade4a..6f16f41ece01738f3a04d11211fa5e96cd8155b4 100644
|
||||||
|
--- a/salt/modules/swarm.py
|
||||||
|
+++ b/salt/modules/swarm.py
|
||||||
|
@@ -30,9 +30,13 @@ from __future__ import absolute_import, unicode_literals, print_function
|
||||||
|
# Import Salt libs
|
||||||
|
import salt.utils.json
|
||||||
|
|
||||||
|
+HAS_DOCKER = False
|
||||||
|
+
|
||||||
|
try:
|
||||||
|
import docker
|
||||||
|
- HAS_DOCKER = True
|
||||||
|
+
|
||||||
|
+ if hasattr(docker, "from_env"):
|
||||||
|
+ HAS_DOCKER = True
|
||||||
|
except ImportError:
|
||||||
|
HAS_DOCKER = False
|
||||||
|
|
||||||
|
--
|
||||||
|
2.23.0
|
||||||
|
|
||||||
|
|
65
info_installed-works-without-status-attr-now.patch
Normal file
65
info_installed-works-without-status-attr-now.patch
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
From 8275c229fcca0e43513ea680e48cbf6263247b41 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jochen Breuer <brejoc@gmail.com>
|
||||||
|
Date: Tue, 19 May 2020 10:34:35 +0200
|
||||||
|
Subject: [PATCH] info_installed works without status attr now
|
||||||
|
|
||||||
|
If 'status' was excluded via attr, info_installed was no longer able to
|
||||||
|
detect if a package was installed or not. Now info_installed adds the
|
||||||
|
'status' for the 'lowpkg.info' request again.
|
||||||
|
---
|
||||||
|
salt/modules/aptpkg.py | 9 +++++++++
|
||||||
|
tests/unit/modules/test_aptpkg.py | 17 +++++++++++++++++
|
||||||
|
2 files changed, 26 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/salt/modules/aptpkg.py b/salt/modules/aptpkg.py
|
||||||
|
index 2835d32263..765d69aff2 100644
|
||||||
|
--- a/salt/modules/aptpkg.py
|
||||||
|
+++ b/salt/modules/aptpkg.py
|
||||||
|
@@ -2867,6 +2867,15 @@ def info_installed(*names, **kwargs):
|
||||||
|
failhard = kwargs.pop('failhard', True)
|
||||||
|
kwargs.pop('errors', None) # Only for compatibility with RPM
|
||||||
|
attr = kwargs.pop('attr', None) # Package attributes to return
|
||||||
|
+
|
||||||
|
+ # status is needed to see if a package is installed. So we have to add it,
|
||||||
|
+ # even if it's excluded via attr parameter. Otherwise all packages are
|
||||||
|
+ # returned.
|
||||||
|
+ if attr:
|
||||||
|
+ attr_list = set(attr.split(','))
|
||||||
|
+ attr_list.add('status')
|
||||||
|
+ attr = ','.join(attr_list)
|
||||||
|
+
|
||||||
|
all_versions = kwargs.pop('all_versions', False) # This is for backward compatible structure only
|
||||||
|
|
||||||
|
if kwargs:
|
||||||
|
diff --git a/tests/unit/modules/test_aptpkg.py b/tests/unit/modules/test_aptpkg.py
|
||||||
|
index ba1d874e69..b0193aeaf7 100644
|
||||||
|
--- a/tests/unit/modules/test_aptpkg.py
|
||||||
|
+++ b/tests/unit/modules/test_aptpkg.py
|
||||||
|
@@ -257,6 +257,23 @@ class AptPkgTestCase(TestCase, LoaderModuleMockMixin):
|
||||||
|
self.assertEqual(aptpkg.info_installed('wget'), installed)
|
||||||
|
self.assertEqual(len(aptpkg.info_installed()), 1)
|
||||||
|
|
||||||
|
+ def test_info_installed_attr_without_status(self):
|
||||||
|
+ '''
|
||||||
|
+ Test info_installed 'attr' for inclusion of 'status' attribute.
|
||||||
|
+
|
||||||
|
+ Since info_installed should only return installed packages, we need to
|
||||||
|
+ call __salt__['lowpkg.info'] with the 'status' attribute even if the user
|
||||||
|
+ is not asking for it in 'attr'. Otherwise info_installed would not be able
|
||||||
|
+ to check if the package is installed and would return everything.
|
||||||
|
+
|
||||||
|
+ :return:
|
||||||
|
+ '''
|
||||||
|
+ with patch('salt.modules.aptpkg.__salt__', {'lowpkg.info': MagicMock(return_value=LOWPKG_INFO)}) as wget_lowpkg:
|
||||||
|
+ ret = aptpkg.info_installed('wget', attr='version')
|
||||||
|
+ calls = wget_lowpkg['lowpkg.info'].call_args_list.pop()
|
||||||
|
+ self.assertIn('status', calls.kwargs['attr'])
|
||||||
|
+ self.assertIn('version', calls.kwargs['attr'])
|
||||||
|
+
|
||||||
|
@patch('salt.modules.aptpkg.__salt__', {'lowpkg.info': MagicMock(return_value=LOWPKG_INFO)})
|
||||||
|
def test_info_installed_attr(self):
|
||||||
|
'''
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
|
|
1340
opensuse-3000-libvirt-engine-fixes-251.patch
Normal file
1340
opensuse-3000-libvirt-engine-fixes-251.patch
Normal file
File diff suppressed because it is too large
Load Diff
112
opensuse-3000.3-spacewalk-runner-parse-command-250.patch
Normal file
112
opensuse-3000.3-spacewalk-runner-parse-command-250.patch
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
From a7e1630d638a7e605a2372e923c0942c655480cd Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jochen Breuer <jbreuer@suse.de>
|
||||||
|
Date: Fri, 3 Jul 2020 14:08:03 +0200
|
||||||
|
Subject: [PATCH] openSUSE-3000.3 spacewalk runner parse command (#250)
|
||||||
|
|
||||||
|
* Accept nested namespaces in spacewalk.api
|
||||||
|
|
||||||
|
salt-run $server spacewalk.api allows users to run arbitrary Spacewalk
|
||||||
|
API functions through Salt. These are passed in a namespace.method
|
||||||
|
notation and may use nested namespaces. Previously only methods in a
|
||||||
|
top-level namespace were supported.
|
||||||
|
|
||||||
|
Fixes https://github.com/saltstack/salt/issues/57442
|
||||||
|
|
||||||
|
Co-authored-by: Wayne Werner <wwerner@saltstack.com>
|
||||||
|
|
||||||
|
* Add spacewalk runner command parsing tests
|
||||||
|
|
||||||
|
Co-authored-by: Alexander Graul <agraul@suse.com>
|
||||||
|
Co-authored-by: Wayne Werner <wwerner@saltstack.com>
|
||||||
|
---
|
||||||
|
changelog/57442.fixed | 1 +
|
||||||
|
salt/runners/spacewalk.py | 6 +++-
|
||||||
|
tests/unit/runners/test_spacewalk.py | 50 ++++++++++++++++++++++++++++
|
||||||
|
3 files changed, 56 insertions(+), 1 deletion(-)
|
||||||
|
create mode 100644 changelog/57442.fixed
|
||||||
|
create mode 100644 tests/unit/runners/test_spacewalk.py
|
||||||
|
|
||||||
|
diff --git a/changelog/57442.fixed b/changelog/57442.fixed
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000..81f394880f
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/changelog/57442.fixed
|
||||||
|
@@ -0,0 +1 @@
|
||||||
|
+Accept nested namespaces in spacewalk.api runner function.
|
||||||
|
diff --git a/salt/runners/spacewalk.py b/salt/runners/spacewalk.py
|
||||||
|
index 07ca9bd711..df4e568a28 100644
|
||||||
|
--- a/salt/runners/spacewalk.py
|
||||||
|
+++ b/salt/runners/spacewalk.py
|
||||||
|
@@ -172,7 +172,11 @@ def api(server, command, *args, **kwargs):
|
||||||
|
log.error(err_msg)
|
||||||
|
return {call: err_msg}
|
||||||
|
|
||||||
|
- namespace, method = command.split('.')
|
||||||
|
+ namespace, _, method = command.rpartition(".")
|
||||||
|
+ if not namespace:
|
||||||
|
+ return {
|
||||||
|
+ call: "Error: command must use the following format: 'namespace.method'"
|
||||||
|
+ }
|
||||||
|
endpoint = getattr(getattr(client, namespace), method)
|
||||||
|
|
||||||
|
try:
|
||||||
|
diff --git a/tests/unit/runners/test_spacewalk.py b/tests/unit/runners/test_spacewalk.py
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000..5b64069cc9
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/tests/unit/runners/test_spacewalk.py
|
||||||
|
@@ -0,0 +1,50 @@
|
||||||
|
+# -*- coding: utf-8 -*-
|
||||||
|
+"""
|
||||||
|
+Unit tests for Spacewalk runner
|
||||||
|
+"""
|
||||||
|
+import salt.runners.spacewalk as spacewalk
|
||||||
|
+from tests.support.mock import Mock, call, patch
|
||||||
|
+from tests.support.unit import TestCase
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+class SpacewalkTest(TestCase):
|
||||||
|
+ """Test the Spacewalk runner"""
|
||||||
|
+
|
||||||
|
+ def test_api_command_must_have_namespace(self):
|
||||||
|
+ _get_session_mock = Mock(return_value=(None, None))
|
||||||
|
+
|
||||||
|
+ with patch.object(spacewalk, "_get_session", _get_session_mock):
|
||||||
|
+ result = spacewalk.api("mocked.server", "badMethod")
|
||||||
|
+ assert result == {
|
||||||
|
+ "badMethod ()": "Error: command must use the following format: 'namespace.method'"
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ def test_api_command_accepts_single_namespace(self):
|
||||||
|
+ client_mock = Mock()
|
||||||
|
+ _get_session_mock = Mock(return_value=(client_mock, "key"))
|
||||||
|
+ getattr_mock = Mock(return_value="mocked_getattr_return")
|
||||||
|
+
|
||||||
|
+ with patch.object(spacewalk, "_get_session", _get_session_mock):
|
||||||
|
+ with patch.object(spacewalk, "getattr", getattr_mock):
|
||||||
|
+ spacewalk.api("mocked.server", "system.listSystems")
|
||||||
|
+ getattr_mock.assert_has_calls(
|
||||||
|
+ [
|
||||||
|
+ call(client_mock, "system"),
|
||||||
|
+ call("mocked_getattr_return", "listSystems"),
|
||||||
|
+ ]
|
||||||
|
+ )
|
||||||
|
+
|
||||||
|
+ def test_api_command_accepts_nested_namespace(self):
|
||||||
|
+ client_mock = Mock()
|
||||||
|
+ _get_session_mock = Mock(return_value=(client_mock, "key"))
|
||||||
|
+ getattr_mock = Mock(return_value="mocked_getattr_return")
|
||||||
|
+
|
||||||
|
+ with patch.object(spacewalk, "_get_session", _get_session_mock):
|
||||||
|
+ with patch.object(spacewalk, "getattr", getattr_mock):
|
||||||
|
+ spacewalk.api("mocked.server", "channel.software.listChildren")
|
||||||
|
+ getattr_mock.assert_has_calls(
|
||||||
|
+ [
|
||||||
|
+ call(client_mock, "channel.software"),
|
||||||
|
+ call("mocked_getattr_return", "listChildren"),
|
||||||
|
+ ]
|
||||||
|
+ )
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
|
|
20
salt.changes
20
salt.changes
@ -1,3 +1,23 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Fri Jul 3 13:19:02 UTC 2020 - Jochen Breuer <jbreuer@suse.de>
|
||||||
|
|
||||||
|
- Fix the registration of libvirt pool and nodedev events
|
||||||
|
- Accept nested namespaces in spacewalk.api runner function. (bsc#1172211)
|
||||||
|
- info_installed works without status attr now (bsc#1171461)
|
||||||
|
|
||||||
|
- Added:
|
||||||
|
* info_installed-works-without-status-attr-now.patch
|
||||||
|
* opensuse-3000.3-spacewalk-runner-parse-command-250.patch
|
||||||
|
* opensuse-3000-libvirt-engine-fixes-251.patch
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu May 28 16:01:10 UTC 2020 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
|
||||||
|
|
||||||
|
- Avoid traceback on debug logging for swarm module (bsc#1172075)
|
||||||
|
|
||||||
|
- Added:
|
||||||
|
* avoid-has_docker-true-if-import-messes-with-salt.uti.patch
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Thu May 28 08:51:19 UTC 2020 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
|
Thu May 28 08:51:19 UTC 2020 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
|
||||||
|
|
||||||
|
12
salt.spec
12
salt.spec
@ -318,6 +318,14 @@ Patch116: fix-for-return-value-ret-vs-return-in-batch-mode.patch
|
|||||||
Patch117: zypperpkg-filter-patterns-that-start-with-dot-244.patch
|
Patch117: zypperpkg-filter-patterns-that-start-with-dot-244.patch
|
||||||
# PATCH-FIX_OPENSUSE: hhttps://github.com/openSUSE/salt/commit/da936daeebd701e147707ad814c07bfc259d4be
|
# PATCH-FIX_OPENSUSE: hhttps://github.com/openSUSE/salt/commit/da936daeebd701e147707ad814c07bfc259d4be
|
||||||
Patch118: add-publish_batch-to-clearfuncs-exposed-methods.patch
|
Patch118: add-publish_batch-to-clearfuncs-exposed-methods.patch
|
||||||
|
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/57489
|
||||||
|
Patch119: avoid-has_docker-true-if-import-messes-with-salt.uti.patch
|
||||||
|
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/57779
|
||||||
|
Patch120: info_installed-works-without-status-attr-now.patch
|
||||||
|
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/57491
|
||||||
|
Patch121: opensuse-3000.3-spacewalk-runner-parse-command-250.patch
|
||||||
|
# PATCH-FIX_UPSTREAM: https://github.com/openSUSE/salt/pull/251
|
||||||
|
Patch122: opensuse-3000-libvirt-engine-fixes-251.patch
|
||||||
|
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
BuildRequires: logrotate
|
BuildRequires: logrotate
|
||||||
@ -942,6 +950,10 @@ cp %{S:5} ./.travis.yml
|
|||||||
%patch116 -p1
|
%patch116 -p1
|
||||||
%patch117 -p1
|
%patch117 -p1
|
||||||
%patch118 -p1
|
%patch118 -p1
|
||||||
|
%patch119 -p1
|
||||||
|
%patch120 -p1
|
||||||
|
%patch121 -p1
|
||||||
|
%patch122 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%if 0%{?build_py2}
|
%if 0%{?build_py2}
|
||||||
|
Loading…
Reference in New Issue
Block a user