def get_cluster(): cluster_summary = vsmapi.cluster_summary(None) cluster_name = vsmapi.get_cluster_list(None)[1]["clusters"][0]["name"] # HEALTH_OK HEALTH_WARN HEALTH_ERROR cluster_status = cluster_summary.health_list[0] cluster_note = [] for note in cluster_summary.health_list[1:]: cluster_note.append(note) vsm_status_dict = {"name": cluster_name, "status": cluster_status, "note": cluster_note} vsmstatusdata = json.dumps(vsm_status_dict) return vsmstatusdata
def get_cluster(): cluster_summary = vsmapi.cluster_summary(None) cluster_name = vsmapi.get_cluster_list(None)[1]['clusters'][0]['name'] #HEALTH_OK HEALTH_WARN HEALTH_ERR cluster_status = cluster_summary.health_list[0] cluster_note = [] for note in cluster_summary.health_list[1:]: cluster_note.append(note) vsm_status_dict = { "name":cluster_name , "status": cluster_status , "note":cluster_note} vsmstatusdata = json.dumps(vsm_status_dict) return vsmstatusdata
def openstack(request): """ Context processor necessary for OpenStack Dashboard functionality. The following variables are added to the request context: ``authorized_tenants`` A list of tenant objects which the current user has access to. ``regions`` A dictionary containing information about region support, the current region, and available regions. """ context = {} # Auth/Keystone context context.setdefault('authorized_tenants', []) current_dash = request.horizon['dashboard'] needs_tenants = getattr(current_dash, 'supports_tenants', False) if request.user.is_authenticated() and needs_tenants: context['authorized_tenants'] = request.user.authorized_tenants # Region context/support available_regions = getattr(settings, 'AVAILABLE_REGIONS', []) regions = { 'support': len(available_regions) > 1, 'current': { 'endpoint': request.session.get('region_endpoint'), 'name': request.session.get('region_name') }, 'available': [{ 'endpoint': region[0], 'name': region[1] } for region in available_regions] } context['regions'] = regions # todo try: cluster = vsmapi.get_cluster_list(request)[1]['clusters'][0] cluster['title'] = "Cluster: %s" % cluster['name'] context['cluster'] = cluster except: context['cluster'] = {'title': "Cluster"} return context
def get_cluster(): cluster_summary = vsmapi.cluster_summary(None) cluster_name = vsmapi.get_cluster_list(None)[1]['clusters'][0]['name'] #HEALTH_OK HEALTH_WARN HEALTH_ERROR cluster_status = cluster_summary.health_list[0] cluster_note = [] if cluster_status == "HEALTH_OK": for note in cluster_summary.health_list[1:]: cluster_note.append(note) else: for index, note in enumerate(cluster_summary.detail): cluster_note.append(note) vsm_status_dict = { "name":cluster_name , "status": cluster_status , "note":cluster_note} vsmstatusdata = json.dumps(vsm_status_dict) return vsmstatusdata
def get_cluster(): cluster_summary = vsmapi.cluster_summary(None) cluster_name = vsmapi.get_cluster_list(None)[1]['clusters'][0]['name'] #HEALTH_OK HEALTH_WARN HEALTH_ERROR cluster_status = cluster_summary.health_list[0] cluster_note = [] if cluster_status == "HEALTH_OK": for note in cluster_summary.health_list[1:]: cluster_note.append(note) else: for index, note in enumerate(cluster_summary.detail): cluster_note.append(note) vsm_status_dict = { "name": cluster_name, "status": cluster_status, "note": cluster_note } vsmstatusdata = json.dumps(vsm_status_dict) return vsmstatusdata
def get_summary(self): cluster_summary = vsmapi.cluster_summary(self.request) cluster_name = vsmapi.get_cluster_list(self.request)[1]['clusters'][0]['name'] data = SortedDict() data["Cluster Name"] = cluster_name try: data["Status"] = cluster_summary.health_list[0] status = data['Status'].lower() if status.find('ok') != -1: self.css_id = "health_ok" elif status.find('war') != -1: self.css_id = "health_warning" elif status.find('error') != -1: self.css_id = "health_error" msg = self.font % (self.css_id, data["Status"]) data["Status"] = mark_safe(msg) except: pass return data
def openstack(request): """ Context processor necessary for OpenStack Dashboard functionality. The following variables are added to the request context: ``authorized_tenants`` A list of tenant objects which the current user has access to. ``regions`` A dictionary containing information about region support, the current region, and available regions. """ context = {} # Auth/Keystone context context.setdefault('authorized_tenants', []) current_dash = request.horizon['dashboard'] needs_tenants = getattr(current_dash, 'supports_tenants', False) if request.user.is_authenticated() and needs_tenants: context['authorized_tenants'] = request.user.authorized_tenants # Region context/support available_regions = getattr(settings, 'AVAILABLE_REGIONS', []) regions = {'support': len(available_regions) > 1, 'current': {'endpoint': request.session.get('region_endpoint'), 'name': request.session.get('region_name')}, 'available': [{'endpoint': region[0], 'name':region[1]} for region in available_regions]} context['regions'] = regions # todo try: cluster = vsmapi.get_cluster_list(request)[1]['clusters'][0] cluster['title'] = "Cluster: %s" % cluster['name'] context['cluster'] = cluster except: context['cluster'] = {'title': "Cluster"} return context