Skip to content

Commit

Permalink
Merge pull request #160 from polycube-network/pr/revert_pr_141
Browse files Browse the repository at this point in the history
Revert polycubed persistency support
  • Loading branch information
frisso committed Jun 28, 2019
2 parents 5554fa7 + 91e0303 commit ff6e368
Show file tree
Hide file tree
Showing 20 changed files with 52 additions and 789 deletions.
29 changes: 1 addition & 28 deletions Documentation/polycubed/polycubed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,7 @@ If the same parameter is specified in both, the configuration file and the comma
daemon: true
#p: 6000 <-- this is NOT supported, only long options are



Persistency
^^^^^^^^^^^

Polycubed has persistent capabilities, which means that (1) it can automatically load the configuration that was present when the daemon was shut down, (2) each time a configuration command is issued, it is automatically dumped on disk.
This enables polycubed also to recover from failures, such as rebooting the machine.
By default, the daemon keeps in memory an instance of all the topology, including the configuration of each individual service.
Topology and configuration are automatically updated at each new command; the configuration is also dumped to disk, on file ``/etc/polycube/cubes.yaml``.
The standard behavior of the daemon at startup is to load the latest topology that was active at the end of the previous execution.
Users can load a different topology file by using the ``--cubes-dump`` flag followed by the path to the file.
In case we want to start polycubed with an empty topology, avoiding any possible load at startup, we can launch polycubed with the ``--cubes-init`` flag. Beware that in this case any existing configuration in the default file will be overwritten.
Finally, persistency can be disabled with the ``--cubes-nodump`` flag; this would also avoid any (very limited) performance penalty introduced by this feature.

::

# start polycubed with custom cubes configuration
polycubed --cubes-dump ~/Desktop/myCubes.yaml

# start polycubed with an empty topology
polycubed --cubes-init

# start daemon without topology saving functionalities
polycubed --cubes-nodump



Rest API
^^^^^^^^

