def test_portchannel_interface_tc2_add_duplicate(duthost):
    """ Test adding duplicate portchannel interface
    """
    json_patch = [
        {
            "op": "add",
            "path": create_path(["PORTCHANNEL_INTERFACE", "PortChannel0001|10.0.0.56/31"]),
            "value": {}
        },
        {
            "op": "add",
            "path": create_path(["PORTCHANNEL_INTERFACE", "PortChannel0001|FC00::71/126"]),
            "value": {}
        }
    ]

    logger.info("json patch {}".format(json_patch))

    tmpfile = generate_tmpfile(duthost)
    logger.info("tmpfile {}".format(tmpfile))

    try:
        output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile)
        expect_op_success(duthost, output)

        check_show_ip_intf(duthost, "PortChannel0001", ["10.0.0.56/31"], [], is_ipv4=True)
        check_show_ip_intf(duthost, "PortChannel0001", ["fc00::71/126"], [], is_ipv4=False)
    finally:
        delete_tmpfile(duthost, tmpfile)
def test_portchannel_interface_tc2_xfail(duthost, op, name,
        dummy_portchannel_interface_v4, dummy_portchannel_interface_v6):
    """ Test invalid ip address and remove unexited interface

    ("add", "PortChannel0001", "10.0.0.256/31", "FC00::71/126"), ADD Invalid IPv4 address
    ("add", "PortChannel0001", "10.0.0.56/31", "FC00::xyz/126"), ADD Invalid IPv6 address
    ("remove", "PortChannel0001", "10.0.0.57/31", "FC00::71/126"), REMOVE Unexist IPv4 address
    ("remove", "PortChannel0001", "10.0.0.56/31", "FC00::72/126"), REMOVE Unexist IPv6 address
    """

    dummy_portchannel_interface_v4 = name + "|" + dummy_portchannel_interface_v4
    dummy_portchannel_interface_v6 = name + "|" + dummy_portchannel_interface_v6
    json_patch = [
        {
            "op": "{}".format(op),
            "path": create_path(["PORTCHANNEL_INTERFACE", dummy_portchannel_interface_v4]),
            "value": {}
        },
        {
            "op": "{}".format(op),
            "path": create_path(["PORTCHANNEL_INTERFACE", dummy_portchannel_interface_v6]),
            "value": {}
        }
    ]

    tmpfile = generate_tmpfile(duthost)
    logger.info("tmpfile {}".format(tmpfile))

    try:
        output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile)
        expect_op_failure(output)
    finally:
        delete_tmpfile(duthost, tmpfile)
示例#3
0
def test_vlan_interface_tc2_xfail(duthost, op, name, dummy_vlan_interface_v4,
                                  dummy_vlan_interface_v6):
    """ Test expect fail testcase

    ("add", "Vlan1000", "587.168.0.1/21", "fc02:1000::1/64"), ADD Invalid IPv4 address
    ("add", "Vlan1000", "192.168.0.1/21", "fc02:1000::xyz/64"), ADD Invalid IPv6 address
    ("remove", "Vlan1000", "192.168.0.2/21", "fc02:1000::1/64"), REMOVE Unexist IPv4 address
    ("remove", "Vlan1000", "192.168.0.1/21", "fc02:1000::2/64") REMOVE Unexist IPv6 address
    """
    dummy_vlan_interface_v4 = name + "|" + dummy_vlan_interface_v4
    dummy_vlan_interface_v6 = name + "|" + dummy_vlan_interface_v6

    json_patch = [{
        "op":
        "{}".format(op),
        "path":
        create_path(["VLAN_INTERFACE", dummy_vlan_interface_v4]),
        "value": {}
    }, {
        "op":
        "{}".format(op),
        "path":
        create_path(["VLAN_INTERFACE", dummy_vlan_interface_v6]),
        "value": {}
    }]

    tmpfile = generate_tmpfile(duthost)
    logger.info("tmpfile {}".format(tmpfile))

    try:
        output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile)
        expect_op_failure(output)
    finally:
        delete_tmpfile(duthost, tmpfile)
示例#4
0
def test_portchannel_interface_tc1_add_new_portchannel(duthost):
    """ Clean up original portchannel intf and apply-patch to default config

    Expected output
    admin@vlab-01:~$ show ip interfaces
    Interface        Master    IPv4 address/mask    Admin/Oper    BGP Neighbor    Neighbor IP
    ---------------  --------  -------------------  ------------  --------------  -------------
    ...
    PortChannel0005            10.0.0.64/31         up/down       N/A             N/A
    admin@vlab-01:~$ show ipv6 interfaces
    Interface        Master           IPv4 address/mask                           Admin/Oper    BGP Neighbor    Neighbor IP
    ---------------  ---------------  ------------------------------------------  ------------  --------------  -------------
    ...
    PortChannel0005                   fc00::81/126                                up/down       N/A             N/A
    """

    json_patch = [{
        "op": "add",
        "path": "/PORTCHANNEL/PortChannel0005",
        "value": {
            "admin_status": "up"
        }
    }, {
        "op": "add",
        "path": "/PORTCHANNEL_INTERFACE/PortChannel0005",
        "value": {}
    }, {
        "op":
        "add",
        "path":
        create_path(["PORTCHANNEL_INTERFACE", "PortChannel0005|10.0.0.64/31"]),
        "value": {}
    }, {
        "op":
        "add",
        "path":
        create_path(["PORTCHANNEL_INTERFACE", "PortChannel0005|FC00::81/126"]),
        "value": {}
    }]

    logger.info("json patch {}".format(json_patch))

    tmpfile = generate_tmpfile(duthost)
    logger.info("tmpfile {}".format(tmpfile))

    try:
        output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile)
        expect_op_success(duthost, output)

        check_show_ip_intf(duthost,
                           "PortChannel0005", ["10.0.0.64/31"], [],
                           is_ipv4=True)
        check_show_ip_intf(duthost,
                           "PortChannel0005", ["fc00::81/126"], [],
                           is_ipv4=False)
    finally:
        delete_tmpfile(duthost, tmpfile)
示例#5
0
def test_portchannel_interface_tc3_replace(duthost, portchannel_table):
    """ Test portchannel interface replace ip address
    """
    org_ip = portchannel_table["PortChannel101"]["ip"]
    org_ipv6 = portchannel_table["PortChannel101"]["ipv6"]
    rep_ip = "10.0.0.156/31"
    rep_ipv6 = "fc00::171/126"
    json_patch = [{
        "op":
        "remove",
        "path":
        create_path(
            ["PORTCHANNEL_INTERFACE", "PortChannel101|{}".format(org_ip)])
    }, {
        "op":
        "remove",
        "path":
        create_path([
            "PORTCHANNEL_INTERFACE",
            "PortChannel101|{}".format(org_ipv6.upper())
        ])
    }, {
        "op":
        "add",
        "path":
        create_path(
            ["PORTCHANNEL_INTERFACE", "PortChannel101|{}".format(rep_ip)]),
        "value": {}
    }, {
        "op":
        "add",
        "path":
        create_path(
            ["PORTCHANNEL_INTERFACE", "PortChannel101|{}".format(rep_ipv6)]),
        "value": {}
    }]

    logger.info("json patch {}".format(json_patch))

    tmpfile = generate_tmpfile(duthost)
    logger.info("tmpfile {}".format(tmpfile))

    try:
        output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile)
        expect_op_success(duthost, output)

        check_show_ip_intf(duthost,
                           "PortChannel101", [rep_ip], [org_ip],
                           is_ipv4=True)
        check_show_ip_intf(duthost,
                           "PortChannel101", [rep_ipv6], [org_ipv6],
                           is_ipv4=False)
    finally:
        delete_tmpfile(duthost, tmpfile)
示例#6
0
def test_vlan_interface_tc4_replace(duthost):
    """ Test replace testcase

    Expected output
        "VLAN_INTERFACE": {
        "Vlan1000": {},
        "Vlan1000|192.168.0.2/21": {},
        "Vlan1000|fc02:1000::2/64": {}
    }
    """
    json_patch = [{
        "op":
        "remove",
        "path":
        create_path(["VLAN_INTERFACE", "Vlan1000|fc02:1000::1/64"]),
    }, {
        "op":
        "remove",
        "path":
        create_path(["VLAN_INTERFACE", "Vlan1000|192.168.0.1/21"]),
    }, {
        "op":
        "add",
        "path":
        create_path(["VLAN_INTERFACE", "Vlan1000|192.168.0.2/21"]),
        "value": {}
    }, {
        "op":
        "add",
        "path":
        create_path(["VLAN_INTERFACE", "Vlan1000|fc02:1000::2/64"]),
        "value": {}
    }]

    tmpfile = generate_tmpfile(duthost)
    logger.info("tmpfile {}".format(tmpfile))

    try:
        output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile)
        expect_op_success(duthost, output)

        check_show_ip_intf(duthost,
                           "Vlan1000", ["192.168.0.2/21"], ["192.168.0.1/21"],
                           is_ipv4=True)
        check_show_ip_intf(duthost,
                           "Vlan1000", ["fc02:1000::2/64"],
                           ["fc02:1000::1/64"],
                           is_ipv4=False)
    finally:
        delete_tmpfile(duthost, tmpfile)
