In modular chassis, add CHASSIS_STATE_DB on control card (#5624)

HLD: Azure/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.
This commit is contained in:
mprabhu-nokia 2020-12-15 20:15:00 -05:00 committed by GitHub
parent 6348248138
commit 41012f791e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 10 deletions

View File

@ -83,6 +83,11 @@
"id" : 12, "id" : 12,
"separator": "|", "separator": "|",
"instance" : "redis_chassis" "instance" : "redis_chassis"
},
"CHASSIS_STATE_DB" : {
"id" : 13,
"separator": "|",
"instance" : "redis_chassis"
} }
}, },
"VERSION" : "1.0" "VERSION" : "1.0"

View File

@ -7,7 +7,7 @@ import syslog
database_config_file = "/var/run/redis/sonic-db/database_config.json" database_config_file = "/var/run/redis/sonic-db/database_config.json"
redis_chassis = 'redis_chassis' redis_chassis = 'redis_chassis'
chassis_db = 'CHASSIS_APP_DB' chassis_db_list = ['CHASSIS_APP_DB', 'CHASSIS_STATE_DB']
def main(): def main():
@ -47,15 +47,17 @@ def main():
'config file {} does notexist'.format(jsonfile)) 'config file {} does notexist'.format(jsonfile))
return return
if 'INSTANCES' in data and redis_chassis in data['INSTANCES']: if 'INSTANCES' in data and redis_chassis in data['INSTANCES']:
data_keep['INSTANCES'] = {} data_keep['INSTANCES'] = {}
data_keep['INSTANCES'][redis_chassis] = data['INSTANCES'][redis_chassis] data_keep['INSTANCES'][redis_chassis] = data['INSTANCES'][redis_chassis]
if delete_config: if delete_config:
del data['INSTANCES'][redis_chassis] del data['INSTANCES'][redis_chassis]
if 'DATABASES' in data and chassis_db in data['DATABASES']: for chassis_db in chassis_db_list:
data_keep['DATABASES'] = {} if 'DATABASES' in data and chassis_db in data['DATABASES']:
data_keep['DATABASES'][chassis_db] = data['DATABASES'][chassis_db] data_keep['DATABASES'] = {}
if delete_config: data_keep['DATABASES'][chassis_db] = data['DATABASES'][chassis_db]
del data['DATABASES'][chassis_db] if delete_config:
del data['DATABASES'][chassis_db]
with open(jsonfile, "w") as write_file: with open(jsonfile, "w") as write_file:
data_publish = data_keep if keep_config else data data_publish = data_keep if keep_config else data
if port_number: if port_number: