summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cluster111
-rwxr-xr-xbin/ohi47
-rw-r--r--bin/openshift_ansible/awsutil.py101
-rwxr-xr-xbin/opssh49
-rwxr-xr-xbin/oscp19
-rwxr-xr-xbin/ossh30
6 files changed, 201 insertions, 156 deletions
diff --git a/bin/cluster b/bin/cluster
index 9b02b4347..c2765ff92 100755
--- a/bin/cluster
+++ b/bin/cluster
@@ -55,94 +55,108 @@ class Cluster(object):
Create an OpenShift cluster for given provider
:param args: command line arguments provided by user
"""
- env = {'cluster_id': args.cluster_id,
+ cluster = {'cluster_id': args.cluster_id,
'deployment_type': self.get_deployment_type(args)}
playbook = "playbooks/{0}/openshift-cluster/launch.yml".format(args.provider)
inventory = self.setup_provider(args.provider)
- env['num_masters'] = args.masters
- env['num_nodes'] = args.nodes
- env['num_infra'] = args.infra
- env['num_etcd'] = args.etcd
+ cluster['num_masters'] = args.masters
+ cluster['num_nodes'] = args.nodes
+ cluster['num_infra'] = args.infra
+ cluster['num_etcd'] = args.etcd
+ cluster['cluster_env'] = args.env
- self.action(args, inventory, env, playbook)
+ self.action(args, inventory, cluster, playbook)
def addNodes(self, args):
"""
Add nodes to an existing cluster for given provider
:param args: command line arguments provided by user
"""
- env = {'cluster_id': args.cluster_id,
- 'deployment_type': self.get_deployment_type(args)}
+ cluster = {'cluster_id': args.cluster_id,
+ 'deployment_type': self.get_deployment_type(args),
+ }
playbook = "playbooks/{0}/openshift-cluster/addNodes.yml".format(args.provider)
inventory = self.setup_provider(args.provider)
- env['num_nodes'] = args.nodes
- env['num_infra'] = args.infra
+ cluster['num_nodes'] = args.nodes
+ cluster['num_infra'] = args.infra
+ cluster['cluster_env'] = args.env
- self.action(args, inventory, env, playbook)
+ self.action(args, inventory, cluster, playbook)
def terminate(self, args):
"""
Destroy OpenShift cluster
:param args: command line arguments provided by user
"""
- env = {'cluster_id': args.cluster_id,
- 'deployment_type': self.get_deployment_type(args)}
+ cluster = {'cluster_id': args.cluster_id,
+ 'deployment_type': self.get_deployment_type(args),
+ 'cluster_env': args.env,
+ }
playbook = "playbooks/{0}/openshift-cluster/terminate.yml".format(args.provider)
inventory = self.setup_provider(args.provider)
- self.action(args, inventory, env, playbook)
+ self.action(args, inventory, cluster, playbook)
def list(self, args):
"""
List VMs in cluster
:param args: command line arguments provided by user
"""
- env = {'cluster_id': args.cluster_id,
- 'deployment_type': self.get_deployment_type(args)}
+ cluster = {'cluster_id': args.cluster_id,
+ 'deployment_type': self.get_deployment_type(args),
+ 'cluster_env': args.env,
+ }
playbook = "playbooks/{0}/openshift-cluster/list.yml".format(args.provider)
inventory = self.setup_provider(args.provider)
- self.action(args, inventory, env, playbook)
+ self.action(args, inventory, cluster, playbook)
def config(self, args):
"""
Configure or reconfigure OpenShift across clustered VMs
:param args: command line arguments provided by user
"""
- env = {'cluster_id': args.cluster_id,
- 'deployment_type': self.get_deployment_type(args)}
+ cluster = {'cluster_id': args.cluster_id,
+ 'deployment_type': self.get_deployment_type(args),
+ 'cluster_env': args.env,
+ }
playbook = "playbooks/{0}/openshift-cluster/config.yml".format(args.provider)
inventory = self.setup_provider(args.provider)
- self.action(args, inventory, env, playbook)
+ self.action(args, inventory, cluster, playbook)
def update(self, args):
"""
Update to latest OpenShift across clustered VMs
:param args: command line arguments provided by user
"""
- env = {'cluster_id': args.cluster_id,
- 'deployment_type': self.get_deployment_type(args)}
+ cluster = {'cluster_id': args.cluster_id,
+ 'deployment_type': self.get_deployment_type(args),
+ 'cluster_env': args.env,
+ }
+
playbook = "playbooks/{0}/openshift-cluster/update.yml".format(args.provider)
inventory = self.setup_provider(args.provider)
- self.action(args, inventory, env, playbook)
+ self.action(args, inventory, cluster, playbook)
def service(self, args):
"""
Make the same service call across all nodes in the cluster
:param args: command line arguments provided by user
"""
- env = {'cluster_id': args.cluster_id,
- 'deployment_type': self.get_deployment_type(args),
- 'new_cluster_state': args.state}
+ cluster = {'cluster_id': args.cluster_id,
+ 'deployment_type': self.get_deployment_type(args),
+ 'new_cluster_state': args.state,
+ 'cluster_env': args.env,
+ }
playbook = "playbooks/{0}/openshift-cluster/service.yml".format(args.provider)
inventory = self.setup_provider(args.provider)
- self.action(args, inventory, env, playbook)
+ self.action(args, inventory, cluster, playbook)
def setup_provider(self, provider):
"""
@@ -152,10 +166,9 @@ class Cluster(object):
"""
config = ConfigParser.ConfigParser()
if 'gce' == provider:
- gce_ini_default_path = os.path.join(
- 'inventory/gce/hosts/gce.ini')
+ gce_ini_default_path = os.path.join('inventory/gce/hosts/gce.ini')
gce_ini_path = os.environ.get('GCE_INI_PATH', gce_ini_default_path)
- if os.path.exists(gce_ini_path):
+ if os.path.exists(gce_ini_path):
config.readfp(open(gce_ini_path))
for key in config.options('gce'):
@@ -190,12 +203,12 @@ class Cluster(object):
return inventory
- def action(self, args, inventory, env, playbook):
+ def action(self, args, inventory, cluster, playbook):
"""
Build ansible-playbook command line and execute
:param args: command line arguments provided by user
:param inventory: derived provider library
- :param env: environment variables for kubernetes
+ :param cluster: cluster variables for kubernetes
:param playbook: ansible playbook to execute
"""
@@ -206,14 +219,14 @@ class Cluster(object):
if args.option:
for opt in args.option:
k, v = opt.split('=', 1)
- env['cli_' + k] = v
+ cluster['cli_' + k] = v
- ansible_env = '-e \'{0}\''.format(
- ' '.join(['%s=%s' % (key, value) for (key, value) in env.items()])
+ ansible_extra_vars = '-e \'{0}\''.format(
+ ' '.join(['%s=%s' % (key, value) for (key, value) in cluster.items()])
)
command = 'ansible-playbook {0} {1} {2} {3}'.format(
- verbose, inventory, ansible_env, playbook
+ verbose, inventory, ansible_extra_vars, playbook
)
if args.profile:
@@ -242,7 +255,7 @@ class ActionFailed(Exception):
if __name__ == '__main__':
"""
- User command to invoke ansible playbooks in a "known" environment
+ User command to invoke ansible playbooks in a "known" configuration
Reads ~/.openshift-ansible for default configuration items
[DEFAULT]
@@ -251,7 +264,7 @@ if __name__ == '__main__':
providers = gce,aws,libvirt,openstack
"""
- environment = ConfigParser.SafeConfigParser({
+ cluster_config = ConfigParser.SafeConfigParser({
'cluster_ids': 'marketing,sales',
'validate_cluster_ids': 'False',
'providers': 'gce,aws,libvirt,openstack',
@@ -259,36 +272,36 @@ if __name__ == '__main__':
path = os.path.expanduser("~/.openshift-ansible")
if os.path.isfile(path):
- environment.read(path)
+ cluster_config.read(path)
cluster = Cluster()
parser = argparse.ArgumentParser(
- description='Python wrapper to ensure proper environment for OpenShift ansible playbooks',
+ description='Python wrapper to ensure proper configuration for OpenShift ansible playbooks',
)
parser.add_argument('-v', '--verbose', action='count',
help='Multiple -v options increase the verbosity')
parser.add_argument('--version', action='version', version='%(prog)s 0.3')
meta_parser = argparse.ArgumentParser(add_help=False)
- providers = environment.get('DEFAULT', 'providers').split(',')
+ providers = cluster_config.get('DEFAULT', 'providers').split(',')
meta_parser.add_argument('provider', choices=providers, help='provider')
- if environment.get('DEFAULT', 'validate_cluster_ids').lower() in ("yes", "true", "1"):
- meta_parser.add_argument('cluster_id', choices=environment.get('DEFAULT', 'cluster_ids').split(','),
+ if cluster_config.get('DEFAULT', 'validate_cluster_ids').lower() in ("yes", "true", "1"):
+ meta_parser.add_argument('cluster_id', choices=cluster_config.get('DEFAULT', 'cluster_ids').split(','),
help='prefix for cluster VM names')
else:
meta_parser.add_argument('cluster_id', help='prefix for cluster VM names')
meta_parser.add_argument('-t', '--deployment-type',
- choices=['origin', 'online', 'enterprise'],
+ choices=['origin', 'online', 'enterprise', 'atomic-enterprise', 'openshift-enterprise'],
help='Deployment type. (default: origin)')
- meta_parser.add_argument('-T', '--product-type',
- choices=['openshift', 'atomic-enterprise'],
- help='Product type. (default: openshift)')
meta_parser.add_argument('-o', '--option', action='append',
help='options')
+ meta_parser.add_argument('--env', default='dev', type=str,
+ help='environment for the cluster. Defaults to \'dev\'.')
+
meta_parser.add_argument('-p', '--profile', action='store_true',
help='Enable playbook profiling')
@@ -350,14 +363,14 @@ if __name__ == '__main__':
args = parser.parse_args()
if 'terminate' == args.action and not args.force:
- answer = raw_input("This will destroy the ENTIRE {0} environment. Are you sure? [y/N] ".format(args.cluster_id))
+ answer = raw_input("This will destroy the ENTIRE {0} cluster. Are you sure? [y/N] ".format(args.cluster_id))
if answer not in ['y', 'Y']:
sys.stderr.write('\nACTION [terminate] aborted by user!\n')
exit(1)
if 'update' == args.action and not args.force:
answer = raw_input(
- "This is destructive and could corrupt {0} environment. Continue? [y/N] ".format(args.cluster_id))
+ "This is destructive and could corrupt {0} cluster. Continue? [y/N] ".format(args.cluster_id))
if answer not in ['y', 'Y']:
sys.stderr.write('\nACTION [update] aborted by user!\n')
exit(1)
diff --git a/bin/ohi b/bin/ohi
index be9c53ec0..d71a4c4b1 100755
--- a/bin/ohi
+++ b/bin/ohi
@@ -48,28 +48,18 @@ class Ohi(object):
self.aws.print_host_types()
return 0
- hosts = None
- if self.args.host_type is not None and \
- self.args.env is not None:
- # Both env and host-type specified
- hosts = self.aws.get_host_list(host_type=self.args.host_type,
- envs=self.args.env,
- version=self.args.openshift_version,
- cached=self.args.cache_only)
-
- if self.args.host_type is None and \
- self.args.env is not None:
- # Only env specified
- hosts = self.aws.get_host_list(envs=self.args.env,
- version=self.args.openshift_version,
- cached=self.args.cache_only)
-
- if self.args.host_type is not None and \
- self.args.env is None:
- # Only host-type specified
- hosts = self.aws.get_host_list(host_type=self.args.host_type,
- version=self.args.openshift_version,
- cached=self.args.cache_only)
+ if self.args.v3:
+ version = '3'
+ elif self.args.all_versions:
+ version = 'all'
+ else:
+ version = '2'
+
+ hosts = self.aws.get_host_list(clusters=self.args.cluster,
+ host_type=self.args.host_type,
+ envs=self.args.env,
+ version=version,
+ cached=self.args.cache_only)
if hosts is None:
# We weren't able to determine what they wanted to do
@@ -104,19 +94,26 @@ class Ohi(object):
parser = argparse.ArgumentParser(description='OpenShift Host Inventory')
parser.add_argument('--list-host-types', default=False, action='store_true', help='List all of the host types')
+ parser.add_argument('--list', default=False, action='store_true', help='List all hosts')
- parser.add_argument('-e', '--env', action="store", help="Which environment to use")
+ parser.add_argument('-c', '--cluster', action="append", help="Which clusterid to use")
+ parser.add_argument('-e', '--env', action="append", help="Which environment to use")
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')
- parser.add_argument('-c', '--cache-only', action='store_true', default=False,
+ parser.add_argument('--cache-only', action='store_true', default=False,
help='Retrieve the host inventory by cache only. Default is false.')
- parser.add_argument('-o', '--openshift-version', action='store', default='2',
+ parser.add_argument('--v2', action='store_true', default=True,
help='Specify the openshift version. Default is 2')
+ parser.add_argument('--v3', action='store_true', default=False,
+ help='Specify the openshift version.')
+
+ parser.add_argument('--all-versions', action='store_true', default=False,
+ help='Specify the openshift version. Return all versions')
self.args = parser.parse_args()
diff --git a/bin/openshift_ansible/awsutil.py b/bin/openshift_ansible/awsutil.py
index 1ea2f914c..e03c0ab15 100644
--- a/bin/openshift_ansible/awsutil.py
+++ b/bin/openshift_ansible/awsutil.py
@@ -59,9 +59,23 @@ class AwsUtil(object):
minv.run()
return minv.result
+ def get_clusters(self):
+ """Searches for cluster tags in the inventory and returns all of the clusters found."""
+ pattern = re.compile(r'^oo_clusterid_(.*)')
+
+ clusters = []
+ inv = self.get_inventory()
+ for key in inv.keys():
+ matched = pattern.match(key)
+ if matched:
+ clusters.append(matched.group(1))
+
+ clusters.sort()
+ return clusters
+
def get_environments(self):
"""Searches for env tags in the inventory and returns all of the envs found."""
- pattern = re.compile(r'^tag_env_(.*)')
+ pattern = re.compile(r'^oo_environment_(.*)')
envs = []
inv = self.get_inventory()
@@ -75,7 +89,7 @@ class AwsUtil(object):
def get_host_types(self):
"""Searches for host-type tags in the inventory and returns all host-types found."""
- pattern = re.compile(r'^tag_host-type_(.*)')
+ pattern = re.compile(r'^oo_host-type_(.*)')
host_types = []
inv = self.get_inventory()
@@ -109,13 +123,13 @@ class AwsUtil(object):
inst_by_env = {}
for _, host in inv['_meta']['hostvars'].items():
# If you don't have an environment tag, we're going to ignore you
- if 'ec2_tag_env' not in host:
+ if 'ec2_tag_environment' not in host:
continue
- if host['ec2_tag_env'] not in inst_by_env:
- inst_by_env[host['ec2_tag_env']] = {}
+ if host['ec2_tag_environment'] not in inst_by_env:
+ inst_by_env[host['ec2_tag_environment']] = {}
host_id = "%s:%s" % (host['ec2_tag_Name'], host['ec2_id'])
- inst_by_env[host['ec2_tag_env']][host_id] = host
+ inst_by_env[host['ec2_tag_environment']][host_id] = host
return inst_by_env
@@ -154,10 +168,22 @@ class AwsUtil(object):
return host_type
@staticmethod
+ def gen_version_tag(ver):
+ """Generate the version tag
+ """
+ return "oo_version_%s" % ver
+
+ @staticmethod
+ def gen_clusterid_tag(clu):
+ """Generate the clusterid tag
+ """
+ return "tag_clusterid_%s" % clu
+
+ @staticmethod
def gen_env_tag(env):
"""Generate the environment tag
"""
- return "tag_env_%s" % env
+ return "tag_environment_%s" % env
def gen_host_type_tag(self, host_type):
"""Generate the host type tag
@@ -165,47 +191,44 @@ class AwsUtil(object):
host_type = self.resolve_host_type(host_type)
return "tag_host-type_%s" % host_type
- def gen_env_host_type_tag(self, host_type, env):
- """Generate the environment host type tag
- """
- host_type = self.resolve_host_type(host_type)
- return "tag_env-host-type_%s-%s" % (env, host_type)
-
- def get_host_list(self, host_type=None, envs=None, version=None, cached=False):
+ # This function uses all of these params to perform a filters on our host inventory.
+ # pylint: disable=too-many-arguments
+ def get_host_list(self, clusters=None, host_type=None, envs=None, version=None, cached=False):
"""Get the list of hosts from the inventory using host-type and environment
"""
retval = set([])
envs = envs or []
+
inv = self.get_inventory(cached=cached)
- # We prefer to deal with a list of environments
- if issubclass(type(envs), basestring):
- if envs == 'all':
- envs = self.get_environments()
+ retval.update(inv.get('all_hosts', []))
+
+ if clusters:
+ cluster_hosts = set([])
+ if len(clusters) > 1:
+ for cluster in clusters:
+ clu_tag = AwsUtil.gen_clusterid_tag(cluster)
+ cluster_hosts.update(inv.get(clu_tag, []))
else:
- envs = [envs]
+ cluster_hosts.update(inv.get(AwsUtil.gen_clusterid_tag(clusters[0]), []))
+
+ retval.intersection_update(cluster_hosts)
+
+ if envs:
+ env_hosts = set([])
+ if len(envs) > 1:
+ for env in envs:
+ env_tag = AwsUtil.gen_env_tag(env)
+ env_hosts.update(inv.get(env_tag, []))
+ else:
+ env_hosts.update(inv.get(AwsUtil.gen_env_tag(envs[0]), []))
+
+ retval.intersection_update(env_hosts)
- if host_type and envs:
- # Both host type and environment were specified
- for env in envs:
- retval.update(inv.get('tag_environment_%s' % env, []))
+ if host_type:
retval.intersection_update(inv.get(self.gen_host_type_tag(host_type), []))
- elif envs and not host_type:
- # Just environment was specified
- for env in envs:
- env_tag = AwsUtil.gen_env_tag(env)
- if env_tag in inv.keys():
- retval.update(inv.get(env_tag, []))
-
- elif host_type and not envs:
- # Just host-type was specified
- host_type_tag = self.gen_host_type_tag(host_type)
- if host_type_tag in inv.keys():
- retval.update(inv.get(host_type_tag, []))
-
- # If version is specified then return only hosts in that version
- if version:
- retval.intersection_update(inv.get('oo_version_%s' % version, []))
+ if version != 'all':
+ retval.intersection_update(inv.get(AwsUtil.gen_version_tag(version), []))
return retval
diff --git a/bin/opssh b/bin/opssh
index 8ac526049..3747bc993 100755
--- a/bin/opssh
+++ b/bin/opssh
@@ -13,6 +13,8 @@ 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
-t HOST_TYPE, --host-type HOST_TYPE
which host type to use
@@ -45,9 +47,9 @@ fi
# See if ohi is installed
if ! which ohi &>/dev/null ; then
- echo "ERROR: can't find ohi (OpenShift Host Inventory) on your system, please either install the openshift-ansible-bin package, or add openshift-ansible/bin to your path."
+ echo "ERROR: can't find ohi (OpenShift Host Inventory) on your system, please either install the openshift-ansible-bin package, or add openshift-ansible/bin to your path."
- exit 10
+ exit 10
fi
PAR=200
@@ -64,12 +66,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"
+ shift # get past the value of the option
+ ;;
+
--timeout)
shift # get past the option
TIMEOUT=$1
@@ -106,20 +119,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
diff --git a/bin/oscp b/bin/oscp
index c79fc8785..b15133642 100755
--- a/bin/oscp
+++ b/bin/oscp
@@ -138,7 +138,7 @@ class Oscp(object):
# attempt to select the correct environment if specified
if self.env:
- results = filter(lambda result: result[1]['ec2_tag_env'] == self.env, results)
+ results = filter(lambda result: result[1]['oo_environment'] == self.env, results)
if results:
return results
@@ -164,10 +164,8 @@ class Oscp(object):
print '{0:<35} {1}'.format(key, server_info[key])
else:
for host_id, server_info in results[:limit]:
- name = server_info['ec2_tag_Name']
- ec2_id = server_info['ec2_id']
- ip = server_info['ec2_ip_address']
- print '{ec2_tag_Name:<35} {ec2_tag_env:<8} {ec2_id:<15} {ec2_ip_address:<18} {ec2_private_ip_address}'.format(**server_info)
+ print '{oo_name:<35} {oo_clusterid:<10} {oo_environment:<8} ' \
+ '{oo_id:<15} {oo_public_ip:<18} {oo_private_ip:<18}'.format(**server_info)
if limit:
print
@@ -177,10 +175,9 @@ class Oscp(object):
else:
for env, host_ids in self.host_inventory.items():
for host_id, server_info in host_ids.items():
- name = server_info['ec2_tag_Name']
- ec2_id = server_info['ec2_id']
- ip = server_info['ec2_ip_address']
- print '{ec2_tag_Name:<35} {ec2_tag_env:<8} {ec2_id:<15} {ec2_ip_address:<18} {ec2_private_ip_address}'.format(**server_info)
+ print '{oo_name:<35} {oo_clusterid:<10} {oo_environment:<8} ' \
+ '{oo_id:<15} {oo_public_ip:<18} {oo_private_ip:<18}'.format(**server_info)
+
def scp(self):
'''scp files to or from a specified host
@@ -209,12 +206,12 @@ class Oscp(object):
if len(results) > 1:
print "Multiple results found for %s." % self.host
for result in results:
- print "{ec2_tag_Name:<35} {ec2_tag_env:<5} {ec2_id:<10}".format(**result[1])
+ print "{oo_name:<35} {oo_clusterid:<5} {oo_environment:<5} {oo_id:<10}".format(**result[1])
return # early exit, too many results
# Assume we have one and only one.
hostname, server_info = results[0]
- dns = server_info['ec2_public_dns_name']
+ dns = server_info['oo_pulic_ip']
host_str = "%s%s%s" % (self.user, dns, self.path)
diff --git a/bin/ossh b/bin/ossh
index 50fa996c3..6519e4e08 100755
--- a/bin/ossh
+++ b/bin/ossh
@@ -55,15 +55,15 @@ class Ossh(object):
def parse_cli_args(self):
parser = argparse.ArgumentParser(description='OpenShift Online SSH Tool.')
parser.add_argument('-e', '--env', action="store",
- help="Which environment to search for the host ")
+ help="Which environment to search for the host ")
parser.add_argument('-d', '--debug', default=False,
- action="store_true", help="debug mode")
+ action="store_true", help="debug mode")
parser.add_argument('-v', '--verbose', default=False,
- action="store_true", help="Verbose?")
+ action="store_true", help="Verbose?")
parser.add_argument('--refresh-cache', default=False,
- action="store_true", help="Force a refresh on the host cache.")
+ action="store_true", help="Force a refresh on the host cache.")
parser.add_argument('--list', default=False,
- action="store_true", help="list out hosts")
+ action="store_true", help="list out hosts")
parser.add_argument('-c', '--command', action='store',
help='Command to run on remote host')
parser.add_argument('-l', '--login_name', action='store',
@@ -127,7 +127,7 @@ class Ossh(object):
# attempt to select the correct environment if specified
if self.env:
- results = filter(lambda result: result[1]['ec2_tag_env'] == self.env, results)
+ results = filter(lambda result: result[1]['oo_environment'] == self.env, results)
if results:
return results
@@ -153,10 +153,8 @@ class Ossh(object):
print '{0:<35} {1}'.format(key, server_info[key])
else:
for host_id, server_info in results[:limit]:
- name = server_info['ec2_tag_Name']
- ec2_id = server_info['ec2_id']
- ip = server_info['ec2_ip_address']
- print '{ec2_tag_Name:<35} {ec2_tag_env:<8} {ec2_id:<15} {ec2_ip_address:<18} {ec2_private_ip_address}'.format(**server_info)
+ print '{oo_name:<35} {oo_clusterid:<10} {oo_environment:<8} ' \
+ '{oo_id:<15} {oo_public_ip:<18} {oo_private_ip:<18}'.format(**server_info)
if limit:
print
@@ -166,10 +164,8 @@ class Ossh(object):
else:
for env, host_ids in self.host_inventory.items():
for host_id, server_info in host_ids.items():
- name = server_info['ec2_tag_Name']
- ec2_id = server_info['ec2_id']
- ip = server_info['ec2_ip_address']
- print '{ec2_tag_Name:<35} {ec2_tag_env:<8} {ec2_id:<15} {ec2_ip_address:<18} {ec2_private_ip_address}'.format(**server_info)
+ print '{oo_name:<35} {oo_clusterid:<10} {oo_environment:<8} ' \
+ '{oo_id:<15} {oo_public_ip:<18} {oo_private_ip:<18}'.format(**server_info)
def ssh(self):
'''SSH to a specified host
@@ -195,12 +191,12 @@ class Ossh(object):
if len(results) > 1:
print "Multiple results found for %s." % self.host
for result in results:
- print "{ec2_tag_Name:<35} {ec2_tag_env:<5} {ec2_id:<10}".format(**result[1])
+ print "{oo_name:<35} {oo_clusterid:<5} {oo_environment:<5} {oo_id:<10}".format(**result[1])
return # early exit, too many results
# Assume we have one and only one.
- hostname, server_info = results[0]
- dns = server_info['ec2_public_dns_name']
+ _, server_info = results[0]
+ dns = server_info['oo_public_ip']
ssh_args.append(dns)