def get_interfaces(self):
        """
        Get interface details.

        last_flapped is not implemented

        Example Output:

        {   u'Vlan1': {   'description': u'',
                      'is_enabled': True,
                      'is_up': True,
                      'last_flapped': -1.0,
                      'mac_address': u'a493.4cc1.67a7',
                      'speed': 100},
        u'Vlan100': {   'description': u'Data Network',
                        'is_enabled': True,
                        'is_up': True,
                        'last_flapped': -1.0,
                        'mac_address': u'a493.4cc1.67a7',
                        'speed': 100},
        u'Vlan200': {   'description': u'Voice Network',
                        'is_enabled': True,
                        'is_up': True,
                        'last_flapped': -1.0,
                        'mac_address': u'a493.4cc1.67a7',
                        'speed': 100}}
        """
        interfaces = {}
        command = "show interface"
        output = self._send_command(command)
        if not output:
            return {}

        # Break output into per-interface sections (note, separator text is retained)
        separator1 = r"^\S+\s+is \S+.*\nadmin state is.*$"
        separator2 = r"^.* is .*, line protocol is .*$"
        separator3 = r"^.* is (?:down|up).*$"
        separators = r"({}|{}|{})".format(separator1, separator2, separator3)
        interface_lines = re.split(separators, output, flags=re.M)

        if len(interface_lines) == 1:
            msg = "Unexpected output data in '{}':\n\n{}".format(
                command, interface_lines
            )
            raise ValueError(msg)

        # Get rid of the blank data at the beginning
        interface_lines.pop(0)

        # Must be pairs of data (the separator and section corresponding to it)
        if len(interface_lines) % 2 != 0:
            msg = "Unexpected output data in '{}':\n\n{}".format(
                command, interface_lines
            )
            raise ValueError(msg)

        # Combine the separator and section into one string
        intf_iter = iter(interface_lines)
        try:
            new_interfaces = [line + next(intf_iter, "") for line in intf_iter]
        except TypeError:
            raise ValueError()

        for entry in new_interfaces:
            interfaces.update(parse_intf_section(entry))

        return interfaces
def get_interfaces ( self ) : interfaces = { } command = "show interface" output = self . _send_command ( command ) if not output : return { } separator1 = r"^\S+\s+is \S+.*\nadmin state is.*$" separator2 = r"^.* is .*, line protocol is .*$" separator3 = r"^.* is (?:down|up).*$" separators = r"({}|{}|{})" . format ( separator1 , separator2 , separator3 ) interface_lines = re . split ( separators , output , flags = re . M ) if len ( interface_lines ) == 1 : msg = "Unexpected output data in '{}':\n\n{}" . format ( command , interface_lines ) raise ValueError ( msg ) interface_lines . pop ( 0 ) if len ( interface_lines ) % 2 != 0 : msg = "Unexpected output data in '{}':\n\n{}" . format ( command , interface_lines ) raise ValueError ( msg ) intf_iter = iter ( interface_lines ) try : new_interfaces = [ line + next ( intf_iter , "" ) for line in intf_iter ] except TypeError : raise ValueError ( ) for entry in new_interfaces : interfaces . update ( parse_intf_section ( entry ) ) return interfaces
Get interface details.

        last_flapped is not implemented

        Example Output:

        {   u'Vlan1': {   'description': u'',
                      'is_enabled': True,
                      'is_up': True,
                      'last_flapped': -1.0,
                      'mac_address': u'a493.4cc1.67a7',
                      'speed': 100},
        u'Vlan100': {   'description': u'Data Network',
                        'is_enabled': True,
                        'is_up': True,
                        'last_flapped': -1.0,
                        'mac_address': u'a493.4cc1.67a7',
                        'speed': 100},
        u'Vlan200': {   'description': u'Voice Network',
                        'is_enabled': True,
                        'is_up': True,
                        'last_flapped': -1.0,
                        'mac_address': u'a493.4cc1.67a7',
                        'speed': 100}}