Beispiel #1
0
def configure(**kwargs):
    '''
     - Configures the IP address in SW1, SW2 and SW3
     - Creates router bgp instance on SW1 and SW2
     - Configures the router id
     - Configures the network range
     - Configure redistribute and neighbor
    '''

    switch1 = kwargs.get('switch1', None)
    switch2 = kwargs.get('switch2', None)

    '''
    - Enable the link.
    - Set IP for the switches.
    '''
    # Enabling interface 1 SW1.
    LogOutput('info', "Enabling interface1 on SW1")
    retStruct = InterfaceEnable(deviceObj=switch1, enable=True,
                                interface=switch1.linkPortMapping['lnk01'])
    retCode = retStruct.returnCode()
    if retCode != 0:
        assert "Unable to enable interface1 on SW1"

    # Assigning an IPv4 address on interface 1 of SW1
    LogOutput('info', "Configuring IPv4 address on link 1 SW1")
    retStruct = InterfaceIpConfig(deviceObj=switch1,
                                  interface=switch1.linkPortMapping['lnk01'],
                                  addr=IP_ADDR1, mask=DEFAULT_PL,
                                  config=True)
    retCode = retStruct.returnCode()
    if retCode != 0:
        assert "Failed to configure an IPv4 address on interface 1 of SW1"

    # Enabling interface 1 SW2
    LogOutput('info', "Enabling interface1 on SW2")
    retStruct = InterfaceEnable(deviceObj=switch2, enable=True,
                                interface=switch2.linkPortMapping['lnk01'])
    retCode = retStruct.returnCode()
    if retCode != 0:
        assert "Unable to enable interface 1 on SW2"

    # Assigning an IPv4 address on interface 1 for link 1 SW2
    LogOutput('info', "Configuring IPv4 address on link 1 SW2")
    retStruct = InterfaceIpConfig(deviceObj=switch2,
                                  interface=switch2.linkPortMapping['lnk01'],
                                  addr=IP_ADDR2, mask=DEFAULT_PL,
                                  config=True)
    retCode = retStruct.returnCode()
    if retCode != 0:
        assert "Failed to configure an IPv4 address on interface 1 of SW2"
