def bond_option_mapping(): file1 = tempfile.NamedTemporaryFile() file2 = tempfile.NamedTemporaryFile() with file1 as f_bond_defaults, file2 as f_bond_name2numeric: if has_sysfs_bond_permission(): ALTERNATIVE_BONDING_DEFAULTS = f_bond_defaults.name ALTERNATIVE_BONDING_NAME2NUMERIC_PATH = f_bond_name2numeric.name else: ALTERNATIVE_BONDING_DEFAULTS = os.path.join( os.path.dirname(network_tests.__file__), 'static', 'bonding-defaults.json' ) ALTERNATIVE_BONDING_NAME2NUMERIC_PATH = os.path.join( os.path.dirname(network_tests.__file__), 'static', 'bonding-name2numeric.json' ) patch_bonding_defaults = mock.patch( 'vdsm.network.link.bond.sysfs_options.BONDING_DEFAULTS', ALTERNATIVE_BONDING_DEFAULTS ) patch_bonding_name2num = mock.patch( 'vdsm.network.link.bond.sysfs_options_mapper.' 'BONDING_NAME2NUMERIC_PATH', ALTERNATIVE_BONDING_NAME2NUMERIC_PATH ) with patch_bonding_defaults, patch_bonding_name2num: if has_sysfs_bond_permission(): sysfs_options_mapper.dump_bonding_options() yield
def bond_option_mapping(): file1 = tempfile.NamedTemporaryFile() file2 = tempfile.NamedTemporaryFile() with file1 as f_bond_defaults, file2 as f_bond_name2numeric: if has_sysfs_bond_permission(): ALTERNATIVE_BONDING_DEFAULTS = f_bond_defaults.name ALTERNATIVE_BONDING_NAME2NUMERIC_PATH = f_bond_name2numeric.name else: ALTERNATIVE_BONDING_DEFAULTS = os.path.join( os.path.dirname(network_tests.__file__), 'static', 'bonding-defaults.json', ) ALTERNATIVE_BONDING_NAME2NUMERIC_PATH = os.path.join( os.path.dirname(network_tests.__file__), 'static', 'bonding-name2numeric.json', ) patch_bonding_defaults = mock.patch( 'vdsm.network.link.bond.sysfs_options.BONDING_DEFAULTS', ALTERNATIVE_BONDING_DEFAULTS, ) patch_bonding_name2num = mock.patch( 'vdsm.network.link.bond.sysfs_options_mapper.' 'BONDING_NAME2NUMERIC_PATH', ALTERNATIVE_BONDING_NAME2NUMERIC_PATH, ) with patch_bonding_defaults, patch_bonding_name2num: if has_sysfs_bond_permission(): sysfs_options_mapper.dump_bonding_options() yield
def _assert_acquired_ifaces_post_switch_setup(self, _ovs_info, nets2add, expected_ifaces): with mock.patch('vdsm.network.ovs.driver.vsctl.Transaction.commit', return_value=None), \ mock.patch('vdsm.network.ovs.switch.link.get_link', return_value={'address': '01:23:45:67:89:ab'}): setup = switch.NetsAdditionSetup(_ovs_info) setup.prepare_setup(nets2add) setup.commit_setup() self.assertEqual(setup.acquired_ifaces, expected_ifaces)