本文整理汇总了Python中vdsm.netinfo.getMtu函数的典型用法代码示例。如果您正苦于以下问题:Python getMtu函数的具体用法?Python getMtu怎么用?Python getMtu使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getMtu函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: objectivize
def objectivize(cls, name, configurator, options, nics, mtu, _netinfo,
destroyOnMasterRemoval=None):
if name and nics: # New bonding or edit bonding.
slaves = cls._objectivizeSlaves(name, configurator, nics, mtu,
_netinfo)
if name in _netinfo.bondings:
mtu = max(netinfo.getMtu(name), mtu)
if not options:
options = _netinfo.bondings[name]['cfg'].get(
'BONDING_OPTS')
elif name in _netinfo.bondings: # Implicit bonding.
mtu = max(netinfo.getMtu(name), mtu)
slaves = [Nic(nic, configurator, mtu=mtu, _netinfo=_netinfo)
for nic in _netinfo.getNicsForBonding(name)]
options = _netinfo.bondings[name]['cfg'].get('BONDING_OPTS')
else:
raise ConfigNetworkError(ne.ERR_BAD_BONDING,
'Bonding %s not specified and it is not '
'already on the system' % name)
if not slaves:
raise ConfigNetworkError(ne.ERR_BAD_PARAMS, 'Missing required nics'
' for bonding device.')
return cls(name, configurator, slaves=slaves, options=options, mtu=mtu,
destroyOnMasterRemoval=destroyOnMasterRemoval)
示例2: objectivize
def objectivize(cls, name, configurator, options, nics, mtu, _netinfo,
destroyOnMasterRemoval=None):
if nics: # New bonding or edit bonding.
slaves = cls._objectivizeSlaves(name, configurator, _nicSort(nics),
mtu, _netinfo)
if name in _netinfo.bondings:
if _netinfo.ifaceUsers(name):
mtu = max(mtu, netinfo.getMtu(name))
if not options:
options = _netinfo.bondings[name]['cfg'].get(
'BONDING_OPTS')
elif name in _netinfo.bondings: # Implicit bonding.
if _netinfo.ifaceUsers(name):
mtu = max(mtu, netinfo.getMtu(name))
slaves = [Nic(nic, configurator, mtu=mtu, _netinfo=_netinfo)
for nic in _netinfo.getNicsForBonding(name)]
options = _netinfo.bondings[name]['cfg'].get('BONDING_OPTS')
else:
raise ConfigNetworkError(ne.ERR_BAD_PARAMS,
'Missing required nics on a bonding %s '
'that is unknown to Vdsm ' % name)
return cls(name, configurator, slaves=slaves, options=options, mtu=mtu,
destroyOnMasterRemoval=destroyOnMasterRemoval)
示例3: _mtus_bonds
def _mtus_bonds(running_config):
""" Bonding and its slaves should have the same MTU. Check slaves of
every bonding, if not consistent, set them all the biggest found MTU.
"""
changes = {}
for bonding, attrs in iter_ovs_bonds(running_config.bonds):
slaves = running_config.bonds[bonding].get('nics')
mtu = max(netinfo.getMtu(bonding),
max([netinfo.getMtu(slave) for slave in slaves]))
_update_mtu_changes(mtu, slaves, changes)
return changes
示例4: objectivize
def objectivize(cls, name, configurator, options, nics, mtu, _netinfo):
if name and nics:
slaves = []
for nic in nics:
nicVlans = tuple(_netinfo.getVlansForIface(nic))
nicNet = _netinfo.getNetworkForIface(nic)
nicBond = _netinfo.getBondingForNic(nic)
if nicVlans or nicNet or nicBond and nicBond != name:
raise ConfigNetworkError(
ne.ERR_USED_NIC, 'nic %s already used by %s' %
(nic, nicVlans or nicNet or nicBond))
slaves.append(Nic(nic, configurator, mtu=mtu,
_netinfo=_netinfo))
elif name in _netinfo.bondings: # Implicit bonding.
mtu = max(netinfo.getMtu(name), mtu)
slaves = [Nic(nic, configurator, mtu=mtu, _netinfo=_netinfo)
for nic in _netinfo.getNicsForBonding(name)]
options = _netinfo.bondings[name]['cfg'].get('BONDING_OPTS')
else:
raise ConfigNetworkError(ne.ERR_BAD_BONDING,
'Bonding %s not specified and it is not '
'already on the system' % name)
if not slaves:
raise ConfigNetworkError(ne.ERR_BAD_PARAMS, 'Missing required nics'
' for bonding device.')
return cls(name, configurator, slaves=slaves, options=options, mtu=mtu)
示例5: __init__
def __init__(self, name, configurator, ipconfig=None, mtu=None,
_netinfo=None):
if _netinfo is None:
_netinfo = netinfo.NetInfo()
if name not in _netinfo.nics:
raise ConfigNetworkError(ne.ERR_BAD_NIC, 'unknown nic: %s' % name)
super(Nic, self).__init__(name, configurator, ipconfig,
mtu=max(mtu, netinfo.getMtu(name)))
示例6: configure
def configure(self, **opts):
# in a limited condition, we should not touch the nic config
if (self.vlan and
netinfo.operstate(self.name) == netinfo.OPERSTATE_UP and
netinfo.ifaceUsed(self.name) and
self.mtu <= netinfo.getMtu(self.name)):
return
self.configurator.configureNic(self, **opts)
示例7: __init__
def __init__(self, name, configurator, ipv4=None, ipv6=None, blockingdhcp=False, mtu=None, _netinfo=None):
if _netinfo is None:
_netinfo = netinfo.NetInfo()
if name not in _netinfo.nics:
raise ConfigNetworkError(ne.ERR_BAD_NIC, "unknown nic: %s" % name)
if _netinfo.ifaceUsers(name):
mtu = max(mtu, netinfo.getMtu(name))
super(Nic, self).__init__(name, configurator, ipv4, ipv6, blockingdhcp, mtu)
示例8: setNewMtu
def setNewMtu(self, network, bridged, _netinfo=None):
"""
Set new MTU value to network and its interfaces
:param network: network name
:type network: string
:param bridged: network type (bridged or bridgeless)
:type bridged: bool
Update MTU to devices (vlans, bonds and nics)
or added a new value
"""
if _netinfo is None:
_netinfo = netinfo.NetInfo()
currmtu = None
if bridged:
try:
currmtu = netinfo.getMtu(network)
except IOError as e:
if e.errno != os.errno.ENOENT:
raise
nics, delvlan, bonding = \
_netinfo.getNicsVlanAndBondingForNetwork(network)
if delvlan is None:
return
iface = bonding if bonding else nics[0]
vlans = _netinfo.getVlansForIface(iface)
newmtu = None
for vlan in vlans:
cf = netinfo.NET_CONF_PREF + iface + '.' + vlan
mtu = self._getConfigValue(cf, 'MTU')
if mtu:
mtu = int(mtu)
if vlan == delvlan:
# For VLANed bridgeless networks use MTU of delvlan
# as current MTU
if not bridged and mtu:
currmtu = mtu
continue
newmtu = max(newmtu, mtu)
# Optimization: if network hasn't custom MTU (currmtu), do nothing
if currmtu and newmtu != currmtu:
if bonding:
self.setBondingMtu(bonding, newmtu)
else:
self.setIfaceMtu(nics[0], newmtu)
示例9: configure
def configure(self, **opts):
# When the bond is up and we are not changing the configuration that
# is already applied in any way, we can skip the configuring.
if (self.vlan and
self.name in netinfo.bondings() and
netinfo.operstate(self.name) == netinfo.OPERSTATE_UP and
netinfo.NetInfo().ifaceUsers(self.name) and
self.mtu <= netinfo.getMtu(self.name) and
self.areOptionsApplied() and
frozenset(slave.name for slave in self.slaves) ==
frozenset(netinfo.slaves(self.name))):
return
self.configurator.configureBond(self, **opts)
示例10: _mtus_vlans
def _mtus_vlans(running_config):
""" OVS vlans MTUs are automaticaly changed to the lowest MTU of
underlying devices. However, in VDSM, vlan's MTU is based on network
settings. In case when current vlan's MTU differs (should be lower than
a minimal underlying device's MTU), get needed changes.
"""
changes = {}
for net, attrs in iter_ovs_nets(running_config.networks):
mtu = attrs.get('mtu')
if mtu is not None and 'vlan' in attrs:
current_mtu = netinfo.getMtu(net)
if current_mtu != mtu:
changes[net] = mtu
return changes
示例11: _setNewMtu
def _setNewMtu(self, iface, ifaceVlans):
"""
Update an interface's MTU when one of its users is removed.
:param iface: interface object (bond or nic device)
:type iface: NetDevice instance
:param ifaceVlans: vlan devices using the interface 'iface'
:type ifaceVlans: iterable
"""
ifaceMtu = netinfo.getMtu(iface.name)
maxMtu = netinfo.getMaxMtu(ifaceVlans, None)
if maxMtu and maxMtu < ifaceMtu:
if isinstance(iface, Bond):
self.configApplier.setBondingMtu(iface.name, maxMtu)
else:
self.configApplier.setIfaceMtu(iface.name, maxMtu)
示例12: _get_net_info
def _get_net_info(attrs, interface, dhcpv4ifaces, dhcpv6ifaces, routes):
mtu = netinfo.getMtu(interface)
addr, netmask, ipv4addrs, ipv6addrs = netinfo.getIpInfo(interface)
dhcpv4 = netinfo._dhcp_used(interface, dhcpv4ifaces, attrs)
dhcpv6 = netinfo._dhcp_used(interface, dhcpv6ifaces, attrs,
family=6)
gateway = netinfo._get_gateway(routes, interface)
ipv6gateway = netinfo._get_gateway(routes, interface, family=6)
return {
'mtu': str(mtu),
'addr': addr,
'gateway': gateway,
'netmask': netmask,
'dhcpv4': dhcpv4,
'ipv4addrs': ipv4addrs,
'ipv6addrs': ipv6addrs,
'ipv6gateway': ipv6gateway,
'dhcpv6': dhcpv6,
'cfg': {'BOOTPROTO': 'dhcp' if dhcpv4 else 'none'}}
示例13: _get_net_info
def _get_net_info(attrs, interface, dhcpv4ifaces, dhcpv6ifaces, routes):
mtu = netinfo.getMtu(interface)
addr, netmask, ipv4addrs, ipv6addrs = netinfo.getIpInfo(interface)
dhcpv4 = netinfo._dhcp_used(interface, dhcpv4ifaces, attrs)
dhcpv6 = netinfo._dhcp_used(interface, dhcpv6ifaces, attrs, family=6)
gateway = netinfo._get_gateway(routes, interface)
ipv6gateway = netinfo._get_gateway(routes, interface, family=6)
return {
"mtu": str(mtu),
"addr": addr,
"gateway": gateway,
"netmask": netmask,
"dhcpv4": dhcpv4,
"ipv4addrs": ipv4addrs,
"ipv6addrs": ipv6addrs,
"ipv6gateway": ipv6gateway,
"dhcpv6": dhcpv6,
"cfg": {"BOOTPROTO": "dhcp" if dhcpv4 else "none"},
}
示例14: _update_mtu_changes
def _update_mtu_changes(mtu, devices, changes):
for device in devices:
current_mtu = netinfo.getMtu(device)
mtu = max(mtu, changes.get(device), current_mtu)
if mtu != current_mtu:
changes[device] = mtu