Skip to content

Commit

Permalink
Merge pull request #1 from dajohnso/tweak_ec2
Browse files Browse the repository at this point in the history
add option for termintated instances
  • Loading branch information
dajohnso committed Nov 1, 2015
2 parents 951e5ca + 3d46e72 commit 944652f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mgmtsystem/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@ def info(self):
"""Returns the current versions of boto and the EC2 API being used"""
return '%s %s' % (boto.UserAgent, self.api.APIVersion)

def list_vm(self):
def list_vm(self, include_terminated=True):
"""Returns a list from instance IDs currently active on EC2 (not terminated)"""
instances = [inst for inst in self._get_all_instances() if inst.state != 'terminated']
instances = None
if include_terminated:
instances = [inst for inst in self._get_all_instances() if inst.state != 'terminated']
else:
instances = [inst for inst in self._get_all_instances()]
return [i.tags.get('Name', i.id) for i in instances]

def list_template(self):
Expand Down

0 comments on commit 944652f

Please sign in to comment.