Add backup search for sql

The patch add backup search for sql

Change-Id: Id2a0aef2fb3c79684e3ce3e09574f58dcc331fb5
This commit is contained in:
gecong1973 2018-11-27 18:14:54 -08:00
parent c2b69c1cef
commit 11977bac68
1 changed files with 14 additions and 2 deletions

View File

@ -576,7 +576,12 @@ def search_action(user_id, project_id=None, offset=0,
actionmap['freezer_action']['log_file'] = action.get('log_file')
actions.append(actionmap)
actions = filter_tuple_by_search_opt(actions, search)
# If search opt is wrong, filter will not work,
# return all tuples.
try:
actions = filter_tuple_by_search_opt(actions, search)
except Exception as e:
LOG.error(e)
return actions
@ -852,7 +857,7 @@ def search_backup(user_id, project_id=None, offset=0,
result = search_tuple(tablename=models.Backup, user_id=user_id,
project_id=project_id, offset=offset,
limit=limit, search=search)
limit=limit)
for backup in result:
backupmap = {}
backupmap['project_id'] = project_id
@ -863,6 +868,13 @@ def search_backup(user_id, project_id=None, offset=0,
json_decode(backup.get('backup_metadata'))
backups.append(backupmap)
# If search opt is wrong, filter will not work,
# return all tuples.
try:
backups = filter_tuple_by_search_opt(backups, search)
except Exception as e:
LOG.error(e)
return backups