TODO...
TODO...
1 change: 0 additions & 1 deletion src/polycubed/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ set(polycubed_sources
utils/veth.cpp
utils/netlink.cpp
utils/utils.cpp
cubes_dump.cpp
${server_sources}
${CMAKE_CURRENT_BINARY_DIR}/load_services.cpp
${CMAKE_CURRENT_BINARY_DIR}/version.cpp)
Expand Down
56 changes: 1 addition & 55 deletions src/polycubed/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,13 @@ namespace configuration {

#define LOGLEVEL spdlog::level::level_enum::info
#define DAEMON false
#define CUBESINIT false
#define CUBESNODUMP false
#define PIDFILE "/var/run/polycube.pid"
#define SERVER_PORT 9000
#define SERVER_IP "localhost"
#define LOGFILE "/var/log/polycube/polycubed.log"
#define CONFIGFILEDIR "/etc/polycube"
#define CONFIGFILENAME "polycubed.conf"
#define CUBESDUMPFILE "cubes.yaml"
#define CONFIGFILE (CONFIGFILEDIR "/" CONFIGFILENAME)
#define CUBESDUMPFILEPATH (CONFIGFILEDIR "/" CUBESDUMPFILE)

static void show_usage(const std::string &name) {
std::cout << std::boolalpha;
Expand All @@ -68,11 +64,6 @@ static void show_usage(const std::string &name) {
<< ")" << std::endl;
std::cout << "--configfile: configuration file (default: " << CONFIGFILE
<< ")" << std::endl;
std::cout << "--cubes-dump: file that keeps the last topology, "
"including the configuration of all cubes (default: " << CUBESDUMPFILEPATH
<< ")" << std::endl;
std::cout << "--cubes-init: starts the daemon with an empty topology" << std::endl;
std::cout << "--cubes-nodump: starts the daemon without dumping updates to file" << std::endl;
std::cout << "--cert-blacklist: path to black listed certificates"
<< std::endl;
std::cout << "--cert-whitelist: path to white listed certificates"
Expand Down Expand Up @@ -104,10 +95,7 @@ Config::Config()
server_port(SERVER_PORT),
server_ip(SERVER_IP),
logfile(LOGFILE),
configfile(CONFIGFILE),
cubes_dump_file(CUBESDUMPFILEPATH),
cubes_init(CUBESINIT),
cubes_nodump(CUBESNODUMP){}
configfile(CONFIGFILE) {}

Config::~Config() {}

Expand Down Expand Up @@ -192,31 +180,6 @@ void Config::setLogFile(const std::string &value) {
logfile = value;
}

std::string Config::getCubesDumpFilePath() const {
return cubes_dump_file;
}

void Config::setCubesDumpFilePath(const std::string &value) {
CHECK_OVERWRITE("cubes-dump", value, cubes_dump_file, CUBESDUMPFILEPATH);
cubes_dump_file = value;
}

bool Config::getCubesInitTopology() const {
return cubes_init;
}

void Config::setCubesInitTopology() {
cubes_init = true;
}

bool Config::getCubesNoDump() const {
return cubes_nodump;
}

void Config::setCubesNoDump() {
cubes_nodump = true;
}

std::string Config::getCertPath() const {
return cert_path;
}
Expand Down Expand Up @@ -283,8 +246,6 @@ void Config::create_configuration_file(const std::string &path) {
file << "addr: " << server_ip << std::endl;
file << "# file to save polycube logs" << std::endl;
file << "logfile: " << logfile << std::endl;
file << "# file to save last topology" << std::endl;
file << "cubes-dump: " << cubes_dump_file << std::endl;
file << "# Security related:" << std::endl;
file << "# server certificate " << std::endl;
file << "#cert: path_to_certificate_file" << std::endl;
Expand All @@ -309,9 +270,6 @@ void Config::dump() {
logger->info(" port: {}", server_port);
logger->info(" addr: {}", server_ip);
logger->info(" logfile: {}", logfile);
logger->info(" cubes-dump: {}", cubes_dump_file);
logger->info(" cubes-init: {}", cubes_init);
logger->info(" cubes-nodump: {}", cubes_nodump);
if (!cert_path.empty()) {
logger->info(" cert: {}", cert_path);
}
Expand Down Expand Up @@ -405,9 +363,6 @@ static struct option options[] = {
{"cacert", required_argument, NULL, 5},
{"cert-whitelist", required_argument, NULL, 6},
{"cert-blacklist", required_argument, NULL, 7},
{"cubes-dump", required_argument, NULL, 8},
{"cubes-init", no_argument, NULL, 9},
{"cubes-nodump", no_argument, NULL, 10},
{NULL, 0, NULL, 0},
};

Expand Down Expand Up @@ -453,15 +408,6 @@ void Config::load_from_cli(int argc, char *argv[]) {
case 7:
setCertBlacklistPath(optarg);
break;
case 8:
setCubesDumpFilePath(optarg);
break;
case 9:
setCubesInitTopology();
break;
case 10:
setCubesNoDump();
break;
}
}
}
Expand Down
15 changes: 0 additions & 15 deletions src/polycubed/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,6 @@ class Config {
std::string getLogFile() const;
void setLogFile(const std::string &value);

// file where last topology is saved
std::string getCubesDumpFilePath() const;
void setCubesDumpFilePath(const std::string &value);

// set to get an empty topology
bool getCubesInitTopology() const;
void setCubesInitTopology();

// set to avoid daemon to dump updates to file
bool getCubesNoDump() const;
void setCubesNoDump();

// path of certificate & key to be used in server
std::string getCertPath() const;
void setCertPath(const std::string &value);
Expand Down Expand Up @@ -92,14 +80,11 @@ class Config {

spdlog::level::level_enum loglevel;
bool daemon;
bool cubes_init;
bool cubes_nodump;
std::string pidfile;
uint16_t server_port;
std::string server_ip;
std::string logfile;
std::string configfile;
std::string cubes_dump_file;
std::string cert_path, key_path;
std::string cacert_path;
std::string cert_whitelist_path;
Expand Down

0 comments on commit ff6e368

Please sign in to comment.