mgcp-client: Convert users supporting new MGW Pool VTY node during write-config

If the user (app) already supports the MGW Pool VTY command set
(mgcp_client_pool_vty_init() was called), then if single MGW mode is in
use it's because the config file was not updated to use the new MGW Pool
node. Let's convert it to the new format to help in transitioning to the
new VTY command set.

Related: SYS#5987
Change-Id: I2f6658cc66f8bcbd4a60ee2b932bb5dd65888233
This commit is contained in:
Pau Espin 2022-10-18 12:34:20 +02:00
parent 8e74c63e15
commit d17a9de79e
1 changed files with 15 additions and 0 deletions

View File

@ -285,6 +285,11 @@ static int config_write(struct vty *vty, const char *indent, struct mgcp_client_
* \returns CMD_SUCCESS on success, CMD_WARNING on error */
int mgcp_client_config_write(struct vty *vty, const char *indent)
{
/* If caller supports MGW pool API (mgcp_client_pool_vty_init was
* called), then skip printing any config in this node and print it when
* the whole 'mgw' node is printed. */
if (global_mgcp_client_pool)
return CMD_SUCCESS;
return config_write(vty, indent, global_mgcp_client_conf);
}
@ -339,6 +344,16 @@ static int config_write_pool(struct vty *vty)
config_write(vty, indent, &pool_member->conf);
}
/* MGW pool API is supported by user (global_mgcp_client_pool is set
* because mgcp_client_pool_vty_init was called). If single MGW was
* configured through old VTY and no mgw in the new MGW pool VTY is
* replacing it, then output the single MGW converted to the new MGW
* pool VTY. */
if (llist_empty(&pool->member_list) && pool->mgcp_client_single) {
vty_out(vty, "%smgw 0%s", pool->vty_indent, VTY_NEWLINE);
config_write(vty, indent, global_mgcp_client_conf);
}
talloc_free(indent);
return CMD_SUCCESS;
}