summaryrefslogtreecommitdiffstats
path: root/src/sbin/bcfg2-reports
diff options
context:
space:
mode:
Diffstat (limited to 'src/sbin/bcfg2-reports')
-rwxr-xr-xsrc/sbin/bcfg2-reports38
1 files changed, 16 insertions, 22 deletions
diff --git a/src/sbin/bcfg2-reports b/src/sbin/bcfg2-reports
index c6cc766c6..559e9fb43 100755
--- a/src/sbin/bcfg2-reports
+++ b/src/sbin/bcfg2-reports
@@ -26,18 +26,15 @@ from getopt import getopt
import datetime
import fileinput
-
def timecompare(client1, client2):
"""Compares two clients by their timestamps."""
return cmp(client1.current_interaction.timestamp, \
client2.current_interaction.timestamp)
-
def namecompare(client1, client2):
"""Compares two clients by their names."""
return cmp(client1.name, client2.name)
-
def statecompare(client1, client2):
"""Compares two clients by their states."""
clean1 = client1.current_interaction.isclean()
@@ -50,7 +47,6 @@ def statecompare(client1, client2):
else:
return 0
-
def crit_compare(criterion, client1, client2):
"""Compares two clients by the criteria provided in criterion."""
for crit in criterion:
@@ -61,13 +57,12 @@ def crit_compare(criterion, client1, client2):
comp = statecompare(client1, client2)
elif crit == 'time':
comp = timecompare(client1, client2)
-
+
if comp != 0:
return comp
-
+
return 0
-
def print_fields(fields, cli, max_name, entrydict):
"""
Prints the fields specified in fields of cli, max_name
@@ -98,15 +93,14 @@ def print_fields(fields, cli, max_name, entrydict):
if len(entrydict) > 0:
display += " "
display += str(entrydict[cli])
- print(display)
-
+ print display
def print_entry(item, max_name):
fmt = ("%%-%ds " % (max_name))
fdata = item.entry.kind + ":" + item.entry.name
display = fmt % (fdata)
- print(display)
-
+ print display
+
fields = ""
sort = ""
badentry = ""
@@ -143,14 +137,14 @@ if expire != "":
if expire == c_inst.name:
if c_inst.expiration == None:
c_inst.expiration = datetime.datetime.now()
- print("Host expired.")
+ print "Host expired."
else:
c_inst.expiration = None
- print("Host un-expired.")
+ print "Host un-expired."
c_inst.save()
elif '-h' in args:
- print("""Usage: bcfg2-reports [option] ...
+ print """Usage: bcfg2-reports [option] ...
Options and arguments (and corresponding environment variables):
-a : shows all hosts, including expired hosts
@@ -176,13 +170,13 @@ Options and arguments (and corresponding environment variables):
(name,time,state)
--sort=ARG1,ARG2,... : sorts output on ARG1,ARG2,... (name,time,state)
--stale : shows hosts which haven't run in the last 24 hours
-""")
+"""
elif singlehost != "":
for c_inst in c_list:
if singlehost == c_inst.name:
baditems = c_inst.current_interaction.bad()
if len(baditems) > 0 and ('-b' in args or '-s' in args):
- print("Bad Entries:")
+ print "Bad Entries:"
max_name = -1
for item in baditems:
if len(item.entry.name) > max_name:
@@ -191,14 +185,14 @@ elif singlehost != "":
print_entry(item, max_name)
extraitems = c_inst.current_interaction.extra()
if len(extraitems) > 0 and ('-e' in args or '-s' in args):
- print("Extra Entries:")
+ print "Extra Entries:"
max_name = -1
for item in extraitems:
if len(item.entry.name) > max_name:
max_name = len(item.entry.name)
for item in extraitems:
print_entry(item, max_name)
-
+
else:
if fields == "":
@@ -214,19 +208,19 @@ else:
if extraentry != "":
extraentry = extraentry.split(',')
-
+
# stale hosts
if '--stale' in args:
for c_inst in c_list:
if c_inst.current_interaction.isstale():
result.append(c_inst)
# clean hosts
- elif '-c' in args:
+ elif '-c' in args:
for c_inst in c_list:
if c_inst.current_interaction.isclean():
result.append(c_inst)
# dirty hosts
- elif '-d' in args:
+ elif '-d' in args:
for c_inst in c_list:
if not c_inst.current_interaction.isclean():
result.append(c_inst)
@@ -287,7 +281,7 @@ else:
if sort != "":
result.sort(lambda x, y: crit_compare(sort, x, y))
-
+
if fields != "":
for c_inst in result:
if '-a' in args or c_inst.expiration == None: