File size: 3,637 Bytes
c7f4bd0
 
1
2
3
{"nwo":"Crapworks\/ceph-dash","sha":"216aed2769894b8caa6513997966445167fa56e4","path":"app\/dashboard\/views.py","language":"python","identifier":"find_host_for_osd","parameters":"(osd, osd_status)","argument_list":"","return_statement":"return 'unknown'","docstring":"find host for a given osd","docstring_summary":"find host for a given osd","docstring_tokens":["find","host","for","a","given","osd"],"function":"def find_host_for_osd(osd, osd_status):\n    \"\"\" find host for a given osd \"\"\"\n\n    for obj in osd_status['nodes']:\n        if obj['type'] == 'host':\n            if osd in obj['children']:\n                return obj['name']\n\n    return 'unknown'","function_tokens":["def","find_host_for_osd","(","osd",",","osd_status",")",":","for","obj","in","osd_status","[","'nodes'","]",":","if","obj","[","'type'","]","==","'host'",":","if","osd","in","obj","[","'children'","]",":","return","obj","[","'name'","]","return","'unknown'"],"url":"https:\/\/github.com\/Crapworks\/ceph-dash\/blob\/216aed2769894b8caa6513997966445167fa56e4\/app\/dashboard\/views.py#L54-L62"}
{"nwo":"Crapworks\/ceph-dash","sha":"216aed2769894b8caa6513997966445167fa56e4","path":"app\/dashboard\/views.py","language":"python","identifier":"get_unhealthy_osd_details","parameters":"(osd_status)","argument_list":"","return_statement":"return unhealthy_osds","docstring":"get all unhealthy osds from osd status","docstring_summary":"get all unhealthy osds from osd status","docstring_tokens":["get","all","unhealthy","osds","from","osd","status"],"function":"def get_unhealthy_osd_details(osd_status):\n    \"\"\" get all unhealthy osds from osd status \"\"\"\n\n    unhealthy_osds = list()\n\n    for obj in osd_status['nodes']:\n        if obj['type'] == 'osd':\n            # if OSD does not exists (DNE in osd tree) skip this entry\n            if obj['exists'] == 0:\n                continue\n            if obj['status'] == 'down' or obj['reweight'] == 0.0:\n                # It is possible to have one host in more than one branch in the tree.\n                # Add each unhealthy OSD only once in the list\n                if obj['status'] == 'down':\n                    status = 'down'\n                else:\n                    status = 'out'\n                entry = {\n                    'name': obj['name'],\n                    'status': status,\n                    'host': find_host_for_osd(obj['id'], osd_status)\n                }\n                if entry not in unhealthy_osds:\n                    unhealthy_osds.append(entry)\n\n    return unhealthy_osds","function_tokens":["def","get_unhealthy_osd_details","(","osd_status",")",":","unhealthy_osds","=","list","(",")","for","obj","in","osd_status","[","'nodes'","]",":","if","obj","[","'type'","]","==","'osd'",":","# if OSD does not exists (DNE in osd tree) skip this entry","if","obj","[","'exists'","]","==","0",":","continue","if","obj","[","'status'","]","==","'down'","or","obj","[","'reweight'","]","==","0.0",":","# It is possible to have one host in more than one branch in the tree.","# Add each unhealthy OSD only once in the list","if","obj","[","'status'","]","==","'down'",":","status","=","'down'","else",":","status","=","'out'","entry","=","{","'name'",":","obj","[","'name'","]",",","'status'",":","status",",","'host'",":","find_host_for_osd","(","obj","[","'id'","]",",","osd_status",")","}","if","entry","not","in","unhealthy_osds",":","unhealthy_osds",".","append","(","entry",")","return","unhealthy_osds"],"url":"https:\/\/github.com\/Crapworks\/ceph-dash\/blob\/216aed2769894b8caa6513997966445167fa56e4\/app\/dashboard\/views.py#L65-L90"}