• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python netinfo.getMtu函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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)
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:25,代码来源:netmodels.py


示例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)
开发者ID:kripper,项目名称:vdsm,代码行数:26,代码来源:models.py


示例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
开发者ID:germanovm,项目名称:vdsm,代码行数:11,代码来源:ovs_before_network_setup_mtu.py


示例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)
开发者ID:lukas-bednar,项目名称:vdsm,代码行数:27,代码来源:netmodels.py


示例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)))
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:8,代码来源:netmodels.py


示例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)
开发者ID:kripper,项目名称:vdsm,代码行数:9,代码来源:models.py


示例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)
开发者ID:nickxiao,项目名称:vdsm,代码行数:10,代码来源:models.py


示例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)
开发者ID:lukas-bednar,项目名称:vdsm,代码行数:52,代码来源:ifcfg.py


示例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)
开发者ID:doronunu,项目名称:vdsm,代码行数:14,代码来源:netmodels.py


示例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
开发者ID:germanovm,项目名称:vdsm,代码行数:14,代码来源:ovs_before_network_setup_mtu.py


示例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)
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:18,代码来源:__init__.py


示例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'}}
开发者ID:borisroman,项目名称:vdsm,代码行数:19,代码来源:ovs_after_get_caps.py


示例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"},
    }
开发者ID:germanovm,项目名称:vdsm,代码行数:19,代码来源:ovs_after_get_caps.py


示例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
开发者ID:germanovm,项目名称:vdsm,代码行数:6,代码来源:ovs_before_network_setup_mtu.py



注:本文中的vdsm.netinfo.getMtu函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python netinfo.ifaceUsed函数代码示例发布时间:2022-05-26
下一篇:
Python netconfpersistence.RunningConfig类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap