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
14 Parses Python configuration files; all variables in the file are
15 assigned to class attributes.
18 def __init__(self, file = "/etc/planetlab/plc_config"):
20 execfile(file, self.__dict__)
22 raise Exception, "Could not parse " + file
24 if int(self.PLC_API_PORT) == 443:
26 if hasattr(self, 'PLC_API_CA_SSL_CRT'):
27 self.cacert = self.PLC_API_CA_SSL_CRT
28 elif os.path.exists('/usr/boot/cacert.pem'):
29 self.cacert = '/usr/boot/cacert.pem'
31 raise Exception, "No boot server certificate bundle available"
36 uri += self.PLC_API_HOST + \
37 ":" + str(self.PLC_API_PORT) + \
38 "/" + self.PLC_API_PATH + "/"
40 self.plc_api_uri = uri
43 if __name__ == '__main__':
44 from pprint import pprint
45 for (k,v) in Config().__dict__.iteritems():
46 if k not in ['__builtins__']: