Add proper failure response to describe_clusters
This commit is contained in:
parent
79e47fd98f
commit
d181897ec9
3 changed files with 29 additions and 3 deletions
|
|
@ -358,6 +358,20 @@ class ContainerInstance(BaseObject):
|
|||
return formatted_attr
|
||||
|
||||
|
||||
class ClusterFailure(BaseObject):
|
||||
def __init__(self, reason, cluster_name):
|
||||
self.reason = reason
|
||||
self.arn = "arn:aws:ecs:us-east-1:012345678910:cluster/{0}".format(
|
||||
cluster_name)
|
||||
|
||||
@property
|
||||
def response_object(self):
|
||||
response_object = self.gen_response_object()
|
||||
response_object['reason'] = self.reason
|
||||
response_object['arn'] = self.arn
|
||||
return response_object
|
||||
|
||||
|
||||
class ContainerInstanceFailure(BaseObject):
|
||||
|
||||
def __init__(self, reason, container_instance_id):
|
||||
|
|
@ -419,6 +433,7 @@ class EC2ContainerServiceBackend(BaseBackend):
|
|||
|
||||
def describe_clusters(self, list_clusters_name=None):
|
||||
list_clusters = []
|
||||
failures = []
|
||||
if list_clusters_name is None:
|
||||
if 'default' in self.clusters:
|
||||
list_clusters.append(self.clusters['default'].response_object)
|
||||
|
|
@ -428,7 +443,9 @@ class EC2ContainerServiceBackend(BaseBackend):
|
|||
if cluster_name in self.clusters:
|
||||
list_clusters.append(
|
||||
self.clusters[cluster_name].response_object)
|
||||
return list_clusters
|
||||
else:
|
||||
failures.append(ClusterFailure('MISSING', cluster_name))
|
||||
return list_clusters, failures
|
||||
|
||||
def delete_cluster(self, cluster_str):
|
||||
cluster_name = cluster_str.split('/')[-1]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue