-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.py
More file actions
47 lines (39 loc) · 1.34 KB
/
config.py
File metadata and controls
47 lines (39 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/python
#
# Parses the PLC configuration file /etc/planetlab/plc_config, which
# is bootstrapped by Boot Manager, but managed by us.
#
# Mark Huang <mlhuang@cs.princeton.edu>
# 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:
execfile(file, 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__.iteritems():
if k not in ['__builtins__']:
pprint ( (k,v), )