vty: Hide unconfigured BTS on 'write'

This prevents the application from crashing when there is a half
configured BTS (e.g. by using the command 'bts 1' when there isn't
a BTS 1) and the 'write' command is used.
This commit is contained in:
Jacob Erlbeck 2013-09-11 10:46:56 +02:00 committed by Holger Hans Peter Freyther
parent 56595f8647
commit 733bec8626
2 changed files with 17 additions and 4 deletions

View File

@ -598,11 +598,13 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
if (bts->excl_from_rf_lock)
vty_out(vty, " rf-lock-exclude%s", VTY_NEWLINE);
if (bts->model->config_write_bts)
bts->model->config_write_bts(vty, bts);
if (bts->model) {
if (bts->model->config_write_bts)
bts->model->config_write_bts(vty, bts);
llist_for_each_entry(trx, &bts->trx_list, list)
config_write_trx_single(vty, trx);
llist_for_each_entry(trx, &bts->trx_list, list)
config_write_trx_single(vty, trx);
}
}
static int config_write_bts(struct vty *v)

View File

@ -88,6 +88,17 @@ class TestVTYGenericBSC(TestVTYBase):
self.assertTrue(self.vty.verify("trx 0",['']))
self.assertEquals(self.vty.node(), 'config-net-bts-trx')
self.checkForEndAndExit()
self.vty.command("write terminal")
self.assertTrue(self.vty.verify("exit",['']))
self.assertEquals(self.vty.node(), 'config-net-bts')
self.assertTrue(self.vty.verify("exit",['']))
self.assertTrue(self.vty.verify("bts 1",['']))
self.assertEquals(self.vty.node(), 'config-net-bts')
self.checkForEndAndExit()
self.assertTrue(self.vty.verify("trx 1",['']))
self.assertEquals(self.vty.node(), 'config-net-bts-trx')
self.checkForEndAndExit()
self.vty.command("write terminal")
self.assertTrue(self.vty.verify("exit",['']))
self.assertEquals(self.vty.node(), 'config-net-bts')
self.assertTrue(self.vty.verify("exit",['']))