diff options
| author | Paul Buetow (lxpbuetow.webde.local) <paul.buetow@1und1.de> | 2014-07-14 14:04:09 +0200 |
|---|---|---|
| committer | Paul Buetow (lxpbuetow.webde.local) <paul.buetow@1und1.de> | 2014-07-14 14:04:09 +0200 |
| commit | f66e53a269428c8a35592dac1edc5928a28ab05b (patch) | |
| tree | db420a5dc2cabb8f018f16e12e823ccc83ca3930 /src | |
| parent | a5f5f04cf76f159342777f95dabee2d3aff8dd10 (diff) | |
add get curl
Diffstat (limited to 'src')
| -rwxr-xr-x | src/fapi | 48 |
1 files changed, 33 insertions, 15 deletions
@@ -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': |
