Commit 23af60f3 authored by Yingjie Xu's avatar Yingjie Xu Committed by Alain Takoudjou

Rewrite log format.

parent d14f275b
import ConfigParser import ConfigParser, argparse
import argparse
import json import json
from random import random, choice from random import random, choice
import os import os, socket, time
import socket
import time
from datetime import datetime from datetime import datetime
from datetime import timedelta from datetime import timedelta
import xmlrpclib import xmlrpclib
...@@ -52,7 +49,7 @@ class Agent: ...@@ -52,7 +49,7 @@ class Agent:
self.log_directory = configuration.get("agent", "log_directory") self.log_directory = configuration.get("agent", "log_directory")
self.state_file = configuration.get("agent", "state_file") self.state_file = configuration.get("agent", "state_file")
filename = os.path.join(self.log_directory, "agent-%s.log" % datetime.strftime(datetime.now(), "%Y-%m-%d")) filename = os.path.join(self.log_directory, "agent-%s.log" % datetime.strftime(datetime.now(), "%Y%m%d"))
basicConfig(filename=filename, format="%(asctime)-15s %(message)s", level="INFO") basicConfig(filename=filename, format="%(asctime)-15s %(message)s", level="INFO")
self.logger = getLogger() self.logger = getLogger()
...@@ -91,18 +88,18 @@ class Agent: ...@@ -91,18 +88,18 @@ class Agent:
return safeRpcCall(portal, "Agent_getSoftwareReleaseUsageOnComputer", computer, software) return safeRpcCall(portal, "Agent_getSoftwareReleaseUsageOnComputer", computer, software)
def requestSoftwareReleaseCleanupOnComputer(self, computer, software): def requestSoftwareReleaseCleanupOnComputer(self, computer, software):
self.logger.info("Request to cleanup %s on %s." % (software, computer))
try: try:
self.supply.supply(self.software_uri[software], computer, "destroyed") self.supply.supply(self.software_uri[software], computer, "destroyed")
self.logger.info("Successfully requested to cleanup %s on %s." % (software, computer))
return True return True
except: except:
self.logger.info("Failed to request to cleanup %s on %s." % (software, computer)) self.logger.info("Failed to request to cleanup %s on %s." % (software, computer))
return False return False
def requestSoftwareReleaseInstallationOnComputer(self, computer, software): def requestSoftwareReleaseInstallationOnComputer(self, computer, software):
self.logger.info("Request to install %s on %s." % (software, computer))
try: try:
self.supply.supply(self.software_uri[software], computer, "available") self.supply.supply(self.software_uri[software], computer, "available")
self.logger.info("Successfully requested to install %s on %s." % (software, computer))
return True return True
except: except:
self.logger.info("Failed to request to install %s on %s." % (software, computer)) self.logger.info("Failed to request to install %s on %s." % (software, computer))
...@@ -116,7 +113,6 @@ class Agent: ...@@ -116,7 +113,6 @@ class Agent:
json.dumps(_encode_software_dict(self.installing_software_dict[computer]))) json.dumps(_encode_software_dict(self.installing_software_dict[computer])))
state.set(computer, "installed_software", \ state.set(computer, "installed_software", \
json.dumps(_encode_software_dict(self.installed_software_dict[computer]))) json.dumps(_encode_software_dict(self.installed_software_dict[computer])))
dirname = os.path.dirname(__file__)
state.write(open(self.state_file, "w")) state.write(open(self.state_file, "w"))
def main(*args): def main(*args):
......
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