Commit 2e0c3e43 authored by Daniele Venzano's avatar Daniele Venzano

Add total_count, essential_count and startup_order to service descriptions

parent 0be10996
......@@ -42,7 +42,7 @@ def app_validate(data):
try:
ver = int(data["version"])
if ver != zoe_lib.version.ZOE_APPLICATION_FORMAT_VERSION:
raise InvalidApplicationDescription(msg="This version of Zoe supports only Application descriptions version {}".format(zoe_lib.version.ZOE_APPLICATION_FORMAT_VERSION))
raise InvalidApplicationDescription(msg="This version of Zoe supports only version {} for application descriptions".format(zoe_lib.version.ZOE_APPLICATION_FORMAT_VERSION))
except ValueError:
raise InvalidApplicationDescription(msg="version field should be an int")
......@@ -79,7 +79,7 @@ def app_validate(data):
def _service_check(data):
required_keys = ['name', 'docker_image', 'monitor', 'ports', 'required_resources']
required_keys = ['name', 'docker_image', 'monitor', 'ports', 'required_resources', 'total_count', 'essential_count', 'start_order']
for k in required_keys:
if k not in data:
raise InvalidApplicationDescription(msg="Missing required key: %s" % k)
......@@ -89,6 +89,21 @@ def _service_check(data):
except ValueError:
raise InvalidApplicationDescription(msg="monitor field should be a boolean")
try:
int(data['total_count'])
except ValueError:
raise InvalidApplicationDescription(msg="total_count field should be an int")
try:
int(data['essential_count'])
except ValueError:
raise InvalidApplicationDescription(msg="essential_count field should be an int")
try:
int(data['start_order'])
except ValueError:
raise InvalidApplicationDescription(msg="start_order field should be an int")
if not hasattr(data['ports'], '__iter__'):
raise InvalidApplicationDescription(msg='ports should be a list')
for pp in data['ports']:
......
ZOE_VERSION = '0.9.7-beta'
ZOE_API_VERSION = '0.6'
ZOE_APPLICATION_FORMAT_VERSION = '1'
ZOE_APPLICATION_FORMAT_VERSION = '2'
......@@ -156,6 +156,9 @@ class ServiceDescription:
self.volumes = [] # list of volumes to mount. Each volume is a three tuple: host path, container path, readonly boolean
self.networks = [] # additional networks IDs this container should be connected to
self.command = None # Commandline to pass to the Docker container
self.total_count = 1 # Total number of services of this type
self.essential_count = 1 # Number of services (out of the total_count) that are needed for the execution to start (the rest is elastic)
self.startup_order = 0 # Relative index between services to start them in the right order
def to_dict(self):
d = {
......@@ -167,7 +170,10 @@ class ServiceDescription:
'command': self.command,
'ports': [],
'volumes': [],
'networks': []
'networks': [],
'total_count': self.total_count,
'essential_count': self.essential_count,
'startup_order': self.startup_order
}
for p in self.ports:
d['ports'].append(p.to_dict())
......@@ -186,6 +192,21 @@ class ServiceDescription:
except ValueError:
raise InvalidApplicationDescription(msg="monitor field should be a boolean")
try:
self.total_count = int(data['total_count'])
except ValueError:
raise InvalidApplicationDescription(msg="total_count field should be an int")
try:
self.essential_count = int(data['essential_count'])
except ValueError:
raise InvalidApplicationDescription(msg="essential_count field should be an int")
try:
self.startup_order = int(data['start_order'])
except ValueError:
raise InvalidApplicationDescription(msg="start_order field should be an int")
if 'ports' not in data:
raise InvalidApplicationDescription(msg="Missing required key: ports")
if not hasattr(data['ports'], '__iter__'):
......
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