diff --git a/License2Deploy/rolling_deploy.py b/License2Deploy/rolling_deploy.py index 93c5d55..1245e4c 100644 --- a/License2Deploy/rolling_deploy.py +++ b/License2Deploy/rolling_deploy.py @@ -165,6 +165,8 @@ def get_instance_ip_addrs(self, id_list=[]): def get_all_instance_ids(self, group_name): """ Gather Instance id's of all instances in the autoscale group """ instances = [i for i in self.get_group_info(group_name)[0].instances] + if len(instances) == 0: + raise Exception("There are no instances in this AutoScalingGroup, please check AutoScalingGroup desired capacity.") id_list = [instance_id.instance_id for instance_id in instances] return id_list diff --git a/setup.py b/setup.py index ee83bef..15061c3 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ def read(fname): setup( name="License2Deploy", - version="0.3.2", + version="0.3.3", author="Dun and Bradstreet", author_email="license2deploy@dandb.com", description="Rolling deploys by changing desired amount of instances AWS EC2 Autoscale Group", diff --git a/tests/rolling_deploy_test.py b/tests/rolling_deploy_test.py index e71a6fd..abe5beb 100644 --- a/tests/rolling_deploy_test.py +++ b/tests/rolling_deploy_test.py @@ -301,6 +301,14 @@ def test_get_all_instance_ids(self): rslt = self.rolling_deploy.get_all_instance_ids(self.GMS_AUTOSCALING_GROUP_STG) self.assertEqual(len(instance_ids), len(rslt)) + @mock_ec2_deprecated + @mock_autoscaling_deprecated + @mock_elb_deprecated + def test_failure_get_all_instance_ids(self): + self.setUpAutoScaleGroup([self.get_autoscaling_configurations(self.GMS_LAUNCH_CONFIGURATION_STG, self.GMS_AUTOSCALING_GROUP_STG)]) + self.assertRaises(SystemExit, lambda: self.rolling_deploy.get_all_instance_ids('cool')) + + @mock_ec2_deprecated @mock_autoscaling_deprecated def test_get_instance_ids_by_requested_build_tag(self):