2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-29 21:18:02 +00:00

[#1077] netconf: throw, don't exit

This commit is contained in:
Andrei Pavel 2021-07-22 22:02:41 +03:00 committed by Tomek Mrugalski
parent 84ab94f931
commit 03c9c10d0c
3 changed files with 7 additions and 13 deletions

View File

@ -272,19 +272,17 @@ void NetconfAgent::getModules() {
S_Context context(running_sess_->get_context()); S_Context context(running_sess_->get_context());
modules = context->get_module_iter(); modules = context->get_module_iter();
} catch (const sysrepo_exception& ex) { } catch (const sysrepo_exception& ex) {
cerr << "ERROR: Can't retrieve available modules: " << ex.what() << endl; isc_throw(Unexpected, "can't retrieve available modules: " << ex.what());
exit(1);
} }
for (S_Module const& module : modules) { for (S_Module const& module : modules) {
if (!module->name()) { if (!module->name()) {
cerr << "ERROR: module name is mangled" << endl; isc_throw(Unexpected, "could not retrieve module name");
exit(2);
} }
string const name(module->name()); string const name(module->name());
if (!module->rev() || !module->rev()->date()) { if (!module->rev() || !module->rev()->date()) {
cerr << "ERROR: module revision is mangled" << endl; isc_throw(Unexpected,
exit(3); "could not retrieve module revision for module " << name);
} }
string const revision(module->rev()->date()); string const revision(module->rev()->date());
modules_.emplace(name, revision); modules_.emplace(name, revision);
@ -328,11 +326,8 @@ NetconfAgent::checkModules(CfgServersMapPtr const& servers /* = {} */) const {
} }
if (faulty_model) { if (faulty_model) {
cerr << "ERROR: The logged YANG module is missing or its revision is not " isc_throw(Unexpected, "YANG module is missing or its revision is not "
"supported. The environment is not suitable for running " "supported. Check logs for details.");
"kea-netconf."
<< endl;
exit(4);
} }
for (auto modrev : YANG_REVISIONS) { for (auto modrev : YANG_REVISIONS) {

View File

@ -107,7 +107,6 @@ protected:
/// ///
/// Emit a fatal error if an essential one (i.e. required in /// Emit a fatal error if an essential one (i.e. required in
/// a further phase) is missing or does not have the expected revision. /// a further phase) is missing or does not have the expected revision.
/// The caller (init) will exit().
/// ///
/// @param module_name The module name. /// @param module_name The module name.
/// @return true if available, false if not. /// @return true if available, false if not.

View File

@ -90,7 +90,7 @@ NetconfCfgMgr::parse(isc::data::ConstElementPtr config_set,
bool check_only) { bool check_only) {
// Do a sanity check first. // Do a sanity check first.
if (!config_set) { if (!config_set) {
isc_throw(DhcpConfigError, "Mandatory config parameter not provided"); isc_throw(ConfigError, "Mandatory config parameter not provided");
} }
NetconfConfigPtr ctx = getNetconfConfig(); NetconfConfigPtr ctx = getNetconfConfig();