Fix issue when running multiple project containing IOU nodes on the same server. Ref #1239.

This commit is contained in:
grossmj committed 2018-01-31 15:51:29 +07:00
1 parent 1045364adc
commit e5c76750b1
5 files changed
+38 -70

No files matched your search

@@ -24,13 +24,14 @@ log = logging.getLogger(__name__)
def get_next_application_id(nodes):
"""
Calculates free application_id from given nodes
:param nodes:
:raises IOUError when exceeds number
:return: integer first free id
"""
used = set([n.properties.get('application_id') for n in nodes if n.node_type == 'iou'])
used = set([n.application_id for n in nodes])
pool = set(range(1, 512))
try:
return (pool - used).pop()
except KeyError:
raise IOUError("Cannot create a new IOU VM (limit of 512 VMs reached)")
raise IOUError("Cannot create a new IOU VM (limit of 512 VMs on one host reached)")