salt/feat-add-grain-for-all-fqdns.patch

89 lines
2.7 KiB
Diff
Raw Normal View History

Accepting request 626472 from home:mdinca:branches:systemsmanagement:saltstack - Update to 2018.3.2 See https://docs.saltstack.com/en/latest/topics/releases/2018.3.2.html for full changelog - Added: * accounting-for-when-files-in-an-archive-contain-non-.patch * add-all_versions-parameter-to-include-all-installed-.patch * add-custom-suse-capabilities-as-grains.patch * add-engine-relaying-libvirt-events.patch * add-environment-variable-to-know-if-yum-is-invoked-f.patch * add-other-attribute-to-gecos-fields-to-avoid-inconsi.patch * align-suse-salt-master.service-limitnofiles-limit-wi.patch * avoid-incomprehensive-message-if-crashes.patch * fix-deprecation-warning-bsc-1095507.patch * fix-diffing-binary-files-in-file.get_diff-bsc-109839.patch * fix-unboundlocalerror-in-file.get_diff.patch * fix-zypper.list_pkgs-to-be-aligned-with-pkg-state.patch * prevent-zypper-from-parsing-repo-configuration-from-.patch * remove-old-hack-when-reporting-multiversion-packages.patch * show-recommendations-for-salt-ssh-cross-version-pyth.patch - Modified: * activate-all-beacons-sources-config-pillar-grains.patch * add-saltssh-multi-version-support-across-python-inte.patch * avoid-excessive-syslogging-by-watchdog-cronjob-58.patch * do-not-override-jid-on-returners-only-sending-back-t.patch * enable-passing-a-unix_socket-for-mysql-returners-bsc.patch * fall-back-to-pymysql.patch * feat-add-grain-for-all-fqdns.patch * fix-bsc-1065792.patch * fix-decrease-loglevel-when-unable-to-resolve-addr.patch * fix-for-ec2-rate-limit-failures.patch OBS-URL: https://build.opensuse.org/request/show/626472 OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=127
2018-07-30 13:52:13 +02:00
From 6e5f0fbbe3c232c7d5212d4fddfe52b5a5a71597 Mon Sep 17 00:00:00 2001
From: Michele Bologna <michele.bologna@suse.com>
Date: Thu, 14 Dec 2017 18:20:02 +0100
Subject: [PATCH] Feat: add grain for all FQDNs
This PR adds a grain named fqdns to the grains.
fqdns represents all the FQDNs known for the system on all available interfaces (excluding lo).
Note: hostname != FQDN
hostname is the UNIX name of the machine. A machine can have one and only one hostname.
FQDN is host.domain that resolves to an IP address that the machines is answering to.
A machine can have 1+ FQDNs.
Upstream PR:
https://github.com/saltstack/salt/pull/45060
---
salt/grains/core.py | 27 +++++++++++++++++++++++++++
tests/integration/modules/test_grains.py | 1 +
Accepting request 581002 from systemsmanagement:saltstack:testing - Remove salt-minion python2 requirement when python3 is default (bsc#1081592) - Remove-obsolete-unicode-handling-in-pkg.info_installed - Added: * remove-obsolete-unicode-handling-in-pkg.info_install.patch - Update to salt-2018.1.99 - Modified: * activate-all-beacons-sources-config-pillar-grains.patch * avoid-excessive-syslogging-by-watchdog-cronjob-58.patch * feat-add-grain-for-all-fqdns.patch * fix-bsc-1065792.patch * list_pkgs-add-parameter-for-returned-attribute-selec.patch * run-salt-api-as-user-salt-bsc-1064520.patch * run-salt-master-as-dedicated-salt-user.patch - Deleted: * python3-compatibility-fix-got-bytes-instead-of-strin.patch * enable-with-salt-version-parameter-for-setup.py-scri.patch * catching-error-when-pidfile-cannot-be-deleted.patch * bugfix-always-return-a-string-list-on-unknown-job-ta.patch * bugfix-the-logic-according-to-the-exact-described-pu.patch * cherrypy-read-reads-bytes-from-the-wire-and-write-th.patch * fix-for-delete_deployment-in-kubernetes-module.patch * fix-salt-master-for-old-psutil.patch * introduce-process_count_max-minion-configuration-par.patch * multiprocessing-minion-option-documentation-fixes.patch * older-logrotate-need-su-directive.patch * return-error-when-gid_from_name-and-group-does-not-e.patch * set-shell-environment-variable-64.patch * split-only-strings-if-they-are-such.patch OBS-URL: https://build.opensuse.org/request/show/581002 OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=112
2018-02-28 16:27:22 +01:00
tests/unit/grains/test_core.py | 1 +
3 files changed, 29 insertions(+)
diff --git a/salt/grains/core.py b/salt/grains/core.py
Accepting request 626472 from home:mdinca:branches:systemsmanagement:saltstack - Update to 2018.3.2 See https://docs.saltstack.com/en/latest/topics/releases/2018.3.2.html for full changelog - Added: * accounting-for-when-files-in-an-archive-contain-non-.patch * add-all_versions-parameter-to-include-all-installed-.patch * add-custom-suse-capabilities-as-grains.patch * add-engine-relaying-libvirt-events.patch * add-environment-variable-to-know-if-yum-is-invoked-f.patch * add-other-attribute-to-gecos-fields-to-avoid-inconsi.patch * align-suse-salt-master.service-limitnofiles-limit-wi.patch * avoid-incomprehensive-message-if-crashes.patch * fix-deprecation-warning-bsc-1095507.patch * fix-diffing-binary-files-in-file.get_diff-bsc-109839.patch * fix-unboundlocalerror-in-file.get_diff.patch * fix-zypper.list_pkgs-to-be-aligned-with-pkg-state.patch * prevent-zypper-from-parsing-repo-configuration-from-.patch * remove-old-hack-when-reporting-multiversion-packages.patch * show-recommendations-for-salt-ssh-cross-version-pyth.patch - Modified: * activate-all-beacons-sources-config-pillar-grains.patch * add-saltssh-multi-version-support-across-python-inte.patch * avoid-excessive-syslogging-by-watchdog-cronjob-58.patch * do-not-override-jid-on-returners-only-sending-back-t.patch * enable-passing-a-unix_socket-for-mysql-returners-bsc.patch * fall-back-to-pymysql.patch * feat-add-grain-for-all-fqdns.patch * fix-bsc-1065792.patch * fix-decrease-loglevel-when-unable-to-resolve-addr.patch * fix-for-ec2-rate-limit-failures.patch OBS-URL: https://build.opensuse.org/request/show/626472 OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=127
2018-07-30 13:52:13 +02:00
index 8545d4368c..24de3cff6b 100644
--- a/salt/grains/core.py
+++ b/salt/grains/core.py
Accepting request 626472 from home:mdinca:branches:systemsmanagement:saltstack - Update to 2018.3.2 See https://docs.saltstack.com/en/latest/topics/releases/2018.3.2.html for full changelog - Added: * accounting-for-when-files-in-an-archive-contain-non-.patch * add-all_versions-parameter-to-include-all-installed-.patch * add-custom-suse-capabilities-as-grains.patch * add-engine-relaying-libvirt-events.patch * add-environment-variable-to-know-if-yum-is-invoked-f.patch * add-other-attribute-to-gecos-fields-to-avoid-inconsi.patch * align-suse-salt-master.service-limitnofiles-limit-wi.patch * avoid-incomprehensive-message-if-crashes.patch * fix-deprecation-warning-bsc-1095507.patch * fix-diffing-binary-files-in-file.get_diff-bsc-109839.patch * fix-unboundlocalerror-in-file.get_diff.patch * fix-zypper.list_pkgs-to-be-aligned-with-pkg-state.patch * prevent-zypper-from-parsing-repo-configuration-from-.patch * remove-old-hack-when-reporting-multiversion-packages.patch * show-recommendations-for-salt-ssh-cross-version-pyth.patch - Modified: * activate-all-beacons-sources-config-pillar-grains.patch * add-saltssh-multi-version-support-across-python-inte.patch * avoid-excessive-syslogging-by-watchdog-cronjob-58.patch * do-not-override-jid-on-returners-only-sending-back-t.patch * enable-passing-a-unix_socket-for-mysql-returners-bsc.patch * fall-back-to-pymysql.patch * feat-add-grain-for-all-fqdns.patch * fix-bsc-1065792.patch * fix-decrease-loglevel-when-unable-to-resolve-addr.patch * fix-for-ec2-rate-limit-failures.patch OBS-URL: https://build.opensuse.org/request/show/626472 OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=127
2018-07-30 13:52:13 +02:00
@@ -1886,6 +1886,33 @@ def append_domain():
return grain
+def fqdns():
+ '''
+ Return all known FQDNs for the system by enumerating all interfaces and
+ then trying to reverse resolve them (excluding 'lo' interface).
+ '''
+ # Provides:
+ # fqdns
+
+ grains = {}
+ fqdns = set()
+
+ addresses = salt.utils.network.ip_addrs(include_loopback=False,
+ interface_data=_INTERFACES)
+ addresses.extend(salt.utils.network.ip_addrs6(include_loopback=False,
+ interface_data=_INTERFACES))
+
+ for ip in addresses:
+ try:
+ fqdns.add(socket.gethostbyaddr(ip)[0])
+ except (socket.error, socket.herror,
+ socket.gaierror, socket.timeout) as e:
+ log.error("Exception during resolving address: " + str(e))
+
+ grains['fqdns'] = list(fqdns)
+ return grains
+
+
def ip_fqdn():
'''
Return ip address and FQDN grains
diff --git a/tests/integration/modules/test_grains.py b/tests/integration/modules/test_grains.py
Accepting request 626472 from home:mdinca:branches:systemsmanagement:saltstack - Update to 2018.3.2 See https://docs.saltstack.com/en/latest/topics/releases/2018.3.2.html for full changelog - Added: * accounting-for-when-files-in-an-archive-contain-non-.patch * add-all_versions-parameter-to-include-all-installed-.patch * add-custom-suse-capabilities-as-grains.patch * add-engine-relaying-libvirt-events.patch * add-environment-variable-to-know-if-yum-is-invoked-f.patch * add-other-attribute-to-gecos-fields-to-avoid-inconsi.patch * align-suse-salt-master.service-limitnofiles-limit-wi.patch * avoid-incomprehensive-message-if-crashes.patch * fix-deprecation-warning-bsc-1095507.patch * fix-diffing-binary-files-in-file.get_diff-bsc-109839.patch * fix-unboundlocalerror-in-file.get_diff.patch * fix-zypper.list_pkgs-to-be-aligned-with-pkg-state.patch * prevent-zypper-from-parsing-repo-configuration-from-.patch * remove-old-hack-when-reporting-multiversion-packages.patch * show-recommendations-for-salt-ssh-cross-version-pyth.patch - Modified: * activate-all-beacons-sources-config-pillar-grains.patch * add-saltssh-multi-version-support-across-python-inte.patch * avoid-excessive-syslogging-by-watchdog-cronjob-58.patch * do-not-override-jid-on-returners-only-sending-back-t.patch * enable-passing-a-unix_socket-for-mysql-returners-bsc.patch * fall-back-to-pymysql.patch * feat-add-grain-for-all-fqdns.patch * fix-bsc-1065792.patch * fix-decrease-loglevel-when-unable-to-resolve-addr.patch * fix-for-ec2-rate-limit-failures.patch OBS-URL: https://build.opensuse.org/request/show/626472 OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=127
2018-07-30 13:52:13 +02:00
index 616e07d455..dfa70afa03 100644
--- a/tests/integration/modules/test_grains.py
+++ b/tests/integration/modules/test_grains.py
@@ -51,6 +51,7 @@ class TestModulesGrains(ModuleCase):
'cpuarch',
'domain',
'fqdn',
+ 'fqdns',
'gid',
'groupname',
'host',
diff --git a/tests/unit/grains/test_core.py b/tests/unit/grains/test_core.py
Accepting request 626472 from home:mdinca:branches:systemsmanagement:saltstack - Update to 2018.3.2 See https://docs.saltstack.com/en/latest/topics/releases/2018.3.2.html for full changelog - Added: * accounting-for-when-files-in-an-archive-contain-non-.patch * add-all_versions-parameter-to-include-all-installed-.patch * add-custom-suse-capabilities-as-grains.patch * add-engine-relaying-libvirt-events.patch * add-environment-variable-to-know-if-yum-is-invoked-f.patch * add-other-attribute-to-gecos-fields-to-avoid-inconsi.patch * align-suse-salt-master.service-limitnofiles-limit-wi.patch * avoid-incomprehensive-message-if-crashes.patch * fix-deprecation-warning-bsc-1095507.patch * fix-diffing-binary-files-in-file.get_diff-bsc-109839.patch * fix-unboundlocalerror-in-file.get_diff.patch * fix-zypper.list_pkgs-to-be-aligned-with-pkg-state.patch * prevent-zypper-from-parsing-repo-configuration-from-.patch * remove-old-hack-when-reporting-multiversion-packages.patch * show-recommendations-for-salt-ssh-cross-version-pyth.patch - Modified: * activate-all-beacons-sources-config-pillar-grains.patch * add-saltssh-multi-version-support-across-python-inte.patch * avoid-excessive-syslogging-by-watchdog-cronjob-58.patch * do-not-override-jid-on-returners-only-sending-back-t.patch * enable-passing-a-unix_socket-for-mysql-returners-bsc.patch * fall-back-to-pymysql.patch * feat-add-grain-for-all-fqdns.patch * fix-bsc-1065792.patch * fix-decrease-loglevel-when-unable-to-resolve-addr.patch * fix-for-ec2-rate-limit-failures.patch OBS-URL: https://build.opensuse.org/request/show/626472 OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=127
2018-07-30 13:52:13 +02:00
index 54c8293dcf..616c62e658 100644
--- a/tests/unit/grains/test_core.py
+++ b/tests/unit/grains/test_core.py
Accepting request 581002 from systemsmanagement:saltstack:testing - Remove salt-minion python2 requirement when python3 is default (bsc#1081592) - Remove-obsolete-unicode-handling-in-pkg.info_installed - Added: * remove-obsolete-unicode-handling-in-pkg.info_install.patch - Update to salt-2018.1.99 - Modified: * activate-all-beacons-sources-config-pillar-grains.patch * avoid-excessive-syslogging-by-watchdog-cronjob-58.patch * feat-add-grain-for-all-fqdns.patch * fix-bsc-1065792.patch * list_pkgs-add-parameter-for-returned-attribute-selec.patch * run-salt-api-as-user-salt-bsc-1064520.patch * run-salt-master-as-dedicated-salt-user.patch - Deleted: * python3-compatibility-fix-got-bytes-instead-of-strin.patch * enable-with-salt-version-parameter-for-setup.py-scri.patch * catching-error-when-pidfile-cannot-be-deleted.patch * bugfix-always-return-a-string-list-on-unknown-job-ta.patch * bugfix-the-logic-according-to-the-exact-described-pu.patch * cherrypy-read-reads-bytes-from-the-wire-and-write-th.patch * fix-for-delete_deployment-in-kubernetes-module.patch * fix-salt-master-for-old-psutil.patch * introduce-process_count_max-minion-configuration-par.patch * multiprocessing-minion-option-documentation-fixes.patch * older-logrotate-need-su-directive.patch * return-error-when-gid_from_name-and-group-does-not-e.patch * set-shell-environment-variable-64.patch * split-only-strings-if-they-are-such.patch OBS-URL: https://build.opensuse.org/request/show/581002 OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=112
2018-02-28 16:27:22 +01:00
@@ -7,6 +7,7 @@
from __future__ import absolute_import, print_function, unicode_literals
import logging
import os
+import socket
# Import Salt Testing Libs
Accepting request 581002 from systemsmanagement:saltstack:testing - Remove salt-minion python2 requirement when python3 is default (bsc#1081592) - Remove-obsolete-unicode-handling-in-pkg.info_installed - Added: * remove-obsolete-unicode-handling-in-pkg.info_install.patch - Update to salt-2018.1.99 - Modified: * activate-all-beacons-sources-config-pillar-grains.patch * avoid-excessive-syslogging-by-watchdog-cronjob-58.patch * feat-add-grain-for-all-fqdns.patch * fix-bsc-1065792.patch * list_pkgs-add-parameter-for-returned-attribute-selec.patch * run-salt-api-as-user-salt-bsc-1064520.patch * run-salt-master-as-dedicated-salt-user.patch - Deleted: * python3-compatibility-fix-got-bytes-instead-of-strin.patch * enable-with-salt-version-parameter-for-setup.py-scri.patch * catching-error-when-pidfile-cannot-be-deleted.patch * bugfix-always-return-a-string-list-on-unknown-job-ta.patch * bugfix-the-logic-according-to-the-exact-described-pu.patch * cherrypy-read-reads-bytes-from-the-wire-and-write-th.patch * fix-for-delete_deployment-in-kubernetes-module.patch * fix-salt-master-for-old-psutil.patch * introduce-process_count_max-minion-configuration-par.patch * multiprocessing-minion-option-documentation-fixes.patch * older-logrotate-need-su-directive.patch * return-error-when-gid_from_name-and-group-does-not-e.patch * set-shell-environment-variable-64.patch * split-only-strings-if-they-are-such.patch OBS-URL: https://build.opensuse.org/request/show/581002 OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=112
2018-02-28 16:27:22 +01:00
try:
--
Accepting request 626472 from home:mdinca:branches:systemsmanagement:saltstack - Update to 2018.3.2 See https://docs.saltstack.com/en/latest/topics/releases/2018.3.2.html for full changelog - Added: * accounting-for-when-files-in-an-archive-contain-non-.patch * add-all_versions-parameter-to-include-all-installed-.patch * add-custom-suse-capabilities-as-grains.patch * add-engine-relaying-libvirt-events.patch * add-environment-variable-to-know-if-yum-is-invoked-f.patch * add-other-attribute-to-gecos-fields-to-avoid-inconsi.patch * align-suse-salt-master.service-limitnofiles-limit-wi.patch * avoid-incomprehensive-message-if-crashes.patch * fix-deprecation-warning-bsc-1095507.patch * fix-diffing-binary-files-in-file.get_diff-bsc-109839.patch * fix-unboundlocalerror-in-file.get_diff.patch * fix-zypper.list_pkgs-to-be-aligned-with-pkg-state.patch * prevent-zypper-from-parsing-repo-configuration-from-.patch * remove-old-hack-when-reporting-multiversion-packages.patch * show-recommendations-for-salt-ssh-cross-version-pyth.patch - Modified: * activate-all-beacons-sources-config-pillar-grains.patch * add-saltssh-multi-version-support-across-python-inte.patch * avoid-excessive-syslogging-by-watchdog-cronjob-58.patch * do-not-override-jid-on-returners-only-sending-back-t.patch * enable-passing-a-unix_socket-for-mysql-returners-bsc.patch * fall-back-to-pymysql.patch * feat-add-grain-for-all-fqdns.patch * fix-bsc-1065792.patch * fix-decrease-loglevel-when-unable-to-resolve-addr.patch * fix-for-ec2-rate-limit-failures.patch OBS-URL: https://build.opensuse.org/request/show/626472 OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=127
2018-07-30 13:52:13 +02:00
2.13.7