3 # Parses the PLC configuration file /etc/planetlab/plc_config, which
4 # is bootstrapped by Boot Manager, but managed by us.
6 # Mark Huang <mlhuang@cs.princeton.edu>
7 # Copyright (C) 2006 The Trustees of Princeton University
9 # $Id: config.py,v 1.5 2006/11/18 18:15:37 mlhuang Exp $
16 Parses Python configuration files; all variables in the file are
17 assigned to class attributes.
20 def __init__(self, file = "/etc/planetlab/plc_config"):
22 execfile(file, self.__dict__)
24 raise Exception, "Could not parse " + file
26 if int(self.PLC_API_PORT) == 443:
28 if hasattr(self, 'PLC_API_CA_SSL_CRT'):
29 self.cacert = self.PLC_API_CA_SSL_CRT
30 elif os.path.exists('/usr/boot/cacert.pem'):
31 self.cacert = '/usr/boot/cacert.pem'
33 raise Exception, "No boot server certificate bundle available"
38 uri += self.PLC_API_HOST + \
39 ":" + str(self.PLC_API_PORT) + \
40 "/" + self.PLC_API_PATH + "/"
42 self.plc_api_uri = uri
45 if __name__ == '__main__':
46 from pprint import pprint
47 pprint(Config().__dict__.items())