mirror of https://github.com/apache/cloudstack.git
Ignore comments in config files during loading
This commit is contained in:
parent
f72146e96f
commit
038608b54f
|
|
@ -632,18 +632,26 @@ def get_setup_config(file):
|
|||
if not os.path.exists(file):
|
||||
raise IOError("config file %s not found. please specify a valid config file"%file)
|
||||
config = cloudstackConfiguration()
|
||||
fp = open(file, 'r')
|
||||
config = json.load(fp)
|
||||
configLines = []
|
||||
with open(file, 'r') as fp:
|
||||
for line in fp:
|
||||
ws = line.strip()
|
||||
if not ws.startswith("#"):
|
||||
configLines.append(ws)
|
||||
config = json.loads("\n".join(configLines))
|
||||
return jsonHelper.jsonLoader(config)
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = OptionParser()
|
||||
|
||||
parser.add_option("-i", "--input", action="store", default=None , dest="inputfile", help="input file")
|
||||
parser.add_option("-a", "--advanced", action="store_true", default=False, dest="advanced", help="use advanced networking")
|
||||
parser.add_option("-o", "--output", action="store", default="./datacenterCfg", dest="output", help="the path where the json config file generated, by default is ./datacenterCfg")
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if options.inputfile:
|
||||
config = get_setup_config(options.inputfile)
|
||||
if options.advanced:
|
||||
config = describe_setup_in_advanced_mode()
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ class deployDataCenters():
|
|||
dev.physicalnetworkid = phynetwrk.id
|
||||
self.apiClient.addF5LoadBalancer(dev)
|
||||
else:
|
||||
print "Device %s doesn't match any know provider type"%device
|
||||
raise cloudstackException.InvalidParameterException("Device %s doesn't match any know provider type"%device)
|
||||
self.enableProvider(result.id)
|
||||
|
||||
def addTrafficTypes(self, physical_network_id, traffictypes):
|
||||
|
|
@ -348,7 +348,7 @@ class deployDataCenters():
|
|||
self.config = configGenerator.get_setup_config(self.configFile)
|
||||
except:
|
||||
raise cloudstackException.InvalidParameterException( \
|
||||
"Failed to load config %s" %sys.exc_info())
|
||||
"Failed to load config %s"%self.configFile)
|
||||
|
||||
mgt = self.config.mgtSvr[0]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue