summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul C. Buetow <paul@buetow.org>2014-04-12 12:07:33 +0200
committerPaul C. Buetow <paul@buetow.org>2014-04-12 12:07:33 +0200
commit73f2caae2c05fe352260e516942a447f492a86b6 (patch)
tree92500dd5d87477d3a066d4e5df4fe7402bdcbf69 /src
parent435b2a1ebe9671c27b61a6c87ec4f9c7e1b32431 (diff)
some refactoring
Diffstat (limited to 'src')
-rwxr-xr-xsrc/fapi.py65
1 files changed, 45 insertions, 20 deletions
diff --git a/src/fapi.py b/src/fapi.py
index df4eaf4..876dee1 100755
--- a/src/fapi.py
+++ b/src/fapi.py
@@ -45,6 +45,7 @@ class Fapi(object):
try:
self._partition = config.get('fapi', 'partition')
self.info('Setting partition to %s' % self._partition)
+
self._f5.Management.Partition.set_active_partition(self._partition)
except Exception, e:
@@ -75,36 +76,60 @@ class Fapi(object):
print >> sys.stderr, '%s %s' % (__prompt__, message)
- def run(self):
- ''' Do the actual stuff '''
+ def __run_pool(self):
+ ''' Do stuff concerning pools '''
+
+ f = self._f5
+ a = self._args
+
+ if a.arg == 'show':
+ if a.subarg == 'status':
+ self.info('Getting pool status')
+ pool_name = args.subarg2
+ print f.LocalLB.Pool.get_object_status([pool_name])
+ return True
+
+ elif a.subarg == 'members':
+ self.info('Get pool members')
+ pool_name = args.subarg2
+ print f.LocalLB.Pool.get_member_v2([pool_name])
+ return True
+
+ else:
+ self.info('Get pool list')
+ print f.LocalLB.Pool.get_list()
+ return True
+
+ return False
+
+
+ def __run_service(self):
+ ''' Do stuff concerning virtual services '''
f = self._f5
a = self._args
+
+ return False
+
+
+ def run(self):
+ ''' Do the actual stuff '''
+
flag = False
+ a = self._args
+
+ if a.action == 'pool':
+ flag = self.__run_pool()
- if a.action == 'show':
- if a.arg == 'pool':
- if a.subarg == 'status':
- self.info('Getting pool status')
- pool_name = args.subarg2
- print f.LocalLB.Pool.get_object_status([pool_name])
- flag = True
-
- elif a.subarg == 'members':
- self.info('Get pool members')
- pool_name = args.subarg2
- print f.LocalLB.Pool.get_member_v2([pool_name])
- flag = True
-
- else:
- self.info('Get pool list')
- print f.LocalLB.Pool.get_list()
- flag = True
+ elif a.action == 'service':
+ flag = self.__run_service()
if not flag:
self.info('Don\'t know what to do')
sys.exit(1)
+
+
if __name__ == '__main__':
''' The main function, here we will have Popcorn for free! '''