Ejemplo n.º 1
0
def test_that_iproute2_address(*args):

    # dummy test device
    dv1 = TestDevice()

    out = IpAddress.show(
        input_data=[{"test_dev": [{}]}],
        device_obj={"test_dev": dv1},
    )
    # check if the command was formed
    assert "command" in out[0]["test_dev"].keys()
    assert "result" in out[0]["test_dev"].keys()
    time.sleep(3)
Ejemplo n.º 2
0
def test_that_ip_address_restore(capfd):

    dv1 = TestDevice(platform="dentos")
    dv2 = TestDevice(platform="dentos")
    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.restore(
            input_data=[{
                # device 1
                "test_dev": [{}],
            }],
            device_obj={"test_dev": dv1},
        ))
    print(out)
    assert "command" in out[0]["test_dev"].keys()
    assert "result" in out[0]["test_dev"].keys()
    # check the rc
    assert out[0]["test_dev"]["rc"] == 0

    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.restore(
            input_data=[{
                # device 1
                "test_dev1": [
                    {
                        # command 1
                        "options": "tikonfxi",
                    },
                    {
                        # command 2
                        "options": "ldnjakto",
                    },
                ],
            }],
            device_obj={
                "test_dev1": dv1,
                "test_dev2": dv2
            },
        ))
    print(out)
    # check if the command was formed
    assert "command" in out[0]["test_dev1"].keys()
    # check if the result was formed
    assert "result" in out[0]["test_dev1"].keys()
    # check the rc
    assert out[0]["test_dev1"]["rc"] == 0

    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.restore(
            input_data=[{
                # device 1
                "test_dev1": [{
                    "options": "tikonfxi",
                }],
                # device 2
                "test_dev2": [{
                    "options": "ldnjakto",
                }],
            }],
            device_obj={
                "test_dev1": dv1,
                "test_dev2": dv2
            },
        ))
    print(out)
    # check if the command was formed
    assert "command" in out[0]["test_dev1"].keys()
    assert "command" in out[1]["test_dev2"].keys()
    # check if the result was formed
    assert "result" in out[0]["test_dev1"].keys()
    assert "result" in out[1]["test_dev2"].keys()
    # check the rc
    assert out[0]["test_dev1"]["rc"] == 0
    assert out[1]["test_dev2"]["rc"] == 0
Ejemplo n.º 3
0
def test_that_ip_address_flush(capfd):

    dv1 = TestDevice(platform="dentos")
    dv2 = TestDevice(platform="dentos")
    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.flush(
            input_data=[{
                # device 1
                "test_dev": [{}],
            }],
            device_obj={"test_dev": dv1},
        ))
    print(out)
    assert "command" in out[0]["test_dev"].keys()
    assert "result" in out[0]["test_dev"].keys()
    # check the rc
    assert out[0]["test_dev"]["rc"] == 0

    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.flush(
            input_data=[{
                # device 1
                "test_dev1": [
                    {
                        # command 1
                        "dev": "jxuixlah",
                        "scope": 2535,
                        "prefix": "128.117.222.54",
                        "options": "qabexiqa",
                    },
                    {
                        # command 2
                        "dev": "oddchjya",
                        "scope": 1173,
                        "prefix": "109.102.251.32",
                        "options": "gpphvqwj",
                    },
                ],
            }],
            device_obj={
                "test_dev1": dv1,
                "test_dev2": dv2
            },
        ))
    print(out)
    # check if the command was formed
    assert "command" in out[0]["test_dev1"].keys()
    # check if the result was formed
    assert "result" in out[0]["test_dev1"].keys()
    # check the rc
    assert out[0]["test_dev1"]["rc"] == 0

    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.flush(
            input_data=[{
                # device 1
                "test_dev1": [{
                    "dev": "jxuixlah",
                    "scope": 2535,
                    "prefix": "128.117.222.54",
                    "options": "qabexiqa",
                }],
                # device 2
                "test_dev2": [{
                    "dev": "oddchjya",
                    "scope": 1173,
                    "prefix": "109.102.251.32",
                    "options": "gpphvqwj",
                }],
            }],
            device_obj={
                "test_dev1": dv1,
                "test_dev2": dv2
            },
        ))
    print(out)
    # check if the command was formed
    assert "command" in out[0]["test_dev1"].keys()
    assert "command" in out[1]["test_dev2"].keys()
    # check if the result was formed
    assert "result" in out[0]["test_dev1"].keys()
    assert "result" in out[1]["test_dev2"].keys()
    # check the rc
    assert out[0]["test_dev1"]["rc"] == 0
    assert out[1]["test_dev2"]["rc"] == 0
Ejemplo n.º 4
0
def test_that_ip_address_show(capfd):

    dv1 = TestDevice(platform="dentos")
    dv2 = TestDevice(platform="dentos")
    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.show(
            input_data=[{
                # device 1
                "test_dev": [{}],
            }],
            device_obj={"test_dev": dv1},
        ))
    print(out)
    assert "command" in out[0]["test_dev"].keys()
    assert "result" in out[0]["test_dev"].keys()
    # check the rc
    assert out[0]["test_dev"]["rc"] == 0

    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.show(
            input_data=[{
                # device 1
                "test_dev1": [
                    {
                        # command 1
                        "dev": "etpmofxl",
                        "scope": 1302,
                        "prefix": "121.185.149.14",
                        "label": "ohmdtsmy",
                        "options": "aetsaobt",
                    },
                    {
                        # command 2
                        "dev": "cekbcgui",
                        "scope": 2358,
                        "prefix": "188.71.46.56",
                        "label": "idmxryad",
                        "options": "chfjsdnf",
                    },
                ],
            }],
            device_obj={
                "test_dev1": dv1,
                "test_dev2": dv2
            },
        ))
    print(out)
    # check if the command was formed
    assert "command" in out[0]["test_dev1"].keys()
    # check if the result was formed
    assert "result" in out[0]["test_dev1"].keys()
    # check the rc
    assert out[0]["test_dev1"]["rc"] == 0

    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.show(
            input_data=[{
                # device 1
                "test_dev1": [{
                    "dev": "etpmofxl",
                    "scope": 1302,
                    "prefix": "121.185.149.14",
                    "label": "ohmdtsmy",
                    "options": "aetsaobt",
                }],
                # device 2
                "test_dev2": [{
                    "dev": "cekbcgui",
                    "scope": 2358,
                    "prefix": "188.71.46.56",
                    "label": "idmxryad",
                    "options": "chfjsdnf",
                }],
            }],
            device_obj={
                "test_dev1": dv1,
                "test_dev2": dv2
            },
        ))
    print(out)
    # check if the command was formed
    assert "command" in out[0]["test_dev1"].keys()
    assert "command" in out[1]["test_dev2"].keys()
    # check if the result was formed
    assert "result" in out[0]["test_dev1"].keys()
    assert "result" in out[1]["test_dev2"].keys()
    # check the rc
    assert out[0]["test_dev1"]["rc"] == 0
    assert out[1]["test_dev2"]["rc"] == 0
Ejemplo n.º 5
0
def test_that_ip_address_save(capfd):

    dv1 = TestDevice(platform="dentos")
    dv2 = TestDevice(platform="dentos")
    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.save(
            input_data=[{
                # device 1
                "test_dev": [{}],
            }],
            device_obj={"test_dev": dv1},
        ))
    print(out)
    assert "command" in out[0]["test_dev"].keys()
    assert "result" in out[0]["test_dev"].keys()
    # check the rc
    assert out[0]["test_dev"]["rc"] == 0

    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.save(
            input_data=[{
                # device 1
                "test_dev1": [
                    {
                        # command 1
                        "dev": "vylnpoey",
                        "scope": 368,
                        "prefix": "239.9.12.238",
                        "options": "vakpkkha",
                    },
                    {
                        # command 2
                        "dev": "daafvgsc",
                        "scope": 8225,
                        "prefix": "196.223.213.188",
                        "options": "vnnjbqfn",
                    },
                ],
            }],
            device_obj={
                "test_dev1": dv1,
                "test_dev2": dv2
            },
        ))
    print(out)
    # check if the command was formed
    assert "command" in out[0]["test_dev1"].keys()
    # check if the result was formed
    assert "result" in out[0]["test_dev1"].keys()
    # check the rc
    assert out[0]["test_dev1"]["rc"] == 0

    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.save(
            input_data=[{
                # device 1
                "test_dev1": [{
                    "dev": "vylnpoey",
                    "scope": 368,
                    "prefix": "239.9.12.238",
                    "options": "vakpkkha",
                }],
                # device 2
                "test_dev2": [{
                    "dev": "daafvgsc",
                    "scope": 8225,
                    "prefix": "196.223.213.188",
                    "options": "vnnjbqfn",
                }],
            }],
            device_obj={
                "test_dev1": dv1,
                "test_dev2": dv2
            },
        ))
    print(out)
    # check if the command was formed
    assert "command" in out[0]["test_dev1"].keys()
    assert "command" in out[1]["test_dev2"].keys()
    # check if the result was formed
    assert "result" in out[0]["test_dev1"].keys()
    assert "result" in out[1]["test_dev2"].keys()
    # check the rc
    assert out[0]["test_dev1"]["rc"] == 0
    assert out[1]["test_dev2"]["rc"] == 0
Ejemplo n.º 6
0
def test_that_ip_address_delete(capfd):

    dv1 = TestDevice(platform="dentos")
    dv2 = TestDevice(platform="dentos")
    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.delete(
            input_data=[{
                # device 1
                "test_dev": [{}],
            }],
            device_obj={"test_dev": dv1},
        ))
    print(out)
    assert "command" in out[0]["test_dev"].keys()
    assert "result" in out[0]["test_dev"].keys()
    # check the rc
    assert out[0]["test_dev"]["rc"] == 0

    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.delete(
            input_data=[{
                # device 1
                "test_dev1": [
                    {
                        # command 1
                        "prefix": "91.82.174.217",
                        "peer": "42.105.119.134",
                        "broadcast": "69:3e:39:7c:fc:9f",
                        "anycast": "69.110.235.248",
                        "label": "uptrfabe",
                        "scope": 3297,
                        "options": "dcboqeou",
                    },
                    {
                        # command 2
                        "prefix": "164.229.126.44",
                        "peer": "193.97.125.30",
                        "broadcast": "68:d3:ae:4e:12:28",
                        "anycast": "165.251.142.70",
                        "label": "bklqqpyg",
                        "scope": 8780,
                        "options": "gvwbdbzs",
                    },
                ],
            }],
            device_obj={
                "test_dev1": dv1,
                "test_dev2": dv2
            },
        ))
    print(out)
    # check if the command was formed
    assert "command" in out[0]["test_dev1"].keys()
    # check if the result was formed
    assert "result" in out[0]["test_dev1"].keys()
    # check the rc
    assert out[0]["test_dev1"]["rc"] == 0

    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.delete(
            input_data=[{
                # device 1
                "test_dev1": [{
                    "prefix": "91.82.174.217",
                    "peer": "42.105.119.134",
                    "broadcast": "69:3e:39:7c:fc:9f",
                    "anycast": "69.110.235.248",
                    "label": "uptrfabe",
                    "scope": 3297,
                    "options": "dcboqeou",
                }],
                # device 2
                "test_dev2": [{
                    "prefix": "164.229.126.44",
                    "peer": "193.97.125.30",
                    "broadcast": "68:d3:ae:4e:12:28",
                    "anycast": "165.251.142.70",
                    "label": "bklqqpyg",
                    "scope": 8780,
                    "options": "gvwbdbzs",
                }],
            }],
            device_obj={
                "test_dev1": dv1,
                "test_dev2": dv2
            },
        ))
    print(out)
    # check if the command was formed
    assert "command" in out[0]["test_dev1"].keys()
    assert "command" in out[1]["test_dev2"].keys()
    # check if the result was formed
    assert "result" in out[0]["test_dev1"].keys()
    assert "result" in out[1]["test_dev2"].keys()
    # check the rc
    assert out[0]["test_dev1"]["rc"] == 0
    assert out[1]["test_dev2"]["rc"] == 0