Beispiel #2
0
def configure(**kwargs):
    '''
     - Configure the IP address in SW1, SW2
     - Configure ipv6 prefix
     - Configure route-map
     - Create router bgp instance on SW1 and SW2
     - Configure the router id
     - Configure the network range
     - Configure the neighbor
     - Apply route-map to neighbor on SW1
    '''

    switch1 = kwargs.get('switch1', None)
    switch2 = kwargs.get('switch2', None)

    # Configuring ipv6 prefix-list on switch 1
    LogOutput('info', "Configuring ipv6 prefix configuration on SW1")
    result = configure_prefix_list(switch1, "BGP1_IN", "10", "deny",\
                                   "9966:1:2::/64", 80, 100)
    assert result is True, "Setting ipv6 prefix configuration failed for SW1"
    result = configure_prefix_list(switch1, "BGP1_IN", "20", "permit",\
                                   "7d5d:1:1::/64", 0, 70)
    assert result is True, "Setting ipv6 prefix configuration failed for SW1"
    result = configure_prefix_list(switch1, "BGP1_IN", "30", "permit",\
                                   "5d5d:1:1::/64", 0, 70)
    assert result is True, "Setting ipv6 prefix configuration failed for SW1"
    result = configure_prefix_list(switch1, "BGP1_IN", "40", "permit",\
                                   "2ccd:1:1::/64", 65, 0)
    assert result is True, "Setting ipv6 prefix configuration failed for SW1"
    result = configure_prefix_list(switch1, "BGP1_IN", "50", "permit",\
                                   "4ddc:1:1::/64", 0, 0)
    assert result is True, "Setting ipv6 prefix configuration failed for SW1"

    # Configuring Route-map on switch 1
    LogOutput('info', "Configuring route-map on SW1")
    result = configure_route_map(switch1, "BGP1_IN", "BGP1_IN")
    assert result is True, "Setting route-map configuration failed for SW1"

    # Configuring BGP on switch 1
    LogOutput('info', "Configuring router-id on SW1")
    result = configure_router_id(switch1, AS_NUM1, SW1_ROUTER_ID)
    assert result is True, "BGP router id set failed for SW1"

    LogOutput('info', "Configuring networks on SW1")
    result = configure_network(switch1, AS_NUM1, "3dcd:1:1::/64")
    assert result is True, "BGP network creation failed for SW1"

    LogOutput('info', "Configuring bgp neighbor on SW1")
    result = configure_neighbor(switch1, AS_NUM1, IPv6_ADDR2, AS_NUM2)
    assert result is True, "BGP neighbor configuration failed for SW1"
    LogOutput('info', "Applying route-map to bgp neighbor on SW1")
    result = configure_neighbor_rmap(switch1, AS_NUM1, IPv6_ADDR2, AS_NUM2,\
                                     "BGP1_IN","in")
    assert result is True, "BGP neighbor route-map configuration failed for SW1"
    exitContext(switch1)
    sleep(5)

    # Enabling interface 1 SW1.
    LogOutput('info', "Enabling interface1 on SW1")
    retStruct = InterfaceEnable(deviceObj=switch1,
                                enable=True,
                                interface=switch1.linkPortMapping['lnk01'])
    retCode = retStruct.returnCode()
    if retCode != 0:
        assert "Unable to enable interface1 on SW1"

    # Assigning an IPv4 address on interface 1 of SW1
    LogOutput('info', "Configuring IPv6 address on link 1 SW1")
    retStruct = InterfaceIpConfig(deviceObj=switch1,
                                  interface=switch1.linkPortMapping['lnk01'],
                                  addr=IPv6_ADDR1,
                                  mask=DEFAULT_PL,
                                  ipv6flag=True,
                                  config=True)
    retCode = retStruct.returnCode()
    if retCode != 0:
        assert "Failed to configure an IPv6 address on interface 1 of SW1"

    # Configuring ipv6 prefix-list on switch 2
    LogOutput('info', "Configuring ipv6 prefix list configuration on SW2")
    result = configure_prefix_list(switch2, "A_sample_name_to_verify_the_"\
                                   "max_length_of_the_prefix_list_name_that_"\
                                   "can_be_confd", "4294967295", "permit",\
                                   "any", 0, 0)
    assert result is True, "Setting ipv6 prefix list configuration failed for SW2"
    LogOutput('info', "Configuring ipv6 prefix list configuration on SW2")
    result = configure_prefix_list(switch2, "p2", "5", "deny",\
                                   "any", 0, 0)
    assert result is True, "Setting ipv6 prefix list configuration failed for SW2"

    # Boundary and limit testing and Negative testing for prefix list
    LogOutput('info', "Boundary and limit testing and Negative testing for"\
              " ipv6 prefix list configuration on SW2")

    result = verify_prefix_list_config(switch2, "p2", "0", "deny",\
                                   "any", 0, 0)
    if result is True:
        LogOutput('info',"Setting wrong ipv6 prefix list configuration"\
                  " failed for SW2")
    assert result is True, "Setting wrong ipv6 prefix list configuration"\
                           " succeeded for SW2"
    result = verify_prefix_list_config(switch2, "p2", "4294967296", "deny",\
                                   "any", 0, 0)
    if result is True:
        LogOutput('info',"Setting wrong ipv6 prefix list configuration"\
                  " failed for SW2")
    assert result is True, "Setting wrong ipv6 prefix list configuration"\
                           " succeeded for SW2"
    result = verify_prefix_list_config(switch2, "p2", "-429", "deny",\
                                   "any", 0, 0)
    if result is True:
        LogOutput('info',"Setting wrong ipv6 prefix list configuration"\
                  " failed for SW2")
    assert result is True, "Setting wrong ipv6 prefix list configuration"\
                           " succeeded for SW2"

    # Configuring Route-map on switch 2
    LogOutput('info', "Configuring route-map on SW2")
    result = configure_route_map(switch2,"BGP2_Rmap1","A_sample_name_to_verify_the_"\
                                   "max_length_of_the_prefix_list_name_that_"\
                                   "can_be_confd")
    assert result is True, "Setting route-map configuration failed for SW2"
    LogOutput('info', "Configuring route-map on SW2")
    result = configure_route_map(switch2, "BGP2_Rmap2", "p2")
    assert result is True, "Setting route-map configuration failed for SW2"

    # Configuring BGP on switch 2
    LogOutput('info', "Configuring router-id on SW2")
    result = configure_router_id(switch2, AS_NUM2, SW2_ROUTER_ID)
    assert result is True, "BGP router id set failed for SW2"

    LogOutput('info', "Configuring networks on SW2")
    result = configure_network(switch2, AS_NUM2, "2ccd:1:1::/67")
    assert result is True, "BGP network creation failed for SW2"
    result = configure_network(switch2, AS_NUM2, "7d5d:1:1::/85")
    assert result is True, "BGP network creation failed for SW2"
    result = configure_network(switch2, AS_NUM2, "5d5d:1:1::/69")
    assert result is True, "BGP network creation failed for SW2"
    result = configure_network(switch2, AS_NUM2, "9966:1:2::/85")
    assert result is True, "BGP network creation failed for SW2"
    result = configure_network(switch2, AS_NUM2, "4ddc:1:1::/64")
    assert result is True, "BGP network creation failed for SW2"
    result = configure_neighbor(switch2, AS_NUM2, IPv6_ADDR1, AS_NUM1)
    assert result is True, "BGP neighbor configuration failed for SW1"
    LogOutput('info', "Applying route-map to bgp neighbor on SW2")
    result = configure_neighbor_rmap(switch2, AS_NUM2, IPv6_ADDR1, AS_NUM1,\
                                     "BGP2_Rmap1","out")
    assert result is True, "BGP neighbor route-map configuration failed for SW2"

    LogOutput('info', "Applying route-map to bgp neighbor on SW2")
    result = configure_neighbor_rmap(switch2, AS_NUM2, IPv6_ADDR1, AS_NUM1,\
                                     "BGP2_Rmap2","in")
    assert result is True, "BGP neighbor route-map configuration failed for SW2"
    exitContext(switch2)
    sleep(10)

    # Enabling interface 1 SW2
    LogOutput('info', "Enabling interface1 on SW2")
    retStruct = InterfaceEnable(deviceObj=switch2,
                                enable=True,
                                interface=switch2.linkPortMapping['lnk01'])
    retCode = retStruct.returnCode()
    if retCode != 0:
        assert "Unable to enable interface 1 on SW2"

    # Assigning an IPv4 address on interface 1 for link 1 SW2
    LogOutput('info', "Configuring IPv6 address on link 1 SW2")
    retStruct = InterfaceIpConfig(deviceObj=switch2,
                                  interface=switch2.linkPortMapping['lnk01'],
                                  addr=IPv6_ADDR2,
                                  mask=DEFAULT_PL,
                                  ipv6flag=True,
                                  config=True)
    retCode = retStruct.returnCode()
    if retCode != 0:
        assert "Failed to configure an IPv6 address on interface 1 of SW2"
