Skip to content

Commit

Permalink
Changes to display objects modb objects in opflex-server via gbpinspect
Browse files Browse the repository at this point in the history
Signed-off-by: Gautam Venkataramanan <gautam.chennai@gmail.com>
  • Loading branch information
gautvenk committed Dec 18, 2020
1 parent a1caf63 commit 0e7213e
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 61 deletions.
11 changes: 11 additions & 0 deletions agent-ovs/cmd/test/Policies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,20 @@ void Policies::writeBasicInit(opflex::ofcore::OFFramework& framework) {
root->addSvcServiceUniverse();
root->addEprL2Universe();
root->addEprL3Universe();
root->addInvUniverse();
root->addEpdrL2Discovered();
root->addEpdrL3Discovered();
root->addGbpeVMUniverse();
root->addObserverEpStatUniverse();
root->addObserverSvcStatUniverse();
root->addObserverPolicyStatUniverse();
root->addObserverDropFlowConfigUniverse();
root->addSpanUniverse();
root->addEpdrExternalDiscovered();
root->addEpdrLocalRouteDiscovered();
root->addEprPeerRouteUniverse();
root->addFaultUniverse();
root->addObserverSysStatUniverse();
mutator.commit();
}

Expand Down
7 changes: 6 additions & 1 deletion agent-ovs/cmd/test/framework_stress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,14 @@ int main(int argc, char** argv) {
initLogging(level_str, false /*syslog*/, log_file, "framework-stress");

try {
opflex::ofcore::OFFramework fw;
fw.setModel(modelgbp::getMetadata());
fw.start();

GbpOpflexServer::peer_vec_t peer_vec;
peer_vec.push_back(make_pair(SERVER_ROLES, LOCALHOST":8009"));
GbpOpflexServer server(8009, SERVER_ROLES, peer_vec, std::vector<std::string>(),
modelgbp::getMetadata(), 30);
fw.getStore(), 30);

if (!policy_file.empty()) {
server.readPolicy(policy_file);
Expand Down Expand Up @@ -207,6 +211,7 @@ int main(int argc, char** argv) {
}

server.stop();
fw.stop();
} catch (const std::exception& e) {
LOG(ERROR) << "Fatal error: " << e.what();
return 4;
Expand Down
7 changes: 6 additions & 1 deletion agent-ovs/cmd/test/mock_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,12 @@ int main(int argc, char** argv) {
peer_vec.push_back(make_pair(SERVER_ROLES, LOCALHOST":"
+std::to_string(server_port)));

opflex::ofcore::OFFramework fw;
fw.setModel(modelgbp::getMetadata());
fw.start();
GbpOpflexServer server(server_port, SERVER_ROLES, peer_vec,
transport_mode_proxies,
modelgbp::getMetadata(), 60);
fw.getStore(), 60);
if (policy_file != "") {
server.readPolicy(policy_file);
}
Expand Down Expand Up @@ -212,6 +215,7 @@ int main(int argc, char** argv) {
LOG(INFO) << "Policy/Config dir modified : " << pf_dir;
/* should be stopped after client */
server.stop();
fw.stop();
if (execv(argv[0], argv)) {
LOG(ERROR) << "mock_server failed to restart self"
<< strerror(errno);
Expand All @@ -224,6 +228,7 @@ int main(int argc, char** argv) {
}
cleanup:
server.stop();
fw.stop();
} catch (const std::exception& e) {
LOG(ERROR) << "Fatal error: " << e.what();
return 4;
Expand Down
4 changes: 2 additions & 2 deletions agent-ovs/server/StatsIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ StatsIO::~StatsIO() {
void StatsIO::start() {
if (stopping)
return;
LOG(DEBUG) << "starting stats IO thread";
LOG(INFO) << "starting stats IO thread; interval:" << stats_interval_secs;
const std::lock_guard<std::mutex> guard(stats_timer_mutex);
stats_timer.reset(new deadline_timer(io, seconds(stats_interval_secs)));
stats_timer->async_wait([this](const boost::system::error_code& ec) {
Expand All @@ -62,7 +62,7 @@ void StatsIO::start() {

void StatsIO::stop() {
stopping = true;
LOG(DEBUG) << "stopping stats IO thread";
LOG(INFO) << "stopping stats IO thread";
{
const std::lock_guard<std::mutex> guard(stats_timer_mutex);
if (stats_timer) {
Expand Down
2 changes: 1 addition & 1 deletion agent-ovs/server/opflex_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ int main(int argc, char** argv) {

GbpOpflexServer server(server_port, SERVER_ROLES, peer_vec,
transport_mode_proxies,
modelgbp::getMetadata(),
framework.getStore(),
prr_interval_secs);
#ifdef HAVE_GRPC_SUPPORT
LOG(INFO) << "Connecting to gbp-server at address: "
Expand Down
19 changes: 12 additions & 7 deletions libopflex/cwrapper/test/cwrapper_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,21 @@ class ServerFixture : public MDFixture {
public:
ServerFixture()
: MDFixture(),
opflexServer(8009, SERVER_ROLES,
peerStatus(-1), poolHealth(1), db(threadManager) {
db.init(md);
db.start();
opflexServer = new GbpOpflexServerImpl(8009, SERVER_ROLES,
list_of(make_pair(SERVER_ROLES, LOCALHOST":8009")),
vector<string>(),
md, 60),
peerStatus(-1), poolHealth(1) {
opflexServer.start();
WAIT_FOR(opflexServer.getListener().isListening(), 1000);
db, 60);
opflexServer->start();
WAIT_FOR(opflexServer->getListener().isListening(), 1000);
}

~ServerFixture() {
try {
opflexServer.stop();
opflexServer->stop();
db.stop();
} catch (...) {
LOG(WARNING) << "Exception thrown while stopping opflex server instance";
}
Expand All @@ -88,12 +91,14 @@ class ServerFixture : public MDFixture {
return poolHealth;
}

GbpOpflexServerImpl opflexServer;
GbpOpflexServerImpl *opflexServer;

private:
int peerStatus;
int poolHealth;
boost::mutex fixtureMutex;
opflex::modb::ObjectStore db;
opflex::util::ThreadManager threadManager;
};

void handler(const char* file, int line,
Expand Down
13 changes: 6 additions & 7 deletions libopflex/engine/GbpOpflexServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <cstdio>

#include "opflex/modb/internal/ObjectStore.h"
#include "opflex/test/GbpOpflexServer.h"
#include "opflex/engine/internal/OpflexMessage.h"
#include "opflex/engine/internal/GbpOpflexServerImpl.h"
Expand All @@ -27,10 +28,10 @@ namespace test {
GbpOpflexServer::GbpOpflexServer(uint16_t port, uint8_t roles,
const peer_vec_t& peers,
const std::vector<std::string>& proxies,
const modb::ModelMetadata& md,
modb::ObjectStore& db,
int prr_interval_secs)
: pimpl(new engine::internal
::GbpOpflexServerImpl(port, roles, peers, proxies, md,
::GbpOpflexServerImpl(port, roles, peers, proxies, db,
prr_interval_secs)) { }

GbpOpflexServer::~GbpOpflexServer() {
Expand Down Expand Up @@ -90,14 +91,14 @@ using boost::posix_time::seconds;
GbpOpflexServerImpl::GbpOpflexServerImpl(uint16_t port_, uint8_t roles_,
const GbpOpflexServer::peer_vec_t& peers_,
const std::vector<std::string>& proxies_,
const modb::ModelMetadata& md,
modb::ObjectStore& db_,
int prr_interval_secs_)
: port(port_), roles(roles_), peers(peers_),
proxies(proxies_),
listener(*this, port_, "name", "domain"),
db(threadManager), serializer(&db, this),
db(db_),
serializer(&db, this),
stopping(false), prr_interval_secs(prr_interval_secs_) {
db.init(md);
client = &db.getStoreClient("_SYSTEM_");
}

Expand All @@ -114,7 +115,6 @@ void GbpOpflexServerImpl::enableSSL(const std::string& caStorePath,
}

void GbpOpflexServerImpl::start() {
db.start();

{
const std::lock_guard<std::mutex> guard(prr_timer_mutex);
Expand Down Expand Up @@ -144,7 +144,6 @@ void GbpOpflexServerImpl::stop() {
io_service_thread.reset();
}
listener.disconnect();
db.stop();
client = NULL;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
*/

#include "opflex/test/GbpOpflexServer.h"
#include "opflex/modb/internal/ObjectStore.h"
#include "opflex/gbp/Policy.h"
#include "opflex/engine/internal/OpflexConnection.h"
#include "opflex/engine/internal/OpflexListener.h"
#include "opflex/engine/internal/OpflexHandler.h"
#include "opflex/engine/internal/OpflexServerHandler.h"
#include "opflex/modb/internal/ObjectStore.h"

#include <mutex>
#include <thread>
Expand Down Expand Up @@ -53,7 +53,7 @@ class GbpOpflexServerImpl : public HandlerFactory,
GbpOpflexServerImpl(uint16_t port, uint8_t roles,
const test::GbpOpflexServer::peer_vec_t& peers,
const std::vector<std::string>& proxies,
const modb::ModelMetadata& md,
modb::ObjectStore& db,
int prr_interval_secs);
virtual ~GbpOpflexServerImpl();

Expand Down Expand Up @@ -205,8 +205,7 @@ class GbpOpflexServerImpl : public HandlerFactory,

OpflexListener listener;

util::ThreadManager threadManager;
modb::ObjectStore db;
modb::ObjectStore& db;
MOSerializer serializer;
modb::mointernal::StoreClient* client;

Expand Down
Loading

0 comments on commit 0e7213e

Please sign in to comment.