Commit 95625c99 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

slaptest check if section are in slapos.cfg

slapos-start exit with 0 if no slapos.cfg is found
parent b9beef3e
...@@ -7,6 +7,11 @@ IPV6WAITTIME=5 ...@@ -7,6 +7,11 @@ IPV6WAITTIME=5
SLAPOS_CONFIGURATION=/etc/opt/slapos/ SLAPOS_CONFIGURATION=/etc/opt/slapos/
if [ ! -f $SLAPOS_CONFIGURATION/slapos.cfg ]; then
echo "No slapos.cfg found"
exit 0
fi
echo "Starting slap script" echo "Starting slap script"
# Check ipv4 # Check ipv4
......
...@@ -114,24 +114,26 @@ def check_networkcache(config,logger,configuration_parser ...@@ -114,24 +114,26 @@ def check_networkcache(config,logger,configuration_parser
Check network cache download Check network cache download
""" """
section = "networkcache" section = "networkcache"
configuration_example_dict = dict(configuration_example_parser.items(section)) if configuration_parser.has_section(section) :
configuration_dict = dict(configuration_parser.items(section)) configuration_example_dict = dict(configuration_example_parser.items(section))
for key in configuration_example_dict: configuration_dict = dict(configuration_parser.items(section))
try: for key in configuration_example_dict:
if not configuration_dict[key] == configuration_example_dict[key] : try:
logger.warn("%s parameter in %s section is out of date" % (key, section)) if not configuration_dict[key] == configuration_example_dict[key] :
except KeyError: logger.warn("%s parameter in %s section is out of date" % (key, section))
logger.warn("No %s parameter in %s section" % (key,section)) except KeyError:
pass logger.warn("No %s parameter in %s section" % (key,section))
pass
if config.test_agent:
configuration_dict = dict(configuration_parser.items('slapformat')) if config.test_agent:
if int(configuration_dict['partition_amount']) < 60 : configuration_dict = dict(configuration_parser.items('slapformat'))
logger.warn("Partition amount is to low for a test agent. Is %s but should be at least 60" if int(configuration_dict['partition_amount']) < 60 :
% configuration_dict['partition_amount'] ) logger.warn("Partition amount is to low for a test agent. Is %s but should be at least 60"
% configuration_dict['partition_amount'] )
if config.check_upload == True :
check_networkcache_upload(config,logger,configuration_dict)
if config.check_upload == True :
check_networkcache_upload(config,logger,configuration_dict)
class Upload: class Upload:
""" """
...@@ -223,8 +225,19 @@ def slapos_conf_check (config): ...@@ -223,8 +225,19 @@ def slapos_conf_check (config):
configuration_example_parser = ConfigParser.RawConfigParser() configuration_example_parser = ConfigParser.RawConfigParser()
configuration_example_parser.read(slapos_cfg_example) configuration_example_parser.read(slapos_cfg_example)
os.remove(slapos_cfg_example) os.remove(slapos_cfg_example)
# Check sections
mandatory_sections = ["slapos","slapformat","networkcache"]
for section in mandatory_sections:
if not configuration_parser.has_section(section):
logger.critical("No %s section in slapos.cfg" % section)
mandatory_sections.remove(section)
if 'networkcache' in mandatory_sections:
mandatory_sections.remove('networkcache')
# Check if parameters for slapos and slapformat exists # Check if parameters for slapos and slapformat exists
for section in ("slapos","slapformat"): for section in mandatory_sections :
configuration_dict = dict(configuration_parser.items(section)) configuration_dict = dict(configuration_parser.items(section))
configuration_example_dict = dict(configuration_example_parser.items(section)) configuration_example_dict = dict(configuration_example_parser.items(section))
for key in configuration_example_dict: for key in configuration_example_dict:
...@@ -239,10 +252,10 @@ def slapos_conf_check (config): ...@@ -239,10 +252,10 @@ def slapos_conf_check (config):
% (files,key)) % (files,key))
else : else :
logger.info ("%s parameter:%s does exists" % (key,files)) logger.info ("%s parameter:%s does exists" % (key,files))
# check if computer id is the same in slapos.cfg and certificate # check if computer id is the same in slapos.cfg and certificate
if key == "cert_file": if key == "cert_file":
check_computer_id(logger,configuration_dict["computer_id"], check_computer_id(logger,configuration_dict["computer_id"],
configuration_dict["cert_file"]) configuration_dict["cert_file"])
# Check networkcache # Check networkcache
check_networkcache(config,logger,configuration_parser, check_networkcache(config,logger,configuration_parser,
configuration_example_parser) configuration_example_parser)
......
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