def cli(self, interface=None, output=None):
    if (output is None):
        if (not interface):
            cmd = self.cli_command[1]
        else:
            cmd = self.cli_command[0].format(interface=interface)
        out = self.device.execute(cmd)
    else:
        out = output
    ret_dict = {}
    p1 = re.compile('^(?P<interface>[a-zA-Z\\-\\d\\/\\.]+)(?P<description>( (\\S)+)*)$')
    p1_1 = re.compile('^(?P<interface>Tunnel\\d+) +Pim +Register +Tunnel +\\(Encap\\) +for +RP +(?P<rp>[\\w\\.]+)$')
    p2 = re.compile('^(?P<protocol>[\\w\\_\\-\\s]+)\\s+(?P<pkts_in>\\d+)\\s+(?P<chars_in>\\d+)\\s+(?P<pkts_out>\\d+)\\s+(?P<chars_out>\\d+)')
    p3 = re.compile('^No +traffic +sent +or +received +on +this +interface\\.$')
    for line in out.splitlines():
        if line:
            line = line.strip()
        else:
            continue
        m = p3.match(line)
        if m:
            continue
        m = p1.match(line)
        if m:
            intf = m.groupdict()['interface']
            description = m.groupdict()['description']
            continue
        m = p2.match(line)
        if m:
            protocol_dict = m.groupdict()
            protocol = protocol_dict.pop('protocol').lower().strip()
            ret_dict.setdefault(intf, {}).setdefault('accounting', {}).setdefault(protocol, {})
            ret_dict[intf]['accounting'][protocol].update({k: int(v) for (k, v) in protocol_dict.items()})
            if description:
                ret_dict[intf].setdefault('description', description.strip())
            continue
    return ret_dict
def cli(self, interface=None, output=None):
    if (output is None):
        if (not interface):
            cmd = self.cli_command[1]
        else:
            cmd = self.cli_command[0].format(interface=interface)
        out = self.device.execute(cmd)
    else:
        out = output
    ret_dict = {}
    p1 = re.compile('^(?P<interface>[a-zA-Z\\-\\d\\/\\.]+)(?P<description>( (\\S)+)*)$')
    p1_1 = re.compile('^(?P<interface>Tunnel\\d+) +Pim +Register +Tunnel +\\(Encap\\) +for +RP +(?P<rp>[\\w\\.]+)$')
    p2 = re.compile('^(?P<protocol>[\\w\\_\\-\\s]+)\\s+(?P<pkts_in>\\d+)\\s+(?P<chars_in>\\d+)\\s+(?P<pkts_out>\\d+)\\s+(?P<chars_out>\\d+)')
    p3 = re.compile('^No +traffic +sent +or +received +on +this +interface\\.$')
    for line in out.splitlines():
        if line:
            line = line.strip()
        else:
            continue
        m = p3.match(line)
        if m:
            continue
        m = p1.match(line)
        if m:
            intf = m.groupdict()['interface']
            description = m.groupdict()['description']
            continue
        m = p2.match(line)
        if m:
            protocol_dict = m.groupdict()
            protocol = protocol_dict.pop('protocol').lower().strip()
            ret_dict.setdefault(intf, {}).setdefault('accounting', {}).setdefault(protocol, {})
            ret_dict[intf]['accounting'][protocol].update({k: int(v) for (k, v) in protocol_dict.items()})
            if description:
                ret_dict[intf].setdefault('description', description.strip())
            continue
    return ret_dict