def extGlobalMode(logs, process): if cmn.execComnd("exit", logs, process) is FAIL: return FAIL if cmn.execComnd("exit", logs, process) is FAIL: return FAIL return SUCCESS
def confIPAddress(logs, process, ip, mask): cmd = "ip address " + ip + " " + mask + " " if cmn.execComnd(cmd, logs, process) is FAIL: return FAIL cmd = "no shutdown " if cmn.execComnd(cmd, logs, process) is FAIL: return FAIL return SUCCESS
def confOSPF(logs, process, ip, wildcard): network = "network " glb.initRouterConf() if cmn.execComnd("router ospf 1", logs, process) is FAIL: return FAIL if glb.valRouterConf() is FAIL: print "ERROR : FAILED TO ENTER ROUTER CONF MODE" return FAIL network = network + ip + " " + wildcard + " area 0" if cmn.execComnd(network, logs, process) is FAIL: return FAIL return SUCCESS
def confEIGRP(logs, process, as_num, ip, wildcard): router_eigrp = "router eigrp " router_eigrp.append(str(as_num)) network = "network " glb.initRouterConf() if cmn.execComnd(router_eigrp, logs, process) is FAIL: return FAIL if glb.valRouterConf() is FAIL: print "ERROR : FAILED TO ENTER ROUTER CONF MODE" return FAIL network = network + ip + " " + wildcard if cmn.execComnd(network, logs, process) is FAIL: return FAIL return SUCCESS
def globalConfMode(logs, process): glb.initGlbExec() if cmn.execComnd("configure terminal", logs, process) is FAIL: return FAIL if glb.valGlbExec() is FAIL: print "ERROR : FAILED TO ENTER GLOBAL EXEC MODE" return FAIL return SUCCESS
def confRIP(logs, process, ip): network = "network " glb.initRouterConf() if cmn.execComnd("router rip", logs, process) is FAIL: return FAIL if glb.valRouterConf() is FAIL: print "ERROR : FAILED TO ENTER ROUTER CONF MODE" return FAIL if cmn.execComnd("version 2", logs, process) is FAIL: return FAIL network = network + ip if cmn.execComnd(network, logs, process) is FAIL: return FAIL if cmn.execComnd("no auto-summary", logs, process) is FAIL: return FAIL return SUCCESS
def showIpIntConfigs(logs, process): if glb.valPrivExec() is FAIL: print "ERROR : CONTROL NOT AT PRIVEXEC MODE" print "ERROR : FUNCTION : \"showIpIntConfigs\" returning failure" return FAIL param_list = "ip interface brief" cmd = genCommand(logs, param_list) if cmn.execComnd(cmd, logs, process) is FAIL: return FAIL return SUCCESS
def chkPing(logs, process, ip): if glb.valPrivExec() is FAIL: print "ERROR : CONTROL NOT AT PRIVEXEC MODE" print "ERROR : FUNCTION : \"chkPing\" returning failure" return FAIL glb.initPingStat() cmd = "ping " + ip if cmn.execComnd(cmd, logs, process) is FAIL: return FAIL if glb.PING_STAT == 0: return FAIL else: return SUCCESS
def intConfMode(logs, process, slot, port): glb.initInfConf() cmd = "" list_cmd = ['interface fastethernet '] list_cmd.append(str(slot)) list_cmd.append("/") list_cmd.append(str(port)) cmd = ''.join(list_cmd) if cmn.execComnd(cmd, logs, process) is FAIL: return FAIL if glb.valInfConf is FAIL: "ERROR : FAILED TO ENTER INTERFACE CONF MODE" return FAIL return SUCCESS