Commit f36665b6 authored by Daniele Venzano's avatar Daniele Venzano

Manage application descriptions in the old format in the database (happens after DB schema upgrade)

parent 2038e012
...@@ -65,7 +65,10 @@ class Execution: ...@@ -65,7 +65,10 @@ class Execution:
self._status = d['status'] self._status = d['status']
self.error_message = d['error_message'] self.error_message = d['error_message']
self.size = self.description['size'] try:
self.size = self.description['size']
except KeyError:
self.size = self.description['priority'] # zapp format v2
self.termination_lock = threading.Lock() self.termination_lock = threading.Lock()
......
...@@ -31,6 +31,9 @@ class ResourceLimits: ...@@ -31,6 +31,9 @@ class ResourceLimits:
elif isinstance(data, ResourceLimits): elif isinstance(data, ResourceLimits):
self.min = data.min self.min = data.min
self.max = data.max self.max = data.max
elif isinstance(data, int):
self.min = data
self.max = data
else: else:
raise TypeError raise TypeError
self.unit = unit self.unit = unit
...@@ -113,14 +116,40 @@ class Service: ...@@ -113,14 +116,40 @@ class Service:
self.essential = d['essential'] self.essential = d['essential']
# Fields parsed from the JSON description # Fields parsed from the JSON description
self.image_name = self.description['image'] try:
self.image_name = self.description['image']
except KeyError:
self.image_name = self.description['docker_image'] # zapp description v2
self.is_monitor = self.description['monitor'] self.is_monitor = self.description['monitor']
self.startup_order = self.description['startup_order'] self.startup_order = self.description['startup_order']
self.environment = self.description['environment']
self.command = self.description['command'] try:
self.resource_reservation = ResourceReservation(self.description['resources']) self.environment = self.description['environment']
self.volumes = [VolumeDescriptionHostPath(v['path'], v['name'], v['read_only']) for v in self.description['volumes']] except KeyError:
self.replicas = self.description['replicas'] self.environment = []
try:
self.command = self.description['command']
except KeyError:
self.command = None
try:
self.resource_reservation = ResourceReservation(self.description['resources'])
except KeyError:
self.resource_reservation = ResourceReservation({'memory': self.description['required_resources']['memory'], 'cores': 0}) # ZApp description v2
try:
self.volumes = [VolumeDescriptionHostPath(v['path'], v['name'], v['read_only']) for v in self.description['volumes']]
except KeyError:
self.volumes = []
except TypeError:
self.volumes = [VolumeDescriptionHostPath(v[0], v[1], v[2]) for v in self.description['volumes']]
try:
self.replicas = self.description['replicas']
except KeyError:
self.replicas = 0
def serialize(self): def serialize(self):
"""Generates a dictionary that can be serialized in JSON.""" """Generates a dictionary that can be serialized in JSON."""
...@@ -186,7 +215,7 @@ class Service: ...@@ -186,7 +215,7 @@ class Service:
@property @property
def user_id(self): def user_id(self):
"""Getter for the user_id, that is actually taken form the parent execution.""" """Getter for the user_id, that is actually taken from the parent execution."""
execution = self.sql_manager.execution_list(only_one=True, id=self.execution_id) execution = self.sql_manager.execution_list(only_one=True, id=self.execution_id)
return execution.user_id return execution.user_id
......
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