13 #include <ovsdb_types.h>
15 using namespace OVSDB;
17 static void SandeshError(
const std::string msg,
const std::string &context) {
18 ErrorResp *resp =
new ErrorResp();
20 resp->set_context(context);
24 static void SetErrorMsg(
bool &error, std::string &error_msg, std::string msg) {
36 ip_(), port_(0), resp_(NULL), resp_data_(resp_ctx), first_(0),
37 last_(kEntriesPerPage - 1), total_count_(0), needs_next_(false),
38 error_(false), error_msg_(
"") {
39 if (!args.
Get(
"session_ip", &
ip_)) {
44 if (args.
Get(
"session_port", &val)) {
45 port_ = (uint32_t) val;
50 if (args.
Get(
"first", &val)) {
56 if (args.
Get(
"last", &val)) {
57 last_ = (uint32_t) val;
66 ip_(ip), port_(port), resp_(NULL), resp_data_(resp_ctx), first_(0),
67 last_(kEntriesPerPage - 1), total_count_(0), needs_next_(false),
68 error_(false), error_msg_(
"") {
84 boost::system::error_code ec;
88 uint32_t table_size = 0;
89 uint32_t display_count = 0;
91 (session != NULL && session->
client_idl() != NULL)) {
107 table_size = table->
Size();
108 uint8_t cur_count = 0;
109 while (entry != NULL) {
122 entry = table->
Next(entry);
149 args.
Add(
"session_ip",
ip_);
152 args.
Add(
"first", 0);
160 uint32_t table_size) {
161 OvsdbPageResp *resp =
new OvsdbPageResp();
163 OvsdbPageRespData resp_data;
166 args.
Add(
"session_ip",
ip_);
171 args.
Add(
"first", 0);
176 resp_data.set_first_page(s);
190 resp_data.set_prev_page(s);
201 resp_data.set_next_page(s);
206 args.
Add(
"first", -1);
207 args.
Add(
"last", -1);
211 resp_data.set_all(s);
214 std::stringstream match_str;
215 if (display_count != 0) {
216 uint32_t last = first + display_count - 1;
217 match_str << first <<
" - " << (last);
222 resp_data.set_entries(match_str.str());
223 resp_data.set_table_size(table_size);
225 resp->set_req(resp_data);
241 void OvsdbPageReq::HandleRequest()
const {
247 args.
Get(
"ovsdb_table", &table_type);
248 switch (table_type) {
boost::asio::ip::address_v4 Ip4Address
bool Add(const std::string &key, const std::string &val)
bool Del(const std::string &key)
bool Get(const std::string &key, std::string *val) const
int Decode(const std::string &str)
int Encode(std::string *str)
OVSDB::OvsdbClient * ovsdb_client() const
static Agent * GetInstance()
KSyncEntry * Next(const KSyncEntry *entry) const
virtual Ip4Address remote_ip() const =0
virtual uint16_t remote_port() const =0
OvsdbClientIdl * client_idl()
virtual OvsdbClientSession * NextSession(OvsdbClientSession *session)=0
virtual OvsdbClientSession * FindSession(Ip4Address ip, uint16_t port)=0
void EncodeSendPageReq(uint32_t display_count, uint32_t table_size)
static const uint8_t kEntriesPerSandesh
virtual TableType GetTableType()=0
virtual void UpdateResp(KSyncEntry *entry, SandeshResponse *resp)=0
virtual bool NoSessionObject()
virtual ~OvsdbSandeshTask()
virtual FilterResp Filter(KSyncEntry *entry)
void SendResponse(bool more)
OvsdbSandeshTask(std::string resp_ctx, AgentSandeshArguments &args)
virtual SandeshResponse * Alloc()=0
static const uint8_t kEntriesPerPage
std::string EncodeFirstPage()
virtual void EncodeArgs(AgentSandeshArguments &args)
@ HA_STALE_L2_ROUTE_TABLE
virtual KSyncObject * GetObject(OvsdbClientSession *session)=0
bool Run()
Code to execute in a task. Returns true if task is completed. Return false to reschedule the task.
virtual void set_more(const bool val)=0
void set_context(std::string context)
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
void Enqueue(Task *task)
Enqueues a task for running. Starts task if all policy rules are met else puts task in waitq....
static TaskScheduler * GetInstance()
Task is a class to describe a computational task within OpenSDN control plane applications....
static void SetErrorMsg(bool &error, std::string &error_msg, std::string msg)
static void SandeshError(const std::string msg, const std::string &context)