From e5fe8f0e38fa96e588d8674bc1352a39e3c4afe6 Mon Sep 17 00:00:00 2001 From: Andy Bavier Date: Mon, 28 Feb 2011 17:26:28 -0500 Subject: [PATCH] Pick up changes in plc_config PL-23 Get bwmon to pick up changes in /etc/planetlab/plc_config without restarting NodeManager. --- bwmon.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/bwmon.py b/bwmon.py index 0f23390..affa092 100644 --- a/bwmon.py +++ b/bwmon.py @@ -27,6 +27,7 @@ import logger import tools import bwlimit import database +from config import Config priority = 20 @@ -38,14 +39,6 @@ ENABLE = True DB_FILE = "/var/lib/nodemanager/bwmon.pickle" -try: - sys.path.append("/etc/planetlab") - from plc_config import * -except: - DEBUG = True - logger.verbose("bwmon: Warning: Configuration file /etc/planetlab/plc_config.py not found") - logger.log("bwmon: Running in DEBUG mode. Logging to file and not emailing.") - # Constants seconds_per_day = 24 * 60 * 60 bits_per_byte = 8 @@ -141,16 +134,17 @@ def slicemail(slice, subject, body): ''' Front end to sendmail. Sends email to slice alias with given subject and body. ''' - - sendmail = os.popen("/usr/sbin/sendmail -N never -t -f%s" % PLC_MAIL_SUPPORT_ADDRESS, "w") + config = Config() + sendmail = os.popen("/usr/sbin/sendmail -N never -t -f%s" % config.PLC_MAIL_SUPPORT_ADDRESS, "w") # Parsed from MyPLC config - to = [PLC_MAIL_MOM_LIST_ADDRESS] + to = [config.PLC_MAIL_MOM_LIST_ADDRESS] if slice is not None and slice != "root": - to.append(PLC_MAIL_SLICE_ADDRESS.replace("SLICE", slice)) + to.append(config.PLC_MAIL_SLICE_ADDRESS.replace("SLICE", slice)) - header = {'from': "%s Support <%s>" % (PLC_NAME, PLC_MAIL_SUPPORT_ADDRESS), + header = {'from': "%s Support <%s>" % (config.PLC_NAME, + config.PLC_MAIL_SUPPORT_ADDRESS), 'to': ", ".join(to), 'version': sys.version.split(" ")[0], 'subject': subject} @@ -671,7 +665,7 @@ def getDefaults(nmdbcopy): ''' status = True # default slice - dfltslice = nmdbcopy.get(PLC_SLICE_PREFIX+"_default") + dfltslice = nmdbcopy.get(Config().PLC_SLICE_PREFIX+"_default") if dfltslice: if dfltslice['rspec']['net_max_rate'] == -1: allOff() -- 2.43.0