How to use the ethtool.get_speed 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 periscope-ps / periscope / newblipp / blipp / net.py View on Github external
def get_interface_subjects(self):
        netdev = self._proc.open('net', 'dev')
        faces = []
        subjects = {}
        for line in netdev:
            line = line.split()
            if line[0].count(":"):
                faces.append(line[0][:line[0].index(":")])
        unis = UNISInstance(unis_url=self.unis_url)
        for face in faces:
            try:
                capacity = ethtool.get_speed(face)
            except OSError:
                capacity = 0
            ### some sort of verification here that capacity is right
            post_dict={"name":face,
                       "capacity":capacity}
            resp = unis.post_port(post_dict)
            if isinstance(resp, dict):
                subjects[face]=resp['selfRef']
        return subjects