def test_request_multi_defroute(self, mockRConfig): mockRConfig.return_value.networks = {} nets_base_setup = _merge_dicts(NET0_SETUP, NET1_SETUP) requested_nets = self._nets_config(nets_base_setup, default_route=True) with self.assertRaises(ne.ConfigNetworkError): canonicalize.canonicalize_networks(requested_nets)
def _addNetworkWithExc(self, netName, opts, errCode): configurator = legacy_switch.ConfiguratorClass() with self.assertRaises(errors.ConfigNetworkError) as cneContext: canonicalize_networks({netName: opts}) legacy_switch._add_network(netName, configurator, **opts) self.assertEqual(cneContext.exception.errCode, errCode)
def _addNetworkWithExc(self, netName, opts, errCode): configurator = legacy_switch.ConfiguratorClass() with self.assertRaises(errors.ConfigNetworkError) as cneContext: canonicalize_networks({netName: opts}) legacy_switch._addNetwork(netName, configurator, **opts) self.assertEqual(cneContext.exception.errCode, errCode)
def _addNetworkWithExc(self, netName, opts, errCode): fakeInfo = netinfo.cache.CachingNetInfo(FAKE_NETINFO) configurator = ifcfg.Ifcfg(fakeInfo) with self.assertRaises(errors.ConfigNetworkError) as cneContext: canonicalize_networks({netName: opts}) legacy_switch._add_network(netName, configurator, fakeInfo, **opts) self.assertEqual(cneContext.exception.errCode, errCode)
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
def test_request_one_defroute_existing_same_defroute(self, mockRConfig): running_config = self._nets_config(NET0_SETUP, default_route=True) requested_nets = self._nets_config(NET0_SETUP, default_route=True) original_requested_nets = copy.deepcopy(requested_nets) mockRConfig.return_value.networks = running_config canonicalize.canonicalize_networks(requested_nets) self._assert_default_route_keys(original_requested_nets, requested_nets)
def test_request_multi_defroute_removing_existing_different_defroute( self, mockRConfig): running_config = self._nets_config(NET2_SETUP, default_route=True) requested_nets = _merge_dicts( self._nets_config(NET0_SETUP, default_route=True), self._nets_config(NET1_SETUP, default_route=True), self._nets_config(NET2_SETUP, default_route=False)) mockRConfig.return_value.networks = running_config with self.assertRaises(ne.ConfigNetworkError): canonicalize.canonicalize_networks(requested_nets)
def test_request_multi_defroute_removing_existing_different_defroute( self, mockRConfig): running_config = self._nets_config(NET2_SETUP, default_route=True) requested_nets = _merge_dicts( self._nets_config(NET0_SETUP, default_route=True), self._nets_config(NET1_SETUP, default_route=True), self._nets_config(NET2_SETUP, default_route=False) ) mockRConfig.return_value.networks = running_config with self.assertRaises(ne.ConfigNetworkError): canonicalize.canonicalize_networks(requested_nets)
def _upgrade_unified_configuration(config): """ Process an unified configuration file and normalize it to an up do date format. """ if config.networks: _normalize_net_address(config.networks) _normalize_net_ifcfg_keys(config.networks) canonicalize_networks(config.networks) canonicalize_bondings(config.bonds) config.save()
def test_request_one_defroute_removing_existing_different_defroute( self, mockRConfig): running_config = self._nets_config(NET1_SETUP, default_route=True) requested_nets = _merge_dicts( self._nets_config(NET0_SETUP, default_route=True), self._nets_config(NET1_SETUP, default_route=False)) original_requested_nets = copy.deepcopy(requested_nets) mockRConfig.return_value.networks = running_config canonicalize.canonicalize_networks(requested_nets) self._assert_default_route_keys(original_requested_nets, requested_nets)
def test_request_one_defroute_removing_existing_different_defroute( self, mockRConfig): running_config = self._nets_config(NET1_SETUP, default_route=True) requested_nets = _merge_dicts( self._nets_config(NET0_SETUP, default_route=True), self._nets_config(NET1_SETUP, default_route=False) ) original_requested_nets = copy.deepcopy(requested_nets) mockRConfig.return_value.networks = running_config canonicalize.canonicalize_networks(requested_nets) self._assert_default_route_keys(original_requested_nets, requested_nets)
def test_request_one_defroute_existing_different_defroute( self, mockRConfig): running_config = self._nets_config(NET1_SETUP, default_route=True) requested_nets = self._nets_config(NET0_SETUP, default_route=True) original_requested_nets = copy.deepcopy(requested_nets) mockRConfig.return_value.networks = running_config canonicalize.canonicalize_networks(requested_nets) auto_generated_net = self._nets_config(NET1_SETUP, default_route=False) expected_canonicalized_request = _merge_dicts(auto_generated_net, original_requested_nets) self._assert_default_route_keys(expected_canonicalized_request, requested_nets)
def setup(networks, bondings, ping_fn): logging.info('Running VDSM setup of desired config: %s %s', networks, bondings) canonicalize.canonicalize_networks(networks) canonicalize.canonicalize_bondings(bondings) _southbound_to_nic_or_bond(networks, bondings) _canonicalize_bondings(bondings) desired = BaseConfig(networks, bondings) diff = desired.diffFrom(RunningConfig()) logging.info('Configuration difference to be applied: %s %s', diff.networks, diff.bonds) if diff: _run_ping_check_thread(ping_fn, _CONNECTIVITY_TIMEOUT) netapi.setupNetworks( diff.networks, diff.bonds, { 'connectivityCheck': True, 'connectivityTimeout': _CONNECTIVITY_TIMEOUT }) logging.info('Setup is now complete.')
def _upgrade_unified_configuration(config): """ Process an unified configuration file and normalize it to an up do date format. """ save_changes = False if config.networks: _normalize_net_address(config.networks) _normalize_net_ifcfg_keys(config.networks) canonicalize_networks(config.networks) canonicalize_bondings(config.bonds) save_changes = True # Upgrading based on the persisted (safe) configuration. old_sriov_confpath = os.path.join(config.netconf_path, 'virtual_functions') if os.path.exists(old_sriov_confpath): _upgrade_sriov_config(config.devices, old_sriov_confpath) save_changes = True if save_changes: config.save()
def setup_module(): canonicalize_networks({'net': NETWORK_ATTRIBUTES})
def __init__(self, savePath): self.networksPath = os.path.join(savePath, 'nets', '') self.bondingsPath = os.path.join(savePath, 'bonds', '') nets = self._getConfigs(self.networksPath) canonicalize_networks(nets) super(Config, self).__init__(nets, self._getConfigs(self.bondingsPath))
def canonicalize_networks_attributes(): canonicalize_networks({'net': NETWORK_ATTRIBUTES})
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