X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=config.py;h=9efdecc748f4b5e802154df0ff691f70a3bc9b0b;hb=95221af187a49007095148f182c74467db555009;hp=6288bf7be55c303dcb78356b19cb9940ba190b4f;hpb=e4ae4a48f2717dd90768340d0f27bfb1b1e76156;p=nodemanager.git diff --git a/config.py b/config.py index 6288bf7..9efdecc 100644 --- a/config.py +++ b/config.py @@ -1,5 +1,8 @@ #!/usr/bin/python # +# $Id$ +# $URL$ +# # Parses the PLC configuration file /etc/planetlab/plc_config, which # is bootstrapped by Boot Manager, but managed by us. # @@ -9,6 +12,8 @@ # $Id$ # +import os + class Config: """ Parses Python configuration files; all variables in the file are @@ -23,11 +28,25 @@ class Config: 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__.iteritems(): + if k not in ['__builtins__']: + pprint ( (k,v), )