How to use the ethtool.get_devices function in ethtool

To help you get started, we’ve selected a few ethtool examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github candlepin / subscription-manager / src / subscription_manager / hwprobe.py View on Github external
def get_network_interfaces(self):
        netinfdict = {}
        old_ipv4_metakeys = ['ipv4_address', 'ipv4_netmask', 'ipv4_broadcast']
        ipv4_metakeys = ['address', 'netmask', 'broadcast']
        ipv6_metakeys = ['address', 'netmask']
        try:
            interfaces_info = ethtool.get_interfaces_info(ethtool.get_devices())
            for info in interfaces_info:
                master = None
                mac_address = info.mac_address
                device = info.device
                # Omit mac addresses for sit and lo device types. See BZ838123
                # mac address are per interface, not per address
                if self._should_get_mac_address(device):
                    key = '.'.join(['net.interface', device, 'mac_address'])
                    netinfdict[key] = mac_address

                # all of our supported versions of python-ethtool support
                # get_ipv6_addresses
                for addr in info.get_ipv6_addresses():
                    # ethtool returns a different scope for "public" IPv6 addresses
                    # on different versions of RHEL.  EL5 is "global", while EL6 is
                    # "universe".  Make them consistent.
github oVirt / ovirt-hosted-engine-setup / src / plugins / gr-he-common / vm / cloud_init.py View on Github external
def _getMyIPAddrList(self):
        device = (
            self.environment[ohostedcons.NetworkEnv.BRIDGE_NAME]
            if self.environment[ohostedcons.NetworkEnv.BRIDGE_NAME]
            in ethtool.get_devices()
            else self.environment[ohostedcons.NetworkEnv.BRIDGE_IF]
        )
        self.logger.debug(
            "Acquiring '{device}' address".format(
                device=device,
            )
        )
        rc, stdout, stderr = self.execute(
            args=(
                self.command.get('ip'),
                'addr',
                'show',
                device,
                'scope',
                'global'
            ),
github cobbler / cobbler / koan / utils.py View on Github external
def get_network_info():
    interfaces = {}
    # get names
    inames = ethtool.get_devices()

    for iname in inames:
        mac = ethtool.get_hwaddr(iname)

        if mac == "00:00:00:00:00:00":
            mac = "?"

        try:
            ip = ethtool.get_ipaddr(iname)
            if ip == "127.0.0.1":
                ip = "?"
        except:
            ip = "?"

        bridge = 0
        module = ""
github uyuni-project / uyuni / client / debian / packages-already-in-debian / python-ethtool / pethtool.py View on Github external
def run_cmd_noargs(cmd, args):
        if args:
                run_cmd(cmd, args[0], None)
        else:
                global all_devices
                all_devices = ethtool.get_devices()
                run_cmd(cmd, None, None)
github kimchi-project / ginger / model / nw_cfginterfaces_utils.py View on Github external
def validate_interface(self, name):
        if encode_value(name) not in ethtool.get_devices():
            raise InvalidParameter('GINNET0014E', {'name': name})