Each iteration (each partition) of main CP loop has sanity checks and makes...

Each iteration (each partition) of main CP loop has sanity checks and makes sure nothing raises outside.
parent df0c78f6
...@@ -610,7 +610,6 @@ class Slapgrid(object): ...@@ -610,7 +610,6 @@ class Slapgrid(object):
if not promise_present: if not promise_present:
self.logger.info("No promise.") self.logger.info("No promise.")
def processComputerPartitionList(self): def processComputerPartitionList(self):
""" """
Will start supervisord and process each Computer Partition. Will start supervisord and process each Computer Partition.
...@@ -623,18 +622,32 @@ class Slapgrid(object): ...@@ -623,18 +622,32 @@ class Slapgrid(object):
# Process Computer Partitions # Process Computer Partitions
clean_run = True clean_run = True
for computer_partition in self.getComputerPartitionList(): for computer_partition in self.getComputerPartitionList():
# Nothing should raise outside of the current loop iteration, so that
# even if something is terribly wrong while processing an instance, it
# won't prevent processing other ones.
try: try:
computer_partition_id = computer_partition.getId() # If id or URL is not defined, then it is an empty partition.
try: try:
software_url = computer_partition.getSoftwareRelease().getURI() computer_partition.getId()
computer_partition.getSoftwareRelease().getURI()
# XXX should test status as well. But getState() returns default # XXX should test status as well. But getState() returns default
# value. # value.
except NotFoundError: except NotFoundError:
# No Software Release information: skip. # No Software Release information: skip.
continue continue
logger.info('Processing Computer Partition %s...' % \ # Process the partition itself
computer_partition_id) computer_partition_id = computer_partition.getId()
software_url = computer_partition.getSoftwareRelease().getURI()
logger.info('Processing Computer Partition %s...' % computer_partition_id)
# Sanity checks before processing
# Those values should not be None or empty string or any falsy value
if not computer_partition_id:
raise ValueError('Computer Partition id is empty.')
if not software_url:
raise ValueError('Software Release URL of Computer Partition is empty.')
# Check if we defined explicit list of partitions to process. # Check if we defined explicit list of partitions to process.
# If so, if current partition not in this list, skip. # If so, if current partition not in this list, skip.
...@@ -732,6 +745,8 @@ class Slapgrid(object): ...@@ -732,6 +745,8 @@ class Slapgrid(object):
if timestamp: if timestamp:
timestamp_path = os.path.join(instance_path, '.timestamp') timestamp_path = os.path.join(instance_path, '.timestamp')
open(timestamp_path, 'w').write(timestamp) open(timestamp_path, 'w').write(timestamp)
except (SystemExit, KeyboardInterrupt): except (SystemExit, KeyboardInterrupt):
exception = traceback.format_exc() exception = traceback.format_exc()
computer_partition.error(exception) computer_partition.error(exception)
...@@ -748,10 +763,10 @@ class Slapgrid(object): ...@@ -748,10 +763,10 @@ class Slapgrid(object):
logger.error('Problem during reporting error, continuing:\n' + logger.error('Problem during reporting error, continuing:\n' +
exception) exception)
logger.info("Finished computer partitions...") logger.info("Finished computer partitions...")
return clean_run return clean_run
def validateXML(self, to_be_validated, xsd_model): def validateXML(self, to_be_validated, xsd_model):
"""Validates a given xml file""" """Validates a given xml file"""
......
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