本文整理汇总了Python中vdsm.ipwrapper.linkSet函数的典型用法代码示例。如果您正苦于以下问题:Python linkSet函数的具体用法?Python linkSet怎么用?Python linkSet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了linkSet函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_ovirtmgmtm_to_ovs
def test_ovirtmgmtm_to_ovs(self):
""" Test transformation of initial management network to OVS.
# TODO: test it with ovirtmgmt and test-network
# NOTE: without default route
# TODO: more asserts
"""
with veth_pair() as (left, right):
addrAdd(left, IP_ADDRESS, IP_CIDR)
addrAdd(left, IPv6_ADDRESS, IPv6_CIDR, 6)
linkSet(left, ['up'])
with dnsmasqDhcp(left):
network = {
NETWORK_NAME: {'nic': right, 'bootproto': 'dhcp',
'bridged': True, 'blockingdhcp': True}}
options = NOCHK
options['ovs'] = False
try:
status, msg = self.setupNetworks(network, {}, options)
self.assertEqual(status, SUCCESS, msg)
self.assertNetworkExists(NETWORK_NAME)
options['ovs'] = True
status, msg = self.setupNetworks(network, {}, options)
self.assertEqual(status, SUCCESS, msg)
self.assertNetworkExists(NETWORK_NAME)
finally:
dhcp.delete_dhclient_leases(NETWORK_NAME, True, False)
开发者ID:mykaul,项目名称:vdsm,代码行数:28,代码来源:networkTestsOVS.py
示例2: _down
def _down(self):
with monitor.Monitor(groups=('link',), timeout=2) as mon:
linkSet(self.devName, ['down'])
for event in mon:
if (event.get('name') == self.devName and
event.get('state') == 'down'):
return
开发者ID:germanovm,项目名称:vdsm,代码行数:7,代码来源:nettestlib.py
示例3: _disconnect_bridge_port
def _disconnect_bridge_port(bridge, port):
try:
ipwrapper.linkSet(port, ['nomaster'])
except ipwrapper.IPRoute2Error:
# REQUIRED_FOR: el6
# rhel6 ip link command does not support 'nomaster'
rc, _, err = utils.execCmd(
[constants.EXT_BRCTL, 'delif', bridge, port])
if rc != 0:
raise ConfigNetworkError(
ne.ERR_FAILED_IFDOWN,
'Failed to disconnect {0} from {1}. error: {2}'.format(
port, bridge, err
))
开发者ID:kripper,项目名称:vdsm,代码行数:14,代码来源:api.py
示例4: removeNic
def removeNic(self, nic, remove_even_if_used=False):
to_be_removed = self._ifaceDownAndCleanup(nic, remove_even_if_used)
if to_be_removed:
self.configApplier.removeNic(nic.name)
if nic.name in nics.nics():
_exec_ifup(nic.name)
else:
logging.warning('host interface %s missing', nic.name)
else:
set_mtu = self._setNewMtu(nic, vlans.vlan_devs_for_iface(nic.name))
# Since we are not taking the device up again, ifcfg will not be
# read at this point and we need to set the live mtu value
if set_mtu is not None:
ipwrapper.linkSet(nic.name, ['mtu', str(set_mtu)])
开发者ID:mykaul,项目名称:vdsm,代码行数:14,代码来源:ifcfg.py
示例5: _set_devices_up
def _set_devices_up(nets, bonds):
devices = set()
for net, attrs in six.iteritems(nets):
if 'remove' not in attrs:
if 'vlan' in attrs:
devices.add(net)
if 'nic' in attrs or 'bond' in attrs:
devices.add(attrs.get('nic') or attrs.get('bond'))
for bond, attrs in six.iteritems(bonds):
if 'remove' not in attrs:
devices.add(bond)
devices.update(attrs['nics'])
if ovs_bridge_exists(BRIDGE_NAME):
devices.add(BRIDGE_NAME)
for device in devices:
linkSet(device, ['up'])
开发者ID:fancyKai,项目名称:vdsm,代码行数:16,代码来源:ovs_before_network_setup.py
示例6: change_numvfs
def change_numvfs(pci_path, numvfs, net_name):
"""Change number of virtual functions of a device.
The persistence is stored in the same place as other network persistence is
stored. A call to setSafeNetworkConfig() will persist it across reboots.
"""
# TODO: net_name is here only because it is hard to call pf_to_net_name
# TODO: from here. once all our code will be under lib/vdsm this should be
# TODO: removed.
logging.info("changing number of vfs on device %s -> %s.",
pci_path, numvfs)
_update_numvfs(pci_path, numvfs)
logging.info("changing number of vfs on device %s -> %s. succeeded.",
pci_path, numvfs)
_persist_numvfs(pci_path, numvfs)
ipwrapper.linkSet(net_name, ['up'])
开发者ID:mykaul,项目名称:vdsm,代码行数:17,代码来源:api.py
示例7: removeBond
def removeBond(self, bonding):
to_be_removed = self._ifaceDownAndCleanup(bonding)
if to_be_removed:
self.configApplier.removeBonding(bonding.name)
if bonding.destroyOnMasterRemoval:
for slave in bonding.slaves:
slave.remove()
if self.unifiedPersistence:
self.runningConfig.removeBonding(bonding.name)
else: # Recreate the bond with ip and master info cleared
bonding.ip = bonding.master = None
bonding.configure()
else:
set_mtu = self._setNewMtu(bonding,
netinfo.vlanDevsForIface(bonding.name))
# Since we are not taking the device up again, ifcfg will not be
# read at this point and we need to set the live mtu value.
# Note that ip link set dev bondX mtu Y sets Y on all its links
if set_mtu is not None:
ipwrapper.linkSet(bonding.name, ['mtu', str(set_mtu)])
开发者ID:mpolednik,项目名称:vdsm,代码行数:20,代码来源:ifcfg.py
示例8: _set_ip_config
def _set_ip_config(iface, ipv4, ipv6, port, blockingdhcp):
net_dev = NetDevice(iface, iproute2, ipv4=ipv4, ipv6=ipv6,
blockingdhcp=blockingdhcp)
DynamicSourceRoute.addInterfaceTracking(net_dev)
ipwrapper.linkSet(iface, ['down'])
if ipv4.address:
ipwrapper.addrAdd(iface, ipv4.address, ipv4.netmask)
if ipv4.gateway and ipv4.defaultRoute:
ipwrapper.routeAdd(['default', 'via', ipv4.gateway])
if ipv6.address or ipv6.ipv6autoconf or ipv6.dhcpv6:
sysctl.disable_ipv6(iface, disable=False)
else:
sysctl.disable_ipv6(iface)
if ipv6.address:
ipv6addr, ipv6netmask = ipv6.address.split('/')
ipwrapper.addrAdd(iface, ipv6addr, ipv6netmask, family=6)
if ipv6.gateway:
ipwrapper.routeAdd(['default', 'via', ipv6.gateway], dev=iface,
family=6)
ipwrapper.linkSet(port, ['up'])
ipwrapper.linkSet(iface, ['up'])
if ipv4.bootproto == 'dhcp':
_run_dhclient(iface, blockingdhcp, ipv4.defaultRoute, 4)
if ipv6.dhcpv6:
_run_dhclient(iface, blockingdhcp, ipv6.defaultRoute, 6)
iproute2._addSourceRoute(net_dev)
开发者ID:germanovm,项目名称:vdsm,代码行数:26,代码来源:ovs_before_network_setup_ip.py
示例9: _set_ip_config
def _set_ip_config(ip_config):
iface = ip_config.top_dev
ipv4 = ip_config.ipv4
ipv6 = ip_config.ipv6
port = ip_config.port
blocking_dhcp = ip_config.blocking_dhcp
net_dev = NetDevice(iface, iproute2, ipv4=ipv4, ipv6=ipv6, blockingdhcp=blocking_dhcp)
DynamicSourceRoute.addInterfaceTracking(net_dev)
ipwrapper.linkSet(iface, ["down"])
if ipv4.address:
ipwrapper.addrAdd(iface, ipv4.address, ipv4.netmask)
if ipv4.gateway and ipv4.defaultRoute:
ipwrapper.routeAdd(["default", "via", ipv4.gateway])
if ipv6.address or ipv6.ipv6autoconf or ipv6.dhcpv6:
sysctl.disable_ipv6(iface, disable=False)
else:
sysctl.disable_ipv6(iface)
if ipv6.address:
ipv6addr, ipv6netmask = ipv6.address.split("/")
ipwrapper.addrAdd(iface, ipv6addr, ipv6netmask, family=6)
if ipv6.gateway:
ipwrapper.routeAdd(["default", "via", ipv6.gateway], dev=iface, family=6)
ipwrapper.linkSet(port, ["up"])
ipwrapper.linkSet(iface, ["up"])
if ipv4.bootproto == "dhcp":
_run_dhclient(iface, blocking_dhcp, ipv4.defaultRoute, 4)
if ipv6.dhcpv6:
_run_dhclient(iface, blocking_dhcp, ipv6.defaultRoute, 6)
iproute2._addSourceRoute(net_dev)
开发者ID:borisroman,项目名称:vdsm,代码行数:30,代码来源:ovs_before_network_setup_ip.py
示例10: test_local_auto_with_dynamic_address_from_ra
def test_local_auto_with_dynamic_address_from_ra(self):
IPV6_NETADDRESS = '2001:1:1:1'
IPV6_NETPREFIX_LEN = '64'
with veth_pair() as (server, client):
with dnsmasq_run(server, ipv6_slaac_prefix=IPV6_NETADDRESS + '::'):
with wait_for_ipv6(client):
ipwrapper.linkSet(client, ['up'])
ipwrapper.linkSet(server, ['up'])
ipwrapper.addrAdd(server, IPV6_NETADDRESS + '::1',
IPV6_NETPREFIX_LEN, family=6)
# Expecting link and global addresses on client iface
# The addresses are given randomly, so we sort them
ip_addrs = sorted(addresses.getIpAddrs()[client],
key=lambda ip: ip['address'])
self.assertEqual(2, len(ip_addrs))
self.assertTrue(addresses.is_dynamic(ip_addrs[0]))
self.assertEqual('global', ip_addrs[0]['scope'])
self.assertEqual(IPV6_NETADDRESS,
ip_addrs[0]['address'][:len(IPV6_NETADDRESS)])
self.assertEqual('link', ip_addrs[1]['scope'])
开发者ID:kanalun,项目名称:vdsm,代码行数:23,代码来源:netinfo_test.py
示例11: removeBond
def removeBond(self, bonding):
to_be_removed = self._ifaceDownAndCleanup(bonding)
if to_be_removed:
if bonding.destroyOnMasterRemoval:
self.configApplier.removeBonding(bonding.name)
for slave in bonding.slaves:
slave.remove()
if self.unifiedPersistence:
self.runningConfig.removeBonding(bonding.name)
else:
self.configApplier.setBondingMtu(bonding.name,
netinfo.DEFAULT_MTU)
if bonding.bridge is not None:
self.configApplier._updateConfigValue(
netinfo.NET_CONF_PREF + bonding.name, 'BRIDGE', None)
ifup(bonding.name)
else:
set_mtu = self._setNewMtu(bonding,
netinfo.vlanDevsForIface(bonding.name))
# Since we are not taking the device up again, ifcfg will not be
# read at this point and we need to set the live mtu value.
# Note that ip link set dev bondX mtu Y sets Y on all its links
if set_mtu is not None:
ipwrapper.linkSet(bonding.name, ['mtu', str(set_mtu)])
开发者ID:loler-zuan,项目名称:vdsm,代码行数:24,代码来源:ifcfg.py
示例12: test_iperf_upper_limit
def test_iperf_upper_limit(self):
# Upper limit is not an accurate measure. This is because it converges
# over time and depends on current machine hardware (CPU).
# Hence, it is hard to make hard assertions on it. The test should run
# at least 60 seconds (the longer the better) and the user should
# inspect the computed average rate and optionally the additional
# traffic data that was collected in client.out in order to be
# convinced QOS is working properly.
limit_kbps = 1000 # 1 Mbps (in kbps)
server_ip = '192.0.2.1'
client_ip = '192.0.2.10'
qos_out = {'ul': {'m2': limit_kbps}, 'ls': {'m2': limit_kbps}}
# using a network namespace is essential since otherwise the kernel
# short-circuits the traffic and bypasses the veth devices and the
# classfull qdisc.
with network_namespace('server_ns') as ns, bridge_device() as bridge, \
veth_pair() as (server_peer, server_dev), \
veth_pair() as (client_dev, client_peer):
linkSet(server_peer, ['up'])
linkSet(client_peer, ['up'])
# iperf server and its veth peer lie in a separate network
# namespace
link_set_netns(server_dev, ns)
bridge.addIf(server_peer)
bridge.addIf(client_peer)
linkSet(client_dev, ['up'])
netns_exec(ns, ['ip', 'link', 'set', 'dev', server_dev, 'up'])
addrAdd(client_dev, client_ip, 24)
netns_exec(ns, ['ip', '-4', 'addr', 'add', 'dev', server_dev,
'%s/24' % server_ip])
qos.configure_outbound(qos_out, client_peer, None)
with running(IperfServer(server_ip, network_ns=ns)):
client = IperfClient(server_ip, client_ip, test_time=60)
client.start()
max_rate = max([float(
interval['streams'][0]['bits_per_second'])/(2**10)
for interval in client.out['intervals']])
self.assertTrue(0 < max_rate < limit_kbps * 1.5)
开发者ID:borisroman,项目名称:vdsm,代码行数:38,代码来源:tcTests.py
示例13: testSetupNetworksAddDelDhcp
def testSetupNetworksAddDelDhcp(self, bridged, families):
"""Copied from networkTests.py, source_route checking changed from
device_name to BRIDGE_NAME.
"""
def _assert_applied(network_name, requested, reported):
self.assertNetworkExists(network_name)
reported_network = reported.networks[network_name]
if requested['bridged']:
self.assertEqual(reported_network['cfg']['BOOTPROTO'],
requested['bootproto'])
reported_devices = reported.bridges
device_name = network_name
else:
# CHANGED: always bridged
pass
self.assertIn(device_name, reported_devices)
reported_device = reported_devices[device_name]
requested_dhcpv4 = requested['bootproto'] == 'dhcp'
self.assertEqual(reported_network['dhcpv4'], requested_dhcpv4)
self.assertEqual(reported_network['dhcpv6'], requested['dhcpv6'])
self.assertEqual(reported_device['cfg']['BOOTPROTO'],
requested['bootproto'])
self.assertEqual(reported_device['dhcpv4'], requested_dhcpv4)
self.assertEqual(reported_device['dhcpv6'], requested['dhcpv6'])
if requested_dhcpv4:
self.assertEqual(reported_network['gateway'], IP_GATEWAY)
# TODO: source routing not ready for IPv6
ip_addr = reported_network['addr']
self.assertSourceRoutingConfiguration(BRIDGE_NAME, # CHANGED
ip_addr)
return device_name, ip_addr
return None, None
with veth_pair() as (left, right):
addrAdd(left, IP_ADDRESS, IP_CIDR)
addrAdd(left, IPv6_ADDRESS, IPv6_CIDR, 6)
linkSet(left, ['up'])
with dnsmasqDhcp(left):
dhcpv4 = 4 in families
dhcpv6 = 6 in families
bootproto = 'dhcp' if dhcpv4 else 'none'
network = {NETWORK_NAME: {'nic': right, 'bridged': bridged,
'bootproto': bootproto,
'dhcpv6': dhcpv6,
'blockingdhcp': True}}
try:
status, msg = self.setupNetworks(network, {}, NOCHK)
self.assertEqual(status, SUCCESS, msg)
device_name, ip_addr = _assert_applied(
NETWORK_NAME, network[NETWORK_NAME],
self.vdsm_net.netinfo)
# Do not report DHCP from (typically still valid) leases
network[NETWORK_NAME]['bootproto'] = 'none'
network[NETWORK_NAME]['dhcpv6'] = False
status, msg = self.setupNetworks(network, {}, NOCHK)
self.assertEqual(status, SUCCESS, msg)
_assert_applied(NETWORK_NAME, network[NETWORK_NAME],
self.vdsm_net.netinfo)
network = {NETWORK_NAME: {'remove': True}}
status, msg = self.setupNetworks(network, {}, NOCHK)
self.assertEqual(status, SUCCESS, msg)
self.assertNetworkDoesntExist(NETWORK_NAME)
# Assert that routes and rules don't exist
if dhcpv4:
source_route = _get_source_route(device_name, ip_addr)
for route in source_route._buildRoutes():
self.assertRouteDoesNotExist(route)
for rule in source_route._buildRules():
self.assertRuleDoesNotExist(rule)
finally:
dhcp.delete_dhclient_leases(
NETWORK_NAME if bridged else right, dhcpv4, dhcpv6)
开发者ID:mykaul,项目名称:vdsm,代码行数:81,代码来源:networkTestsOVS.py
示例14: _update_bridge_ports_mtu
def _update_bridge_ports_mtu(bridge, mtu):
for port in netinfo.ports(bridge):
ipwrapper.linkSet(port, ["mtu", str(mtu)])
开发者ID:nickxiao,项目名称:vdsm,代码行数:3,代码来源:api.py
示例15: _set_iface_mtu
def _set_iface_mtu(iface, mtu):
ipwrapper.linkSet(iface, ['mtu', str(mtu)])
开发者ID:kanalun,项目名称:vdsm,代码行数:2,代码来源:ovs_before_network_setup_mtu.py
示例16: ifdown
def ifdown(self, iface):
ipwrapper.linkSet(iface.name, ['down'])
dhclient = DhcpClient(iface.name)
dhclient.shutdown()
开发者ID:Caez83,项目名称:vdsm,代码行数:4,代码来源:iproute2.py
示例17: ifup
def ifup(self, iface):
ipwrapper.linkSet(iface.name, ['up'])
if iface.ipv4.bootproto == 'dhcp':
runDhclient(iface)
if iface.ipv6.dhcpv6:
runDhclient(iface, 6)
开发者ID:Caez83,项目名称:vdsm,代码行数:6,代码来源:iproute2.py
示例18: setIfaceMtu
def setIfaceMtu(self, iface, mtu):
ipwrapper.linkSet(iface, ['mtu', str(mtu)])
开发者ID:Caez83,项目名称:vdsm,代码行数:2,代码来源:iproute2.py
示例19: _update_bridge_ports_mtu
def _update_bridge_ports_mtu(bridge, mtu):
for port in bridges.ports(bridge):
ipwrapper.linkSet(port, ['mtu', str(mtu)])
开发者ID:sshnaidm,项目名称:vdsm,代码行数:3,代码来源:legacy_switch.py
示例20: _disconnect_bridge_port
def _disconnect_bridge_port(port):
ipwrapper.linkSet(port, ['nomaster'])
开发者ID:sshnaidm,项目名称:vdsm,代码行数:2,代码来源:legacy_switch.py
注:本文中的vdsm.ipwrapper.linkSet函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论