Example #1
0
    def test_two_identical_qos_on_same_bond(self):
        nets_info = {
            NETWORK1_NAME: {
                'vlan': VLAN1,
                'bonding': BOND,
                'southbound': BOND + '.' + str(VLAN1),
                'hostQos': HOST_QOS_CONFIG1,
            },
            NETWORK2_NAME: {
                'bonding': BOND,
                'southbound': BOND,
                'hostQos': HOST_QOS_CONFIG1,
            },
        }

        devices_info = _create_devices_info_dict(
            vlans={BOND + '.' + str(VLAN1): {'iface': BOND}},
            bondings={BOND: {}},
        )

        expected_devices_info = _create_devices_info_dict(
            vlans=devices_info['vlans'],
            bondings={
                BOND: {
                    'qos': [
                        {'hostQos': HOST_QOS_CONFIG1, 'vlan': -1},
                        {'hostQos': HOST_QOS_CONFIG1, 'vlan': VLAN1},
                    ]
                }
            },
        )

        add_qos_info_to_devices(nets_info, devices_info)

        assert devices_info == expected_devices_info
Example #2
0
    def test_non_vlanned_qos_on_nic_and_bonded_nets(self):
        nets_info = {
            NETWORK1_NAME: {
                'nic': NIC,
                'southbound': NIC,
                'hostQos': HOST_QOS_CONFIG1,
            },
            NETWORK2_NAME: {
                'bonding': BOND,
                'southbound': BOND,
                'hostQos': HOST_QOS_CONFIG2,
            },
        }

        devices_info = _create_devices_info_dict(
            bondings={BOND: {}}, nics={NIC: {}}
        )

        expected_devices_info = _create_devices_info_dict(
            bondings={
                BOND: {'qos': [{'hostQos': HOST_QOS_CONFIG2, 'vlan': -1}]}
            },
            nics={NIC: {'qos': [{'hostQos': HOST_QOS_CONFIG1, 'vlan': -1}]}},
        )

        add_qos_info_to_devices(nets_info, devices_info)

        assert devices_info == expected_devices_info
Example #3
0
    def test_no_devices_no_networks(self):
        nets_info = {}

        devices_info = _create_devices_info_dict()
        expected_devices_info = _create_devices_info_dict()

        add_qos_info_to_devices(nets_info, devices_info)

        assert devices_info == expected_devices_info
Example #4
0
    def test_no_qos_on_nic_and_bonded_nets(self):
        nets_info = {
            NETWORK1_NAME: {'nic': NIC, 'southbound': NIC},
            NETWORK2_NAME: {'bonding': BOND, 'southbound': BOND},
        }

        devices_info = _create_devices_info_dict()
        expected_devices_info = _create_devices_info_dict()

        add_qos_info_to_devices(nets_info, devices_info)

        assert devices_info == expected_devices_info
Example #5
0
    def test_vlanned_nets_with_qos(self):
        nets_info = {
            NETWORK1_NAME: {
                'nic': NIC,
                'vlan': VLAN1,
                'southbound': NIC + '.' + str(VLAN1),
                'hostQos': HOST_QOS_CONFIG1,
            },
            NETWORK2_NAME: {
                'bonding': BOND,
                'vlan': VLAN2,
                'southbound': BOND + '.' + str(VLAN2),
                'hostQos': HOST_QOS_CONFIG2,
            },
        }

        devices_info = _create_devices_info_dict(
            vlans={
                NIC + '.' + str(VLAN1): {
                    'iface': NIC
                },
                BOND + '.' + str(VLAN2): {
                    'iface': BOND
                },
            },
            bondings={BOND: {}},
            nics={NIC: {}},
        )

        expected_devices_info = _create_devices_info_dict(
            vlans=devices_info['vlans'],
            bondings={
                BOND: {
                    'qos': [{
                        'hostQos': HOST_QOS_CONFIG2,
                        'vlan': VLAN2
                    }]
                }
            },
            nics={
                NIC: {
                    'qos': [{
                        'hostQos': HOST_QOS_CONFIG1,
                        'vlan': VLAN1
                    }]
                }
            },
        )

        add_qos_info_to_devices(nets_info, devices_info)

        assert devices_info == expected_devices_info