def configure(**kwargs):
    '''
     - Configures the IP address in SW1, SW2 and SW3
     - Creates router bgp instance on SW1 and SW2
     - Configures the router id
     - Configures the network range
     - Configure redistribute and neighbor
    '''

    switch1 = kwargs.get('switch1', None)
    switch2 = kwargs.get('switch2', None)
    '''
    - Enable the link.
    - Set IP for the switches.
    '''
    # Enabling interface 1 SW1.
    LogOutput('info', "Enabling interface1 on SW1")
    retStruct = InterfaceEnable(deviceObj=switch1,
                                enable=True,
                                interface=switch1.linkPortMapping['lnk01'])
    retCode = retStruct.returnCode()
    if retCode != 0:
        assert "Unable to enable interface1 on SW1"

    # Assigning an IPv4 address on interface 1 of SW1
    LogOutput('info', "Configuring IPv4 address on link 1 SW1")
    retStruct = InterfaceIpConfig(deviceObj=switch1,
                                  interface=switch1.linkPortMapping['lnk01'],
                                  addr=IP_ADDR1,
                                  mask=DEFAULT_PL,
                                  config=True)
    retCode = retStruct.returnCode()
    if retCode != 0:
        assert "Failed to configure an IPv4 address on interface 1 of SW1"

    # Enabling interface 1 SW2
    LogOutput('info', "Enabling interface1 on SW2")
    retStruct = InterfaceEnable(deviceObj=switch2,
                                enable=True,
                                interface=switch2.linkPortMapping['lnk01'])
    retCode = retStruct.returnCode()
    if retCode != 0:
        assert "Unable to enable interface 1 on SW2"

    # Assigning an IPv4 address on interface 1 for link 1 SW2
    LogOutput('info', "Configuring IPv4 address on link 1 SW2")
    retStruct = InterfaceIpConfig(deviceObj=switch2,
                                  interface=switch2.linkPortMapping['lnk01'],
                                  addr=IP_ADDR2,
                                  mask=DEFAULT_PL,
                                  config=True)
    retCode = retStruct.returnCode()
    if retCode != 0:
        assert "Failed to configure an IPv4 address on interface 1 of SW2"


