add method describe_clusters for service ecs
This commit is contained in:
parent
ac4ce7d53f
commit
f89721328a
@ -117,6 +117,20 @@ class EC2ContainerServiceBackend(BaseBackend):
|
|||||||
"""
|
"""
|
||||||
return [cluster.arn for cluster in self.clusters.values()]
|
return [cluster.arn for cluster in self.clusters.values()]
|
||||||
|
|
||||||
|
def describe_clusters(self, list_clusters_name=None):
|
||||||
|
list_clusters = []
|
||||||
|
if list_clusters_name is None:
|
||||||
|
if 'default' in self.clusters:
|
||||||
|
list_clusters.append(self.clusters['default'].response_object)
|
||||||
|
else:
|
||||||
|
for cluster in list_clusters_name:
|
||||||
|
cluster_name = cluster.split('/')[-1]
|
||||||
|
if cluster_name in self.clusters:
|
||||||
|
list_clusters.append(self.clusters[cluster_name].response_object)
|
||||||
|
else:
|
||||||
|
raise Exception("{0} is not a cluster".format(cluster_name))
|
||||||
|
return list_clusters
|
||||||
|
|
||||||
def delete_cluster(self, cluster_str):
|
def delete_cluster(self, cluster_str):
|
||||||
cluster_name = cluster_str.split('/')[-1]
|
cluster_name = cluster_str.split('/')[-1]
|
||||||
if cluster_name in self.clusters:
|
if cluster_name in self.clusters:
|
||||||
|
@ -35,6 +35,14 @@ class EC2ContainerServiceResponse(BaseResponse):
|
|||||||
'nextToken': str(uuid.uuid1())
|
'nextToken': str(uuid.uuid1())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def describe_clusters(self):
|
||||||
|
list_clusters_name = self._get_param('clusters')
|
||||||
|
clusters = self.ecs_backend.describe_clusters(list_clusters_name)
|
||||||
|
return json.dumps({
|
||||||
|
'clusters': clusters,
|
||||||
|
'failures': []
|
||||||
|
})
|
||||||
|
|
||||||
def delete_cluster(self):
|
def delete_cluster(self):
|
||||||
cluster_str = self._get_param('cluster')
|
cluster_str = self._get_param('cluster')
|
||||||
cluster = self.ecs_backend.delete_cluster(cluster_str)
|
cluster = self.ecs_backend.delete_cluster(cluster_str)
|
||||||
|
Loading…
Reference in New Issue
Block a user