.arg(model);
S_Subscribe subscription(std::make_shared<Subscribe>(running_sess_));
- auto event_notif_callback =
- [=](sysrepo::S_Session session,
- sr_ev_notif_type_t const notification_type, char const* path,
- sysrepo::S_Vals const vals, time_t timestamp) {
- NetconfAgentCallback agent(service_pair);
- return agent.event_notif(session, notification_type, path, vals,
- timestamp, nullptr);
- };
+ auto callback = [=](sysrepo::S_Session session,
+ sr_ev_notif_type_t const notification_type,
+ char const* path,
+ sysrepo::S_Vals const vals,
+ time_t timestamp) {
+ NetconfAgentCallback agent(service_pair);
+ return agent.event_notif(session, notification_type, path, vals, timestamp, nullptr);
+ };
try {
// The alternative event_notif_subscribe_tree() might expose more data
// as S_Data_Node if needed.
- subscription->event_notif_subscribe(model.c_str(),
- event_notif_callback);
+ subscription->event_notif_subscribe(model.c_str(), callback);
} catch (const std::exception& ex) {
ostringstream msg;
msg << "event notification subscription for model " << model <<
LOG_ERROR(netconf_logger, NETCONF_VALIDATE_CONFIG_FAILED)
.arg(service_pair.first)
.arg(msg.str());
- return SR_ERR_OPERATION_FAILED;
+ return (SR_ERR_OPERATION_FAILED);
} else {
LOG_DEBUG(netconf_logger, NETCONF_DBG_TRACE_DETAIL_DATA,
NETCONF_VALIDATE_CONFIG)
/// @brief Retrieve names and revisions of installed modules through the
/// sysrepo API.
+ ///
+ /// @throw Unexpected if module information cannot be retrieved from sysrepo
void getModules();
/// @brief Check module availability.
/// @param servers the configured servers to check against YANG_REVISIONS.
/// Is empty by default for when the caller only wants to check
/// installed modules.
+ ///
+ /// @throw Unexpected if a module from YANG_REVISIONS is not installed or
+ /// has the wrong revision.
void checkModules(CfgServersMapPtr const& servers = {}) const;
/// @brief Retrieve Kea server configuration from the YANG startup
} catch (const sysrepo_exception& ex) {
cerr << "ERROR: Can't initialize sysrepo: " << ex.what() << endl;
cerr << "ERROR: Make sure you have the right permissions to the sysrepo repository." << endl;
- return 1;
+ return (1);
}
S_Session sess;
} catch (const sysrepo_exception& ex) {
cerr << "ERROR: Can't establish a sysrepo session: "
<< ex.what() << endl;
- return 2;
+ return (2);
}
vector<S_Module> modules;
modules = context->get_module_iter();
} catch (const sysrepo_exception& ex) {
cerr << "ERROR: Can't retrieve available modules: " << ex.what() << endl;
- return 3;
+ return (3);
}
std::unordered_map<std::string, std::string> installed_modules;
for (S_Module const& module : modules) {
if (!module->name()) {
cerr << "ERROR: module name is mangled" << endl;
- return 4;
+ return (4);
}
string const name(module->name());
if (!module->rev() || !module->rev()->date()) {
cerr << "ERROR: module revision is mangled" << endl;
- return 5;
+ return (5);
}
string const revision(module->rev()->date());
installed_modules.emplace(name, revision);
std::string const& revision(kv.second);
if (!installed_modules.count(name)) {
cerr << missingModuleText(name, revision);
- return 6;
+ return (6);
}
string const& expected_revision(installed_modules.at(name));
if (expected_revision != revision) {
cerr << badRevisionModuleText(name, expected_revision, revision);
- return 7;
+ return (7);
}
}
// Not found.
xpath = "/keatest-module:main/no_such_string";
- // sysrepo_exception: "Invalid argument" ¯\_(ツ)_/¯
+
+ // sysrepo_exception: "Invalid argument"
EXPECT_THROW(sess->delete_item(xpath.c_str()), sysrepo_exception);
EXPECT_THROW(elem = t_obj->getItem(xpath), SysrepoError);
EXPECT_FALSE(elem);
sess->set_item_str(xpath.c_str(), "2");
sess->set_item_str(xpath.c_str(), "3");
sess->apply_changes();
- // sysrepo_exception: "Invalid argument" ¯\_(ツ)_/¯
+
+ // sysrepo_exception: "Invalid argument"
EXPECT_THROW(data_node = sess->get_subtree(xpath.c_str()),
sysrepo_exception);
EXPECT_FALSE(data_node);
EXPECT_TRUE(s_val);
s_val.reset();
EXPECT_NO_THROW(t_obj->delItem(xpath));
- // sysrepo_exception: "Item not found" ¯\_(ツ)_/¯
+
+ // sysrepo_exception: "Item not found"
EXPECT_THROW(s_val = sess->get_item(xpath.c_str()), sysrepo_exception);
EXPECT_FALSE(s_val);
EXPECT_NO_THROW(t_obj->delItem(xpath));