Implement placement constraints model
This commit is contained in:
parent
8a1b24b234
commit
f23f706825
3 changed files with 47 additions and 1 deletions
|
|
@ -121,6 +121,7 @@ class TaskDefinition(BaseObject):
|
|||
network_mode=None,
|
||||
volumes=None,
|
||||
tags=None,
|
||||
placement_constraints=None,
|
||||
):
|
||||
self.family = family
|
||||
self.revision = revision
|
||||
|
|
@ -137,6 +138,9 @@ class TaskDefinition(BaseObject):
|
|||
self.network_mode = "bridge"
|
||||
else:
|
||||
self.network_mode = network_mode
|
||||
self.placement_constraints = (
|
||||
placement_constraints if placement_constraints is not None else []
|
||||
)
|
||||
|
||||
@property
|
||||
def response_object(self):
|
||||
|
|
@ -558,7 +562,13 @@ class EC2ContainerServiceBackend(BaseBackend):
|
|||
raise Exception("{0} is not a cluster".format(cluster_name))
|
||||
|
||||
def register_task_definition(
|
||||
self, family, container_definitions, volumes=None, network_mode=None, tags=None
|
||||
self,
|
||||
family,
|
||||
container_definitions,
|
||||
volumes=None,
|
||||
network_mode=None,
|
||||
tags=None,
|
||||
placement_constraints=None,
|
||||
):
|
||||
if family in self.task_definitions:
|
||||
last_id = self._get_last_task_definition_revision_id(family)
|
||||
|
|
@ -574,6 +584,7 @@ class EC2ContainerServiceBackend(BaseBackend):
|
|||
volumes=volumes,
|
||||
network_mode=network_mode,
|
||||
tags=tags,
|
||||
placement_constraints=placement_constraints,
|
||||
)
|
||||
self.task_definitions[family][revision] = task_definition
|
||||
|
||||
|
|
|
|||
|
|
@ -63,12 +63,14 @@ class EC2ContainerServiceResponse(BaseResponse):
|
|||
volumes = self._get_param("volumes")
|
||||
tags = self._get_param("tags")
|
||||
network_mode = self._get_param("networkMode")
|
||||
placement_constraints = self._get_param("placementConstraints")
|
||||
task_definition = self.ecs_backend.register_task_definition(
|
||||
family,
|
||||
container_definitions,
|
||||
volumes=volumes,
|
||||
network_mode=network_mode,
|
||||
tags=tags,
|
||||
placement_constraints=placement_constraints,
|
||||
)
|
||||
return json.dumps({"taskDefinition": task_definition.response_object})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue