fix empty policy building

This commit is contained in:
simon 2022-10-29 15:32:08 +07:00
parent 59f347c135
commit 749f61aba6
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
1 changed files with 5 additions and 1 deletions

View File

@ -147,7 +147,8 @@ class ElasticSnapshot:
def get_snapshot_stats(self):
"""get snapshot info for frontend"""
snapshot_info = self._build_policy_details()
snapshot_info.update({"snapshots": self._get_all_snapshots()})
if snapshot_info:
snapshot_info.update({"snapshots": self._get_all_snapshots()})
return snapshot_info
@ -180,6 +181,9 @@ class ElasticSnapshot:
def _build_policy_details(self):
"""get additional policy details"""
policy = self._get_policy()
if not policy:
return False
next_exec = policy["next_execution_millis"]
next_exec_date = datetime.fromtimestamp(next_exec // 1000)
next_exec_str = next_exec_date.strftime("%Y-%m-%d %H:%M")