summaryrefslogtreecommitdiffstats
path: root/bin/opssh
diff options
context:
space:
mode:
authorThomas Wiest <twiest@redhat.com>2015-03-30 11:25:03 -0400
committerThomas Wiest <twiest@redhat.com>2015-03-30 14:40:44 -0400
commitb1b462f4db3ce1a26cfc251895d5f8fe2e15c484 (patch)
tree4e1dd8346126e37bd79e69e37fcf1f5683a5d002 /bin/opssh
parent78a45fc50509eca27164452325529cc46a99cc8c (diff)
downloadopenshift-b1b462f4db3ce1a26cfc251895d5f8fe2e15c484.tar.gz
openshift-b1b462f4db3ce1a26cfc251895d5f8fe2e15c484.tar.bz2
openshift-b1b462f4db3ce1a26cfc251895d5f8fe2e15c484.tar.xz
openshift-b1b462f4db3ce1a26cfc251895d5f8fe2e15c484.zip
added config file support to opssh, ossh, and oscp
Diffstat (limited to 'bin/opssh')
-rwxr-xr-xbin/opssh32
1 files changed, 30 insertions, 2 deletions
diff --git a/bin/opssh b/bin/opssh
index 71e5bf9f2..d64096fd4 100755
--- a/bin/opssh
+++ b/bin/opssh
@@ -10,16 +10,30 @@ import re
import tempfile
import time
import subprocess
+import ConfigParser
-DEFAULT_PSSH_PAR=200
+DEFAULT_PSSH_PAR = 200
PSSH = '/usr/bin/pssh'
+CONFIG_MAIN_SECTION = 'main'
+CONFIG_HOST_TYPE_ALIAS_SECTION = 'host_type_aliases'
+CONFIG_INVENTORY_OPTION = 'inventory'
+
class Opssh(object):
def __init__(self):
+ self.inventory = None
+ self.host_type_aliases = {}
self.file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)))
- self.aws = awsutil.AwsUtil()
+
+ # Default the config path to /etc
+ self.config_path = os.path.join(os.path.sep, 'etc', \
+ 'openshift_ansible', \
+ 'openshift_ansible.conf')
self.parse_cli_args()
+ self.parse_config_file()
+
+ self.aws = awsutil.AwsUtil(self.inventory, self.host_type_aliases)
if self.args.list_host_types:
self.aws.print_host_types()
@@ -66,6 +80,20 @@ class Opssh(object):
return None
+ def parse_config_file(self):
+ if os.path.isfile(self.config_path):
+ config = ConfigParser.ConfigParser()
+ config.read(self.config_path)
+
+ if config.has_section(CONFIG_MAIN_SECTION) and \
+ config.has_option(CONFIG_MAIN_SECTION, CONFIG_INVENTORY_OPTION):
+ self.inventory = config.get(CONFIG_MAIN_SECTION, CONFIG_INVENTORY_OPTION)
+
+ self.host_type_aliases = {}
+ if config.has_section(CONFIG_HOST_TYPE_ALIAS_SECTION):
+ for alias in config.options(CONFIG_HOST_TYPE_ALIAS_SECTION):
+ value = config.get(CONFIG_HOST_TYPE_ALIAS_SECTION, alias).split(',')
+ self.host_type_aliases[alias] = value
def parse_cli_args(self):
"""Setup the command line parser with the options we want