How to use the ovs.stream.Stream.open 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-stream.py View on Github external
def main(argv):
    remote = argv[1]
    err, stream = ovs.stream.Stream.open_block(
            ovs.stream.Stream.open(remote), 10000)

    if err or stream is None:
        sys.exit(1)

    sys.exit(0)
github osrg / ryu / ryu / lib / ovs / db_client.py View on Github external
_COMMANDS = {
            'list-dbs': self._list_dbs,
            'get-schema': self._get_schema,
            'get-schema-version': self._get_schema_version,
            'list-tables': self._list_tables,
            'list-columns': self._list_columns,
            'transact': self._transact,
            'monitor': self._monitor,
            'dump': self._dump,
        }

        command = args[0]
        args = args[1:]

        error, stream_ = stream.Stream.open_block(
            stream.Stream.open(self.remote))
        if error:
            raise RuntimeError('can not open socket to %s: %s' %
                               (self.remote, os.strerror(error)))
        rpc = jsonrpc.Connection(stream_)

        ret = _COMMANDS[command](rpc, *args)
        LOG.info('ret %s', ret)
        rpc.close()
github osrg / ryu / ryu / lib / ovs / vsctl.py View on Github external
def _rpc_get_schema_json(self, database):
        LOG.debug('remote %s', self.remote)
        error, stream_ = stream.Stream.open_block(
            stream.Stream.open(self.remote))
        if error:
            vsctl_fatal('error %s' % os.strerror(error))
        rpc = jsonrpc.Connection(stream_)
        request = jsonrpc.Message.create_request('get_schema', [database])
        error, reply = rpc.transact_block(request)
        rpc.close()

        if error:
            vsctl_fatal(os.strerror(error))
        elif reply.error:
            vsctl_fatal('error %s' % reply.error)
        return reply.result
github ovn-org / ovn / python / ovs / unixctl / server.py View on Github external
def create(path):
        assert isinstance(path, str)

        unix = "unix:%s" % ovs.util.abs_file_name(ovs.dirs.RUNDIR, path)
        error, stream = ovs.stream.Stream.open_block(
            ovs.stream.Stream.open(unix))

        if error:
            vlog.warn("failed to connect to %s" % path)
            return error, None

        return 0, UnixctlClient(ovs.jsonrpc.Connection(stream))
github frenetic-lang / pyretic / pyretic / vendor / ryu / ryu / contrib / ovs / jsonrpc.py View on Github external
def __connect(self):
        self.__disconnect()

        name = self.reconnect.get_name()
        if not self.reconnect.is_passive():
            error, self.stream = ovs.stream.Stream.open(name)
            if not error:
                self.reconnect.connecting(ovs.timeval.msec())
            else:
                self.reconnect.connect_failed(ovs.timeval.msec(), error)
        elif self.pstream is not None:
            error, self.pstream = ovs.stream.PassiveStream.open(name)
            if not error:
                self.reconnect.listening(ovs.timeval.msec())
            else:
                self.reconnect.connect_failed(ovs.timeval.msec(), error)

        self.seqno += 1