def show_extension_tunnel(session, name=None, ipsec=None, ipextn=None, ficon=None, admin=None): tnlobject = extension_tunnel() tnlobject.set_name(name) tnlobject.set_ip_extension(ipsec) tnlobject.set_admin_enabled(admin) tnlobject.set_ipsec_enabled(ipsec) result = _show_extension_tunnel(session, tnlobject) return result
def create_extension_tunnel(session, name): value_dict = {'name': name} tnlobject = extension_tunnel(value_dict) result = _create_extension_tunnel(session, tnlobject) return result
def modify_extension_tunnel(session, name, ipext=0, ipsec=None): value_dict = {'name': name, 'ip-extension': ipext, 'ipsec-policy': ipsec} tnlobject = extension_tunnel() tnlobject.load(value_dict, 1) result = _modify_extension_tunnel(session, value_dict) return result
def handler(user_command): argv = user_command.split() argc = len(argv) if argc < 2: return i = 0 value_dict = dict() myobject = None cmd = None op = "undef" # print(argv) while i < argc and i <= 4: if i == 0 and argv[i] == 'portshow': cmd = 'show' elif i == 0 and argv[i] == 'portcfg': cmd = 'cfg' elif i == 0: print(argv[i], "Incorrect Argument passed") usage() return if i == 1 and argv[i] == 'ipif': myobject = extension_ip_interface() if i == 1 and argv[i] == 'iproute': myobject = extension_ip_route() if i == 1 and argv[i] == 'fciptunnel': myobject = extension_tunnel() if i == 1 and argv[i] == 'fcipcircuit': myobject = extension_circuit() if i == 2: if argv[i] == 'help': usage() if parse_port(argv[i], myobject, value_dict): return if cmd == 'cfg' and i == 3: if argv[i] == 'create' or argv[i] == 'modify' or argv[ i] == 'delete': op = argv[i] else: print("Incorrect option used") usage(myobject) if cmd == 'show' and i == 3: if parse_ipaddress(argv[i], myobject, value_dict): return if cmd == 'cfg' and i == 4: if parse_cid(argv[i], myobject, value_dict): return elif parse_ipaddress(argv[i], myobject, value_dict): return i += 1 if cmd == 'cfg': # if argc > 4 and isinstance(myobject, extension_tunnel): # parse_tunnel(user_command, myobject, value_dict) if argc > 4 and isinstance(myobject, extension_circuit): parse_circuit(argv[i:argc], myobject, value_dict) if myobject: myobject.load(value_dict, 1) # print(value_dict) else: return if cmd == 'show': if argc == 2: result = myobject.show_all(session) print( json.dumps(result, cls=pyfos_util.json_encoder, sort_keys=True, indent=4)) elif argc > 2: result = super(rest_object, myobject).get(session) print( json.dumps(result, cls=pyfos_util.json_encoder, sort_keys=True, indent=4)) elif cmd == 'cfg': if op == 'create': result = myobject.post(session) print(result) elif op == 'modify': result = myobject.patch(session) print(result) elif op == 'delete': result = myobject.delete(session) print(result) else: print("Incorrect options used") usage(myobject) return else: print("Incorrect options used") usage(myobject) return