summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/fapi27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/fapi b/src/fapi
index 0d0d3fb..9a4dd9f 100755
--- a/src/fapi
+++ b/src/fapi
@@ -20,12 +20,14 @@ __program__ = 'fapi'
__version__ = 'VERSION_DEVEL' # Replaced by a Makefile tsubet
__prompt__ = '>>>' # Default prompt
+def print_version():
+ print 'This is %s version %s' % (__program__, __version__)
def print_synopsis():
''' Prints the full Synopsis string '''
+ print_version()
print "\n".join([
- 'This is %s version %s' % (__program__, __version__),
'',
'Synopsis:',
' fapi monitor',
@@ -62,7 +64,11 @@ class Fapi(object):
self._args = args
self._config = ConfigParser.ConfigParser()
self._config.read(args.C)
- self._partition = self._config.get('fapi', 'partition')
+
+ if args.p != None:
+ self._partition = args.p
+ else:
+ self._partition = self._config.get('fapi', 'partition')
def __login(self):
@@ -83,11 +89,12 @@ class Fapi(object):
self.info('Login to BigIP API with user %s' % username)
# Try a comma separated lists of F5 boxes, use the first one
+ loadbalancers = c.get('fapi', 'loadbalancers_' + a.e)
err = None
- for hostname in c.get('fapi', 'hostnames').split(','):
+ for loadbalancer in loadbalancers.split(','):
try:
- self.info('Trying to login to \'%s\'' % hostname)
- self._f5 = bigsuds.BIGIP(hostname = hostname,
+ self.info('Trying to login to \'%s\'' % loadbalancer)
+ self._f5 = bigsuds.BIGIP(hostname = loadbalancer,
username = username,
password = password)
self._f5.Management.Partition.set_active_partition(self._partition)
@@ -95,7 +102,7 @@ class Fapi(object):
err = None
break
except Exception, e:
- err = '%s:%s' % (hostname, e)
+ err = '%s:%s' % (loadbalancer, e)
pass
if err:
@@ -230,7 +237,7 @@ class Fapi(object):
elif a.sub == 'create':
poolmembers = []
- method = a.m
+ method = 'LB_METHOD_ROUND_ROBIN'
if a.sub3:
for x in a.sub3.split(','):
fqdn, ip, port = self.lookup(x)
@@ -431,11 +438,12 @@ if __name__ == '__main__':
''' The main function, here we will have Popcorn for free! '''
parser = argparse.ArgumentParser(add_help=False)
+ parser.add_argument('-e', action='store', help='Env to use, e.g. dev,qa,live',
+ default='qa')
parser.add_argument('-h', action='store_true', help='Help')
+ parser.add_argument('-p', action='store', help='Overwrite partition from fapi.conf')
parser.add_argument('-v', action='store_true', help='Verbose')
parser.add_argument('-V', action='store_true', help='Print version')
- parser.add_argument('-m', action='store', help='The default lbmethod',
- default='LB_METHOD_ROUND_ROBIN')
parser.add_argument('-C', action='store', help='Config file',
default=expanduser('~') + '/.fapi.conf')
@@ -456,6 +464,7 @@ if __name__ == '__main__':
sys.exit(0)
if args.V:
+ print_version()
sys.exit(0)
fapi = Fapi(args)