client/rhel/rhn-client-tools/src/up2date_client/hardware.py | 130 ++++++------ rel-eng/packages/spacewalk-admin | 2 spacewalk/admin/man/rhn-sat-restart-silent.pod | 18 + spacewalk/admin/rhn-sat-restart-silent | 19 - spacewalk/admin/spacewalk-admin.spec | 7 5 files changed, 92 insertions(+), 84 deletions(-)
New commits: commit 71f08f0fa1b379f10e3732578238fb5f768adcb8 Author: Miroslav Suchý msuchy@redhat.com Date: Tue Oct 4 15:42:38 2011 +0200
Automatic commit of package [spacewalk-admin] release [1.6.1-1].
diff --git a/rel-eng/packages/spacewalk-admin b/rel-eng/packages/spacewalk-admin index 37730e5..4f2f3f6 100644 --- a/rel-eng/packages/spacewalk-admin +++ b/rel-eng/packages/spacewalk-admin @@ -1 +1 @@ -1.5.5-1 spacewalk/admin/ +1.6.1-1 spacewalk/admin/ diff --git a/spacewalk/admin/spacewalk-admin.spec b/spacewalk/admin/spacewalk-admin.spec index c0b9888..555badd 100644 --- a/spacewalk/admin/spacewalk-admin.spec +++ b/spacewalk/admin/spacewalk-admin.spec @@ -2,7 +2,7 @@ Summary: Various utility scripts and data files for RHN Satellite installations Name: spacewalk-admin URL: https://fedorahosted.org/spacewalk -Version: 1.6.0 +Version: 1.6.1 Release: 1%{?dist} Source0: https://fedorahosted.org/releases/s/p/spacewalk/%%7Bname%7D-%%7Bversion%7D.t... License: GPLv2 @@ -76,6 +76,9 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man8/rhn-config-satellite.pl.8*
%changelog +* Tue Oct 04 2011 Miroslav Suchý 1.6.1-1 +- writing pod documentation to shell script is not smart, move it aside + * Tue Jul 19 2011 Jan Pazdziora 1.5.5-1 - Updating the copyright years.
commit 0efadaf30cb196b93e55c8087f607c8dbae9dbcd Author: Miroslav Suchý msuchy@redhat.com Date: Tue Oct 4 15:40:21 2011 +0200
writing pod documentation to shell script is not smart, move it aside
diff --git a/spacewalk/admin/man/rhn-sat-restart-silent.pod b/spacewalk/admin/man/rhn-sat-restart-silent.pod new file mode 100644 index 0000000..9afb330 --- /dev/null +++ b/spacewalk/admin/man/rhn-sat-restart-silent.pod @@ -0,0 +1,18 @@ +=pod + +=head1 NAME + +rhn-sat-restart-silent - restart Spacewalk silently + +=head1 SYNOPSIS + +B<rhn-sat-restart-silent> + +=head1 DESCRIPTION + +This command will restart all Spacewalk services and omit all output. Including errors! +This script is used internally by Spacewalk server. You should never call it directly. You should use B<spacewalk-service>(8) instead. + +=head1 SEE ALSO + +B<spacewalk-service>(8) diff --git a/spacewalk/admin/rhn-sat-restart-silent b/spacewalk/admin/rhn-sat-restart-silent index 5947ea6..1954708 100644 --- a/spacewalk/admin/rhn-sat-restart-silent +++ b/spacewalk/admin/rhn-sat-restart-silent @@ -22,22 +22,3 @@ #
/usr/sbin/rhn-satellite restart &> /dev/null < /dev/null - -=pod - -=head1 NAME - -rhn-sat-restart-silent - restart Spacewalk silently - -=head1 SYNOPSIS - -B<rhn-sat-restart-silent> - -=head1 DESCRIPTION - -This command will restart all Spacewalk services and omit all output. Including errors! -This script is used internally by Spacewalk server. You should never call it directly. You should use B<spacewalk-service>(8) instead. - -=head1 SEE ALSO - -B<spacewalk-service>(8) diff --git a/spacewalk/admin/spacewalk-admin.spec b/spacewalk/admin/spacewalk-admin.spec index 39e0d53..c0b9888 100644 --- a/spacewalk/admin/spacewalk-admin.spec +++ b/spacewalk/admin/spacewalk-admin.spec @@ -38,7 +38,7 @@ mkdir -p $RPM_BUILD_ROOT%{_mandir}/man8/ %{_bindir}/pod2man --section=8 rhn-config-schema.pl > $RPM_BUILD_ROOT%{_mandir}/man8/rhn-config-schema.pl.8 %{_bindir}/pod2man --section=8 rhn-load-ssl-cert.pl > $RPM_BUILD_ROOT%{_mandir}/man8/rhn-load-ssl-cert.pl.8 %{_bindir}/pod2man --section=8 man/spacewalk-service.pod > $RPM_BUILD_ROOT%{_mandir}/man8/spacewalk-service.8 -%{_bindir}/pod2man --section=8 rhn-sat-restart-silent > $RPM_BUILD_ROOT%{_mandir}/man8/rhn-sat-restart-silent.8 +%{_bindir}/pod2man --section=8 man/rhn-sat-restart-silent.pod > $RPM_BUILD_ROOT%{_mandir}/man8/rhn-sat-restart-silent.8 %{_bindir}/pod2man --section=8 rhn-config-satellite.pl > $RPM_BUILD_ROOT%{_mandir}/man8/rhn-config-satellite.pl.8 install -p man/rhn-satellite.8 $RPM_BUILD_ROOT%{_mandir}/man8/ install -p man/validate-sat-cert.pl.8 $RPM_BUILD_ROOT%{_mandir}/man8/
commit 4228cb94848219837e914df946fe8f219dbd239a Author: Miroslav Suchý msuchy@redhat.com Date: Tue Oct 4 15:33:10 2011 +0200
W:374:read_memory_2_6: Redefining built-in 'dict'
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py index 9c4ebd8..b4a096f 100644 --- a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py +++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py @@ -371,7 +371,7 @@ def read_memory_2_6(): return {} meminfo = open("/proc/meminfo", "r").read() lines = meminfo.split("\n") - dict = {} + meminfo_dict = {} for line in lines: blobs = line.split(":", 1) key = blobs[0] @@ -379,17 +379,17 @@ def read_memory_2_6(): continue #print blobs value = blobs[1].strip() - dict[key] = value + meminfo_dict[key] = value
memdict = {} memdict["class"] = "MEMORY"
- total_str = dict['MemTotal'] + total_str = meminfo_dict['MemTotal'] blips = total_str.split(" ") total_k = long(blips[0]) megs = long(total_k/(1024))
- swap_str = dict['SwapTotal'] + swap_str = meminfo_dict['SwapTotal'] blips = swap_str.split(' ') swap_k = long(blips[0]) swap_megs = long(swap_k/(1024))
commit 30b6adf1c0bbbd94d0f772e87de1ba20501ca4bf Author: Miroslav Suchý msuchy@redhat.com Date: Tue Oct 4 15:31:18 2011 +0200
C:489:read_network: Comma not followed by a space
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py index 45e04fe..9c4ebd8 100644 --- a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py +++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py @@ -486,7 +486,7 @@ def read_network():
netdict['hostname'] = gethostname() try: - list_of_addrs = getaddrinfo(gethostname(),None) + list_of_addrs = getaddrinfo(gethostname(), None) ipv4_addrs = filter(lambda x:x[0]==socket.AF_INET, list_of_addrs) # take first ipv4 addr netdict['ipaddr'] = ipv4_addrs[0][4][0]
commit 0eb4fd5000ab589224fff4fd6fb877daac8f4802 Author: Miroslav Suchý msuchy@redhat.com Date: Tue Oct 4 15:30:36 2011 +0200
add docstring for findHostByRoute()
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py index 8b81cc0..45e04fe 100644 --- a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py +++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py @@ -400,6 +400,13 @@ def read_memory_2_6():
def findHostByRoute(): + """ returns [hostname, intf] + + Where hostname is you FQDN of this machine. + And intf is numeric IP address. If IPv4 is present, then it + is prefered, but IPv6 address can be returned if IPv4 is not + present. + """ cfg = config.initUp2dateConfig() sl = config.getServerlURL()
commit 9c51e415878d619b89c89ce4d7bc922567c0b3f9 Author: Miroslav Suchý msuchy@redhat.com Date: Tue Oct 4 14:58:51 2011 +0200
W:147:cpu_count: Redefining built-in 'dir'
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py index 8508fee..8b81cc0 100644 --- a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py +++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py @@ -144,12 +144,12 @@ def cpu_count(): Beware that it can be different from number of active CPU (e.g. on s390x architecture """ try: - dir = os.listdir('/sys/devices/system/cpu/') + cpu_dir = os.listdir('/sys/devices/system/cpu/') except OSError: - dir = [] + cpu_dir = []
re_cpu = re.compile(r"^cpu[0-9]+$") - return len([i for i in dir if re_cpu.match(i)]) + return len([i for i in cpu_dir if re_cpu.match(i)])
# This has got to be one of the ugliest fucntions alive
commit efb262726dc1ad359bdc7ecfab425ab091635c88 Author: Miroslav Suchý msuchy@redhat.com Date: Tue Oct 4 14:54:53 2011 +0200
W: 23: Uses of a deprecated module 'string'
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py index a6f94aa..8508fee 100644 --- a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py +++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py @@ -20,7 +20,6 @@ import socket import re import os import sys -import string import config
import ethtool @@ -130,13 +129,13 @@ def read_installinfo(): for info in installinfo: if not len(info): continue - vals = string.split(info, '=') + vals = info.split('=') if len(vals) <= 1: continue - strippedstring = string.strip(vals[0]) + strippedstring = vals[0].strip() vals[0] = strippedstring
- installdict[vals[0]] = string.strip(string.join(vals[1:])) + installdict[vals[0]] = ''.join(vals[1:]).strip() return installdict
def cpu_count(): @@ -156,7 +155,7 @@ def cpu_count(): # This has got to be one of the ugliest fucntions alive def read_cpuinfo(): def get_entry(a, entry): - e = string.lower(entry) + e = entry.lower() if not a.has_key(e): return "" return a[e] @@ -165,21 +164,21 @@ def read_cpuinfo(): def get_cpulist_as_dict(cpulist): count = 0 tmpdict = {} - for cpu in string.split(cpulist, "\n\n"): + for cpu in cpulist.split("\n\n"): if not len(cpu): continue count = count + 1 if count > 1: break # no need to parse rest - for cpu_attr in string.split(cpu, "\n"): + for cpu_attr in cpu.split("\n"): if not len(cpu_attr): continue - vals = string.split(cpu_attr, ":") + vals = cpu_attr.split(":") if len(vals) != 2: # XXX: make at least some effort to recover this data... continue - name, value = string.strip(vals[0]), string.strip(vals[1]) - tmpdict[string.lower(name)] = value + name, value = vals[0].strip(), vals[1].strip() + tmpdict[name.lower()] = value return tmpdict
if not os.access("/proc/cpuinfo", os.R_OK): @@ -192,7 +191,7 @@ def read_cpuinfo(): locale.setlocale(locale.LC_NUMERIC, "C")
cpulist = open("/proc/cpuinfo", "r").read() - uname = string.lower(os.uname()[4]) + uname = os.uname()[4].lower() count = cpu_count()
# This thing should return a hwdict that has the following @@ -248,7 +247,7 @@ def read_cpuinfo(): hwdict['other'] = get_entry(tmpdict, 'platform string') hz_speed = get_entry(tmpdict, 'cycle frequency [Hz]') # some funky alphas actually report in the form "462375000 est." - hz_speed = string.split(hz_speed) + hz_speed = hz_speed.split() try: hwdict['speed'] = int(round(float(hz_speed[0]))) / 1000000 except ValueError: @@ -288,8 +287,8 @@ def read_cpuinfo():
elif uname in ['s390', 's390x']: tmpdict = {} - for cpu in string.split(cpulist, "\n"): - vals = string.split(cpu, ": ") + for cpu in cpulist.split("\n"): + vals = cpu.split(cpu, ": ") if len(vals) != 2: continue tmpdict[vals[0].strip()] = vals[1].strip() @@ -349,9 +348,9 @@ def read_memory_2_4(): return {}
meminfo = open("/proc/meminfo", "r").read() - lines = string.split(meminfo,"\n") + lines = meminfo.split("\n") curline = lines[1] - memlist = string.split(curline) + memlist = curline.split() memdict = {} memdict['class'] = "MEMORY" megs = int(long(memlist[1])/(1024*1024)) @@ -361,7 +360,7 @@ def read_memory_2_4(): megs = megs + (16 - (megs % 16)) memdict['ram'] = str(megs) curline = lines[2] - memlist = string.split(curline) + memlist = curline.split() # otherwise, it breaks on > ~4gigs of swap megs = int(long(memlist[1])/(1024*1024)) memdict['swap'] = str(megs) @@ -371,27 +370,27 @@ def read_memory_2_6(): if not os.access("/proc/meminfo", os.R_OK): return {} meminfo = open("/proc/meminfo", "r").read() - lines = string.split(meminfo,"\n") + lines = meminfo.split("\n") dict = {} for line in lines: - blobs = string.split(line, ":", 1) + blobs = line.split(":", 1) key = blobs[0] if len(blobs) == 1: continue #print blobs - value = string.strip(blobs[1]) + value = blobs[1].strip() dict[key] = value
memdict = {} memdict["class"] = "MEMORY"
total_str = dict['MemTotal'] - blips = string.split(total_str, " ") + blips = total_str.split(" ") total_k = long(blips[0]) megs = long(total_k/(1024))
swap_str = dict['SwapTotal'] - blips = string.split(swap_str, ' ') + blips = swap_str.split(' ') swap_k = long(blips[0]) swap_megs = long(swap_k/(1024))
@@ -410,13 +409,13 @@ def findHostByRoute(): for serverUrl in sl: for family in (AF_INET, AF_INET6): s = socket.socket(family) - server = string.split(serverUrl, '/')[2] - servertype = string.split(serverUrl, ':')[0] + server = serverUrl.split('/')[2] + servertype = serverUrl.split(':')[0] port = st[servertype]
if cfg['enableProxy']: server_port = config.getProxySetting() - (server, port) = string.split(server_port, ':') + (server, port) = server_port.split(':') port = int(port)
try: @@ -440,13 +439,13 @@ def findHostByRoute(): for info in networkinfo: if not len(info): continue - vals = string.split(info, '=') + vals = info.split('=') if len(vals) <= 1: continue - strippedstring = string.strip(vals[0]) + strippedstring = vals[0].strip() vals[0] = strippedstring if vals[0] == "HOSTNAME": - hostname = string.strip(string.join(vals[1:])) + hostname = ''.join(vals[1:]).strip() break
if hostname == None or hostname == 'localhost.localdomain': @@ -462,12 +461,12 @@ def get_slave_hwaddr(master, slave):
slave_found = False for line in bonding.readlines(): - if slave_found and string.find(line, "Permanent HW addr: ") != -1: - hwaddr = string.split(line)[3] + if slave_found and line.find("Permanent HW addr: ") != -1: + hwaddr = line.split()[3] break
- if string.find(line, "Slave Interface: ") != -1: - ifname = string.split(line)[2] + if line.find("Slave Interface: ") != -1: + ifname = line.split()[2] if ifname == slave: slave_found = True
@@ -572,7 +571,7 @@ def read_dmi(): dmidict["class"] = "DMI"
# Try to obtain DMI info if architecture is i386, x86_64 or ia64 - uname = string.lower(os.uname()[4]) + uname = os.uname()[4].lower() if not (uname[0] == "i" and uname[-2:] == "86") and not (uname == "x86_64"): return dmidict
commit 5006538ec4fc486a916d402f30e11dd0992e37c6 Author: Miroslav Suchý msuchy@redhat.com Date: Tue Oct 4 14:37:44 2011 +0200
W:580: Unnecessary semicolon
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py index a36fe61..a6f94aa 100644 --- a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py +++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py @@ -577,7 +577,7 @@ def read_dmi(): return dmidict
# System Information - vendor = dmi_vendor(); + vendor = dmi_vendor() if vendor: dmidict["vendor"] = vendor
commit 801c489a15468eb9f7d1604fe498eaca18886bab Author: Miroslav Suchý msuchy@redhat.com Date: Tue Oct 4 14:37:20 2011 +0200
W: 89: Unnecessary semicolon
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py index 4a3ad55..a36fe61 100644 --- a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py +++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py @@ -86,7 +86,7 @@ def _initialize_dmi_data(): if dmi_warn: dmidecode.clear_warnings() return None - _dmi_data = data.xpathNewContext(); + _dmi_data = data.xpathNewContext() return _dmi_data
def get_dmi_data(path):
commit 463699d9c15740628d5888d4515618b55024b40a Author: Miroslav Suchý msuchy@redhat.com Date: Tue Oct 4 14:36:39 2011 +0200
W: 99: Bad indentation. Found 7 spaces, expected 8
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py index 5a58e0c..4a3ad55 100644 --- a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py +++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py @@ -96,7 +96,7 @@ def get_dmi_data(path): """ dmi_data = _initialize_dmi_data() if dmi_data is None: - return '' + return '' data = dmi_data.xpathEval(path) if data != []: return data[0].content
commit b495bd4cee0f8c1883131361c0fb980b20c86461 Author: Miroslav Suchý msuchy@redhat.com Date: Tue Oct 4 14:33:59 2011 +0200
whispace fix: replace tab with spaces
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py index 9b24ffc..5a58e0c 100644 --- a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py +++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py @@ -435,7 +435,7 @@ def findHostByRoute(): # for bz# 457953
if os.access("/etc/sysconfig/network", os.R_OK): - networkinfo = open("/etc/sysconfig/network", "r").readlines() + networkinfo = open("/etc/sysconfig/network", "r").readlines() for info in networkinfo: if not len(info):
commit 92331fb66a4c4430ac3c9a700eb6210b068bded9 Author: Miroslav Suchý msuchy@redhat.com Date: Tue Oct 4 14:33:07 2011 +0200
743259 - make findHostByRoute() IPv6 aware
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py index ca80e5b..9b24ffc 100644 --- a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py +++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py @@ -408,27 +408,28 @@ def findHostByRoute(): hostname = None intf = None for serverUrl in sl: - s = socket.socket() - server = string.split(serverUrl, '/')[2] - servertype = string.split(serverUrl, ':')[0] - port = st[servertype] - - if cfg['enableProxy']: - server_port = config.getProxySetting() - (server, port) = string.split(server_port, ':') - port = int(port) + for family in (AF_INET, AF_INET6): + s = socket.socket(family) + server = string.split(serverUrl, '/')[2] + servertype = string.split(serverUrl, ':')[0] + port = st[servertype]
- try: - s.settimeout(5) - s.connect((server, port)) - (intf, port) = s.getsockname() - hostname = socket.gethostbyaddr(intf)[0] - # I dislike generic excepts, but is the above fails - # for any reason, were not going to be able to - # find a good hostname.... - except: + if cfg['enableProxy']: + server_port = config.getProxySetting() + (server, port) = string.split(server_port, ':') + port = int(port) + + try: + s.settimeout(5) + s.connect((server, port)) + (intf, port) = s.getsockname()[:2] + hostname = socket.getfqdn(server) + except socket.error: + s.close() + continue + # we have hostname do not continue for other family s.close() - continue + break
# Override hostname with the one in /etc/sysconfig/network # for bz# 457953 @@ -450,7 +451,6 @@ def findHostByRoute():
if hostname == None or hostname == 'localhost.localdomain': hostname = "unknown" - s.close() return hostname, intf
def get_slave_hwaddr(master, slave):
spacewalk-commits@lists.fedorahosted.org