ovs_dbg package

Submodules

ovs_dbg.flows module

Common helper classes for flow (ofproto/dpif) parsing

class ovs_dbg.flows.KVDecoders(decoders=None, default=None, default_free=None)[source]

Bases: object

KVDecoders class is used by KVParser to select how to decoode the value of a specific keyword.

A decoder is simply a function that accepts the keyword and value strings and returns the keyword and value objects to be stored. The returned keyword must be a string but may not be the same as the given keyword. The returned value may be of any type.

Parameters
  • decoders (dict) – Optional; A dictionary of decoders indexed by keyword.

  • default (callable) – Optional; A decoder used if a match is not found in configured decoders. If not provided, the default behavior is to try to decode the value into an integer and, if that fails, just return the string as-is.

  • default_free (callable) – Optional; A decoder used if a match is not found in configured decoders and it’s a free value (e.g: a keyword without a value). Defaults to returning the free value as keyword and “True” as value.

decode(keyword, value_str)[source]

Decode a keyword and value.

Parameters
  • keyword (str) – The keyword whose value is to be decoded.

  • value_str (str) – The value string.

Returns

The key (str) and value(any) to be stored.

class ovs_dbg.flows.KVParser(decoders=None)[source]

Bases: object

KVParser parses a string looking for key-value pairs.

Parameters

decoders (KVDecoders) – Optional; the KVDecoders instance to use.

keys()[source]
kv()[source]
parse(string)[source]

Parse the key-value pairs in string.

Parameters

string (str) – the string to parse.

Raises

ParseError if any parsing error occurs.

class ovs_dbg.flows.KeyMetadata(kpos, vpos, kstring, vstring, end_del)[source]

Bases: object

Class for keeping key metadata.

kpos

The position of the keyword in the parent string.

Type

int

vpos

The position of the value in the parent string.

Type

int

kstring

The keyword string as found in the flow string.

Type

string

vstring

The value as found in the flow string.

Type

string

end_del

Whether the key has end delimiter.

Type

bool

class ovs_dbg.flows.KeyValue(key, value, meta=None)[source]

Bases: object

Class for keeping key-value data

key

The key string.

Type

str

value

The value data.

Type

any

meta

The key metadata.

Type

KeyMetadata

exception ovs_dbg.flows.ParseError[source]

Bases: RuntimeError

Exception raised when an error occurs during parsing.

ovs_dbg.flows.default_kv_decoder(key, value)

A key-value decoder that extracts nested key-value pairs and returns them in a dictionary

Parameters
  • decoders (KVDecoders) – the KVDecoders to use.

  • key (str) – the keyword we’re decoding.

  • value (str) – the value string to decode.

Module contents