예제 #1
0
    def _addNetworkWithExc(self, netName, opts, errCode):
        fakeInfo = netinfo.cache.CachingNetInfo(FAKE_NETINFO)
        configurator = ifcfg.Ifcfg(fakeInfo)

        with pytest.raises(errors.ConfigNetworkError) as cneContext:
            canonicalize_networks({netName: opts})
            validator.validate_network_setup({netName: opts}, {}, FAKE_NETINFO)
            legacy_switch._add_network(netName, configurator, fakeInfo, None,
                                       **opts)
        assert cneContext.value.errCode == errCode
예제 #2
0
 def testValidateNetSetupRemoveParamValidation(self):
     networks = {
         'test-network': {
             'nic': 'dummy',
             'remove': True,
             'bridged': True
         }
     }
     with pytest.raises(errors.ConfigNetworkError) as cneContext:
         validator.validate_network_setup(networks, {}, FAKE_NETINFO)
     assert cneContext.value.errCode == errors.ERR_BAD_PARAMS
예제 #3
0
 def testValidateNetSetupRemoveParamValidation(self, bond_mock):
     bond_mock.return_value.bonds.return_value = []
     networks = {
         'test-network': {
             'nic': 'dummy',
             'remove': True,
             'bridged': True
         }
     }
     with pytest.raises(errors.ConfigNetworkError) as cneContext:
         validator.validate_network_setup(networks, {}, {'networks': {}})
     assert cneContext.value.errCode == errors.ERR_BAD_PARAMS
예제 #4
0
 def testValidateNetSetupRemoveParamValidation(self, bond_mock):
     bond_mock.return_value.bonds.return_value = []
     networks = {
         'test-network': {
             'nic': 'dummy',
             'remove': True,
             'bridged': True
         }
     }
     with self.assertRaises(errors.ConfigNetworkError) as cneContext:
         validator.validate_network_setup(networks, {}, {})
     self.assertEqual(cneContext.exception.errCode, errors.ERR_BAD_PARAMS)
예제 #5
0
 def _validate_network_with_err(self, netName, opts, errCode):
     with pytest.raises(errors.ConfigNetworkError) as cneContext:
         canonicalize_networks({netName: opts})
         validator.validate_network_setup({netName: opts}, {}, FAKE_NETINFO)
     assert cneContext.value.errCode == errCode