From b652256c43d2b046348d93428f0d9677dd6f0152 Mon Sep 17 00:00:00 2001 From: "Riccardo M. Cefala" Date: Tue, 14 Jun 2016 17:58:49 +0200 Subject: [PATCH] simplify cluster existence check in register_container_instance --- moto/ecs/models.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/moto/ecs/models.py b/moto/ecs/models.py index 30d7c21e3..293880242 100644 --- a/moto/ecs/models.py +++ b/moto/ecs/models.py @@ -251,10 +251,8 @@ class EC2ContainerServiceBackend(BaseBackend): def register_container_instance(self, cluster_str, ec2_instance_id): cluster_name = cluster_str.split('/')[-1] - if cluster_name in self.clusters: - cluster = self.clusters[cluster_name] - else: - raise Exception("{0} is not a cluster".format(cluster.name)) + if cluster_name not in self.clusters: + raise Exception("{0} is not a cluster".format(cluster_name)) container_instance = ContainerInstance(ec2_instance_id) if not self.container_instances.get(cluster_name): self.container_instances[cluster_name] = {}