Add support for [slapconsole] config part and aliases (you have variables kvm,...

Add support for [slapconsole] config part and aliases (you have variables kvm, mysql, etc, defined from config
parent 068cbe88
...@@ -76,11 +76,13 @@ class Config: ...@@ -76,11 +76,13 @@ class Config:
configuration_parser = ConfigParser.SafeConfigParser() configuration_parser = ConfigParser.SafeConfigParser()
configuration_parser.read(configuration_file_path) configuration_parser.read(configuration_file_path)
# Merges the arguments and configuration # Merges the arguments and configuration
for section in ("slapos",): for section in ("slapconsole",):
configuration_dict = dict(configuration_parser.items(section)) configuration_dict = dict(configuration_parser.items(section))
for key in configuration_dict: for key in configuration_dict:
if not getattr(self, key, None): if not getattr(self, key, None):
setattr(self, key, configuration_dict[key]) setattr(self, key, configuration_dict[key])
configuration_dict = dict(configuration_parser.items('slapos'))
setattr(self, 'master_url', configuration_dict['master_url'])
if not self.master_url: if not self.master_url:
raise ValueError('master-url is required.') raise ValueError('master-url is required.')
...@@ -96,6 +98,11 @@ def run(): ...@@ -96,6 +98,11 @@ def run():
key_file=config.key_file, cert_file=config.cert_file) key_file=config.key_file, cert_file=config.cert_file)
local = globals() local = globals()
local['slap'] = slap local['slap'] = slap
alias = config.alias.split('\n')
for software in alias:
if software is not '':
name, url = software.split(' ')
local[name] = url
# XXX-Cedric Maybe we should generate a new OpenOrder for each request? # XXX-Cedric Maybe we should generate a new OpenOrder for each request?
local['request'] = slap.registerOpenOrder().request local['request'] = slap.registerOpenOrder().request
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment