X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=config.py;fp=config.py;h=6288bf7be55c303dcb78356b19cb9940ba190b4f;hb=e4ae4a48f2717dd90768340d0f27bfb1b1e76156;hp=0000000000000000000000000000000000000000;hpb=948429864757336486360bcb8da7005414b6ee3d;p=nodemanager.git diff --git a/config.py b/config.py new file mode 100644 index 0000000..6288bf7 --- /dev/null +++ b/config.py @@ -0,0 +1,33 @@ +#!/usr/bin/python +# +# Parses the PLC configuration file /etc/planetlab/plc_config, which +# is bootstrapped by Boot Manager, but managed by us. +# +# Mark Huang +# Copyright (C) 2006 The Trustees of Princeton University +# +# $Id$ +# + +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://" + else: + uri = "http://" + + uri += self.PLC_API_HOST + \ + ":" + str(self.PLC_API_PORT) + \ + "/" + self.PLC_API_PATH + "/" + + self.plc_api_uri = uri