#    For SW1 and SW2, configure bgp
    LogOutput('info', "Configuring route context on SW1")
    result = enterRouterContext(switch1, AS_NUM1)
    assert result is True, "Failed to configure router Context on SW1"
    LogOutput('info', "Configuring router id on SW1")
    result = configure_router_id(switch1, AS_NUM1, SW1_ROUTER_ID)
    assert result is True, "Failed to configure router Context on SW1"
    LogOutput('info', "Configuring networks on SW1")
    result = configure_network(switch1, AS_NUM1, "9.0.0.0/8")
    assert result is True, "Failed to configure network on SW1"
    LogOutput('info', "Configuring neighbors on SW1")
    result = configure_neighbor(switch1, AS_NUM1, IP_ADDR2, AS_NUM2)
    assert result is True, "Failed to configur neighbor on SW1"

    LogOutput('info', "Configuring route context on SW2")
    result = enterRouterContext(switch2, AS_NUM2)
    assert result is True, "Failed to configure router Context on SW2"
    LogOutput('info', "Configuring router id on SW2")
    result = configure_router_id(switch2, AS_NUM2, SW2_ROUTER_ID)
    assert result is True, "Failed to configure router Context on SW2"
    LogOutput('info', "Configuring networks on SW2")
    result = configure_network(switch2, AS_NUM2, "10.0.0.0/8")
    assert result is True, "Failed to configure network on SW2"
    LogOutput('info', "Configuring networks on SW2")
    result = configure_network(switch2, AS_NUM2, "11.0.0.0/8")
    assert result is True, "Failed to configure network on SW2"

    LogOutput('info', "Configuring neighbors on SW2")
    result = configure_neighbor(switch2, AS_NUM2, IP_ADDR1, AS_NUM1)
    assert result is True, "Failed to configur neighbor on SW2"
