Commit 833e4782 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos/collect: getint don't support fallback

parent 9d796b73
...@@ -89,8 +89,10 @@ def do_collect(conf): ...@@ -89,8 +89,10 @@ def do_collect(conf):
user_dict[snapshot.username].append(snapshot) user_dict[snapshot.username].append(snapshot)
except (KeyboardInterrupt, SystemExit, NoSuchProcess): except (KeyboardInterrupt, SystemExit, NoSuchProcess):
raise raise
days_to_preserve = 15
days_to_preserve = conf.getint("slapos", "collect_cache", 15) if conf.has_option("slapos", "collect_cache"):
days_to_preserve = conf.getint("slapos", "collect_cache")
log_directory = "%s/var/data-log" % conf.get("slapos", "instance_root") log_directory = "%s/var/data-log" % conf.get("slapos", "instance_root")
mkdir_p(log_directory, 0o755) mkdir_p(log_directory, 0o755)
...@@ -149,7 +151,7 @@ def do_collect(conf): ...@@ -149,7 +151,7 @@ def do_collect(conf):
base = datetime.datetime.utcnow().date() base = datetime.datetime.utcnow().date()
for x in range(1, 3): for x in range(1, 3):
report_file = consumption_report.buildXMLReport( report_file = consumption_report.buildXMLReport(
(base - datetime.timedelta(days=x)).strftime("%Y-%m-%d"), gmtime()) (base - datetime.timedelta(days=x)).strftime("%Y-%m-%d"))
if report_file is not None: if report_file is not None:
shutil.copy(report_file, xml_report_directory) shutil.copy(report_file, xml_report_directory)
...@@ -162,7 +164,7 @@ def do_collect(conf): ...@@ -162,7 +164,7 @@ def do_collect(conf):
compressLogFolder(log_directory) compressLogFolder(log_directory)
# Drop older entries already reported # Drop older entries already reported
database.garbageCollect(int(days_to_preserve)) database.garbageCollect(days_to_preserve)
except AccessDenied: except AccessDenied:
print("You HAVE TO execute this script with root permission.") print("You HAVE TO execute this script with root permission.")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment