Change in osmo-hlr[master]: add 'show subscriber' command, alias for 'subscriber ... show'

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
Mon Dec 3 13:14:19 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/12055 )

Change subject: add 'show subscriber' command, alias for 'subscriber ... show'
......................................................................

add 'show subscriber' command, alias for 'subscriber ... show'

When I wrote the osmo-hlr subscriber command, I failed to heed the common
'show foo' scheme and instead created a 'subscriber [...] show' command.
Relieve that weirdness by creating an alias that has 'show' at the start.

Arrange string macros so that the 'show subscriber' cmd doesn't end in a space
(the SUBSCR macro ends in a space ' ' to implicitly include the space to
commands like 'create', 'show', 'update').

Add the new command to test_nodes.vty and test_subscriber.vty.

Change-Id: I01ce9b0868302d40ed05c6a588316a194d6071e4
---
M src/hlr_vty_subscr.c
M tests/test_nodes.vty
M tests/test_subscriber.vty
3 files changed, 16 insertions(+), 2 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Pau Espin Pedrol: Looks good to me, approved
  Vadim Yanitskiy: Looks good to me, but someone else must approve



diff --git a/src/hlr_vty_subscr.c b/src/hlr_vty_subscr.c
index 6ce96fe..ddbaf26 100644
--- a/src/hlr_vty_subscr.c
+++ b/src/hlr_vty_subscr.c
@@ -130,14 +130,14 @@
 #define SUBSCR_CMD "subscriber "
 #define SUBSCR_CMD_HELP "Subscriber management commands\n"
 
-#define SUBSCR_ID "(imsi|msisdn|id) IDENT "
+#define SUBSCR_ID "(imsi|msisdn|id) IDENT"
 #define SUBSCR_ID_HELP \
 	"Identify subscriber by IMSI\n" \
 	"Identify subscriber by MSISDN (phone number)\n" \
 	"Identify subscriber by database ID\n" \
 	"IMSI/MSISDN/ID of the subscriber\n"
 
-#define SUBSCR 		SUBSCR_CMD SUBSCR_ID
+#define SUBSCR 		SUBSCR_CMD SUBSCR_ID " "
 #define SUBSCR_HELP	SUBSCR_CMD_HELP SUBSCR_ID_HELP
 
 #define SUBSCR_UPDATE		SUBSCR "update "
@@ -159,6 +159,10 @@
 	return CMD_SUCCESS;
 }
 
+ALIAS(subscriber_show, show_subscriber_cmd,
+      "show " SUBSCR_CMD SUBSCR_ID,
+      SHOW_STR SUBSCR_CMD_HELP SUBSCR_ID_HELP);
+
 DEFUN(subscriber_create,
       subscriber_create_cmd,
       SUBSCR_CMD "imsi IDENT create",
@@ -478,6 +482,7 @@
 void hlr_vty_subscriber_init(void)
 {
 	install_element_ve(&subscriber_show_cmd);
+	install_element_ve(&show_subscriber_cmd);
 	install_element(ENABLE_NODE, &subscriber_create_cmd);
 	install_element(ENABLE_NODE, &subscriber_delete_cmd);
 	install_element(ENABLE_NODE, &subscriber_msisdn_cmd);
diff --git a/tests/test_nodes.vty b/tests/test_nodes.vty
index a9d4ac4..e1f57a9 100644
--- a/tests/test_nodes.vty
+++ b/tests/test_nodes.vty
@@ -18,6 +18,7 @@
   show talloc-context (application|all) (full|brief|DEPTH) filter REGEXP
   show gsup-connections
   subscriber (imsi|msisdn|id) IDENT show
+  show subscriber (imsi|msisdn|id) IDENT
 
 OsmoHLR> enable
 OsmoHLR# list
diff --git a/tests/test_subscriber.vty b/tests/test_subscriber.vty
index 2da455f..c22f2df 100644
--- a/tests/test_subscriber.vty
+++ b/tests/test_subscriber.vty
@@ -3,6 +3,7 @@
 OsmoHLR# list
 ...
   subscriber (imsi|msisdn|id) IDENT show
+  show subscriber (imsi|msisdn|id) IDENT
   subscriber imsi IDENT create
   subscriber (imsi|msisdn|id) IDENT delete
   subscriber (imsi|msisdn|id) IDENT update msisdn MSISDN
@@ -33,6 +34,13 @@
 OsmoHLR# subscriber msisdn 12345 show
 % No subscriber for msisdn = '12345'
 
+OsmoHLR# show subscriber imsi 123456789023000
+% No subscriber for imsi = '123456789023000'
+OsmoHLR# show subscriber id 1
+% No subscriber for id = '1'
+OsmoHLR# show subscriber msisdn 12345
+% No subscriber for msisdn = '12345'
+
 OsmoHLR# subscriber imsi 1234567890230001 create
 % Not a valid IMSI: 1234567890230001
 OsmoHLR# subscriber imsi 12345678902300x create

-- 
To view, visit https://gerrit.osmocom.org/12055
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I01ce9b0868302d40ed05c6a588316a194d6071e4
Gerrit-Change-Number: 12055
Gerrit-PatchSet: 2
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181203/1d155aca/attachment.htm>


More information about the gerrit-log mailing list