How to use the ovs.json.to_string 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 ovn-org / ovn / tests / test-jsonrpc.py View on Github external
% (name, os.strerror(error)))
        sys.exit(1)

    rpc = ovs.jsonrpc.Connection(stream)

    error = rpc.send(msg)
    if error:
        sys.stderr.write("could not send request: %s\n" % os.strerror(error))
        sys.exit(1)

    error, msg = rpc.recv_block()
    if error:
        sys.stderr.write("error waiting for reply: %s\n" % os.strerror(error))
        sys.exit(1)

    print(ovs.json.to_string(msg.to_json()))

    rpc.close()
github ovn-org / ovn / tests / test-ovsdb.py View on Github external
def do_parse_type(type_string):
    type_json = unbox_json(ovs.json.from_string(type_string))
    type_ = ovs.db.types.Type.from_json(type_json)
    print(ovs.json.to_string(type_.to_json(), sort_keys=True))
github ovn-org / ovn / python / ovs / jsonrpc.py View on Github external
def send(self, msg):
        if self.status:
            return self.status

        self.__log_msg("send", msg)

        was_empty = len(self.output) == 0
        self.output += ovs.json.to_string(msg.to_json())
        if was_empty:
            self.run()
        return self.status
github frenetic-lang / pyretic / pyretic / vendor / ryu / ryu / contrib / ovs / jsonrpc.py View on Github external
def __str__(self):
        s = [Message.type_to_string(self.type)]
        if self.method is not None:
            s.append("method=\"%s\"" % self.method)
        if self.params is not None:
            s.append("params=" + ovs.json.to_string(self.params))
        if self.result is not None:
            s.append("result=" + ovs.json.to_string(self.result))
        if self.error is not None:
            s.append("error=" + ovs.json.to_string(self.error))
        if self.id is not None:
            s.append("id=" + ovs.json.to_string(self.id))
        return ", ".join(s)
github frenetic-lang / pyretic / pyretic / vendor / ryu / ryu / contrib / ovs / jsonrpc.py View on Github external
def send(self, msg):
        if self.status:
            return self.status

        self.__log_msg("send", msg)

        was_empty = len(self.output) == 0
        self.output += ovs.json.to_string(msg.to_json())
        if was_empty:
            self.run()
        return self.status
github ovn-org / ovn / python / ovs / db / data.py View on Github external
def to_string(self):
        if self.type == ovs.db.types.IntegerType:
            return '%d' % self.value
        elif self.type == ovs.db.types.RealType:
            return '%.15g' % self.value
        elif self.type == ovs.db.types.BooleanType:
            if self.value:
                return 'true'
            else:
                return 'false'
        elif self.type == ovs.db.types.StringType:
            if Atom.__string_needs_quotes(self.value):
                return ovs.json.to_string(self.value)
            else:
                return self.value
        elif self.type == ovs.db.types.UuidType:
            return str(self.value)