diff options
| -rw-r--r-- | docs/fapi.pod | 9 | ||||
| -rwxr-xr-x | src/fapi | 48 |
2 files changed, 41 insertions, 16 deletions
diff --git a/docs/fapi.pod b/docs/fapi.pod index 9b3c564..afabd99 100644 --- a/docs/fapi.pod +++ b/docs/fapi.pod @@ -20,11 +20,18 @@ because it's shorter to type. This is a simple command line client to do basic stuff with the iControl F5 API such as: - Managing Nodes Managing Monitors + Managing Nodes Managing Pools Managing Virtual Servers +And some extended usage: + + Managing Folders + Managing Self IPs + Managing Traffic Groups + Managing VLANs + This is a private programming project programmed in my spare time. Therefore I didn't bother to put it on a public website and github. Please open bug @@ -2,7 +2,7 @@ # 2014 (c) Paul C. Buetow # I'm sorry, but this is my first Python program to find out if it's worth -# using it. I'm more into Perl, and it will stay so. +# using it. I'm more into Perl. import argparse import base64 @@ -49,6 +49,8 @@ class FapiBase(object): if result != None: if self._args.l and isinstance(result, (list, tuple)): print"\n".join(result) + elif isinstance(result, basestring): + print result else: pp = pprint.PrettyPrinter(indent=4) pp.pprint(result) @@ -96,7 +98,7 @@ class FapiBase(object): ' vserver', ' vserver NAME create [protocol] [profile] [poolname] [mask]', ' vserver NAME delete', - ' vserver NAME get brief|detail|status|vlan|persistence|profile|rule', + ' vserver NAME get brief|detail|status|vlan|persistence|profile|rule|curl', ' vserver NAME set nat|pat disabled|enabled', ' vserver NAME set pool POOLNAME', ' vserver NAME set snat automap|none', @@ -468,20 +470,36 @@ class Fapi(FapiBase): return lambda: detail(f5) elif a.sub2 == 'brief': def brief(f5): - d = {} - d['actual_hardware_acceleration'] = f5().get_actual_hardware_acceleration([name]) - d['default_pool_name'] = f5().get_default_pool_name([name]) - d['destination'] = f5().get_destination_v2([name]) - d['enabled_state'] = f5().get_enabled_state([name]) - d['object_status'] = f5().get_object_status([name]) - d['persistence_profile'] = f5().get_persistence_profile([name]) - d['profile'] = f5().get_profile([name]) - d['protocol'] = f5().get_protocol([name]) - d['translate_address_state'] = f5().get_translate_address_state([name]) - d['translate_port_state'] = f5().get_translate_port_state([name]) - d['type'] = f5().get_type([name]) - return d + b = {} + b['actual_hardware_acceleration'] = f5().get_actual_hardware_acceleration([name]) + b['default_pool_name'] = f5().get_default_pool_name([name]) + b['destination'] = f5().get_destination_v2([name]) + b['enabled_state'] = f5().get_enabled_state([name]) + b['object_status'] = f5().get_object_status([name]) + b['persistence_profile'] = f5().get_persistence_profile([name]) + b['profile'] = f5().get_profile([name]) + b['protocol'] = f5().get_protocol([name]) + b['translate_address_state'] = f5().get_translate_address_state([name]) + b['translate_port_state'] = f5().get_translate_port_state([name]) + b['type'] = f5().get_type([name]) + return b return lambda: brief(f5) + elif a.sub2 == 'curl': + def curl(f5): + protocol = f5().get_protocol([name])[0] + if protocol == 'PROTOCOL_TCP': + destination = f5().get_destination_v2([name])[0] + port = str(destination['port']) + ip = destination['address'].split('/')[-1] + headerdump = ip + '-header.txt' + m = re.match('43$', port) + if m: + return 'curl -D ' + headerdump + ' -k https://' + ip + else: + return 'curl -D ' + headerdump + ' http://' + ip + else: + return protocol + ': Can only curl PROTOCOL_TCP' + return lambda: curl(f5) elif a.sub2 == 'status': return lambda: f5().get_object_status([name]) elif a.sub2 == 'persistence': |
