Ejemplo n.º 1
0
def config_vrf(input_json):
    username = input_json["username"]
    interface = input_json["interface"]
    src_ip = input_json["src-ip"]
    route = input_json["route"]
    gw = input_json["gateway"]
    create_ip_instance = u"create ip instance %s interface %s %s\n" %(username, interface, src_ip)
    create_ip_route = u"create ip route %s gateway %s in %s\n" %(route, gw, username)
    # logger.debug("%s", create_ip_instance)
    # logger.debug("%s", create_ip_route)
    client = SmartemtTelnetlib(ne_ip_addr = NE_IP_ADDR, login_id = NE_LOGIN_ID, password = NE_PASS)
    try:
        client.telnet_connect()
    except:
        raise
    else:
        try:
            client.exec_cmd(create_ip_instance)
            client.exec_cmd(create_ip_route)
        finally:
            client.telnet_disconnect()
Ejemplo n.º 2
0
def get_config():
    gl_res = {"config":[]}
    client = SmartemtTelnetlib(ne_ip_addr = NE_IP_ADDR, login_id = NE_LOGIN_ID, password = NE_PASS)
    try:
        client.telnet_connect()
    except:
        raise
    else:
        try:
            gl_res["config"] = client.exec_cmd("show config\n")
        finally:
            client.telnet_disconnect()
    return gl_res
Ejemplo n.º 3
0
def config_target(input_json):
    targetname = input_json["targetname"]
    mode = input_json["mode"]
    targetip = input_json["targetip"]
    ip = input_json["ip"]
    index = input_json["index"]
    upcount = input_json["upcount"]
    downcount = input_json["downcount"]
    normaltxinterval = input_json["normaltxinterval"]
    checktxinterval = input_json["checktxinterval"]
    normalrxtimeout = input_json["normalrxtimeout"]
    checkrxtimeout = input_json["checkrxtimeout"]
    statsaverage = input_json["statsaverage"]
    delaythreshold = input_json["delaythreshold"]
    framelength = input_json["framelength"]
    ttl = input_json["ttl"]

    create_icmpmng = u"create icmpmng %s mode %s target %s ip %s index %s\n" %(targetname, mode, targetip, ip, index)
    set_icmpmng_txframe = u"set icmpmng %s txframe length %s ttl %s\n" %(targetname, framelength, ttl)
    set_icmpmng_state = u"set icmpmng %s state count %s %s interval %s %s timeout %s %s\n" %(targetname, upcount, downcount, normaltxinterval, checktxinterval, normalrxtimeout, checkrxtimeout)
    set_icmpmng_stats = u"set icmpmng %s stats average %s delay %s\n" %(targetname, statsaverage, delaythreshold)
    set_icmpmng_on = u"set icmpmng %s mnglog on\n" %(targetname)
    enable_icmpmng = u"enable icmpmng %s\n" %(targetname)

    client = SmartemtTelnetlib(ne_ip_addr = NE_IP_ADDR, login_id = NE_LOGIN_ID, password = NE_PASS)
    try:
        client.telnet_connect()
    except:
        raise
    else:
        try:
            client.exec_cmd(create_icmpmng)
            client.exec_cmd(set_icmpmng_txframe)
            client.exec_cmd(set_icmpmng_state)
            client.exec_cmd(set_icmpmng_stats)
            client.exec_cmd(set_icmpmng_on)
            client.exec_cmd(enable_icmpmng)
        finally:
            client.telnet_disconnect()