summaryrefslogtreecommitdiffstats
path: root/bin/oscp
diff options
context:
space:
mode:
authorThomas Wiest <twiest@users.noreply.github.com>2015-03-30 14:47:06 -0400
committerThomas Wiest <twiest@users.noreply.github.com>2015-03-30 14:47:06 -0400
commitd083ffef71cbb7394e3eab70f1516dd419ce6b92 (patch)
tree4e1dd8346126e37bd79e69e37fcf1f5683a5d002 /bin/oscp
parent78a45fc50509eca27164452325529cc46a99cc8c (diff)
parentb1b462f4db3ce1a26cfc251895d5f8fe2e15c484 (diff)
downloadopenshift-d083ffef71cbb7394e3eab70f1516dd419ce6b92.tar.gz
openshift-d083ffef71cbb7394e3eab70f1516dd419ce6b92.tar.bz2
openshift-d083ffef71cbb7394e3eab70f1516dd419ce6b92.tar.xz
openshift-d083ffef71cbb7394e3eab70f1516dd419ce6b92.zip
Merge pull request #126 from twiest/pr
added config file support to opssh, ossh, and oscp
Diffstat (limited to 'bin/oscp')
-rwxr-xr-xbin/oscp25
1 files changed, 23 insertions, 2 deletions
diff --git a/bin/oscp b/bin/oscp
index 146bbbea5..011f37c7c 100755
--- a/bin/oscp
+++ b/bin/oscp
@@ -7,16 +7,28 @@ import traceback
import sys
import os
import re
+import ConfigParser
+
+CONFIG_MAIN_SECTION = 'main'
+CONFIG_INVENTORY_OPTION = 'inventory'
class Oscp(object):
def __init__(self):
+ self.inventory = None
self.file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)))
+
+ # 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()
# parse host and user
self.process_host()
- self.aws = awsutil.AwsUtil()
+ self.aws = awsutil.AwsUtil(self.inventory)
# get a dict of host inventory
if self.args.list:
@@ -38,9 +50,18 @@ class Oscp(object):
else:
self.scp()
+ 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)
+
def parse_cli_args(self):
parser = argparse.ArgumentParser(description='Openshift Online SSH Tool.')
- parser.add_argument('-e', '--env',
+ parser.add_argument('-e', '--env',
action="store", help="Environment where this server exists.")
parser.add_argument('-d', '--debug', default=False,
action="store_true", help="debug mode")