+def get_retention(config, host, db):
+ assert('retention' in config)
+
+ assert('backups' in config)
+ assert(isinstance(config['backups'], dict))
+
+ assert(host in config['backups'])
+ assert(isinstance(config['backups'][host], dict))
+
+ assert(db in config['backups'][host])
+ if isinstance(config['backups'][host][db], dict) and 'retention' in config['backups'][host][db]:
+ r = config['backups'][host][db]['retention']
+ elif '_retention' in config['backups'][host]:
+ r = config['backups'][host]['_retention']
+ else:
+ r = config['retention']
+
+ assert(isinstance(r, int))
+ return r