6 # Parses the PLC configuration file /etc/planetlab/plc_config, which
7 # is bootstrapped by Boot Manager, but managed by us.
9 # Mark Huang <mlhuang@cs.princeton.edu>
10 # Copyright (C) 2006 The Trustees of Princeton University
19 Parses Python configuration files; all variables in the file are
20 assigned to class attributes.
23 def __init__(self, file = "/etc/planetlab/plc_config"):
25 execfile(file, self.__dict__)
27 raise Exception, "Could not parse " + file
29 if int(self.PLC_API_PORT) == 443:
31 if hasattr(self, 'PLC_API_CA_SSL_CRT'):
32 self.cacert = self.PLC_API_CA_SSL_CRT
33 elif os.path.exists('/usr/boot/cacert.pem'):
34 self.cacert = '/usr/boot/cacert.pem'
36 raise Exception, "No boot server certificate bundle available"
41 uri += self.PLC_API_HOST + \
42 ":" + str(self.PLC_API_PORT) + \
43 "/" + self.PLC_API_PATH + "/"
45 self.plc_api_uri = uri
48 if __name__ == '__main__':
49 from pprint import pprint
50 pprint(Config().__dict__.items())