diff options
| author | Kenny Woodson <kwoodson@redhat.com> | 2016-01-29 15:37:16 -0500 | 
|---|---|---|
| committer | Kenny Woodson <kwoodson@redhat.com> | 2016-01-29 16:17:16 -0500 | 
| commit | 303305a3789d65e026db01f318647a036ddfa5ef (patch) | |
| tree | 75bcbb033a873882dffc01a8d96d3bf8af65d84c | |
| parent | 7345fcf2a00e3011599b2b04a42b99ae707e7484 (diff) | |
Adding ip address option
| -rwxr-xr-x | bin/ohi | 6 | ||||
| -rw-r--r-- | bin/openshift_ansible/awsutil.py | 12 | ||||
| -rwxr-xr-x | bin/opscp | 46 | ||||
| -rwxr-xr-x | bin/opssh | 4 | 
4 files changed, 52 insertions, 16 deletions
| @@ -65,6 +65,9 @@ class Ohi(object):              # We weren't able to determine what they wanted to do              raise ArgumentError("Invalid combination of arguments") +        if self.args.ip: +            hosts = self.aws.convert_to_ip(hosts) +          for host in sorted(hosts, key=utils.normalize_dnsname):              if self.args.user:                  print "%s@%s" % (self.args.user, host) @@ -112,6 +115,9 @@ class Ohi(object):          parser.add_argument('--v3', action='store_true', default=False,                              help='Specify the openshift version.') +        parser.add_argument('--ip', action='store_true', default=False, +                            help='Return ip address only.') +          parser.add_argument('--all-versions', action='store_true', default=False,                              help='Specify the openshift version. Return all versions') diff --git a/bin/openshift_ansible/awsutil.py b/bin/openshift_ansible/awsutil.py index 3639ef733..945e6a20c 100644 --- a/bin/openshift_ansible/awsutil.py +++ b/bin/openshift_ansible/awsutil.py @@ -232,4 +232,14 @@ class AwsUtil(object):          if version != 'all':              retval.intersection_update(inv.get(AwsUtil.gen_version_tag(version), [])) -        return retval +        return list(retval) + +    def convert_to_ip(self, hosts, cached=False): +        """convert a list of host names to ip addresses""" + +        inv = self.get_inventory(cached=cached) +        ips = [] +        for host in hosts: +            ips.append(inv['_meta']['hostvars'][host]['oo_public_ip']) + +        return ips @@ -13,7 +13,10 @@ Options:    -p PAR, --par=PAR     max number of parallel threads (OPTIONAL)    --outdir=OUTDIR       output directory for stdout files (OPTIONAL)    --errdir=ERRDIR       output directory for stderr files (OPTIONAL) +  -c CLUSTER, --cluster CLUSTER +                        which cluster to use    -e ENV, --env ENV     which environment to use +  --v3                  When working with v3 environments.  v2 by default    -t HOST_TYPE, --host-type HOST_TYPE                          which host type to use    --list-host-types     list all of the host types @@ -61,12 +64,23 @@ while [ $# -gt 0 ] ; do              shift # get past the value of the option              ;; +        -c) +            shift # get past the option +            CLUSTER=$1 +            shift # get past the value of the option +            ;; +          -e)              shift # get past the option              ENV=$1              shift # get past the value of the option              ;; +        --v3) +            OPENSHIFT_VERSION="--v3 --ip" +            shift # get past the value of the option +            ;; +          --timeout)              shift # get past the option              TIMEOUT=$1 @@ -103,20 +117,26 @@ while [ $# -gt 0 ] ; do  done  # Get host list from ohi -if [ -n "$ENV" -a -n "$HOST_TYPE" ] ; then -    HOSTS="$(ohi -t "$HOST_TYPE" -e "$ENV" 2>/dev/null)" -    OHI_ECODE=$? -elif [ -n "$ENV" ] ; then -    HOSTS="$(ohi -e "$ENV" 2>/dev/null)" -    OHI_ECODE=$? -elif [ -n "$HOST_TYPE" ] ; then -    HOSTS="$(ohi -t "$HOST_TYPE" 2>/dev/null)" +CMD="" +if [ -n "$CLUSTER" ] ; then +  CMD="$CMD -c $CLUSTER" +fi + +if [ -n "$ENV" ] ; then +  CMD="$CMD -e $ENV" +fi + +if [ -n "$HOST_TYPE" ] ; then +  CMD="$CMD -t $HOST_TYPE" +fi + +if [ -n "$OPENSHIFT_VERSION" ] ; then +  CMD="$CMD $OPENSHIFT_VERSION" +fi + +if [ -n "$CMD" ] ; then +    HOSTS="$(ohi $CMD 2>/dev/null)"      OHI_ECODE=$? -else -    echo -    echo "Error: either -e or -t must be specified" -    echo -    exit 10  fi  if [ $OHI_ECODE -ne 0 ] ; then @@ -56,9 +56,9 @@ fi  PAR=200  USER=root  TIMEOUT=0 -ARGS=()  ENV=""  HOST_TYPE="" +  while [ $# -gt 0 ] ; do      case $1 in          -t|--host-type) @@ -80,7 +80,7 @@ while [ $# -gt 0 ] ; do              ;;          --v3) -            OPENSHIFT_VERSION="--v3" +            OPENSHIFT_VERSION="--v3 --ip"              shift # get past the value of the option              ;; | 
