Пример #1
0
 def db_add(self, table, record, column, *values):
     args = [table, record, column]
     for value in values:
         if isinstance(value, collections.Mapping):
             args += ["{}={}".format(ovsdb.py_to_val(k), ovsdb.py_to_val(v))
                      for k, v in six.iteritems(value)]
         else:
             args.append(ovsdb.py_to_val(value))
     return BaseCommand(self.context, 'add', args=args)
Пример #2
0
def _set_colval_args(*col_values):
    args = []
    # TODO(twilson) This is ugly, but set/find args are very similar except for
    # op. Will try to find a better way to default this op to '='
    for entry in col_values:
        if len(entry) == 2:
            col, op, val = entry[0], '=', entry[1]
        else:
            col, op, val = entry
        if isinstance(val, collections.Mapping):
            args += ["%s:%s%s%s" % (
                col, k, op, ovsdb.py_to_val(v)) for k, v in val.items()]
        elif (isinstance(val, collections.Sequence)
                and not isinstance(val, six.string_types)):
            args.append(
                "%s%s%s" % (col, op, ",".join(map(ovsdb.py_to_val, val))))
        else:
            args.append("%s%s%s" % (col, op, ovsdb.py_to_val(val)))
    return args
Пример #3
0
def _set_colval_args(*col_values):
    args = []
    # TODO(twilson) This is ugly, but set/find args are very similar except for
    # op. Will try to find a better way to default this op to '='
    for entry in col_values:
        if len(entry) == 2:
            col, op, val = entry[0], '=', entry[1]
        else:
            col, op, val = entry
        if isinstance(val, collections.Mapping):
            args += [
                "%s:%s%s%s" % (col, k, op, ovsdb.py_to_val(v))
                for k, v in val.items()
            ]
        elif (isinstance(val, collections.Sequence)
              and not isinstance(val, six.string_types)):
            args.append("%s%s%s" %
                        (col, op, ",".join(map(ovsdb.py_to_val, val))))
        else:
            args.append("%s%s%s" % (col, op, ovsdb.py_to_val(val)))
    return args