Skip to content

Commit

Permalink
Merge pull request newsapps#193 from FliesLikeABrick/hotfix/fix-beesw…
Browse files Browse the repository at this point in the history
…ithmachineguns-issue-76

Fixes newsapps/beeswithmachineguns issue newsapps#76 - allows adding instances
  • Loading branch information
cosmin committed Nov 16, 2017
2 parents 798ed6a + 50673df commit 49dab15
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions beeswithmachineguns/bees.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def up(count, group, zone, image_id, instance_type, username, key_name, subnet,
if existing_username == username and existing_key_name == key_name and existing_zone == zone:
ec2_connection = boto.ec2.connect_to_region(_get_region(zone))
existing_reservations = ec2_connection.get_all_instances(instance_ids=instance_ids)
existing_instances = [i for i in [r.instances[0] for r in existing_reservations] if i.state == 'running']
existing_instances = [instance for reservation in existing_reservations for instance in reservation.instances if instance.state == 'running']
# User, key and zone match existing values and instance ids are found on state file
if count <= len(existing_instances):
# Count is less than the amount of existing instances. No need to create new ones.
Expand Down Expand Up @@ -223,7 +223,7 @@ def up(count, group, zone, image_id, instance_type, username, key_name, subnet,

if instance_ids:
existing_reservations = ec2_connection.get_all_instances(instance_ids=instance_ids)
existing_instances = [i for i in [r.instances[0] for r in existing_reservations] if i.state == 'running']
existing_instances = [instance for reservation in existing_reservations for instance in reservation.instances if instance.state == 'running']
list(map(instances.append, existing_instances))
dead_instances = [i for i in instance_ids if i not in [j.id for j in existing_instances]]
list(map(instance_ids.pop, [instance_ids.index(i) for i in dead_instances]))
Expand Down

0 comments on commit 49dab15

Please sign in to comment.