Ejemplo n.º 7
0
def test_that_ip_address_replace(capfd):

    dv1 = TestDevice(platform="dentos")
    dv2 = TestDevice(platform="dentos")
    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.replace(
            input_data=[{
                # device 1
                "test_dev": [{}],
            }],
            device_obj={"test_dev": dv1},
        ))
    print(out)
    assert "command" in out[0]["test_dev"].keys()
    assert "result" in out[0]["test_dev"].keys()
    # check the rc
    assert out[0]["test_dev"]["rc"] == 0

    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.replace(
            input_data=[{
                # device 1
                "test_dev1": [
                    {
                        # command 1
                        "prefix": "16.214.42.217",
                        "peer": "214.236.182.233",
                        "broadcast": "da:60:d9:47:a8:a9",
                        "anycast": "159.36.3.144",
                        "label": "aeypcwzv",
                        "scope": 8625,
                        "dev": "yqqrlzza",
                        "options": "kjlavsco",
                    },
                    {
                        # command 2
                        "prefix": "76.57.238.65",
                        "peer": "185.187.131.35",
                        "broadcast": "13:37:56:fa:f2:ad",
                        "anycast": "8.192.141.162",
                        "label": "nsegzhdr",
                        "scope": 7812,
                        "dev": "qeksffph",
                        "options": "kghpfzfp",
                    },
                ],
            }],
            device_obj={
                "test_dev1": dv1,
                "test_dev2": dv2
            },
        ))
    print(out)
    # check if the command was formed
    assert "command" in out[0]["test_dev1"].keys()
    # check if the result was formed
    assert "result" in out[0]["test_dev1"].keys()
    # check the rc
    assert out[0]["test_dev1"]["rc"] == 0

    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.replace(
            input_data=[{
                # device 1
                "test_dev1": [{
                    "prefix": "16.214.42.217",
                    "peer": "214.236.182.233",
                    "broadcast": "da:60:d9:47:a8:a9",
                    "anycast": "159.36.3.144",
                    "label": "aeypcwzv",
                    "scope": 8625,
                    "dev": "yqqrlzza",
                    "options": "kjlavsco",
                }],
                # device 2
                "test_dev2": [{
                    "prefix": "76.57.238.65",
                    "peer": "185.187.131.35",
                    "broadcast": "13:37:56:fa:f2:ad",
                    "anycast": "8.192.141.162",
                    "label": "nsegzhdr",
                    "scope": 7812,
                    "dev": "qeksffph",
                    "options": "kghpfzfp",
                }],
            }],
            device_obj={
                "test_dev1": dv1,
                "test_dev2": dv2
            },
        ))
    print(out)
    # check if the command was formed
    assert "command" in out[0]["test_dev1"].keys()
    assert "command" in out[1]["test_dev2"].keys()
    # check if the result was formed
    assert "result" in out[0]["test_dev1"].keys()
    assert "result" in out[1]["test_dev2"].keys()
    # check the rc
    assert out[0]["test_dev1"]["rc"] == 0
    assert out[1]["test_dev2"]["rc"] == 0
Ejemplo n.º 8
0
def test_that_ip_address_add(capfd):

    dv1 = TestDevice(platform="dentos")
    dv2 = TestDevice(platform="dentos")
    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.add(
            input_data=[{
                # device 1
                "test_dev": [{}],
            }],
            device_obj={"test_dev": dv1},
        ))
    print(out)
    assert "command" in out[0]["test_dev"].keys()
    assert "result" in out[0]["test_dev"].keys()
    # check the rc
    assert out[0]["test_dev"]["rc"] == 0

    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.add(
            input_data=[{
                # device 1
                "test_dev1": [
                    {
                        # command 1
                        "prefix": "62.88.202.186",
                        "peer": "72.94.157.47",
                        "broadcast": "3e:0b:5f:fc:fe:b0",
                        "anycast": "7.5.191.119",
                        "label": "dtvanysl",
                        "scope": 1408,
                        "dev": "uwwuixxr",
                        "options": "srrugtrq",
                    },
                    {
                        # command 2
                        "prefix": "20.230.182.124",
                        "peer": "30.125.168.110",
                        "broadcast": "5c:93:5e:22:2e:7e",
                        "anycast": "42.239.73.54",
                        "label": "ikbbvcoc",
                        "scope": 2828,
                        "dev": "kfcdtxyv",
                        "options": "jbtddqwl",
                    },
                ],
            }],
            device_obj={
                "test_dev1": dv1,
                "test_dev2": dv2
            },
        ))
    print(out)
    # check if the command was formed
    assert "command" in out[0]["test_dev1"].keys()
    # check if the result was formed
    assert "result" in out[0]["test_dev1"].keys()
    # check the rc
    assert out[0]["test_dev1"]["rc"] == 0

    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.add(
            input_data=[{
                # device 1
                "test_dev1": [{
                    "prefix": "62.88.202.186",
                    "peer": "72.94.157.47",
                    "broadcast": "3e:0b:5f:fc:fe:b0",
                    "anycast": "7.5.191.119",
                    "label": "dtvanysl",
                    "scope": 1408,
                    "dev": "uwwuixxr",
                    "options": "srrugtrq",
                }],
                # device 2
                "test_dev2": [{
                    "prefix": "20.230.182.124",
                    "peer": "30.125.168.110",
                    "broadcast": "5c:93:5e:22:2e:7e",
                    "anycast": "42.239.73.54",
                    "label": "ikbbvcoc",
                    "scope": 2828,
                    "dev": "kfcdtxyv",
                    "options": "jbtddqwl",
                }],
            }],
            device_obj={
                "test_dev1": dv1,
                "test_dev2": dv2
            },
        ))
    print(out)
    # check if the command was formed
    assert "command" in out[0]["test_dev1"].keys()
    assert "command" in out[1]["test_dev2"].keys()
    # check if the result was formed
    assert "result" in out[0]["test_dev1"].keys()
    assert "result" in out[1]["test_dev2"].keys()
    # check the rc
    assert out[0]["test_dev1"]["rc"] == 0
    assert out[1]["test_dev2"]["rc"] == 0
