diff options
| author | Paul C. Buetow <paul@buetow.org> | 2014-04-12 12:26:41 +0200 |
|---|---|---|
| committer | Paul C. Buetow <paul@buetow.org> | 2014-04-12 12:26:41 +0200 |
| commit | 5b1ac5b54f04aa437ebbb40528ef4a8b4ba4aff7 (patch) | |
| tree | 64ea8acf1b28c66e75028fe17174cfb5ae48f454 /src | |
| parent | 73f2caae2c05fe352260e516942a447f492a86b6 (diff) | |
can create pools
Diffstat (limited to 'src')
| -rwxr-xr-x | src/fapi.py | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/src/fapi.py b/src/fapi.py index 876dee1..5cde08d 100755 --- a/src/fapi.py +++ b/src/fapi.py @@ -85,14 +85,14 @@ class Fapi(object): 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]) + poolname = a.subarg2 + print f.LocalLB.Pool.get_object_status([poolname]) return True elif a.subarg == 'members': self.info('Get pool members') - pool_name = args.subarg2 - print f.LocalLB.Pool.get_member_v2([pool_name]) + poolname = a.subarg2 + print f.LocalLB.Pool.get_member_v2([poolname]) return True else: @@ -100,6 +100,21 @@ class Fapi(object): print f.LocalLB.Pool.get_list() return True + elif a.arg == 'create': + poolname = a.subarg + poolmembers = [] + method = a.m + if a.subarg2: + for x in a.subarg2.split(','): + pm = {} + y = x.split(':') + if 1 == len(y): y.append(80) + pm['address'] = str(y[0]) + pm['port'] = int(y[1]) + poolmembers.append(pm) + f.LocalLB.Pool.create_v2([poolname],[method],[poolmembers]) + return True + return False @@ -136,6 +151,8 @@ if __name__ == '__main__': parser = argparse.ArgumentParser() #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 lb method', + default='LB_METHOD_RATIO_LEAST_CONNECTION_MEMBER') parser.add_argument('-C', action='store', help='Config file', default=expanduser('~') + '/.fapi.conf') @@ -152,10 +169,10 @@ if __name__ == '__main__': print 'This is %s version %s' % (__program__, __version__) sys.exit(0) - try: - fapi.run() - except Exception, e: - fapi.info(e) - sys.exit(2) + #try: + fapi.run() + #except Exception, e: + # fapi.info(e) + # sys.exit(2) # vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 |
