dashboard_json_data["folderId"] = folder_id
dashboard_json_data["overwrite"] = False
- response = requests.request(
- "POST", self.url + "/api/dashboards/db/", data=json.dumps(dashboard_json_data), headers=self.headers)
+ response = self.send_request_for_creating_dashboard(dashboard_json_data)
- # Don't create the dashboard if already exists.
+ # Admin dashboard will be created if already exists. Rest will remain same.
if json.loads(response.text).get("status") == "name-exists":
- return
+ # Delete any previous project-admin dashboard if it already exist.
+ if name == 'admin':
+ self.delete_admin_dashboard()
+ response = self.send_request_for_creating_dashboard(dashboard_json_data)
+ else:
+ return
# Get team id
if project_name is not None:
except Exception:
log.exception("Exception processing message: ")
+ def send_request_for_creating_dashboard(self, dashboard_data):
+ response = requests.request(
+ "POST", self.url + "/api/dashboards/db/", data=json.dumps(dashboard_data), headers=self.headers)
+ return response
+
def delete_dashboard(self, uid):
response = requests.request("DELETE", self.url + "/api/dashboards/uid/" + uid, headers=self.headers)
log.debug("Dashboard %s deleted from Grafana", uid)
return response
+ def delete_admin_dashboard(self):
+ requests.request(
+ "DELETE", self.url + "/api/dashboards/db/osm-project-status-admin", headers=self.headers)
+ log.debug("Dashboard osm-project-status-admin deleted from Grafana")
+
def create_grafana_users(self, user):
email = "{}@osm.etsi.org".format(user)
user_payload = {
)
except Exception:
log.error('Cannot retrieve projects from keystone')
+ else:
+ projects.extend(self.common_db.get_projects())
# Reads existing project list and creates a dashboard for each
- projects.extend(self.common_db.get_projects())
for project in projects:
project_id = project['_id']
# Collect Project IDs for periodical dashboard clean-up