osc copypac from project:systemsmanagement:saltstack:testing package:salt revision:382
OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=184
This commit is contained in:
parent
588fc6c9b9
commit
c0058217c7
1334
3002.2-xen-spicevmc-dns-srv-records-backports-314.patch
Normal file
1334
3002.2-xen-spicevmc-dns-srv-records-backports-314.patch
Normal file
File diff suppressed because it is too large
Load Diff
@ -1 +1 @@
|
||||
73673e4ab1d13c4393183b8ad6066dfab39c7e63
|
||||
98a9fb14263d76c4873bc68f208aeee04b583044
|
130
do-not-crash-when-unexpected-cmd-output-at-listing-p.patch
Normal file
130
do-not-crash-when-unexpected-cmd-output-at-listing-p.patch
Normal file
@ -0,0 +1,130 @@
|
||||
From cec95ba8f9b561d7ca4c66be9483e4b9386cb741 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
|
||||
<psuarezhernandez@suse.com>
|
||||
Date: Mon, 25 Jan 2021 12:15:59 +0000
|
||||
Subject: [PATCH] Do not crash when unexpected cmd output at listing
|
||||
patches (bsc#1181290)
|
||||
|
||||
Add unit tests to cover unexpected output when listing patches
|
||||
---
|
||||
salt/modules/yumpkg.py | 20 ++++++++--
|
||||
tests/unit/modules/test_yumpkg.py | 63 +++++++++++++++++++++++++++++++
|
||||
2 files changed, 80 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/salt/modules/yumpkg.py b/salt/modules/yumpkg.py
|
||||
index df174e737d..82adbbd59d 100644
|
||||
--- a/salt/modules/yumpkg.py
|
||||
+++ b/salt/modules/yumpkg.py
|
||||
@@ -3291,10 +3291,17 @@ def _get_patches(installed_only=False):
|
||||
|
||||
cmd = [_yum(), "--quiet", "updateinfo", "list", "all"]
|
||||
ret = __salt__["cmd.run_stdout"](cmd, python_shell=False, env={"SALT_RUNNING": "1"})
|
||||
+ parsing_errors = False
|
||||
+
|
||||
for line in salt.utils.itertools.split(ret, os.linesep):
|
||||
- inst, advisory_id, sev, pkg = re.match(
|
||||
- r"([i|\s]) ([^\s]+) +([^\s]+) +([^\s]+)", line
|
||||
- ).groups()
|
||||
+ try:
|
||||
+ inst, advisory_id, sev, pkg = re.match(
|
||||
+ r"([i|\s]) ([^\s]+) +([^\s]+) +([^\s]+)", line
|
||||
+ ).groups()
|
||||
+ except Exception: # pylint: disable=broad-except
|
||||
+ parsing_errors = True
|
||||
+ continue
|
||||
+
|
||||
if advisory_id not in patches:
|
||||
patches[advisory_id] = {
|
||||
"installed": True if inst == "i" else False,
|
||||
@@ -3305,6 +3312,13 @@ def _get_patches(installed_only=False):
|
||||
if inst != "i":
|
||||
patches[advisory_id]["installed"] = False
|
||||
|
||||
+ if parsing_errors:
|
||||
+ log.warning(
|
||||
+ "Skipped some unexpected output while running '{}' to list patches. Please check output".format(
|
||||
+ " ".join(cmd)
|
||||
+ )
|
||||
+ )
|
||||
+
|
||||
if installed_only:
|
||||
patches = {k: v for k, v in patches.items() if v["installed"]}
|
||||
return patches
|
||||
diff --git a/tests/unit/modules/test_yumpkg.py b/tests/unit/modules/test_yumpkg.py
|
||||
index b97e82d307..96d3f12b17 100644
|
||||
--- a/tests/unit/modules/test_yumpkg.py
|
||||
+++ b/tests/unit/modules/test_yumpkg.py
|
||||
@@ -383,6 +383,69 @@ class YumTestCase(TestCase, LoaderModuleMockMixin):
|
||||
_patch in patches["my-fake-patch-installed-1234"]["summary"]
|
||||
)
|
||||
|
||||
+ def test_list_patches_with_unexpected_output(self):
|
||||
+ """
|
||||
+ Test patches listin with unexpected output from updateinfo list
|
||||
+
|
||||
+ :return:
|
||||
+ """
|
||||
+ yum_out = [
|
||||
+ "Update notice RHBA-2014:0722 (from rhel7-dev-rhel7-rpm-x86_64) is broken, or a bad duplicate, skipping.",
|
||||
+ "You should report this problem to the owner of the rhel7-dev-rhel7-rpm-x86_64 repository.",
|
||||
+ 'To help pinpoint the issue, please attach the output of "yum updateinfo --verbose" to the report.',
|
||||
+ "Update notice RHSA-2014:1971 (from rhel7-dev-rhel7-rpm-x86_64) is broken, or a bad duplicate, skipping.",
|
||||
+ "Update notice RHSA-2015:1981 (from rhel7-dev-rhel7-rpm-x86_64) is broken, or a bad duplicate, skipping.",
|
||||
+ "Update notice RHSA-2015:0067 (from rhel7-dev-rhel7-rpm-x86_64) is broken, or a bad duplicate, skipping",
|
||||
+ "i my-fake-patch-not-installed-1234 recommended spacewalk-usix-2.7.5.2-2.2.noarch",
|
||||
+ " my-fake-patch-not-installed-1234 recommended spacewalksd-5.0.26.2-21.2.x86_64",
|
||||
+ "i my-fake-patch-not-installed-1234 recommended suseRegisterInfo-3.1.1-18.2.x86_64",
|
||||
+ "i my-fake-patch-installed-1234 recommended my-package-one-1.1-0.1.x86_64",
|
||||
+ "i my-fake-patch-installed-1234 recommended my-package-two-1.1-0.1.x86_64",
|
||||
+ ]
|
||||
+
|
||||
+ expected_patches = {
|
||||
+ "my-fake-patch-not-installed-1234": {
|
||||
+ "installed": False,
|
||||
+ "summary": [
|
||||
+ "spacewalk-usix-2.7.5.2-2.2.noarch",
|
||||
+ "spacewalksd-5.0.26.2-21.2.x86_64",
|
||||
+ "suseRegisterInfo-3.1.1-18.2.x86_64",
|
||||
+ ],
|
||||
+ },
|
||||
+ "my-fake-patch-installed-1234": {
|
||||
+ "installed": True,
|
||||
+ "summary": [
|
||||
+ "my-package-one-1.1-0.1.x86_64",
|
||||
+ "my-package-two-1.1-0.1.x86_64",
|
||||
+ ],
|
||||
+ },
|
||||
+ }
|
||||
+
|
||||
+ with patch.dict(yumpkg.__grains__, {"osarch": "x86_64"}), patch.dict(
|
||||
+ yumpkg.__salt__,
|
||||
+ {"cmd.run_stdout": MagicMock(return_value=os.linesep.join(yum_out))},
|
||||
+ ):
|
||||
+ patches = yumpkg.list_patches()
|
||||
+ self.assertFalse(patches["my-fake-patch-not-installed-1234"]["installed"])
|
||||
+ self.assertTrue(
|
||||
+ len(patches["my-fake-patch-not-installed-1234"]["summary"]) == 3
|
||||
+ )
|
||||
+ for _patch in expected_patches["my-fake-patch-not-installed-1234"][
|
||||
+ "summary"
|
||||
+ ]:
|
||||
+ self.assertTrue(
|
||||
+ _patch in patches["my-fake-patch-not-installed-1234"]["summary"]
|
||||
+ )
|
||||
+
|
||||
+ self.assertTrue(patches["my-fake-patch-installed-1234"]["installed"])
|
||||
+ self.assertTrue(
|
||||
+ len(patches["my-fake-patch-installed-1234"]["summary"]) == 2
|
||||
+ )
|
||||
+ for _patch in expected_patches["my-fake-patch-installed-1234"]["summary"]:
|
||||
+ self.assertTrue(
|
||||
+ _patch in patches["my-fake-patch-installed-1234"]["summary"]
|
||||
+ )
|
||||
+
|
||||
def test_latest_version_with_options(self):
|
||||
with patch.object(yumpkg, "list_pkgs", MagicMock(return_value={})):
|
||||
|
||||
--
|
||||
2.29.2
|
||||
|
||||
|
287
fix-onlyif-unless-when-multiple-conditions-bsc-11808.patch
Normal file
287
fix-onlyif-unless-when-multiple-conditions-bsc-11808.patch
Normal file
@ -0,0 +1,287 @@
|
||||
From 828ca76e2083d87ace12b488277e51d4e30c8c9a Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
|
||||
<psuarezhernandez@suse.com>
|
||||
Date: Thu, 21 Jan 2021 11:19:07 +0000
|
||||
Subject: [PATCH] Fix onlyif/unless when multiple conditions
|
||||
(bsc#1180818)
|
||||
|
||||
Add unit tests to ensure right onlyif/unless behavior
|
||||
|
||||
Add extra unit test to cover valid cases
|
||||
|
||||
Add unit tests cases to ensure proper onlyif/unless behavior
|
||||
|
||||
Change tests to use 'exit' cmd and work outside Linux
|
||||
---
|
||||
salt/state.py | 20 ++++--
|
||||
tests/unit/test_state.py | 148 ++++++++++++++++++++++++++++++++++++++-
|
||||
2 files changed, 163 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/salt/state.py b/salt/state.py
|
||||
index cc6db7e1b2..070a914636 100644
|
||||
--- a/salt/state.py
|
||||
+++ b/salt/state.py
|
||||
@@ -947,8 +947,10 @@ class State:
|
||||
"result": True,
|
||||
}
|
||||
)
|
||||
+ return False
|
||||
elif cmd == 0:
|
||||
ret.update({"comment": "onlyif condition is true", "result": False})
|
||||
+ return True
|
||||
|
||||
for entry in low_data_onlyif:
|
||||
if isinstance(entry, str):
|
||||
@@ -960,7 +962,8 @@ class State:
|
||||
# Command failed, notify onlyif to skip running the item
|
||||
cmd = 100
|
||||
log.debug("Last command return code: %s", cmd)
|
||||
- _check_cmd(cmd)
|
||||
+ if not _check_cmd(cmd):
|
||||
+ return ret
|
||||
elif isinstance(entry, dict):
|
||||
if "fun" not in entry:
|
||||
ret["comment"] = "no `fun` argument in onlyif: {}".format(entry)
|
||||
@@ -972,7 +975,8 @@ class State:
|
||||
if get_return:
|
||||
result = salt.utils.data.traverse_dict_and_list(result, get_return)
|
||||
if self.state_con.get("retcode", 0):
|
||||
- _check_cmd(self.state_con["retcode"])
|
||||
+ if not _check_cmd(self.state_con["retcode"]):
|
||||
+ return ret
|
||||
elif not result:
|
||||
ret.update(
|
||||
{
|
||||
@@ -981,6 +985,7 @@ class State:
|
||||
"result": True,
|
||||
}
|
||||
)
|
||||
+ return ret
|
||||
else:
|
||||
ret.update({"comment": "onlyif condition is true", "result": False})
|
||||
|
||||
@@ -991,6 +996,7 @@ class State:
|
||||
"result": False,
|
||||
}
|
||||
)
|
||||
+ return ret
|
||||
return ret
|
||||
|
||||
def _run_check_unless(self, low_data, cmd_opts):
|
||||
@@ -1013,8 +1019,10 @@ class State:
|
||||
"result": True,
|
||||
}
|
||||
)
|
||||
+ return False
|
||||
elif cmd != 0:
|
||||
ret.update({"comment": "unless condition is false", "result": False})
|
||||
+ return True
|
||||
|
||||
for entry in low_data_unless:
|
||||
if isinstance(entry, str):
|
||||
@@ -1026,7 +1034,8 @@ class State:
|
||||
except CommandExecutionError:
|
||||
# Command failed, so notify unless to skip the item
|
||||
cmd = 0
|
||||
- _check_cmd(cmd)
|
||||
+ if not _check_cmd(cmd):
|
||||
+ return ret
|
||||
elif isinstance(entry, dict):
|
||||
if "fun" not in entry:
|
||||
ret["comment"] = "no `fun` argument in unless: {}".format(entry)
|
||||
@@ -1038,7 +1047,8 @@ class State:
|
||||
if get_return:
|
||||
result = salt.utils.data.traverse_dict_and_list(result, get_return)
|
||||
if self.state_con.get("retcode", 0):
|
||||
- _check_cmd(self.state_con["retcode"])
|
||||
+ if not _check_cmd(self.state_con["retcode"]):
|
||||
+ return ret
|
||||
elif result:
|
||||
ret.update(
|
||||
{
|
||||
@@ -1047,6 +1057,7 @@ class State:
|
||||
"result": True,
|
||||
}
|
||||
)
|
||||
+ return ret
|
||||
else:
|
||||
ret.update(
|
||||
{"comment": "unless condition is false", "result": False}
|
||||
@@ -1058,6 +1069,7 @@ class State:
|
||||
"result": False,
|
||||
}
|
||||
)
|
||||
+ return ret
|
||||
|
||||
# No reason to stop, return ret
|
||||
return ret
|
||||
diff --git a/tests/unit/test_state.py b/tests/unit/test_state.py
|
||||
index b1bcf8fe83..95018a9cf3 100644
|
||||
--- a/tests/unit/test_state.py
|
||||
+++ b/tests/unit/test_state.py
|
||||
@@ -205,6 +205,152 @@ class StateCompilerTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
|
||||
)
|
||||
self.assertEqual(expected_result, return_result)
|
||||
|
||||
+ def test_verify_unless_list_cmd(self):
|
||||
+ low_data = {
|
||||
+ "state": "cmd",
|
||||
+ "name": 'echo "something"',
|
||||
+ "__sls__": "tests.cmd",
|
||||
+ "__env__": "base",
|
||||
+ "__id__": "check unless",
|
||||
+ "unless": ["exit 0", "exit 1"],
|
||||
+ "order": 10001,
|
||||
+ "fun": "run",
|
||||
+ }
|
||||
+ expected_result = {
|
||||
+ "comment": "unless condition is true",
|
||||
+ "result": True,
|
||||
+ "skip_watch": True,
|
||||
+ }
|
||||
+ with patch("salt.state.State._gather_pillar") as state_patch:
|
||||
+ minion_opts = self.get_temp_config("minion")
|
||||
+ state_obj = salt.state.State(minion_opts)
|
||||
+ return_result = state_obj._run_check_unless(low_data, {})
|
||||
+ self.assertEqual(expected_result, return_result)
|
||||
+
|
||||
+ def test_verify_unless_list_cmd_different_order(self):
|
||||
+ low_data = {
|
||||
+ "state": "cmd",
|
||||
+ "name": 'echo "something"',
|
||||
+ "__sls__": "tests.cmd",
|
||||
+ "__env__": "base",
|
||||
+ "__id__": "check unless",
|
||||
+ "unless": ["exit 1", "exit 0"],
|
||||
+ "order": 10001,
|
||||
+ "fun": "run",
|
||||
+ }
|
||||
+ expected_result = {
|
||||
+ "comment": "unless condition is true",
|
||||
+ "result": True,
|
||||
+ "skip_watch": True,
|
||||
+ }
|
||||
+ with patch("salt.state.State._gather_pillar") as state_patch:
|
||||
+ minion_opts = self.get_temp_config("minion")
|
||||
+ state_obj = salt.state.State(minion_opts)
|
||||
+ return_result = state_obj._run_check_unless(low_data, {})
|
||||
+ self.assertEqual(expected_result, return_result)
|
||||
+
|
||||
+ def test_verify_onlyif_list_cmd_different_order(self):
|
||||
+ low_data = {
|
||||
+ "state": "cmd",
|
||||
+ "name": 'echo "something"',
|
||||
+ "__sls__": "tests.cmd",
|
||||
+ "__env__": "base",
|
||||
+ "__id__": "check onlyif",
|
||||
+ "onlyif": ["exit 1", "exit 0"],
|
||||
+ "order": 10001,
|
||||
+ "fun": "run",
|
||||
+ }
|
||||
+ expected_result = {
|
||||
+ "comment": "onlyif condition is false",
|
||||
+ "result": True,
|
||||
+ "skip_watch": True,
|
||||
+ }
|
||||
+ with patch("salt.state.State._gather_pillar") as state_patch:
|
||||
+ minion_opts = self.get_temp_config("minion")
|
||||
+ state_obj = salt.state.State(minion_opts)
|
||||
+ return_result = state_obj._run_check_onlyif(low_data, {})
|
||||
+ self.assertEqual(expected_result, return_result)
|
||||
+
|
||||
+ def test_verify_unless_list_cmd_valid(self):
|
||||
+ low_data = {
|
||||
+ "state": "cmd",
|
||||
+ "name": 'echo "something"',
|
||||
+ "__sls__": "tests.cmd",
|
||||
+ "__env__": "base",
|
||||
+ "__id__": "check unless",
|
||||
+ "unless": ["exit 1", "exit 1"],
|
||||
+ "order": 10001,
|
||||
+ "fun": "run",
|
||||
+ }
|
||||
+ expected_result = {"comment": "unless condition is false", "result": False}
|
||||
+ with patch("salt.state.State._gather_pillar") as state_patch:
|
||||
+ minion_opts = self.get_temp_config("minion")
|
||||
+ state_obj = salt.state.State(minion_opts)
|
||||
+ return_result = state_obj._run_check_unless(low_data, {})
|
||||
+ self.assertEqual(expected_result, return_result)
|
||||
+
|
||||
+ def test_verify_onlyif_list_cmd_valid(self):
|
||||
+ low_data = {
|
||||
+ "state": "cmd",
|
||||
+ "name": 'echo "something"',
|
||||
+ "__sls__": "tests.cmd",
|
||||
+ "__env__": "base",
|
||||
+ "__id__": "check onlyif",
|
||||
+ "onlyif": ["exit 0", "exit 0"],
|
||||
+ "order": 10001,
|
||||
+ "fun": "run",
|
||||
+ }
|
||||
+ expected_result = {"comment": "onlyif condition is true", "result": False}
|
||||
+ with patch("salt.state.State._gather_pillar") as state_patch:
|
||||
+ minion_opts = self.get_temp_config("minion")
|
||||
+ state_obj = salt.state.State(minion_opts)
|
||||
+ return_result = state_obj._run_check_onlyif(low_data, {})
|
||||
+ self.assertEqual(expected_result, return_result)
|
||||
+
|
||||
+ def test_verify_unless_list_cmd_invalid(self):
|
||||
+ low_data = {
|
||||
+ "state": "cmd",
|
||||
+ "name": 'echo "something"',
|
||||
+ "__sls__": "tests.cmd",
|
||||
+ "__env__": "base",
|
||||
+ "__id__": "check unless",
|
||||
+ "unless": ["exit 0", "exit 0"],
|
||||
+ "order": 10001,
|
||||
+ "fun": "run",
|
||||
+ }
|
||||
+ expected_result = {
|
||||
+ "comment": "unless condition is true",
|
||||
+ "result": True,
|
||||
+ "skip_watch": True,
|
||||
+ }
|
||||
+ with patch("salt.state.State._gather_pillar") as state_patch:
|
||||
+ minion_opts = self.get_temp_config("minion")
|
||||
+ state_obj = salt.state.State(minion_opts)
|
||||
+ return_result = state_obj._run_check_unless(low_data, {})
|
||||
+ self.assertEqual(expected_result, return_result)
|
||||
+
|
||||
+ def test_verify_onlyif_list_cmd_invalid(self):
|
||||
+ low_data = {
|
||||
+ "state": "cmd",
|
||||
+ "name": 'echo "something"',
|
||||
+ "__sls__": "tests.cmd",
|
||||
+ "__env__": "base",
|
||||
+ "__id__": "check onlyif",
|
||||
+ "onlyif": ["exit 1", "exit 1"],
|
||||
+ "order": 10001,
|
||||
+ "fun": "run",
|
||||
+ }
|
||||
+ expected_result = {
|
||||
+ "comment": "onlyif condition is false",
|
||||
+ "result": True,
|
||||
+ "skip_watch": True,
|
||||
+ }
|
||||
+ with patch("salt.state.State._gather_pillar") as state_patch:
|
||||
+ minion_opts = self.get_temp_config("minion")
|
||||
+ state_obj = salt.state.State(minion_opts)
|
||||
+ return_result = state_obj._run_check_onlyif(low_data, {})
|
||||
+ self.assertEqual(expected_result, return_result)
|
||||
+
|
||||
def test_verify_unless_parse(self):
|
||||
low_data = {
|
||||
"unless": [{"fun": "test.arg", "args": ["arg1", "arg2"]}],
|
||||
@@ -376,7 +522,7 @@ class StateCompilerTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
|
||||
"__sls__": "tests.cmd",
|
||||
"__env__": "base",
|
||||
"__id__": "check onlyif",
|
||||
- "onlyif": ["/bin/true", "/bin/false"],
|
||||
+ "onlyif": ["exit 0", "exit 1"],
|
||||
"order": 10001,
|
||||
"fun": "run",
|
||||
}
|
||||
--
|
||||
2.29.2
|
||||
|
||||
|
211
open-suse-3002.2-xen-grub-316.patch
Normal file
211
open-suse-3002.2-xen-grub-316.patch
Normal file
@ -0,0 +1,211 @@
|
||||
From 6573d8ca0087f5ce6a8639c0ff583b3248f0704e Mon Sep 17 00:00:00 2001
|
||||
From: Cedric Bosdonnat <cbosdonnat@suse.com>
|
||||
Date: Thu, 11 Feb 2021 16:41:14 +0100
|
||||
Subject: [PATCH] Open suse 3002.2 xen grub (#316)
|
||||
|
||||
* virt: convert xen pv XML generation test to pytest
|
||||
|
||||
* virt: better look for grub.xen when generating xen pv definition
|
||||
|
||||
openSUSE 15.3 and SLES 15 SP3 have removed the compatibility symlink for
|
||||
/usr/share/grub2/x86_64-xen/grub.xen to
|
||||
/usr/lib/grub2/x86_64-xen/grub.xen. virt._gen_xml() need to check which
|
||||
is present and put in Xen PV VMs XML definition.
|
||||
---
|
||||
changelog/59484.fixed | 1 +
|
||||
salt/modules/virt.py | 9 +-
|
||||
.../pytests/unit/modules/virt/test_domain.py | 82 ++++++++++++++++++-
|
||||
tests/unit/modules/test_virt.py | 48 -----------
|
||||
4 files changed, 90 insertions(+), 50 deletions(-)
|
||||
create mode 100644 changelog/59484.fixed
|
||||
|
||||
diff --git a/changelog/59484.fixed b/changelog/59484.fixed
|
||||
new file mode 100644
|
||||
index 0000000000..b685510ad9
|
||||
--- /dev/null
|
||||
+++ b/changelog/59484.fixed
|
||||
@@ -0,0 +1 @@
|
||||
+Detect and fix grub.xen path
|
||||
diff --git a/salt/modules/virt.py b/salt/modules/virt.py
|
||||
index da132630dd..35711fcef4 100644
|
||||
--- a/salt/modules/virt.py
|
||||
+++ b/salt/modules/virt.py
|
||||
@@ -889,7 +889,14 @@ def _gen_xml(
|
||||
# Compute the Xen PV boot method
|
||||
if __grains__["os_family"] == "Suse":
|
||||
if not boot or not boot.get("kernel", None):
|
||||
- context["boot"]["kernel"] = "/usr/lib/grub2/x86_64-xen/grub.xen"
|
||||
+ paths = [
|
||||
+ path
|
||||
+ for path in ["/usr/share", "/usr/lib"]
|
||||
+ if os.path.exists(path + "/grub2/x86_64-xen/grub.xen")
|
||||
+ ]
|
||||
+ if not paths:
|
||||
+ raise CommandExecutionError("grub-x86_64-xen needs to be installed")
|
||||
+ context["boot"]["kernel"] = paths[0] + "/grub2/x86_64-xen/grub.xen"
|
||||
context["boot_dev"] = []
|
||||
|
||||
default_port = 23023
|
||||
diff --git a/tests/pytests/unit/modules/virt/test_domain.py b/tests/pytests/unit/modules/virt/test_domain.py
|
||||
index 72fa599a6c..76433eaef4 100644
|
||||
--- a/tests/pytests/unit/modules/virt/test_domain.py
|
||||
+++ b/tests/pytests/unit/modules/virt/test_domain.py
|
||||
@@ -5,7 +5,7 @@ import salt.modules.virt as virt
|
||||
import salt.utils.xmlutil as xmlutil
|
||||
import salt.syspaths
|
||||
from salt._compat import ElementTree as ET
|
||||
-from salt.exceptions import SaltInvocationError
|
||||
+from salt.exceptions import CommandExecutionError, SaltInvocationError
|
||||
from tests.support.mock import MagicMock, patch
|
||||
|
||||
from .conftest import loader_modules_config
|
||||
@@ -17,6 +17,86 @@ def configure_loader_modules():
|
||||
return loader_modules_config()
|
||||
|
||||
|
||||
+@pytest.mark.parametrize(
|
||||
+ "loader",
|
||||
+ [
|
||||
+ "/usr/lib/grub2/x86_64-xen/grub.xen",
|
||||
+ "/usr/share/grub2/x86_64-xen/grub.xen",
|
||||
+ None,
|
||||
+ ],
|
||||
+)
|
||||
+def test_gen_xml_for_xen_default_profile(loader):
|
||||
+ """
|
||||
+ Test virt._gen_xml(), XEN PV default profile case
|
||||
+ """
|
||||
+ diskp = virt._disk_profile(
|
||||
+ virt.libvirt.openAuth.return_value, "default", "xen", [], "hello"
|
||||
+ )
|
||||
+ nicp = virt._nic_profile("default", "xen")
|
||||
+ with patch.dict(
|
||||
+ virt.__grains__, {"os_family": "Suse"} # pylint: disable=no-member
|
||||
+ ):
|
||||
+ os_mock = MagicMock(spec=virt.os)
|
||||
+
|
||||
+ def fake_exists(path):
|
||||
+ return loader and path == loader
|
||||
+
|
||||
+ os_mock.path.exists = MagicMock(side_effect=fake_exists)
|
||||
+
|
||||
+ with patch.dict(virt.__dict__, {"os": os_mock}):
|
||||
+ if loader:
|
||||
+ xml_data = virt._gen_xml(
|
||||
+ virt.libvirt.openAuth.return_value,
|
||||
+ "hello",
|
||||
+ 1,
|
||||
+ 512,
|
||||
+ diskp,
|
||||
+ nicp,
|
||||
+ "xen",
|
||||
+ "xen",
|
||||
+ "x86_64",
|
||||
+ boot=None,
|
||||
+ )
|
||||
+ root = ET.fromstring(xml_data)
|
||||
+ assert root.attrib["type"] == "xen"
|
||||
+ assert root.find("vcpu").text == "1"
|
||||
+ assert root.find("memory").text == str(512 * 1024)
|
||||
+ assert root.find("memory").attrib["unit"] == "KiB"
|
||||
+ assert root.find(".//kernel").text == loader
|
||||
+
|
||||
+ disks = root.findall(".//disk")
|
||||
+ assert len(disks) == 1
|
||||
+ disk = disks[0]
|
||||
+ root_dir = salt.config.DEFAULT_MINION_OPTS.get("root_dir")
|
||||
+ assert disk.find("source").attrib["file"].startswith(root_dir)
|
||||
+ assert "hello_system" in disk.find("source").attrib["file"]
|
||||
+ assert disk.find("target").attrib["dev"] == "xvda"
|
||||
+ assert disk.find("target").attrib["bus"] == "xen"
|
||||
+ assert disk.find("driver").attrib["name"] == "qemu"
|
||||
+ assert disk.find("driver").attrib["type"] == "qcow2"
|
||||
+
|
||||
+ interfaces = root.findall(".//interface")
|
||||
+ assert len(interfaces) == 1
|
||||
+ iface = interfaces[0]
|
||||
+ assert iface.attrib["type"] == "bridge"
|
||||
+ assert iface.find("source").attrib["bridge"] == "br0"
|
||||
+ assert iface.find("model") is None
|
||||
+ else:
|
||||
+ with pytest.raises(CommandExecutionError):
|
||||
+ xml_data = virt._gen_xml(
|
||||
+ virt.libvirt.openAuth.return_value,
|
||||
+ "hello",
|
||||
+ 1,
|
||||
+ 512,
|
||||
+ diskp,
|
||||
+ nicp,
|
||||
+ "xen",
|
||||
+ "xen",
|
||||
+ "x86_64",
|
||||
+ boot=None,
|
||||
+ )
|
||||
+
|
||||
+
|
||||
def test_update_xen_disk_volumes(make_mock_vm, make_mock_storage_pool):
|
||||
xml_def = """
|
||||
<domain type='xen'>
|
||||
diff --git a/tests/unit/modules/test_virt.py b/tests/unit/modules/test_virt.py
|
||||
index a739efdbf6..5c7e1e1cc4 100644
|
||||
--- a/tests/unit/modules/test_virt.py
|
||||
+++ b/tests/unit/modules/test_virt.py
|
||||
@@ -1126,54 +1126,6 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
|
||||
self.assertEqual(iface.find("source").attrib["bridge"], "DEFAULT")
|
||||
self.assertEqual(iface.find("model").attrib["type"], "e1000")
|
||||
|
||||
- def test_gen_xml_for_xen_default_profile(self):
|
||||
- """
|
||||
- Test virt._gen_xml(), XEN PV default profile case
|
||||
- """
|
||||
- diskp = virt._disk_profile(self.mock_conn, "default", "xen", [], "hello")
|
||||
- nicp = virt._nic_profile("default", "xen")
|
||||
- with patch.dict(
|
||||
- virt.__grains__, {"os_family": "Suse"} # pylint: disable=no-member
|
||||
- ):
|
||||
- xml_data = virt._gen_xml(
|
||||
- self.mock_conn,
|
||||
- "hello",
|
||||
- 1,
|
||||
- 512,
|
||||
- diskp,
|
||||
- nicp,
|
||||
- "xen",
|
||||
- "xen",
|
||||
- "x86_64",
|
||||
- boot=None,
|
||||
- )
|
||||
- root = ET.fromstring(xml_data)
|
||||
- self.assertEqual(root.attrib["type"], "xen")
|
||||
- self.assertEqual(root.find("vcpu").text, "1")
|
||||
- self.assertEqual(root.find("memory").text, str(512 * 1024))
|
||||
- self.assertEqual(root.find("memory").attrib["unit"], "KiB")
|
||||
- self.assertEqual(
|
||||
- root.find(".//kernel").text, "/usr/lib/grub2/x86_64-xen/grub.xen"
|
||||
- )
|
||||
-
|
||||
- disks = root.findall(".//disk")
|
||||
- self.assertEqual(len(disks), 1)
|
||||
- disk = disks[0]
|
||||
- root_dir = salt.config.DEFAULT_MINION_OPTS.get("root_dir")
|
||||
- self.assertTrue(disk.find("source").attrib["file"].startswith(root_dir))
|
||||
- self.assertTrue("hello_system" in disk.find("source").attrib["file"])
|
||||
- self.assertEqual(disk.find("target").attrib["dev"], "xvda")
|
||||
- self.assertEqual(disk.find("target").attrib["bus"], "xen")
|
||||
- self.assertEqual(disk.find("driver").attrib["name"], "qemu")
|
||||
- self.assertEqual(disk.find("driver").attrib["type"], "qcow2")
|
||||
-
|
||||
- interfaces = root.findall(".//interface")
|
||||
- self.assertEqual(len(interfaces), 1)
|
||||
- iface = interfaces[0]
|
||||
- self.assertEqual(iface.attrib["type"], "bridge")
|
||||
- self.assertEqual(iface.find("source").attrib["bridge"], "br0")
|
||||
- self.assertIsNone(iface.find("model"))
|
||||
-
|
||||
def test_gen_xml_for_esxi_custom_profile(self):
|
||||
"""
|
||||
Test virt._gen_xml(), ESXi/vmware custom profile case
|
||||
--
|
||||
2.30.0
|
||||
|
||||
|
30
salt.changes
30
salt.changes
@ -1,3 +1,33 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Feb 11 16:02:59 UTC 2021 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
|
||||
|
||||
- virt: search for grub.xen path
|
||||
- Xen spicevmc, DNS SRV records backports:
|
||||
Fix virtual network generated DNS XML for SRV records
|
||||
Don't add spicevmc channel to xen VMs
|
||||
- virt UEFI fix: virt.update when efi=True
|
||||
|
||||
- Added:
|
||||
* virt-uefi-fix-backport-312.patch
|
||||
* 3002.2-xen-spicevmc-dns-srv-records-backports-314.patch
|
||||
* open-suse-3002.2-xen-grub-316.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Jan 25 13:52:50 UTC 2021 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
|
||||
|
||||
- Do not crash when unexpected cmd output at listing patches (bsc#1181290)
|
||||
|
||||
- Added:
|
||||
* do-not-crash-when-unexpected-cmd-output-at-listing-p.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Jan 22 16:28:51 UTC 2021 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
|
||||
|
||||
- Fix behavior for "onlyif/unless" when multiple conditions (bsc#1180818)
|
||||
|
||||
- Added:
|
||||
* fix-onlyif-unless-when-multiple-conditions-bsc-11808.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Jan 13 13:49:34 UTC 2021 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
|
||||
|
||||
|
16
salt.spec
16
salt.spec
@ -348,6 +348,17 @@ Patch143: force-zyppnotify-to-prefer-packages.db-than-packages.patch
|
||||
Patch144: revert-add-patch-support-for-allow-vendor-change-opt.patch
|
||||
# PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/commit/73e357d7eee19a73cade22becb30d9689cae27ba
|
||||
Patch145: remove-deprecated-warning-that-breaks-miniion-execut.patch
|
||||
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/59345
|
||||
Patch146: fix-onlyif-unless-when-multiple-conditions-bsc-11808.patch
|
||||
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/59354
|
||||
Patch147: do-not-crash-when-unexpected-cmd-output-at-listing-p.patch
|
||||
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/59189
|
||||
Patch148: virt-uefi-fix-backport-312.patch
|
||||
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/59355
|
||||
# https://github.com/saltstack/salt/pull/59417
|
||||
Patch149: 3002.2-xen-spicevmc-dns-srv-records-backports-314.patch
|
||||
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/59485
|
||||
Patch150: open-suse-3002.2-xen-grub-316.patch
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
BuildRequires: logrotate
|
||||
@ -892,6 +903,11 @@ cp %{S:5} ./.travis.yml
|
||||
%patch143 -p1
|
||||
%patch144 -p1
|
||||
%patch145 -p1
|
||||
%patch146 -p1
|
||||
%patch147 -p1
|
||||
%patch148 -p1
|
||||
%patch149 -p1
|
||||
%patch150 -p1
|
||||
|
||||
%build
|
||||
# Putting /usr/bin at the front of $PATH is needed for RHEL/RES 7. Without this
|
||||
|
2449
virt-uefi-fix-backport-312.patch
Normal file
2449
virt-uefi-fix-backport-312.patch
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user