Skip to content

Commit

Permalink
In modular chassis, add CHASSIS_STATE_DB on control card (#5624)
Browse files Browse the repository at this point in the history
HLD: sonic-net/SONiC#646

In modular chassis, add CHASSIS_STATE_DB on control card

Why I did it
Modular Chassis has control-cards, line-cards and fabric-cards along with other peripherals. Control-Card CHASSIS_STATE_DB will be the central DB to maintain any state information of cards that is accessible to control-card/

How I did it
Adding another DB on an existing REDIS instance running on port 6380.
  • Loading branch information
mprabhu-nokia authored Dec 16, 2020
1 parent 6348248 commit 41012f7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
5 changes: 5 additions & 0 deletions dockers/docker-database/database_config.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@
"id" : 12,
"separator": "|",
"instance" : "redis_chassis"
},
"CHASSIS_STATE_DB" : {
"id" : 13,
"separator": "|",
"instance" : "redis_chassis"
}
},
"VERSION" : "1.0"
Expand Down
22 changes: 12 additions & 10 deletions files/scripts/update_chassisdb_config
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import syslog

database_config_file = "/var/run/redis/sonic-db/database_config.json"
redis_chassis = 'redis_chassis'
chassis_db = 'CHASSIS_APP_DB'
chassis_db_list = ['CHASSIS_APP_DB', 'CHASSIS_STATE_DB']


def main():
Expand Down Expand Up @@ -47,15 +47,17 @@ def main():
'config file {} does notexist'.format(jsonfile))
return
if 'INSTANCES' in data and redis_chassis in data['INSTANCES']:
data_keep['INSTANCES'] = {}
data_keep['INSTANCES'][redis_chassis] = data['INSTANCES'][redis_chassis]
if delete_config:
del data['INSTANCES'][redis_chassis]
if 'DATABASES' in data and chassis_db in data['DATABASES']:
data_keep['DATABASES'] = {}
data_keep['DATABASES'][chassis_db] = data['DATABASES'][chassis_db]
if delete_config:
del data['DATABASES'][chassis_db]
data_keep['INSTANCES'] = {}
data_keep['INSTANCES'][redis_chassis] = data['INSTANCES'][redis_chassis]
if delete_config:
del data['INSTANCES'][redis_chassis]
for chassis_db in chassis_db_list:
if 'DATABASES' in data and chassis_db in data['DATABASES']:
data_keep['DATABASES'] = {}
data_keep['DATABASES'][chassis_db] = data['DATABASES'][chassis_db]
if delete_config:
del data['DATABASES'][chassis_db]

with open(jsonfile, "w") as write_file:
data_publish = data_keep if keep_config else data
if port_number:
Expand Down

0 comments on commit 41012f7

Please sign in to comment.