def test_add_network_with_running_bond(self): fake_running_bonds = {'bond1': {}} fake_to_be_added_bonds = {} fake_kernel_nics = [] validator.validate_net_configuration( 'net1', {'bonding': 'bond1', 'switch': 'ovs'}, fake_to_be_added_bonds, fake_running_bonds, fake_kernel_nics)
def test_adding_a_second_untagged_net(self): fake_running_bonds = {} fake_to_be_added_bonds = {} fake_kernel_nics = ['eth0', 'eth1'] validator.validate_net_configuration( 'net2', {'nic': 'eth1', 'switch': 'ovs'}, fake_to_be_added_bonds, fake_running_bonds, fake_kernel_nics)
def test_add_network_with_non_existing_bond(self): fake_running_bonds = {} fake_to_be_added_bonds = {} fake_kernel_nics = [] with self.assertRaises(ne.ConfigNetworkError) as e: validator.validate_net_configuration( 'net1', {'bonding': 'bond1', 'switch': 'ovs'}, fake_to_be_added_bonds, fake_running_bonds, fake_kernel_nics) self.assertEqual(e.exception.args[0], ne.ERR_BAD_BONDING)
def test_add_network_with_non_existing_bond(self): fake_running_bonds = {} fake_to_be_added_bonds = {} fake_kernel_nics = [] with pytest.raises(ne.ConfigNetworkError) as e: validator.validate_net_configuration('net1', { 'bonding': 'bond1', 'switch': 'ovs' }, fake_to_be_added_bonds, fake_running_bonds, fake_kernel_nics) assert e.value.errCode == ne.ERR_BAD_BONDING
def test_edit_single_untagged_net_nic(self): fake_running_bonds = {} fake_to_be_added_bonds = {} fake_kernel_nics = ['eth0', 'eth1'] validator.validate_net_configuration( 'net1', {'nic': 'eth1', 'switch': 'ovs'}, fake_to_be_added_bonds, fake_running_bonds, fake_kernel_nics, )
def test_network_with_invalid_vlan_id(self, vlan_id): net_name = 'net1' net_attrs = { 'vlan': vlan_id, 'bridged': True, 'legacy': True, 'nic': 'eth0' } bonds = desired_bonds = {} nics = {} with pytest.raises(ne.ConfigNetworkError) as cne_context: validator.validate_net_configuration(net_name, net_attrs, desired_bonds, bonds, nics) assert cne_context.value.errCode == ne.ERR_BAD_VLAN
def test_remove_broken_net_succeeds(self): net_name = 'net1' net_attrs = {'remove': True} bonds = desired_bonds = {} nics = {} validator.validate_net_configuration( net_name, net_attrs, desired_bonds, bonds, nics, running_config_networks={net_name: {'nic': 'eth0'}}, )
def test_remove_missing_net_fails(self): net_name = 'net1' net_attrs = {'remove': True} bonds = desired_bonds = {} nics = {} with pytest.raises(ne.ConfigNetworkError) as cne: validator.validate_net_configuration(net_name, net_attrs, desired_bonds, bonds, nics, netinfo_networks={}, running_config_networks={}) assert cne.value.errCode == ne.ERR_BAD_BRIDGE