def _format_rule(self, protocol, cidr, min_port, max_port, direction):
        """Get EOS formatted rule"""
        if cidr is None:
            cidr = 'any'

        if direction == n_const.INGRESS_DIRECTION:
            dst_ip = 'any'
            src_ip = cidr
        elif direction == n_const.EGRESS_DIRECTION:
            dst_ip = cidr
            src_ip = 'any'

        if protocol == n_const.PROTO_NAME_ICMP:
            rule = "permit icmp %s %s" % (src_ip, dst_ip)
            if min_port:
                rule += " %s" % (min_port)
                if max_port:
                    rule += " %s" % (max_port)
        else:
            rule = "permit %s %s %s" % (protocol, src_ip, dst_ip)
            if min_port and max_port:
                rule += " range %s %s" % (min_port, max_port)
            elif min_port and not max_port:
                rule += " eq %s" % min_port
        return rule
Get EOS formatted rule