本文整理汇总了Python中network.nettestlib.dummy_devices函数的典型用法代码示例。如果您正苦于以下问题:Python dummy_devices函数的具体用法?Python dummy_devices怎么用?Python dummy_devices使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dummy_devices函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_static_ip_to_the_existing_net_with_bond
def test_add_static_ip_to_the_existing_net_with_bond(self, switch):
with dummy_devices(2) as (nic1, nic2):
network_attrs1 = {'bonding': BOND_NAME,
'bridged': False,
'ipaddr': IPv4_ADDRESS,
'netmask': IPv4_NETMASK,
'switch': switch}
network_attrs2 = {'bonding': BOND_NAME,
'bridged': True,
'vlan': VLAN,
'switch': switch}
bond = {BOND_NAME: {'nics': [nic1, nic2], 'switch': switch}}
netconf = {NETWORK_NAME: network_attrs1,
NETWORK2_NAME: network_attrs2}
net2 = {NETWORK2_NAME: netconf[NETWORK2_NAME]}
with adapter.setupNetworks(netconf, bond, NOCHK):
adapter.assertNetworkIp(NETWORK_NAME, network_attrs1)
adapter.assertNetworkIp(NETWORK2_NAME, network_attrs2)
network_attrs2['ipaddr'] = IPv4_ADDRESS2
network_attrs2['netmask'] = IPv4_NETMASK
adapter.setupNetworks(net2, bond, NOCHK)
adapter.assertNetworkIp(NETWORK_NAME, network_attrs1)
adapter.assertNetworkIp(NETWORK2_NAME, network_attrs2)
示例2: test_add_bond_with_two_nics
def test_add_bond_with_two_nics(self, switch):
with dummy_devices(2) as (nic1, nic2):
BONDCREATE = {
BOND_NAME: {'nics': [nic1, nic2], 'switch': switch}}
with adapter.setupNetworks({}, BONDCREATE, NOCHK):
adapter.assertBond(BOND_NAME, BONDCREATE[BOND_NAME])
示例3: _test_add_net_with_ip
def _test_add_net_with_ip(self, families, switch,
bonded=False, vlaned=False, bridged=False):
with dummy_devices(2) as (nic1, nic2):
network_attrs = {'bridged': bridged, 'switch': switch}
if IpFamily.IPv4 in families:
network_attrs['ipaddr'] = IPv4_ADDRESS
network_attrs['netmask'] = IPv4_NETMASK
if IpFamily.IPv6 in families:
network_attrs['ipv6addr'] = IPv6_ADDRESS
if bonded:
bondcreate = {
BOND_NAME: {'nics': [nic1, nic2], 'switch': switch}}
network_attrs['bonding'] = BOND_NAME
else:
bondcreate = {}
network_attrs['nic'] = nic1
if vlaned:
network_attrs['vlan'] = VLAN
netcreate = {NETWORK_NAME: network_attrs}
with adapter.setupNetworks(netcreate, bondcreate, NOCHK):
adapter.assertNetworkIp(NETWORK_NAME,
netcreate[NETWORK_NAME])
示例4: test_adding_a_net_with_mtu_lower_than_base_nic_mtu
def test_adding_a_net_with_mtu_lower_than_base_nic_mtu(self, switch,
bridged, bonded):
with dummy_devices(1) as (nic,):
NETWORK1_ATTRS = {'bridged': bridged,
'vlan': VLAN1,
'mtu': 1000,
'switch': switch}
NETNEW = {NETWORK1_NAME: NETWORK1_ATTRS}
if bonded:
NETWORK1_ATTRS['bonding'] = BOND_NAME
BONDBASE = {BOND_NAME: {'nics': [nic], 'switch': switch}}
link2monitor = BOND_NAME
else:
NETWORK1_ATTRS['nic'] = nic
BONDBASE = {}
link2monitor = nic
with adapter.setupNetworks(NETNEW, BONDBASE, nftestlib.NOCHK):
with nftestlib.monitor_stable_link_state(link2monitor):
adapter.assertLinkMtu(nic, NETWORK1_ATTRS)
if bonded:
vlan1 = BOND_NAME + '.' + str(
NETWORK1_ATTRS['vlan'])
adapter.assertLinkMtu(BOND_NAME, NETWORK1_ATTRS)
else:
vlan1 = nic + '.' + str(NETWORK1_ATTRS['vlan'])
adapter.assertLinkMtu(vlan1, NETWORK1_ATTRS)
示例5: test_mtu_default_value_of_base_nic_after_all_nets_are_removed
def test_mtu_default_value_of_base_nic_after_all_nets_are_removed(self,
switch,
bridged,
bonded):
if switch == 'legacy' and bonded:
pytest.xfail('BZ#1633528')
with dummy_devices(1) as (nic,):
NETWORK1_ATTRS = {'bridged': bridged,
'vlan': VLAN1,
'mtu': 1600,
'switch': switch}
NETBASE = {NETWORK1_NAME: NETWORK1_ATTRS}
DEFAULT_MTU = {'mtu': 1500}
if bonded:
NETWORK1_ATTRS['bonding'] = BOND_NAME
BONDBASE = {BOND_NAME: {'nics': [nic], 'switch': switch}}
else:
NETWORK1_ATTRS['nic'] = nic
BONDBASE = {}
with adapter.setupNetworks(NETBASE, BONDBASE, nftestlib.NOCHK):
adapter.setupNetworks(
{NETWORK1_NAME: {'remove': True}}, {}, nftestlib.NOCHK)
adapter.assertLinkMtu(nic, DEFAULT_MTU)
if bonded:
adapter.assertLinkMtu(BOND_NAME, DEFAULT_MTU)
示例6: test_bond_devices_are_up
def test_bond_devices_are_up(self):
with dummy_devices(2) as (nic1, nic2):
with bond_device() as bond:
bond.add_slaves((nic1, nic2))
bond.up()
self.assertTrue(iface(nic1).is_up())
self.assertTrue(iface(nic2).is_up())
self.assertTrue(iface(bond.master).is_up())
示例7: test_configured_connections_attributes_existence
def test_configured_connections_attributes_existence(self):
with dummy_devices(1) as nics:
with nm_connections(self.iface, IPV4ADDR, slaves=nics) as connames:
nm_con = self._get_connection(connames[0])
self.assertEqual(connames[0], nm_con.connection.id)
self.assertIsNotNone(nm_con.connection.uuid)
self.assertIsNotNone(nm_con.connection.type)
示例8: test_remove_all_non_active_connection_from_a_device
def test_remove_all_non_active_connection_from_a_device(self):
iface = iface_name()
with dummy_devices(1) as nics:
with nm_connections(iface, IPV4ADDR, slaves=nics, con_count=3):
device = networkmanager.Device(iface)
device.cleanup_inactive_connections()
self.assertEqual(1, sum(1 for _ in device.connections()))
示例9: test_remove_bond
def test_remove_bond(self, switch):
with dummy_devices(2) as (nic1, nic2):
BONDCREATE = {
BOND_NAME: {'nics': [nic1, nic2], 'switch': switch}}
BONDREMOVE = {BOND_NAME: {'remove': True}}
with adapter.setupNetworks({}, BONDCREATE, NOCHK):
adapter.setupNetworks({}, BONDREMOVE, NOCHK)
adapter.assertNoBond(BOND_NAME)
示例10: test_bond_options_with_the_mode_specified_last
def test_bond_options_with_the_mode_specified_last(self, switch):
with dummy_devices(2) as (nic1, nic2):
BONDCREATE = {BOND_NAME: {
'nics': [nic1, nic2],
'options': 'lacp_rate=fast mode=802.3ad',
'switch': switch}}
with adapter.setupNetworks({}, BONDCREATE, NOCHK):
adapter.assertBond(BOND_NAME, BONDCREATE[BOND_NAME])
示例11: test_add_net_with_mtu
def test_add_net_with_mtu(self, switch, bridged):
with dummy_devices(1) as (nic,):
NETCREATE = {NETWORK_NAME: {'nic': nic,
'bridged': bridged,
'mtu': 2000,
'switch': switch}}
with adapter.setupNetworks(NETCREATE, {}, nftestlib.NOCHK):
adapter.assertNetwork(NETWORK_NAME, NETCREATE[NETWORK_NAME])
adapter.assertLinkMtu(nic, NETCREATE[NETWORK_NAME])
示例12: test_bond_mode_1
def test_bond_mode_1(self, switch):
with dummy_devices(2) as (nic1, nic2):
BONDCREATE = {BOND_NAME: {
'nics': [nic1, nic2],
'options': 'mode=1 primary=' + nic1,
'switch': switch}}
with adapter.setupNetworks({}, BONDCREATE, NOCHK):
adapter.assertBond(BOND_NAME, BONDCREATE[BOND_NAME])
示例13: test_add_bridge_with_custom_opts
def test_add_bridge_with_custom_opts(self, switch):
with dummy_devices(1) as (nic,):
NETCREATE = {NETWORK_NAME: {
'nic': nic,
'switch': switch,
'custom': {
'bridge_opts': 'multicast_snooping=0 multicast_router=0'}}}
with adapter.setupNetworks(NETCREATE, {}, nftestlib.NOCHK):
adapter.assertBridgeOpts(NETWORK_NAME,
NETCREATE[NETWORK_NAME])
示例14: test_bond_create_failure_on_slave_add
def test_bond_create_failure_on_slave_add(self):
with dummy_devices(2) as (nic1, nic2):
with bond_device() as base_bond:
base_bond.add_slaves((nic1, nic2))
bond_name = random_iface_name('bond_', max_length=11)
with self.assertRaises(IOError):
with Bond(bond_name) as broken_bond:
broken_bond.create()
broken_bond.add_slaves((nic1, nic2))
self.assertFalse(Bond(bond_name).exists())
示例15: test_do_not_detach_slaves_while_changing_options
def test_do_not_detach_slaves_while_changing_options(self):
OPTIONS = {'miimon': '110'}
with dummy_devices(2) as (nic1, nic2):
with bond_device() as bond:
bond.add_slaves((nic1, nic2))
mock_slaves = bond.del_slaves = bond.add_slaves = mock.Mock()
bond.set_options(OPTIONS)
mock_slaves.assert_not_called()