Hi Iwamoto-San,

Basically, this feature is very similar to "ryu.lib.ofctl_v1_*", I guess.
In case of ofctl_v1_*, this library provides the translation layer (json like
object -> OFP* instance) and seems to be well separated from "ryu.ofproto"
module ("ofctl_v1_*" have many duplicated codes though...).

For example, OFPInstructionGotoTable.from_string() is not for the pure OpenFlow
protocol and is specifically for the "ovs-ofctl" command of OVS.
So I think it might be better to implement this feature under "ryu.lib" module
(e.g., "ryu.lib.ovs_ofctl" or ""ryu.lib.ofctl")
But NOT strong will, and the current implementation works well with short codes.


On 2017年05月02日 16:19, IWAMOTO Toshihiro wrote:
> This commit adds a new method called ofp_instruction_from_str,
> which takes an ovs-ofctl style action string and returns a list of
> OFPInstructionActions. Currently only a few action strings are
> understood.
> 
> Signed-off-by: IWAMOTO Toshihiro <iwam...@valinux.co.jp>
> ---
> diff --git a/ryu/ofproto/ofproto_parser.py b/ryu/ofproto/ofproto_parser.py
> ...(snip)
> +
> +def tokenize_ofp_instruction_arg(arg):
> +    """
> +    Tokenize an argument portion of ovs-ofctl style action string.
> +    """
> +    arg_re = re.compile("[^,()]*")
> +    try:
> +        rest = arg
> +        result = []
> +        while len(rest):
> +            m = arg_re.match(rest)
> +            if m.end(0) == len(rest):
> +                result.append(rest)
> +                return result
> +            if rest[m.end(0)] == '(':
> +                this_block, rest = _tokenize_paren_block(
> +                    rest, m.end(0) + 1)
> +                result.append(this_block)
> +            elif rest[m.end(0)] == ',':
> +                result.append(m.group(0))
> +                rest = rest[m.end(0):]
> +            else:  # is ')'
> +                raise Exception
> +            if len(rest):
> +                assert rest[0] == ','
> +                rest = rest[1:]
> +        return result
> +    except Exception:
> +        raise ryu.exception.OFPInvalidActionString(action_str=arg)

"ryu.exception" cannot be access from here because it is imported with
"from ryu import exception".
It should be like "exception.OFPInvalidActionString(action_str=arg)"?

Thanks,
Iwase

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to