Ejemplo n.º 1
0
def test_GivenShowNeighbor_RouterCouldCreateInterfaces():
    rt = cisco.Router(None)
    file = open(os.path.join(os.path.dirname(__file__), 'outputNeighbor.txt'),
                "r")
    rt.MapInterfacesByNeighbor(file.read())
    assert len(rt.Interfaces) == 3
    assert rt.Interfaces[0].Name == 'FastEthernet0/24'
    assert rt.Interfaces[0].Neighbor == 'MikroTik'
    assert rt.Interfaces[1].Name == 'FastEthernet0/10'
    assert rt.Interfaces[1].Neighbor == 'Cisco IP Phone 7911'
Ejemplo n.º 2
0
def test_GivenShowPower_RouterCouldCreateInterfaces():
    rt = cisco.Router(None)
    file = open(os.path.join(os.path.dirname(__file__), 'outputPower.txt'),
                "r")
    rt.MapInterfacesByPower(file.read())
    assert len(rt.Interfaces) == 72
    assert rt.Interfaces[0].Name == 'Gi1/0/1'
    assert rt.Interfaces[0].Admin == cisco.InterfaceAdmin.Static
    assert rt.Interfaces[0].Operation == cisco.InterfaceOperation.On
    assert rt.Interfaces[0].Power == 10.2
Ejemplo n.º 3
0
def test_GivenShowBrief_RouterCouldCreateInterfaces():
    rt = cisco.Router(None)
    file = open(os.path.join(os.path.dirname(__file__), 'outputBrief.txt'),
                "r")
    rt.MapInterfacesByBrief(file.read())
    assert len(rt.Interfaces) == 18
    assert rt.Interfaces[0].Name == 'FastEthernet0/0'
    assert rt.Interfaces[0].IP == None
    assert rt.Interfaces[
        0].Status == cisco.InterfaceStatus.AdministrativelyDown
    assert rt.Interfaces[0].Protocol == cisco.InterfaceProtocol.Down
Ejemplo n.º 4
0
def CallRouter(ipAddress, username, password, power):
    myClient = common.EstablishConn(ipAddress, username, password)
    if not myClient:
        return
    router = cisco.Router(myClient)
    router.GetInterfacesByPower()
    result = filter(
        lambda port: port.Power == float(power) and port.Admin == cisco.
        InterfaceAdmin.Auto, router.Interfaces)
    if len(result) > 0:
        print 'Found **', len(result), '** interfaces'
        ApplyConf(myClient, result)
    '''
Ejemplo n.º 5
0
def CallRouter(ipAddress, username, password, neighbor):
    myClient = common.EstablishConn(ipAddress, username, password)
    if not myClient:
        return
    router = cisco.Router(myClient)
    router.GetInterfacesByNeighbor()
    result = filter(lambda port: neighbor.lower() in port.Neighbor.lower(),
                    router.Interfaces)
    if len(result) > 0:
        print 'Found **', len(result), '** interfaces'
        for item in result:
            print "Platform: " + item.Neighbor
            print "Interface: " + item.Name
            print "============================="
        ApplyConf(myClient, result)
    else:
        print "No matched Device !"
Ejemplo n.º 6
0
def CallRouter(ipAddress, username, password, neighbor):
    myClient = common.EstablishConn(ipAddress, username, password)
    if not myClient:
        return
    router = cisco.Router(myClient)
    router.GetInterfacesByNeighbor()
    result = filter(lambda port: neighbor.lower() in port.Neighbor.lower(),
                    router.Interfaces)
    if len(result) > 0:
        print 'Found **', len(result), '** interfaces'
        for item in result:
            print "Platform: " + item.Neighbor
            print "Interface: " + item.Name
            print "============================="

        #input = raw_input("Would you like to configure, press[Y/y] ")
        # if(input.lower()== "y"):
        ApplyConf(myClient, result)