This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.orgNeels Hofmeyr has uploaded this change for review. ( https://gerrit.osmocom.org/13586
Change subject: osmo-hlr: allow configuring db path from cfg file
......................................................................
osmo-hlr: allow configuring db path from cfg file
So far, the cmdline argument was the only way to set a database config file.
Add a similar config to VTY as 'hlr' / 'database'. The cmdline arg is stronger
than the 'database' cfg item. DB is not reloaded from VTY command.
Change-Id: I87b8673324e1e6225afb758fb4963ff3279ea3d8
---
M src/hlr.c
M src/hlr.h
M src/hlr_vty.c
3 files changed, 23 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/86/13586/1
diff --git a/src/hlr.c b/src/hlr.c
index ce8c388..836d57b 100644
--- a/src/hlr.c
+++ b/src/hlr.c
@@ -621,7 +621,7 @@
bool db_upgrade;
} cmdline_opts = {
.config_file = "osmo-hlr.cfg",
- .db_file = "hlr.db",
+ .db_file = NULL,
.daemonize = false,
.db_upgrade = false,
};
@@ -736,6 +736,7 @@
INIT_LLIST_HEAD(&g_hlr->iuse_list);
INIT_LLIST_HEAD(&g_hlr->ss_sessions);
INIT_LLIST_HEAD(&g_hlr->ussd_routes);
+ osmo_talloc_replace_string(g_hlr, &g_hlr->db_file_path, HLR_DEFAULT_DB_FILE_PATH);
/* Init default (call independent) SS session guard timeout value */
g_hlr->ncss_guard_timeout = NCSS_GUARD_TIMEOUT_DEFAULT;
@@ -774,9 +775,12 @@
exit(1);
}
- g_hlr->dbc = db_open(hlr_ctx, cmdline_opts.db_file, true, cmdline_opts.db_upgrade);
+ if (cmdline_opts.db_file)
+ osmo_talloc_replace_string(g_hlr, &g_hlr->db_file_path, cmdline_opts.db_file);
+
+ g_hlr->dbc = db_open(hlr_ctx, g_hlr->db_file_path, true, cmdline_opts.db_upgrade);
if (!g_hlr->dbc) {
- LOGP(DMAIN, LOGL_FATAL, "Error opening database\n");
+ LOGP(DMAIN, LOGL_FATAL, "Error opening database %s\n", osmo_quote_str(g_hlr->db_file_path, -1));
exit(1);
}
diff --git a/src/hlr.h b/src/hlr.h
index 00fa43c..e2e96a4 100644
--- a/src/hlr.h
+++ b/src/hlr.h
@@ -25,6 +25,8 @@
#include <stdbool.h>
#include <osmocom/core/linuxlist.h>
+#define HLR_DEFAULT_DB_FILE_PATH "hlr.db"
+
struct hlr_euse;
struct hlr {
@@ -32,6 +34,7 @@
struct osmo_gsup_server *gs;
/* DB context */
+ char *db_file_path;
struct db_context *dbc;
/* Control Interface */
diff --git a/src/hlr_vty.c b/src/hlr_vty.c
index d0a623a..e4cc4be 100644
--- a/src/hlr_vty.c
+++ b/src/hlr_vty.c
@@ -74,6 +74,8 @@
vty_out(vty, "hlr%s", VTY_NEWLINE);
if (g_hlr->store_imei)
vty_out(vty, " store-imei%s", VTY_NEWLINE);
+ if (g_hlr->db_file_path && strcmp(g_hlr->db_file_path, HLR_DEFAULT_DB_FILE_PATH))
+ vty_out(vty, " database %s%s", g_hlr->db_file_path, VTY_NEWLINE);
return CMD_SUCCESS;
}
@@ -224,6 +226,15 @@
return CMD_SUCCESS;
}
+DEFUN(cfg_database, cfg_database_cmd,
+ "database PATH",
+ "Set the path to the HLR database file\n"
+ "Relative or absolute file system path to the database file (default is '" HLR_DEFAULT_DB_FILE_PATH "')\n")
+{
+ osmo_talloc_replace_string(g_hlr, &g_hlr->db_file_path, argv[0]);
+ return CMD_SUCCESS;
+}
+
struct cmd_node euse_node = {
EUSE_NODE,
"%s(config-hlr-euse)# ",
@@ -380,6 +391,8 @@
install_element(GSUP_NODE, &cfg_hlr_gsup_bind_ip_cmd);
+ install_element(HLR_NODE, &cfg_database_cmd);
+
install_element(HLR_NODE, &cfg_euse_cmd);
install_element(HLR_NODE, &cfg_no_euse_cmd);
install_node(&euse_node, config_write_euse);
--
To view, visit https://gerrit.osmocom.org/13586
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I87b8673324e1e6225afb758fb4963ff3279ea3d8
Gerrit-Change-Number: 13586
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190410/aa701bfe/attachment.htm>