def cli(self, interface, output=None):
    if (output is None):
        out = self.device.execute(self.cli_command.format(interface=interface))
    else:
        out = output
    p1 = re.compile('^(?P<name>[\\w\\-\\/\\.]+) +(?P<octets>\\d+) +(?P<ucast_pkts>\\d+) +(?P<mcast_pkts>\\d+) +(?P<bcast_pkts>\\d+)$')
    p2 = re.compile('Port +InOctets +InUcastPkts +InMcastPkts +InBcastPkts')
    p2_1 = re.compile('Port +OutOctets +OutUcastPkts +OutMcastPkts +OutBcastPkts')
    ret_dict = {}
    for line in out.splitlines():
        line = line.strip()
        if p2.match(line):
            in_out = 'in'
            continue
        if p2_1.match(line):
            in_out = 'out'
            continue
        m = p1.match(line)
        if m:
            group = m.groupdict()
            intf = Common.convert_intf_name(group.pop('name'))
            intf_dict = ret_dict.setdefault('interface', {}).setdefault(intf, {}).setdefault(in_out, {})
            intf_dict['name'] = intf
            intf_dict.update({k: int(v) for (k, v) in group.items()})
            continue
    return ret_dict
def cli(self, interface, output=None):
    if (output is None):
        out = self.device.execute(self.cli_command.format(interface=interface))
    else:
        out = output
    p1 = re.compile('^(?P<name>[\\w\\-\\/\\.]+) +(?P<octets>\\d+) +(?P<ucast_pkts>\\d+) +(?P<mcast_pkts>\\d+) +(?P<bcast_pkts>\\d+)$')
    p2 = re.compile('Port +InOctets +InUcastPkts +InMcastPkts +InBcastPkts')
    p2_1 = re.compile('Port +OutOctets +OutUcastPkts +OutMcastPkts +OutBcastPkts')
    ret_dict = {}
    for line in out.splitlines():
        line = line.strip()
        if p2.match(line):
            in_out = 'in'
            continue
        if p2_1.match(line):
            in_out = 'out'
            continue
        m = p1.match(line)
        if m:
            group = m.groupdict()
            intf = Common.convert_intf_name(group.pop('name'))
            intf_dict = ret_dict.setdefault('interface', {}).setdefault(intf, {}).setdefault(in_out, {})
            intf_dict['name'] = intf
            intf_dict.update({k: int(v) for (k, v) in group.items()})
            continue
    return ret_dict