|
11 | 11 |
|
12 | 12 | import sonic_platform |
13 | 13 | from swsssdk import ConfigDBConnector |
| 14 | +from swsssdk import SonicV2Connector |
14 | 15 | from minigraph import parse_device_desc_xml |
15 | 16 |
|
16 | 17 | import aaa |
@@ -591,22 +592,34 @@ def warm_restart(ctx, redis_unix_socket_path): |
591 | 592 | kwargs['unix_socket_path'] = redis_unix_socket_path |
592 | 593 | config_db = ConfigDBConnector(**kwargs) |
593 | 594 | config_db.connect(wait_for_init=False) |
594 | | - ctx.obj = {'db': config_db} |
| 595 | + |
| 596 | + # warm restart enable/disable config is put in stateDB, not persistent across cold reboot, not saved to config_DB.json file |
| 597 | + state_db = SonicV2Connector(host='127.0.0.1') |
| 598 | + state_db.connect(state_db.STATE_DB, False) |
| 599 | + TABLE_NAME_SEPARATOR = '|' |
| 600 | + prefix = 'WARM_RESTART_ENABLE_TABLE' + TABLE_NAME_SEPARATOR |
| 601 | + ctx.obj = {'db': config_db, 'state_db': state_db, 'prefix': prefix} |
595 | 602 | pass |
596 | 603 |
|
597 | 604 | @warm_restart.command('enable') |
598 | 605 | @click.argument('module', metavar='<module>', default='system', required=False, type=click.Choice(["system", "swss", "bgp", "teamd"])) |
599 | 606 | @click.pass_context |
600 | 607 | def warm_restart_enable(ctx, module): |
601 | | - db = ctx.obj['db'] |
602 | | - db.mod_entry('WARM_RESTART', module, {'enable': 'true'}) |
| 608 | + state_db = ctx.obj['state_db'] |
| 609 | + prefix = ctx.obj['prefix'] |
| 610 | + _hash = '{}{}'.format(prefix, module) |
| 611 | + state_db.set(state_db.STATE_DB, _hash, 'enable', 'true') |
| 612 | + state_db.close(state_db.STATE_DB) |
603 | 613 |
|
604 | 614 | @warm_restart.command('disable') |
605 | 615 | @click.argument('module', metavar='<module>', default='system', required=False, type=click.Choice(["system", "swss", "bgp", "teamd"])) |
606 | 616 | @click.pass_context |
607 | 617 | def warm_restart_enable(ctx, module): |
608 | | - db = ctx.obj['db'] |
609 | | - db.mod_entry('WARM_RESTART', module, {'enable': 'false'}) |
| 618 | + state_db = ctx.obj['state_db'] |
| 619 | + prefix = ctx.obj['prefix'] |
| 620 | + _hash = '{}{}'.format(prefix, module) |
| 621 | + state_db.set(state_db.STATE_DB, _hash, 'enable', 'false') |
| 622 | + state_db.close(state_db.STATE_DB) |
610 | 623 |
|
611 | 624 | @warm_restart.command('neighsyncd_timer') |
612 | 625 | @click.argument('seconds', metavar='<seconds>', required=True, type=int) |
@@ -1053,7 +1066,7 @@ def interval(interval): |
1053 | 1066 | """Configure watermark telemetry interval""" |
1054 | 1067 | command = 'watermarkcfg --config-interval ' + interval |
1055 | 1068 | run_command(command) |
1056 | | - |
| 1069 | + |
1057 | 1070 |
|
1058 | 1071 | # |
1059 | 1072 | # 'interface_naming_mode' subgroup ('config interface_naming_mode ...') |
|
0 commit comments