Ejemplo n.º 9
0
def test_that_ip_address_change(capfd):

    dv1 = TestDevice(platform="dentos")
    dv2 = TestDevice(platform="dentos")
    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.change(
            input_data=[{
                # device 1
                "test_dev": [{}],
            }],
            device_obj={"test_dev": dv1},
        ))
    print(out)
    assert "command" in out[0]["test_dev"].keys()
    assert "result" in out[0]["test_dev"].keys()
    # check the rc
    assert out[0]["test_dev"]["rc"] == 0

    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.change(
            input_data=[{
                # device 1
                "test_dev1": [
                    {
                        # command 1
                        "prefix": "143.53.8.129",
                        "peer": "28.216.44.84",
                        "broadcast": "f6:df:96:33:01:a5",
                        "anycast": "19.174.71.166",
                        "label": "xzbicfav",
                        "scope": 9750,
                        "dev": "amkxzfea",
                        "options": "abipgeog",
                    },
                    {
                        # command 2
                        "prefix": "247.18.109.109",
                        "peer": "175.8.73.198",
                        "broadcast": "58:36:9e:a3:12:85",
                        "anycast": "63.140.185.186",
                        "label": "gfegvakh",
                        "scope": 8881,
                        "dev": "snddfnck",
                        "options": "fxbrggeq",
                    },
                ],
            }],
            device_obj={
                "test_dev1": dv1,
                "test_dev2": dv2
            },
        ))
    print(out)
    # check if the command was formed
    assert "command" in out[0]["test_dev1"].keys()
    # check if the result was formed
    assert "result" in out[0]["test_dev1"].keys()
    # check the rc
    assert out[0]["test_dev1"]["rc"] == 0

    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.change(
            input_data=[{
                # device 1
                "test_dev1": [{
                    "prefix": "143.53.8.129",
                    "peer": "28.216.44.84",
                    "broadcast": "f6:df:96:33:01:a5",
                    "anycast": "19.174.71.166",
                    "label": "xzbicfav",
                    "scope": 9750,
                    "dev": "amkxzfea",
                    "options": "abipgeog",
                }],
                # device 2
                "test_dev2": [{
                    "prefix": "247.18.109.109",
                    "peer": "175.8.73.198",
                    "broadcast": "58:36:9e:a3:12:85",
                    "anycast": "63.140.185.186",
                    "label": "gfegvakh",
                    "scope": 8881,
                    "dev": "snddfnck",
                    "options": "fxbrggeq",
                }],
            }],
            device_obj={
                "test_dev1": dv1,
                "test_dev2": dv2
            },
        ))
    print(out)
    # check if the command was formed
    assert "command" in out[0]["test_dev1"].keys()
    assert "command" in out[1]["test_dev2"].keys()
    # check if the result was formed
    assert "result" in out[0]["test_dev1"].keys()
    assert "result" in out[1]["test_dev2"].keys()
    # check the rc
    assert out[0]["test_dev1"]["rc"] == 0
    assert out[1]["test_dev2"]["rc"] == 0