aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2021-03-03 15:31:52 +0100
committerJake Hunsaker <jhunsake@redhat.com>2021-03-04 10:19:23 -0500
commit794a4589b1e8b00d95d5aa9bbb577a91c50fc2f5 (patch)
treebe3c878ba318fbed60110ec387f05df60953750d
parent3b439fb64d8d65b0c09aa8452bf0181ec20f8bcf (diff)
downloadsos-794a4589b1e8b00d95d5aa9bbb577a91c50fc2f5.tar.gz
[foreman] get conditionally list of smart-proxies features
Two changes applied: - drop printing IP address of a smart proxy - add plugopt foreman.proxyfeatures that will trigger collecting features of all smart proxies Closes: #2424 Resolves: #2433 Signed-off-by: Pavel Moravec <pmoravec@redhat.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--sos/report/plugins/foreman.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/sos/report/plugins/foreman.py b/sos/report/plugins/foreman.py
index 0ff47076..af295b6a 100644
--- a/sos/report/plugins/foreman.py
+++ b/sos/report/plugins/foreman.py
@@ -24,7 +24,8 @@ class Foreman(Plugin):
profiles = ('sysmgmt',)
packages = ('foreman', 'foreman-proxy')
option_list = [
- ('months', 'number of months for dynflow output', 'fast', 1)
+ ('months', 'number of months for dynflow output', 'fast', 1),
+ ('proxyfeatures', 'collect features of smart proxies', 'slow', False),
]
def setup(self):
@@ -225,10 +226,8 @@ class Foreman(Plugin):
'audits_table_count': 'select count(*) from audits',
'logs_table_count': 'select count(*) from logs',
'fact_names_prefixes': factnamescmd,
- 'smart_proxies': 'select sp.name, sp.url, ' +
- 'sp.download_policy,n.ip from smart_proxies ' +
- 'as sp left join hosts as h on h.name=sp.name ' +
- 'left join nics as n on n.host_id=h.id'
+ 'smart_proxies': 'select name,url,download_policy ' +
+ 'from smart_proxies'
}
# Same as above, but tasks should be in CSV output
@@ -250,6 +249,24 @@ class Foreman(Plugin):
self.add_cmd_output(_cmd, suggest_filename=dyn, timeout=600,
sizelimit=100, env=self.env)
+ if self.get_option('proxyfeatures'):
+ # get a list of proxy names and URLs, and query for their features
+ # store results in smart_proxies_features subdirectory
+ _cmd = self.build_query_cmd('select name,url from smart_proxies',
+ csv=True)
+ proxies = self.exec_cmd(_cmd, env=self.env)
+ if proxies['status'] == 0:
+ # output contains header as the first line, skip it
+ for proxy in proxies['output'].splitlines()[1:]:
+ proxy = proxy.split(',')
+ # proxy is now tuple [name, url]
+ _cmd = 'curl -s --key /etc/foreman/client_key.pem ' \
+ '--cert /etc/foreman/client_cert.pem ' \
+ '%s/v2/features' % proxy[1]
+ self.add_cmd_output(_cmd, suggest_filename=proxy[0],
+ subdir='smart_proxies_features',
+ timeout=10)
+
# collect http[|s]_proxy env.variables
self.add_env_var(["http_proxy", "https_proxy"])