Skip to content

Commit

Permalink
Merge pull request boto#870 from jijojv/develop
Browse files Browse the repository at this point in the history
fix boto#869 in boto/boto for tab delimiter output in list_instances
  • Loading branch information
garnaat committed Jul 23, 2012
2 parents c084c15 + 8dc8d20 commit 24a9e35
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions bin/list_instances
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def main():
parser = OptionParser()
parser.add_option("-r", "--region", help="Region (default us-east-1)", dest="region", default="us-east-1")
parser.add_option("-H", "--headers", help="Set headers (use 'T:tagname' for including tags)", default=None, action="store", dest="headers", metavar="ID,Zone,Groups,Hostname,State,T:Name")
parser.add_option("-t", "--tab", help="Tab delimited, skip header - useful in shell scripts", action="store_true", default=False)
(options, args) = parser.parse_args()

# Connect the region
Expand Down Expand Up @@ -61,13 +62,20 @@ def main():


# List and print
print format_string % headers
print "-" * len(format_string % headers)

if not options.tab:
print format_string % headers
print "-" * len(format_string % headers)

for r in ec2.get_all_instances():
groups = [g.name for g in r.groups]
for i in r.instances:
i.groups = ','.join(groups)
print format_string % tuple(get_column(h, i) for h in headers)
if options.tab:
print "\t".join(tuple(get_column(h, i) for h in headers))
else:
print format_string % tuple(get_column(h, i) for h in headers)


if __name__ == "__main__":
main()

0 comments on commit 24a9e35

Please sign in to comment.