Merge pull request #1697 from spulec/ecs-tasks
Improve ECS update_service and describing tasks.
This commit is contained in:
commit
bb6da93891
3 changed files with 40 additions and 4 deletions
11
moto/ecs/exceptions.py
Normal file
11
moto/ecs/exceptions.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
from __future__ import unicode_literals
|
||||
from moto.core.exceptions import RESTError
|
||||
|
||||
|
||||
class ServiceNotFoundException(RESTError):
|
||||
code = 400
|
||||
|
||||
def __init__(self, service_name):
|
||||
super(ServiceNotFoundException, self).__init__(
|
||||
error_type="ServiceNotFoundException",
|
||||
message="The service {0} does not exist".format(service_name))
|
||||
|
|
@ -10,6 +10,8 @@ from moto.core import BaseBackend, BaseModel
|
|||
from moto.ec2 import ec2_backends
|
||||
from copy import copy
|
||||
|
||||
from .exceptions import ServiceNotFoundException
|
||||
|
||||
|
||||
class BaseObject(BaseModel):
|
||||
|
||||
|
|
@ -601,8 +603,9 @@ class EC2ContainerServiceBackend(BaseBackend):
|
|||
raise Exception("tasks cannot be empty")
|
||||
response = []
|
||||
for cluster, cluster_tasks in self.tasks.items():
|
||||
for task_id, task in cluster_tasks.items():
|
||||
if task_id in tasks or task.task_arn in tasks:
|
||||
for task_arn, task in cluster_tasks.items():
|
||||
task_id = task_arn.split("/")[-1]
|
||||
if task_arn in tasks or task.task_arn in tasks or any(task_id in task for task in tasks):
|
||||
response.append(task)
|
||||
return response
|
||||
|
||||
|
|
@ -700,8 +703,7 @@ class EC2ContainerServiceBackend(BaseBackend):
|
|||
cluster_service_pair].desired_count = desired_count
|
||||
return self.services[cluster_service_pair]
|
||||
else:
|
||||
raise Exception("cluster {0} or service {1} does not exist".format(
|
||||
cluster_name, service_name))
|
||||
raise ServiceNotFoundException(service_name)
|
||||
|
||||
def delete_service(self, cluster_name, service_name):
|
||||
cluster_service_pair = '{0}:{1}'.format(cluster_name, service_name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue