本文整理汇总了Python中vdsm.network.ipwrapper.linkSet函数的典型用法代码示例。如果您正苦于以下问题:Python linkSet函数的具体用法?Python linkSet怎么用?Python linkSet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了linkSet函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _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:andrewlukoshko,项目名称:vdsm,代码行数:7,代码来源:nettestlib.py
示例2: removeBond
def removeBond(self, bonding):
if not self.owned_device(bonding.name):
IfcfgAcquire.acquire_device(bonding.name)
to_be_removed = self._ifaceDownAndCleanup(bonding)
if to_be_removed:
self.configApplier.removeBonding(bonding.name)
if bonding.on_removal_just_detach_from_network:
# Recreate the bond with ip and master info cleared
bonding.ipv4 = address.IPv4()
bonding.ipv6 = address.IPv6()
bonding.master = None
bonding.configure()
else:
for slave in bonding.slaves:
slave.remove()
self.runningConfig.removeBonding(bonding.name)
else:
vlans = link_vlan.get_vlans_on_base_device(bonding.name)
set_mtu = self._setNewMtu(bonding, vlans)
# 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)])
# If the bond was bridged, we must remove BRIDGE parameter from its
# ifcfg configuration file.
if bonding.bridge:
self.configApplier.dropBridgeParameter(bonding.name)
bond_used_by_net = self.net_info.getNetworkForIface(bonding.name)
bond_info = self.net_info.bondings[bonding.name]
if (not bond_used_by_net and
(bond_info['ipv4addrs'] or bond_info['ipv6addrs'])):
ipwrapper.addrFlush(bonding.name)
开发者ID:oVirt,项目名称:vdsm,代码行数:35,代码来源:ifcfg.py
示例3: removeNic
def removeNic(self, nic, remove_even_if_used=False):
if not self.owned_device(nic.name):
IfcfgAcquire.acquire_device(nic.name)
# If the nic is top device we should ifdown it even if it is
# used by a VLAN. Otherwise we would keep its IP address.
remove_even_if_used |= nic.master is None
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)
else:
logging.warning('host interface %s missing', nic.name)
else:
vlans = link_vlan.get_vlans_on_base_device(nic.name)
set_mtu = self._setNewMtu(nic, vlans)
# 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)])
# If the nic was bridged, we must remove BRIDGE parameter from its
# ifcfg configuration file.
if nic.bridge:
self.configApplier.dropBridgeParameter(nic.name)
开发者ID:oVirt,项目名称:vdsm,代码行数:27,代码来源:ifcfg.py
示例4: test_switch_change_bonded_network_with_dhclient
def test_switch_change_bonded_network_with_dhclient(self):
with veth_pair() as (server, nic1):
with dummy_device() as nic2:
NETSETUP_SOURCE = {NET1_NAME: {
'bonding': BOND_NAME,
'bootproto': 'dhcp',
'blockingdhcp': True,
'switch': self.switch_type_source}}
NETSETUP_TARGET = _change_switch_type(
NETSETUP_SOURCE, self.switch_type_target)
BONDSETUP_SOURCE = {BOND_NAME: {
'nics': [nic1, nic2], 'switch': self.switch_type_source}}
BONDSETUP_TARGET = _change_switch_type(
BONDSETUP_SOURCE, self.switch_type_target)
addrAdd(server, IPv4_ADDRESS, IPv4_PREFIX_LEN)
linkSet(server, ['up'])
with dnsmasq_run(server, DHCPv4_RANGE_FROM, DHCPv4_RANGE_TO):
with self.setupNetworks(
NETSETUP_SOURCE, BONDSETUP_SOURCE, NOCHK):
self.setupNetworks(
NETSETUP_TARGET, BONDSETUP_TARGET, NOCHK)
self.assertNetwork(
NET1_NAME, NETSETUP_TARGET[NET1_NAME])
self.assertBond(BOND_NAME, BONDSETUP_TARGET[BOND_NAME])
开发者ID:EdDev,项目名称:vdsm,代码行数:26,代码来源:func_switch_type_change_test.py
示例5: removeBond
def removeBond(self, bonding):
if not self.owned_device(bonding.name):
IfcfgAcquire.acquire_device(bonding.name)
to_be_removed = self._ifaceDownAndCleanup(bonding)
if to_be_removed:
self.configApplier.removeBonding(bonding.name)
if bonding.on_removal_just_detach_from_network:
# Recreate the bond with ip and master info cleared
bonding.ipv4 = address.IPv4()
bonding.ipv6 = address.IPv6()
bonding.master = None
bonding.configure()
else:
for slave in bonding.slaves:
slave.remove()
if self.unifiedPersistence:
self.runningConfig.removeBonding(bonding.name)
else:
set_mtu = self._setNewMtu(bonding, vlans.vlan_devs_for_iface(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)])
# If the bond was bridged, we must remove BRIDGE parameter from its
# ifcfg configuration file.
if bonding.bridge:
self.configApplier.dropBridgeParameter(bonding.name)
开发者ID:nirs,项目名称:vdsm,代码行数:29,代码来源:ifcfg.py
示例6: 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 dnsmasq_run(left, DHCP_RANGE_FROM, DHCP_RANGE_TO,
DHCPv6_RANGE_FROM, DHCPv6_RANGE_TO, IP_GATEWAY):
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:andrewlukoshko,项目名称:vdsm,代码行数:29,代码来源:networkTestsOVS.py
示例7: test_add_net_with_dhcp
def test_add_net_with_dhcp(self, switch, families, bridged):
with veth_pair() as (server, client):
addrAdd(server, IPv4_ADDRESS, IPv4_PREFIX_LEN)
addrAdd(server, IPv6_ADDRESS, IPv6_CIDR, IpFamily.IPv6)
linkSet(server, ['up'])
with dnsmasq_run(server, DHCPv4_RANGE_FROM, DHCPv4_RANGE_TO,
DHCPv6_RANGE_FROM, DHCPv6_RANGE_TO,
router=DHCPv4_GATEWAY):
network_attrs = {'bridged': bridged,
'nic': client,
'blockingdhcp': True,
'switch': switch}
if IpFamily.IPv4 in families:
network_attrs['bootproto'] = 'dhcp'
if IpFamily.IPv6 in families:
network_attrs['dhcpv6'] = True
netcreate = {NETWORK_NAME: network_attrs}
with adapter.setupNetworks(netcreate, {}, NOCHK):
adapter.assertNetworkIp(
NETWORK_NAME, netcreate[NETWORK_NAME])
开发者ID:nirs,项目名称:vdsm,代码行数:25,代码来源:dynamic_ip_test.py
示例8: up
def up(self, admin_blocking=True, oper_blocking=False):
if self._is_dpdk_type:
dpdk.up(self._dev)
return
if admin_blocking:
self._up_blocking(oper_blocking)
else:
ipwrapper.linkSet(self._dev, [STATE_UP])
开发者ID:nirs,项目名称:vdsm,代码行数:8,代码来源:iface.py
示例9: 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)
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:andrewlukoshko,项目名称:vdsm,代码行数:14,代码来源:ifcfg.py
示例10: test_attach_dhcp_nic_to_ipless_network
def test_attach_dhcp_nic_to_ipless_network(self):
with veth_pair() as (server, client):
addrAdd(server, IPv4_ADDRESS, IPv4_PREFIX_LEN)
linkSet(server, ["up"])
with dnsmasq_run(server, DHCPv4_RANGE_FROM, DHCPv4_RANGE_TO):
with dhclient_run(client):
self.assertDhclient(client, family=4)
NETCREATE = {NETWORK_NAME: {"nic": client, "switch": self.switch}}
with self.setupNetworks(NETCREATE, {}, NOCHK):
nic_netinfo = self.netinfo.nics[client]
self.assertDisabledIPv4(nic_netinfo)
net_netinfo = self.netinfo.networks[NETWORK_NAME]
self.assertDisabledIPv4(net_netinfo)
开发者ID:nirs,项目名称:vdsm,代码行数:14,代码来源:func_dhclient_test.py
示例11: _test_add_net_with_dhcpv4
def _test_add_net_with_dhcpv4(self, bridged=False):
with veth_pair() as (server, client):
addrAdd(server, IPv4_ADDRESS, IPv4_PREFIX_LEN)
linkSet(server, ['up'])
with dnsmasq_run(server, DHCPv4_RANGE_FROM, DHCPv4_RANGE_TO):
netcreate = {NETWORK_NAME: {
'bridged': bridged, 'nic': client, 'blockingdhcp': True,
'bootproto': 'dhcp', 'switch': self.switch}}
with self.setupNetworks(netcreate, {}, NOCHK):
self.assertNetworkIp(
NETWORK_NAME, netcreate[NETWORK_NAME])
开发者ID:yingyun001,项目名称:vdsm,代码行数:14,代码来源:func_dhclient_test.py
示例12: 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:nirs,项目名称:vdsm,代码行数:16,代码来源:api.py
示例13: test_attach_dhcp_nic_to_dhcpv6_bridged_network
def test_attach_dhcp_nic_to_dhcpv6_bridged_network(self, switch):
with veth_pair() as (server, client):
addrAdd(server, IPv6_ADDRESS, IPv6_CIDR, IpFamily.IPv6)
linkSet(server, ['up'])
with dnsmasq_run(server, DHCPv6_RANGE_FROM, DHCPv6_RANGE_TO):
with dhclient_run(client, family=IpFamily.IPv6):
adapter.assertDhclient(client, family=IpFamily.IPv6)
NETCREATE = {NETWORK_NAME: {
'nic': client, 'dhcpv6': True,
'blockingdhcp': True, 'switch': switch}}
with adapter.setupNetworks(NETCREATE, {}, NOCHK):
nic_netinfo = adapter.netinfo.nics[client]
adapter.assertDisabledIPv6(nic_netinfo)
adapter.assertNoDhclient(client, family=IpFamily.IPv6)
net_netinfo = adapter.netinfo.networks[NETWORK_NAME]
adapter.assertDHCPv6(net_netinfo)
adapter.assertDhclient(NETWORK_NAME,
family=IpFamily.IPv6)
开发者ID:nirs,项目名称:vdsm,代码行数:19,代码来源:dynamic_ip_test.py
示例14: _test_add_net_with_dhcpv4
def _test_add_net_with_dhcpv4(self, bridged=False):
with veth_pair() as (server, client):
addrAdd(server, IPv4_ADDRESS, IPv4_PREFIX_LEN)
linkSet(server, ["up"])
with dnsmasq_run(server, DHCPv4_RANGE_FROM, DHCPv4_RANGE_TO):
netcreate = {
NETWORK_NAME: {
"bridged": bridged,
"nic": client,
"blockingdhcp": True,
"bootproto": "dhcp",
"switch": self.switch,
}
}
with self.setupNetworks(netcreate, {}, NOCHK):
self.assertNetworkIp(NETWORK_NAME, netcreate[NETWORK_NAME])
开发者ID:nirs,项目名称:vdsm,代码行数:19,代码来源:func_dhclient_test.py
示例15: removeNic
def removeNic(self, nic, remove_even_if_used=False):
if not self.owned_device(nic.name):
IfcfgAcquire.acquire_device(nic.name)
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)
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)])
# If the nic was bridged, we must remove BRIDGE parameter from its
# ifcfg configuration file.
if nic.bridge:
self.configApplier.dropBridgeParameter(nic.name)
开发者ID:nirs,项目名称:vdsm,代码行数:21,代码来源:ifcfg.py
示例16: test_attach_dhcp_nic_to_ipless_network
def test_attach_dhcp_nic_to_ipless_network(self, switch):
with veth_pair() as (server, client):
addrAdd(server, IPv4_ADDRESS, IPv4_PREFIX_LEN)
addrAdd(server, IPv6_ADDRESS, IPv6_CIDR, IpFamily.IPv6)
linkSet(server, ['up'])
with dnsmasq_run(server, DHCPv4_RANGE_FROM, DHCPv4_RANGE_TO,
DHCPv6_RANGE_FROM, DHCPv6_RANGE_TO,
router=DHCPv4_GATEWAY):
with dhclient_run(client):
adapter.assertDhclient(client, family=IpFamily.IPv4)
adapter.assertDhclient(client, family=IpFamily.IPv6)
NETCREATE = {NETWORK_NAME: {
'nic': client, 'switch': switch}}
with adapter.setupNetworks(NETCREATE, {}, NOCHK):
nic_netinfo = adapter.netinfo.nics[client]
adapter.assertDisabledIPv4(nic_netinfo)
adapter.assertDisabledIPv6(nic_netinfo)
net_netinfo = adapter.netinfo.networks[NETWORK_NAME]
adapter.assertDisabledIPv4(net_netinfo)
adapter.assertDisabledIPv6(nic_netinfo)
开发者ID:nirs,项目名称:vdsm,代码行数:21,代码来源:dynamic_ip_test.py
示例17: _set_network_ip_config
def _set_network_ip_config(ip_config):
"""Set IP configuration on Vdsm controlled OVS network"""
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:andrewlukoshko,项目名称:vdsm,代码行数:33,代码来源:ovs_before_network_setup_ip.py
示例18: removeBond
def removeBond(self, bonding):
to_be_removed = self._ifaceDownAndCleanup(bonding)
if to_be_removed:
self.configApplier.removeBonding(bonding.name)
if bonding.on_removal_just_detach_from_network:
# Recreate the bond with ip and master info cleared
bonding.ipv4 = IPv4()
bonding.ipv6 = IPv6()
bonding.master = None
bonding.configure()
else:
for slave in bonding.slaves:
slave.remove()
if self.unifiedPersistence:
self.runningConfig.removeBonding(bonding.name)
else:
set_mtu = self._setNewMtu(bonding,
vlans.vlan_devs_for_iface(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:andrewlukoshko,项目名称:vdsm,代码行数:23,代码来源:ifcfg.py
示例19: 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):
ipwrapper.addrAdd(server, IPV6_NETADDRESS + '::1',
IPV6_NETPREFIX_LEN, family=6)
ipwrapper.linkSet(server, ['up'])
with dnsmasq_run(server, ipv6_slaac_prefix=IPV6_NETADDRESS + '::'):
with wait_for_ipv6(client):
ipwrapper.linkSet(client, ['up'])
# 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), 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:nirs,项目名称:vdsm,代码行数:23,代码来源:netinfo_test.py
示例20: ifdown
def ifdown(self, iface):
ipwrapper.linkSet(iface.name, ['down'])
dhclient = DhcpClient(iface.name)
dhclient.shutdown()
开发者ID:andrewlukoshko,项目名称:vdsm,代码行数:4,代码来源:iproute2.py
注:本文中的vdsm.network.ipwrapper.linkSet函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论