From dad421c863006f9774f2fed9fc32f3de8f871af6 Mon Sep 17 00:00:00 2001 From: Thomas Wiest Date: Fri, 1 May 2015 16:58:41 -0400 Subject: Added utils.py that contains a normalize_dnsname function good for sorting dns names to a human readable list. --- bin/ohi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bin/ohi') diff --git a/bin/ohi b/bin/ohi index 408961ee4..af1fb8068 100755 --- a/bin/ohi +++ b/bin/ohi @@ -12,12 +12,15 @@ import subprocess import ConfigParser from openshift_ansible import awsutil +from openshift_ansible import utils from openshift_ansible.awsutil import ArgumentError CONFIG_MAIN_SECTION = 'main' CONFIG_HOST_TYPE_ALIAS_SECTION = 'host_type_aliases' CONFIG_INVENTORY_OPTION = 'inventory' + + class Ohi(object): def __init__(self): self.inventory = None @@ -60,7 +63,7 @@ class Ohi(object): # We weren't able to determine what they wanted to do raise ArgumentError("Invalid combination of arguments") - for host in hosts: + for host in sorted(hosts, key=utils.normalize_dnsname): print host return 0 -- cgit v1.2.3 From e12c6a4ce54959dd073741a8c77ab4f55c739baa Mon Sep 17 00:00:00 2001 From: Thomas Wiest Date: Fri, 1 May 2015 17:23:02 -0400 Subject: Added --user option to ohi to pre-pend the username in the hostlist output. --- bin/ohi | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'bin/ohi') diff --git a/bin/ohi b/bin/ohi index af1fb8068..bb52166df 100755 --- a/bin/ohi +++ b/bin/ohi @@ -64,7 +64,11 @@ class Ohi(object): raise ArgumentError("Invalid combination of arguments") for host in sorted(hosts, key=utils.normalize_dnsname): - print host + if self.args.user: + print "%s@%s" % (self.args.user, host) + else: + print host + return 0 def parse_config_file(self): @@ -97,6 +101,10 @@ class Ohi(object): parser.add_argument('-t', '--host-type', action="store", help="Which host type to use") + parser.add_argument('-l', '--user', action='store', default=None, + help='username') + + self.args = parser.parse_args() -- cgit v1.2.3