X-Git-Url: http://git.onelab.eu/?p=nodemanager.git;a=blobdiff_plain;f=config.py;h=700b2db2e0dbea4ff5bcd555924242bcc3bc4e09;hp=3b413263062d80df5c89036dbb02878c47984598;hb=HEAD;hpb=aac3e5d7c3443d6e1cb33525aefad35be5fe077a diff --git a/config.py b/config.py index 3b41326..700b2db 100644 --- a/config.py +++ b/config.py @@ -1,33 +1,47 @@ -"""Global parameters and configuration.""" - -try: - from bwlimit import bwmin, bwmax - - DEFAULT_RSPEC = {'nm_cpu_share': 32, 'nm_cpu_guaranteed_share': 0, - 'nm_disk_quota': 5000000, - 'nm_enabled': 1, - 'nm_net_min_rate': bwmin, 'nm_net_max_rate': bwmax, - 'nm_net_exempt_min_rate': bwmin, - 'nm_net_exempt_max_rate': bwmax, - 'nm_net_share': 1} -except ImportError: pass - -API_SERVER_PORT = 812 - -DB_FILE = '/root/pl_node_mgr_db.pickle' - -KEY_FILE = '/home/deisenst/nm/key.pem' - -LOANABLE_RESOURCES = set(['nm_cpu_share', 'nm_cpu_guaranteed_share', - 'nm_net_max_rate', 'nm_net_exempt_max_rate', - 'nm_net_share']) - -LOG_FILE = '/var/log/pl_node_mgr.log' - -PID_FILE = '/var/run/pl_node_mgr.pid' - -SA_HOSTNAME = 'plc-a.demo.vmware' - -START_DELAY_SECS = 10 - -TICKET_SERVER_PORT = 1813 +#!/usr/bin/python3 +# +# Parses the PLC configuration file /etc/planetlab/plc_config, which +# is bootstrapped by Boot Manager, but managed by us. +# +# Mark Huang +# Copyright (C) 2006 The Trustees of Princeton University +# + +import os + +class Config: + """ + Parses Python configuration files; all variables in the file are + assigned to class attributes. + """ + + def __init__(self, file = "/etc/planetlab/plc_config"): + try: + exec(compile(open(file).read(), file, 'exec'), self.__dict__) + except: + raise Exception("Could not parse " + file) + + if int(self.PLC_API_PORT) == 443: + uri = "https://" + if hasattr(self, 'PLC_API_CA_SSL_CRT'): + self.cacert = self.PLC_API_CA_SSL_CRT + elif os.path.exists('/usr/boot/cacert.pem'): + self.cacert = '/usr/boot/cacert.pem' + else: + raise Exception("No boot server certificate bundle available") + else: + uri = "http://" + self.cacert = None + + uri += self.PLC_API_HOST + \ + ":" + str(self.PLC_API_PORT) + \ + "/" + self.PLC_API_PATH + "/" + + self.plc_api_uri = uri + + +if __name__ == '__main__': + from pprint import pprint + for (k, v) in Config().__dict__.items(): + if k not in ['__builtins__']: + pprint ( (k, v), )