[MERGED] osmo-hlr[master]: db-tool: add command 'create'

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Sun Nov 12 14:22:01 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: db-tool: add command 'create'
......................................................................


db-tool: add command 'create'

Change-Id: Ic4997d17763e50fb63c36fc0001570230bf64a12
---
M src/hlr_db_tool.c
1 file changed, 12 insertions(+), 4 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/hlr_db_tool.c b/src/hlr_db_tool.c
index eb82c92..13281f2 100644
--- a/src/hlr_db_tool.c
+++ b/src/hlr_db_tool.c
@@ -51,8 +51,7 @@
 static void print_help()
 {
 	printf("\n");
-	printf("Usage: osmo-hlr-db-tool [-l <hlr.db>] import-nitb-db <nitb.db>]\n");
-	printf("Call without arguments to create a new empty ./hlr.db.\n");
+	printf("Usage: osmo-hlr-db-tool [-l <hlr.db>] [create|import-nitb-db <nitb.db>]\n");
 	printf("  -l --database db-name      The OsmoHLR database to use, default '%s'.\n",
 	       cmdline_opts.db_file);
 	printf("  -h --help                  This text.\n");
@@ -61,6 +60,11 @@
 	printf("  -T --timestamp             Prefix every log line with a timestamp.\n");
 	printf("  -e --log-level number      Set a global loglevel.\n");
 	printf("  -V --version               Print the version of OsmoHLR-db-tool.\n");
+	printf("\n");
+	printf("Commands:\n");
+	printf("\n");
+	printf("  create                     Create an empty OsmoHLR database.\n");
+	printf("                             (All commands imply this if none exists yet.)\n");
 	printf("\n");
 	printf("  import-nitb-db db          Add OsmoNITB db's subscribers to OsmoHLR db.\n");
 	printf("                             Be aware that the import is lossy, only the\n");
@@ -141,7 +145,10 @@
 	cmd = argv[optind++];
 	printf("command '%s', %d extra arguments\n", cmd, argc - optind);
 
-	if (!strcmp(cmd, "import-nitb-db")) {
+	if (!strcmp(cmd, "create")) {
+		/* Nothing to do, just run the main program to open the database without running any
+		 * action, which will bootstrap all tables. */
+	} else if (!strcmp(cmd, "import-nitb-db")) {
 		if (argc - optind < 1) {
 			fprintf(stderr, "You must specify an input db file\n");
 			print_help();
@@ -387,7 +394,8 @@
 			goto too_many_actions;
 		main_action = import_nitb_db;
 	}
-	/* Future: add more main_actions, besides --import-nitb-db, here. */
+	/* Future: add more main_actions, besides import-nitb-db, here.
+	 * For command 'create', no action is required. */
 
 	/* Just in case any db actions need randomness */
 	rc = rand_init();

-- 
To view, visit https://gerrit.osmocom.org/4776
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic4997d17763e50fb63c36fc0001570230bf64a12
Gerrit-PatchSet: 2
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list