def configure(**kwargs):
    '''
     - Configures the IP address in SW1, SW2 and SW3
     - Creates router bgp instance on SW1 and SW2
     - Configures the router id
     - Configures the network range
     - Configure redistribute and neighbor
    '''

    switch1 = kwargs.get('switch1', None)
    switch2 = kwargs.get('switch2', None)
    switch3 = kwargs.get('switch3', None)
    '''
    - Enable the link.
    - Set IP for the switches.
    '''
    # Enabling interface 1 SW1.
    LogOutput('info', "Enabling interface1 on SW1")
    retStruct = InterfaceEnable(deviceObj=switch1,
                                enable=True,
                                interface=switch1.linkPortMapping['lnk01'])
    retCode = retStruct.returnCode()
    if retCode != 0:
        assert "Unable to enable interface1 on SW1"

    # Assigning an IPv4 address on interface 1 of SW1
    LogOutput('info', "Configuring IPv4 address on link 1 SW1")
    retStruct = InterfaceIpConfig(deviceObj=switch1,
                                  interface=switch1.linkPortMapping['lnk01'],
                                  addr=IP_ADDR1,
                                  mask=DEFAULT_PL,
                                  config=True)
    retCode = retStruct.returnCode()
    if retCode != 0:
        assert "Failed to configure an IPv4 address on interface 1 of SW1"

    # Enabling interface 1 SW2
    LogOutput('info', "Enabling interface1 on SW2")
    retStruct = InterfaceEnable(deviceObj=switch2,
                                enable=True,
                                interface=switch2.linkPortMapping['lnk01'])
    retCode = retStruct.returnCode()
    if retCode != 0:
        assert "Unable to enable interface 1 on SW2"

    # Assigning an IPv4 address on interface 1 for link 1 SW2
    LogOutput('info', "Configuring IPv4 address on link 1 SW2")
    retStruct = InterfaceIpConfig(deviceObj=switch2,
                                  interface=switch2.linkPortMapping['lnk01'],
                                  addr=IP_ADDR2,
                                  mask=DEFAULT_PL,
                                  config=True)
    retCode = retStruct.returnCode()
    if retCode != 0:
        assert "Failed to configure an IPv4 address on interface 1 of SW2"

    # Enabling interface 2 SW2
    LogOutput('info', "Enabling interface2 on SW2")
    retStruct = InterfaceEnable(deviceObj=switch2,
                                enable=True,
                                interface=switch2.linkPortMapping['lnk02'])
    retCode = retStruct.returnCode()
    if retCode != 0:
        assert "Unable to enable interface 2 on SW2"

    # Assigning an IPv4 address on interface 1 for link 2 SW2
    LogOutput('info', "Configuring IPv4 address on link 2 SW2")
    retStruct = InterfaceIpConfig(deviceObj=switch2,
                                  interface=switch2.linkPortMapping['lnk02'],
                                  addr=IP_ADDR3,
                                  mask=DEFAULT_PL,
                                  config=True)
    retCode = retStruct.returnCode()
    if retCode != 0:
        assert "Failed to configure an IPv4 address on interface 2 of SW2"

    # Enabling interface 1 SW3
    LogOutput('info', "Enabling interface1 on SW3")
    retStruct = InterfaceEnable(deviceObj=switch3,
                                enable=True,
                                interface=switch3.linkPortMapping['lnk02'])
    retCode = retStruct.returnCode()
    if retCode != 0:
        assert "Unable to enable interface 1 on SW3"

    # Assigning an IPv4 address on interface 1 for link 2 SW3
    LogOutput('info', "Configuring IPv4 address on link 2 SW3")
    retStruct = InterfaceIpConfig(deviceObj=switch3,
                                  interface=switch3.linkPortMapping['lnk02'],
                                  addr=IP_ADDR4,
                                  mask=DEFAULT_PL,
                                  config=True)
    retCode = retStruct.returnCode()
    if retCode != 0:
        assert "Failed to configure an IPv4 address on interface 1 of SW3"
    '''
    For SW2 and SW3, configure bgp
    '''
    LogOutput('info', "Configuring static routes on SW2")
    result = configure_static_route(switch2, "12.0.0.0/8", "7.0.0.1")
    assert result is True, "Setting static route configuration failed for SW2"
    LogOutput('info', "Configuring route-map routes on SW2")
    result = configure_route_map(switch2, "BGP_Rmap")
    assert result is True, "Setting route-map configuration failed for SW2"
    LogOutput('info', "Configuring router-id on SW2")
    result = configure_router_id(switch2, AS_NUM1, SW2_ROUTER_ID)
    assert result is True, "BGP router id set failed for SW2"
    LogOutput('info', "Configuring networks on SW2")
    result = configure_network(switch2, AS_NUM1, "10.0.0.0/8")
    assert result is True, "BGP network creation failed for SW2"
    LogOutput('info', "Configuring redistribute configuration on SW2")
    result = configure_redistribute(switch2, AS_NUM1, "connected")
    assert result is True, "BGP redistribute connected configuration failed"\
                           " for SW2"
    LogOutput('info',
              "Configuring redistribute route-map configuration on SW2")
    result = configure_redistribute_rmap(switch2, AS_NUM1, "static",
                                         "BGP_Rmap")
    assert result is True, "BGP redistribute static route-map configuration"\
                           " failed for SW2"
    LogOutput('info', "Configuring bgp neighbor on SW2")
    result = configure_neighbor(switch2, AS_NUM1, IP_ADDR4, AS_NUM2)
    assert result is True, "BGP neighbor configuration failed for SW2"
    LogOutput('info', "Applying route-map to bgp neighbor on SW2")
    result = configure_neighbor_rmap(switch2, AS_NUM1, IP_ADDR4, AS_NUM2,\
                                     "BGP_Rmap")
    assert result is True, "BGP neighbor route-map configuration failed for SW2"
    exitContext(switch2)

    LogOutput('info', "Configuring router-id on SW3")
    result = configure_router_id(switch3, AS_NUM2, SW3_ROUTER_ID)
    assert result is True, "BGP router id set failed for SW3"
    LogOutput('info', "Configuring networks on SW2")
    result = configure_network(switch3, AS_NUM2, "19.0.0.0/8")
    assert result is True, "BGP network creation failed for SW3"
    result = configure_neighbor(switch3, AS_NUM2, IP_ADDR3, AS_NUM1)
    assert result is True, "BGP neighbor configuration failed for SW3"
    exitContext(switch3)