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

dexter gerrit-no-reply at lists.osmocom.org
Mon Jun 21 13:05:47 UTC 2021


dexter has uploaded this change for review. ( 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(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/35/24735/1

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..6d66ab5 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, "default"))
+		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: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210621/bc5ed3a6/attachment.htm>


More information about the gerrit-log mailing list