summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTim Laszlo <tim.laszlo@gmail.com>2012-06-05 05:44:55 -0500
committerTim Laszlo <tim.laszlo@gmail.com>2012-06-05 05:55:48 -0500
commit5dbca666092d679935bb7dacf339c929f3c12114 (patch)
treeea7348028cbb2022e6a2fc3ff972b0503a872122 /src
parent11913d1203f928eee1b549d7232e205626a5bb88 (diff)
downloadbcfg2-5dbca666092d679935bb7dacf339c929f3c12114.tar.gz
bcfg2-5dbca666092d679935bb7dacf339c929f3c12114.tar.bz2
bcfg2-5dbca666092d679935bb7dacf339c929f3c12114.zip
DBStats: Remove clients.xml from the import process
Diffstat (limited to 'src')
-rw-r--r--src/lib/Bcfg2/Server/Admin/Reports.py26
-rwxr-xr-xsrc/lib/Bcfg2/Server/Reports/importscript.py25
2 files changed, 9 insertions, 42 deletions
diff --git a/src/lib/Bcfg2/Server/Admin/Reports.py b/src/lib/Bcfg2/Server/Admin/Reports.py
index 6c1a18968..17e1e1e4d 100644
--- a/src/lib/Bcfg2/Server/Admin/Reports.py
+++ b/src/lib/Bcfg2/Server/Admin/Reports.py
@@ -81,7 +81,6 @@ class Reports(Bcfg2.Server.Admin.Mode):
" init Initialize the database\n"
" load_stats Load statistics data\n"
" -s|--stats Path to statistics.xml file\n"
- " -c|--clients-file Path to clients.xml file\n"
" -O3 Fast mode. Duplicates data!\n"
" purge Purge records\n"
" --client [n] Client to operate on\n"
@@ -111,15 +110,12 @@ class Reports(Bcfg2.Server.Admin.Mode):
elif args[0] in ['init', 'update']:
try:
update_database()
- #except SchemaTooOldError:
- # logger.error("Sc
except UpdaterError:
print "Update failed"
raise SystemExit(-1)
elif args[0] == 'load_stats':
quick = '-O3' in args
stats_file = None
- clients_file = None
i = 1
while i < len(args):
if args[i] == '-s' or args[i] == '--stats':
@@ -127,11 +123,9 @@ class Reports(Bcfg2.Server.Admin.Mode):
if stats_file[0] == '-':
self.errExit("Invalid statistics file: %s" % stats_file)
elif args[i] == '-c' or args[i] == '--clients-file':
- clients_file = args[i + 1]
- if clients_file[0] == '-':
- self.errExit("Invalid clients file: %s" % clients_file)
+ print "DeprecationWarning: %s is no longer used" % args[i]
i = i + 1
- self.load_stats(stats_file, clients_file, self.log.getEffectiveLevel() > logging.WARNING, quick)
+ self.load_stats(stats_file, self.log.getEffectiveLevel() > logging.WARNING, quick)
elif args[0] == 'purge':
expired = False
client = None
@@ -229,7 +223,7 @@ class Reports(Bcfg2.Server.Admin.Mode):
else:
django.core.management.call_command(command)
- def load_stats(self, stats_file=None, clientspath=None, verb=0, quick=False):
+ def load_stats(self, stats_file=None, verb=0, quick=False):
'''Load statistics data into the database'''
location = ''
@@ -248,20 +242,8 @@ class Reports(Bcfg2.Server.Admin.Mode):
except:
encoding = 'UTF-8'
- if not clientspath:
- try:
- clientspath = "%s/Metadata/clients.xml" % \
- self.cfp.get('server', 'repository')
- except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
- self.errExit("Could not read bcfg2.conf; exiting")
- try:
- clientsdata = XML(open(clientspath).read())
- except (IOError, XMLSyntaxError):
- self.errExit("StatReports: Failed to parse %s" % (clientspath))
-
try:
- load_stats(clientsdata,
- statsdata,
+ load_stats(statsdata,
encoding,
verb,
self.log,
diff --git a/src/lib/Bcfg2/Server/Reports/importscript.py b/src/lib/Bcfg2/Server/Reports/importscript.py
index 486cb8254..3f9f5ec35 100755
--- a/src/lib/Bcfg2/Server/Reports/importscript.py
+++ b/src/lib/Bcfg2/Server/Reports/importscript.py
@@ -87,7 +87,7 @@ def build_reason_kwargs(r_ent, encoding, logger):
unpruned=unpruned_entries)
-def load_stats(cdata, sdata, encoding, vlevel, logger, quick=False, location=''):
+def load_stats(sdata, encoding, vlevel, logger, quick=False, location=''):
for node in sdata.findall('Node'):
name = node.get('name')
for statistics in node.findall('Statistics'):
@@ -203,18 +203,17 @@ if __name__ == '__main__':
except GetoptError:
mesg = sys.exc_info()[1]
# print help information and exit:
- print("%s\nUsage:\nimportscript.py [-h] [-v] [-u] [-d] [-S] [-C bcfg2 config file] [-c clients-file] [-s statistics-file]" % (mesg))
+ print("%s\nUsage:\nimportscript.py [-h] [-v] [-u] [-d] [-S] [-C bcfg2 config file] [-s statistics-file]" % (mesg))
raise SystemExit(2)
for o, a in opts:
if o in ("-h", "--help"):
- print("Usage:\nimportscript.py [-h] [-v] -c <clients-file> -s <statistics-file> \n")
+ print("Usage:\nimportscript.py [-h] [-v] -s <statistics-file> \n")
print("h : help; this message")
print("v : verbose; print messages on record insertion/skip")
print("u : updates; print status messages as items inserted semi-verbose")
print("d : debug; print most SQL used to manipulate database")
print("C : path to bcfg2.conf config file.")
- print("c : clients.xml file")
print("s : statistics.xml file")
print("S : syslog; output to syslog")
raise SystemExit
@@ -228,7 +227,7 @@ if __name__ == '__main__':
if o in ("-d", "--debug"):
verb = 3
if o in ("-c", "--clients"):
- clientspath = a
+ print "DeprecationWarning: %s is no longer used" % o
if o in ("-s", "--stats"):
statpath = a
@@ -261,27 +260,13 @@ if __name__ == '__main__':
except:
encoding = 'UTF-8'
- if not clientpath:
- try:
- clientspath = "%s/Metadata/clients.xml" % \
- cf.get('server', 'repository')
- except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
- print("Could not read bcfg2.conf; exiting")
- raise SystemExit(1)
- try:
- clientsdata = XML(open(clientspath).read())
- except (IOError, XMLSyntaxError):
- print("StatReports: Failed to parse %s" % (clientspath))
- raise SystemExit(1)
-
q = '-O3' in sys.argv
# Be sure the database is ready for new schema
try:
update_database()
except UpdaterError:
raise SystemExit(1)
- load_stats(clientsdata,
- statsdata,
+ load_stats(statsdata,
encoding,
verb,
logger,