How to use the ovs.db.error.Error function in ovs

To help you get started, we’ve selected a few ovs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github frenetic-lang / pyretic / pyretic / vendor / ryu / ryu / contrib / ovs / db / idl.py View on Github external
def __do_parse_update(self, table_updates):
        if type(table_updates) != dict:
            raise error.Error(" is not an object",
                              table_updates)

        for table_name, table_update in table_updates.iteritems():
            table = self.tables.get(table_name)
            if not table:
                raise error.Error(' includes unknown '
                                  'table "%s"' % table_name)

            if type(table_update) != dict:
                raise error.Error(' for table "%s" is not '
                                  'an object' % table_name, table_update)

            for uuid_string, row_update in table_update.iteritems():
                if not ovs.ovsuuid.is_valid_string(uuid_string):
                    raise error.Error(' for table "%s" '
                                      'contains bad UUID "%s" as member '
                                      'name' % (table_name, uuid_string),
                                      table_update)
                uuid = ovs.ovsuuid.from_string(uuid_string)

                if type(row_update) != dict:
                    raise error.Error(' for table "%s" '
github ovn-org / ovn / python / ovs / db / parser.py View on Github external
def parse_json_pair(json):
    if not isinstance(json, list) or len(json) != 2:
        raise error.Error("expected 2-element array", json)
    return json
github ovn-org / ovn / python / ovs / db / schema.py View on Github external
for column_name, column_json in six.iteritems(columns_json):
            _check_id(column_name, json)
            columns[column_name] = ColumnSchema.from_json(column_json,
                                                          column_name,
                                                          allow_extensions)

        indexes = []
        for index_json in indexes_json:
            index = column_set_from_json(index_json, columns)
            if not index:
                raise error.Error("index must have at least one column", json)
            elif len(index) == 1:
                index[0].unique = True
            for column in index:
                if not column.persistent:
                    raise error.Error("ephemeral columns (such as %s) may "
                                      "not be indexed" % column.name, json)
            indexes.append(index)

        return TableSchema(name, columns, mutable, max_rows, is_root, indexes,
                           extensions)
github frenetic-lang / pyretic / pyretic / vendor / ryu / ryu / contrib / ovs / db / types.py View on Github external
def __n_from_json(json, default):
        if json is None:
            return default
        elif type(json) == int and 0 <= json <= sys.maxint:
            return json
        else:
            raise error.Error("bad min or max value", json)
github frenetic-lang / pyretic / pyretic / vendor / ryu / ryu / contrib / ovs / db / types.py View on Github external
if (base.min is not None and base.max is not None
                    and base.min > base.max):
                raise error.Error("minReal exceeds maxReal", json)
        elif base.type == StringType:
            base.min_length = BaseType.__parse_uint(parser, "minLength", 0)
            base.max_length = BaseType.__parse_uint(parser, "maxLength",
                                                    sys.maxint)
            if base.min_length > base.max_length:
                raise error.Error("minLength exceeds maxLength", json)
        elif base.type == UuidType:
            base.ref_table_name = parser.get_optional("refTable", ['id'])
            if base.ref_table_name:
                base.ref_type = parser.get_optional("refType", [str, unicode],
                                                   "strong")
                if base.ref_type not in ['strong', 'weak']:
                    raise error.Error('refType must be "strong" or "weak" '
                                      '(not "%s")' % base.ref_type)
        parser.finish()

        return base
github ovn-org / ovn / python / ovs / db / types.py View on Github external
key = BaseType.from_json(key_json)
        if value_json:
            value = BaseType.from_json(value_json)
        else:
            value = None

        n_min = Type.__n_from_json(min_json, Type.DEFAULT_MIN)

        if max_json == 'unlimited':
            n_max = sys.maxsize
        else:
            n_max = Type.__n_from_json(max_json, Type.DEFAULT_MAX)

        type_ = Type(key, value, n_min, n_max)
        if not type_.is_valid():
            raise error.Error("ovsdb type fails constraint checks", json)
        return type_
github ovn-org / ovn / python / ovs / db / data.py View on Github external
values = {}
            for element in inner:
                if is_map:
                    key, value = ovs.db.parser.parse_json_pair(element)
                    keyAtom = Atom.from_json(type_.key, key, symtab)
                    valueAtom = Atom.from_json(type_.value, value, symtab)
                else:
                    keyAtom = Atom.from_json(type_.key, element, symtab)
                    valueAtom = None

                if keyAtom in values:
                    if is_map:
                        raise error.Error("map contains duplicate key")
                    else:
                        raise error.Error("set contains duplicate")

                values[keyAtom] = valueAtom

            return Datum(type_, values)
        else:
            keyAtom = Atom.from_json(type_.key, json, symtab)
            return Datum(type_, {keyAtom: None})
github ovn-org / ovn / python / ovs / db / idl.py View on Github external
def __do_parse_update(self, table_updates, version, tables):
        if not isinstance(table_updates, dict):
            raise error.Error(" is not an object",
                              table_updates)

        for table_name, table_update in six.iteritems(table_updates):
            table = tables.get(table_name)
            if not table:
                raise error.Error(' includes unknown '
                                  'table "%s"' % table_name)

            if not isinstance(table_update, dict):
                raise error.Error(' for table "%s" is not '
                                  'an object' % table_name, table_update)

            for uuid_string, row_update in six.iteritems(table_update):
                if not ovs.ovsuuid.is_valid_string(uuid_string):
                    raise error.Error(' for table "%s" '
                                      'contains bad UUID "%s" as member '
github frenetic-lang / pyretic / pyretic / vendor / ryu / ryu / contrib / ovs / db / idl.py View on Github external
table_update)
                uuid = ovs.ovsuuid.from_string(uuid_string)

                if type(row_update) != dict:
                    raise error.Error(' for table "%s" '
                                      'contains  for %s that '
                                      'is not an object'
                                      % (table_name, uuid_string))

                parser = ovs.db.parser.Parser(row_update, "row-update")
                old = parser.get_optional("old", [dict])
                new = parser.get_optional("new", [dict])
                parser.finish()

                if not old and not new:
                    raise error.Error(' missing "old" and '
                                      '"new" members', row_update)

                if self.__process_update(table, uuid, old, new):
                    self.change_seqno += 1
github frenetic-lang / pyretic / pyretic / vendor / ryu / ryu / contrib / ovs / db / types.py View on Github external
def from_string(s):
        if s != "void":
            for atomic_type in ATOMIC_TYPES:
                if s == atomic_type.name:
                    return atomic_type
        raise error.Error('"%s" is not an atomic-type' % s, s)