Change in osmo-bsc[master]: bsc_ctrl_commands: add command to write vty config

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

laforge gerrit-no-reply at lists.osmocom.org
Fri Jun 25 08:14:38 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/24735 )

Change subject: bsc_ctrl_commands: add command to write vty config
......................................................................

bsc_ctrl_commands: add command to write vty config

we recently added control commands to apply vty config files during
runtime using the control interface. However, there is no command that
allows us to store the config file modifications.

Change-Id: If17095bb86f82dd8feb86eb72c4133ea3aa1c3b3
Related: SYS#5369
---
M doc/manuals/chapters/control.adoc
M src/osmo-bsc/bsc_ctrl_commands.c
2 files changed, 28 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve



diff --git a/doc/manuals/chapters/control.adoc b/doc/manuals/chapters/control.adoc
index 6b1609a..bd49100 100644
--- a/doc/manuals/chapters/control.adoc
+++ b/doc/manuals/chapters/control.adoc
@@ -27,6 +27,7 @@
 |inform-msc-v1|WO|Yes|Arbitrary value| See <<infomsc>> for details.
 |rf_locked|RW|No|"0","1"|See <<rfl>> for details.
 |number-of-bts|RO|No|"<num>"|Get number of configured BTS.
+|write-config-file|WO|No|"overwrite", "<filename>"|Write running configuration to file.
 |bts.N.location-area-code|RW|No|"<lac>"|Set/Get LAC (value between (0, 65535)).
 |bts.N.cell-identity|RW|No|"<id>"|Set/Get Cell Identity (value between (0, 65535)).
 |bts.N.apply-configuration|WO|No|Ignored|Restart BTS via OML.
diff --git a/src/osmo-bsc/bsc_ctrl_commands.c b/src/osmo-bsc/bsc_ctrl_commands.c
index 2d37b5d..15f5536 100644
--- a/src/osmo-bsc/bsc_ctrl_commands.c
+++ b/src/osmo-bsc/bsc_ctrl_commands.c
@@ -24,6 +24,7 @@
 #include <osmocom/ctrl/control_cmd.h>
 
 #include <osmocom/vty/command.h>
+#include <osmocom/vty/misc.h>
 
 #include <osmocom/gsm/gsm48.h>
 #include <osmocom/bsc/ipaccess.h>
@@ -82,6 +83,31 @@
 }
 CTRL_CMD_DEFINE_WO(net_apply_config_file, "apply-config-file");
 
+static int verify_net_write_config_file(struct ctrl_cmd *cmd, const char *value, void *_data)
+{
+	return 0;
+}
+static int set_net_write_config_file(struct ctrl_cmd *cmd, void *_data)
+{
+	const char *cfile_name;
+	unsigned cmd_ret = CTRL_CMD_ERROR;
+
+	if (strcmp(cmd->value, "overwrite"))
+		host_config_set(cmd->value);
+
+	cfile_name = host_config_file();
+
+	LOGP(DCTRL, LOGL_NOTICE, "Writing VTY config to file %s...\n", cfile_name);
+	if (osmo_vty_write_config_file(cfile_name) < 0)
+		goto ret;
+
+	cmd->reply = "OK";
+	cmd_ret = CTRL_CMD_REPLY;
+ret:
+	return cmd_ret;
+}
+CTRL_CMD_DEFINE_WO(net_write_config_file, "write-config-file");
+
 CTRL_CMD_DEFINE(net_mcc, "mcc");
 static int get_net_mcc(struct ctrl_cmd *cmd, void *_data)
 {
@@ -528,6 +554,7 @@
 {
 	int rc = 0;
 	rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_apply_config_file);
+	rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_write_config_file);
 	rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_mnc);
 	rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_mcc);
 	rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_apply_config);

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/24735
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: If17095bb86f82dd8feb86eb72c4133ea3aa1c3b3
Gerrit-Change-Number: 24735
Gerrit-PatchSet: 3
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210625/7706aafb/attachment.htm>


More information about the gerrit-log mailing list