示例#7
0
def test_vlan_interface_tc1_add_duplicate(duthost):
    """ Add duplicate v4 and v6 lo intf to config

    Sample output
        "VLAN_INTERFACE": {
        "Vlan1000": {},
        "Vlan1000|192.168.0.1/21": {},
        "Vlan1000|fc02:1000::1/64": {}
    }
    """
    json_patch = [{
        "op":
        "add",
        "path":
        create_path(["VLAN_INTERFACE", "Vlan1000|192.168.0.1/21"]),
        "value": {}
    }, {
        "op":
        "add",
        "path":
        create_path(["VLAN_INTERFACE", "Vlan1000|fc02:1000::1/64"]),
        "value": {}
    }]

    logger.info("json patch {}".format(json_patch))

    tmpfile = generate_tmpfile(duthost)
    logger.info("tmpfile {}".format(tmpfile))

    try:
        output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile)
        expect_op_success(duthost, output)

        check_show_ip_intf(duthost,
                           "Vlan1000", ["192.168.0.1/21"], [],
                           is_ipv4=True)
        check_show_ip_intf(duthost,
                           "Vlan1000", ["fc02:1000::1/64"], [],
                           is_ipv4=False)
    finally:
        delete_tmpfile(duthost, tmpfile)
示例#8
0
def test_portchannel_interface_tc2_add_duplicate(duthost, portchannel_table):
    """ Test adding duplicate portchannel interface
    """
    dup_ip = portchannel_table["PortChannel101"]["ip"]
    dup_ipv6 = portchannel_table["PortChannel101"]["ipv6"]
    json_patch = [{
        "op":
        "add",
        "path":
        create_path(
            ["PORTCHANNEL_INTERFACE", "PortChannel101|{}".format(dup_ip)]),
        "value": {}
    }, {
        "op":
        "add",
        "path":
        create_path([
            "PORTCHANNEL_INTERFACE",
            "PortChannel101|{}".format(dup_ipv6.upper())
        ]),
        "value": {}
    }]

    logger.info("json patch {}".format(json_patch))

    tmpfile = generate_tmpfile(duthost)
    logger.info("tmpfile {}".format(tmpfile))

    try:
        output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile)
        expect_op_success(duthost, output)

        check_show_ip_intf(duthost,
                           "PortChannel101", [dup_ip], [],
                           is_ipv4=True)
        check_show_ip_intf(duthost,
                           "PortChannel101", [dup_ipv6], [],
                           is_ipv4=False)
    finally:
        delete_tmpfile(duthost, tmpfile)
示例#9
0
def test_vlan_interface_tc3_add_new(duthost):
    """ Add an brand new vlan interface Vlan2000

    Sample output:
    "VLAN": {
        "Vlan1000": {
            "dhcp_servers": [
                "192.0.0.1",
                "192.0.0.2",
                "192.0.0.3",
                "192.0.0.4"
            ],
            "vlanid": "1000"
        },
        "Vlan2000": {
            "vlanid": "2000"
        }
    },
    "VLAN_INTERFACE": {
        "Vlan1000": {},
        "Vlan2000": {},
        "Vlan1000|192.168.0.1/21": {},
        "Vlan1000|fc02:1000::1/64": {},
        "Vlan2000|192.168.8.1/21": {},
        "Vlan2000|fc02:2000::1/64": {}
    }

    admin@vlab-01:~/vlan$ show ip interfaces | grep -w Vlan2000
    Vlan2000                   192.168.8.1/21       up/up         N/A             N/A
    admin@vlab-01:~/vlan$ show ipv6 interfaces | grep -w Vlan2000
    Vlan2000                          fc02:2000::1/64                             up/up         N/A             N/A
                                      fe80::5054:ff:feda:c6af%Vlan2000/64                       N/A             N/A

    """
    json_patch = [{
        "op": "add",
        "path": "/VLAN_INTERFACE/Vlan2000",
        "value": {}
    }, {
        "op":
        "add",
        "path":
        create_path(["VLAN_INTERFACE", "Vlan2000|192.168.8.1/21"]),
        "value": {}
    }, {
        "op":
        "add",
        "path":
        create_path(["VLAN_INTERFACE", "Vlan2000|fc02:2000::1/64"]),
        "value": {}
    }, {
        "op": "add",
        "path": "/VLAN/Vlan2000",
        "value": {
            "vlanid": "2000"
        }
    }]

    tmpfile = generate_tmpfile(duthost)
    logger.info("tmpfile {}".format(tmpfile))

    try:
        output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile)
        expect_op_success(duthost, output)

        check_show_ip_intf(duthost,
                           "Vlan2000", ["192.168.8.1/21"], [],
                           is_ipv4=True)
        check_show_ip_intf(duthost,
                           "Vlan2000", ["fc02:2000::1/64"], [],
                           is_ipv4=False)
    finally:
        delete_tmpfile(duthost, tmpfile)