summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul C. Buetow <paul@buetow.org>2014-04-13 15:12:25 +0200
committerPaul C. Buetow <paul@buetow.org>2014-04-13 15:12:25 +0200
commit43b123bc07a2b0094ac1293a46ba33f6c7afa2cb (patch)
tree1ecefaa642a4c090a9251a24f224fbc299a5ccaf /src
parente6daf2b92a4e3a143503a0c6931a9849562f0246 (diff)
trying a list of loadbalancers and use the first one which has working iControl
Diffstat (limited to 'src')
-rwxr-xr-xsrc/fapi.py32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/fapi.py b/src/fapi.py
index 9d2cdc9..c33da9d 100755
--- a/src/fapi.py
+++ b/src/fapi.py
@@ -45,18 +45,26 @@ class Fapi(object):
prompt = 'Enter API password for user %s: ' % username
password = getpass.getpass(prompt)
self.info('Login to BigIP API with user %s' % username)
- hostname = c.get('fapi', 'hostname')
-
- # Enhance to try to login to a list of hosts
- try:
- self._f5 = bigsuds.BIGIP(hostname = hostname,
- username = username,
- password = password)
- self._partition = c.get('fapi', 'partition')
- self.info('Setting partition to \'%s\'' % self._partition)
- self._f5.Management.Partition.set_active_partition(self._partition)
- except Exception, e:
- self.info(e)
+ self._partition = c.get('fapi', 'partition')
+
+ # Try a comma separated lists of F5 boxes, use the first one
+ err = None
+ for hostname in c.get('fapi', 'hostnames').split(','):
+ try:
+ self.info('Trying to login to \'%s\'' % hostname)
+ self._f5 = bigsuds.BIGIP(hostname = hostname,
+ username = username,
+ password = password)
+ self._f5.Management.Partition.set_active_partition(self._partition)
+ self.info('Set partition to \'%s\'' % self._partition)
+ err = None
+ break
+ except Exception, e:
+ err = '%s:%s' % (hostname, e)
+ pass
+
+ if err:
+ self.info(err)
sys.exit(2)