Пример #1
0
 def get_text(self):
     _cfg = vsmapi.get_setting_dict(self.request)
     threshold = {}
     threshold['full_threshold'] = _cfg["storage_group_full_threshold"]
     threshold['near_full_threshold'] = _cfg[
         "storage_group_near_full_threshold"]
     return json.dumps(threshold)
Пример #2
0
    def get_data(self):
        _sgs = []
        #_sgs= vsmapi.get_sg_list(self.request,)
        try:
            _sgs = vsmapi.storage_group_status(self.request,)
            if _sgs:
                logging.debug("resp body in view: %s" % _sgs)
            settings = vsmapi.get_setting_dict(self.request)
            sg_near_full_threshold = settings['storage_group_near_full_threshold']
            sg_full_threshold = settings['storage_group_full_threshold']
        except:
            exceptions.handle(self.request,
                              _('Unable to retrieve sever list. '))

        storage_group_status = []
        for _sg in _sgs:
            sg = {"id": _sg.id,
                        "name": _sg.name,
                        "friendly_name", _sg.friendly_name
                        "attached_pools": _sg.attached_pools,
                        "capacity_total": 0 if not _sg.capacity_total else round(_sg.capacity_total * 1.0 / 1024 / 1024, 1),
                        "capacity_used": 0 if not _sg.capacity_used else round(_sg.capacity_used * 1.0 / 1024 / 1024, 1),
                        "capacity_avail": 0 if not _sg.capacity_avail else round(_sg.capacity_avail * 1.0 / 1024 / 1024, 1),
                        "capacity_percent_used": 0 if not _sg.capacity_total else _sg.capacity_used * 10000 / _sg.capacity_total / 100.0,
                        "largest_node_capacity_used": 0 if not _sg.largest_node_capacity_used else round(_sg.largest_node_capacity_used * 1.0 / 1024 / 1024, 1),
                        "status": _sg.status,
                        "updated_at": get_time_delta(_sg.updated_at),
                        }

            if sg['capacity_percent_used'] >= int(sg_full_threshold):
def chart_data(request):
    charts = []
    _cfg = vsmapi.get_setting_dict(None)
    _sgs = vsmapi.storage_group_status(None)

    for _sg in _sgs:
        _sg.capacity_total = 1 if not _sg.capacity_total else _sg.capacity_total

        capacity_percent_used = 0 if not _sg.capacity_total else _sg.capacity_used * 10000.0 / _sg.capacity_total / 100.0
        capacity_percent_used = round(capacity_percent_used, 2)
        capacity_percent_avail = 100 - capacity_percent_used

        #0:normal;1:near full;2:full;
        status = 0
        if capacity_percent_used < int(
                _cfg["storage_group_near_full_threshold"]):
            status = 0
        elif capacity_percent_used < int(_cfg["storage_group_full_threshold"]):
            status = 1
        else:
            status = 2

        chart = {
            "id": _sg.id,
            "name": _sg.name,
            "status": status,
            "used": capacity_percent_used,
            "available": capacity_percent_avail
        }
        charts.append(chart)

    print charts

    chartsdata = json.dumps(charts)
    return HttpResponse(chartsdata)
Пример #4
0
def chart_data(request):
    charts = []
    _cfg = vsmapi.get_setting_dict(None)
    _sgs = vsmapi.storage_group_status(None)

    for _sg in _sgs:
        _sg.capacity_total = 1 if not _sg.capacity_total else _sg.capacity_total

        capacity_percent_used = 0 if not _sg.capacity_total else _sg.capacity_used * 10000.0 / _sg.capacity_total / 100.0
        capacity_percent_used = round(capacity_percent_used, 2)
        capacity_percent_avail = 100 - capacity_percent_used

        #0:normal;1:near full;2:full;  
        status = 0 
        if capacity_percent_used < int(_cfg["storage_group_near_full_threshold"]):
            status = 0
        elif capacity_percent_used < int(_cfg["storage_group_full_threshold"]):
            status = 1
        else:
            status = 2

        chart = {"id": _sg.id
                ,"name":_sg.name
                ,"status":status
                ,"used":capacity_percent_used
                ,"available":capacity_percent_avail}
        charts.append(chart)

    print charts

    chartsdata = json.dumps(charts)
    return HttpResponse(chartsdata)
Пример #5
0
def get_storage():
    #get the threshold for storage group
    settings = vsmapi.get_setting_dict(None)
    _sgs = vsmapi.storage_group_status(None)

    _num = 0
    _num_normal = 0
    _num_near_full = 0
    _num_full = 0
    for _sg in _sgs:
        _sg.capacity_total = 1 if not _sg.capacity_total else _sg.capacity_total
        capcity_percent_used = 0 if not _sg.capacity_total else _sg.capacity_used * 100 / _sg.capacity_total
        if capcity_percent_used < settings["storage_group_near_full_threshold"]:
            _num_normal+=1
        elif capcity_percent_used < settings["storage_group_full_threshold"]:
            _num_near_full+=1
        else:
            _num_full+=1
        _num+=1

    Storage_dict = {"nearfull":_num_near_full
                   ,"full":_num_full
                   ,"normal":_num_normal
                   ,"update":get_time_delta(_sgs[0].updated_at)}

    storagedata = json.dumps(Storage_dict)
    return storagedata
Пример #6
0
    def get_data(self):
        default_limit = 10000;
        default_sort_dir = "asc";
        default_sort_keys = ['osd_name']
        marker = self.request.GET.get('marker', "")
        osd_id = self.request.GET.get('osdid',"-1")
        try:
            _osds = vsmapi.osd_status(self.request, paginate_opts={
                "limit": default_limit,
                "sort_dir": default_sort_dir,
                "marker":   marker,
            })
        except:
            _osds = []
            exceptions.handle(self.request,
                              _('Unable to retrieve osds. '))
        if _osds:
            logging.debug("resp osds in view: %s" % _osds)
        osds = []
        settings = vsmapi.get_setting_dict(self.request)
        disk_near_full_threshold = int(settings['disk_near_full_threshold'])
        disk_full_threshold = int(settings['disk_full_threshold'])
        for _osd in _osds:
            osd = {
                    'id': _osd.id,
                    'osd': _osd.osd_name,
                    'vsm_status': _osd.operation_status,
                    'osd_state': _osd.state,
                    'osd_weight': _osd.weight,
                    'storage_group': _osd.device['device_type'],
                    'data_dev_path': _osd.device['path'],
                    'data_dev_status': _osd.device['state'],
                    'data_dev_capacity': 0 if not _osd.device['total_capacity_kb']\
            else int(_osd.device['total_capacity_kb']/1024),
                    'data_dev_used': 0 if not _osd.device['used_capacity_kb']\
            else int(_osd.device['used_capacity_kb']/1024),
                    'data_dev_available': 0 if not _osd.device['avail_capacity_kb']\
            else int(_osd.device['avail_capacity_kb']/1024),
                    'journal_device_path': _osd.device['journal'],
                    'journal_device_status': _osd.device['journal_state'], 
                    'server': _osd.service['host'],
                    'zone': _osd.zone,
                    'full_warn': 0
                  }

            if osd['data_dev_capacity']:
                osd['full_status'] = round(osd['data_dev_used'] * 1.0 / osd['data_dev_capacity'] * 100, 2)
                if osd['full_status'] >= disk_near_full_threshold and osd['full_status'] < disk_full_threshold:
                    osd['full_warn'] = 1
                elif osd['full_status'] >=disk_full_threshold:
                    osd['full_warn'] = 2
            else:
                osd['full_status'] = ''
            if osd_id == "-1":
                osds.append(osd)  #all of the deivces
            elif str(_osd.id) == str(osd_id):
                osds.append(osd)  #filter the devices by osd_id
            else:
                pass
        return osds
Пример #7
0
def get_storage():
    #get the threshold for storage group
    settings = vsmapi.get_setting_dict(None)
    _sgs = vsmapi.storage_group_status(None)

    _num = 0
    _num_normal = 0
    _num_near_full = 0
    _num_full = 0
    for _sg in _sgs:
        _sg.capacity_total = 1 if not _sg.capacity_total else _sg.capacity_total
        capcity_percent_used = 0 if not _sg.capacity_total else _sg.capacity_used * 100 / _sg.capacity_total
        if capcity_percent_used > float(
                settings["storage_group_full_threshold"]):
            _num_full += 1
        elif capcity_percent_used > float(
                settings["storage_group_near_full_threshold"]):
            _num_near_full += 1
        else:
            _num_normal += 1
        _num += 1

    Storage_dict = {
        "nearfull": _num_near_full,
        "full": _num_full,
        "normal": _num_normal,
        "update": get_time_delta(_sgs[0].updated_at)
    }

    storagedata = json.dumps(Storage_dict)
    return storagedata
Пример #8
0
def get_OSD():
    #get the full or near full threshold
    settings = vsmapi.get_setting_dict(None)
    disk_near_full_threshold = int(settings['disk_near_full_threshold'])
    disk_full_threshold = int(settings['disk_full_threshold'])

    in_up = 0
    in_down = 0
    out_up = 0
    out_down = 0
    available_count = 0
    near_full_count = 0
    full_count = 0
    osd_summary = vsmapi.osd_summary(None)
    _osd_status = vsmapi.osd_status(None)

    for _osd in _osd_status:
        _osd_capacity_avaliable = 0 if not _osd.device['avail_capacity_kb']\
            else int(_osd.device['avail_capacity_kb']/1024)
        _osd_capacity_used = 0 if not _osd.device['used_capacity_kb']\
            else int(_osd.device['used_capacity_kb']/1024)
        _osd_capacity_total = 0 if not _osd.device['total_capacity_kb']\
            else int(_osd.device['total_capacity_kb']/1024)

        if _osd_capacity_total and _osd.state in [
                "In-Up", "In-Down", "Out-Up", "Out-Down", "Out-Down-Autoout"
        ]:
            _osd_capacity_status = round(
                _osd_capacity_used * 1.0 / _osd_capacity_total * 100, 2)
            if _osd_capacity_status >= disk_full_threshold:
                full_count = full_count + 1
            elif _osd_capacity_status >= disk_near_full_threshold:
                near_full_count = near_full_count + 1
            else:
                available_count = available_count + 1

        if _osd.state == "In-Up":
            in_up = in_up + 1
        elif _osd.state == "In-Down":
            in_down = in_down + 1
        elif _osd.state == "Out-Up":
            out_up = out_up + 1
        elif _osd.state == "Out-Down" or _osd.state == "Out-Down-Autoout":
            out_down = out_down + 1

    OSD_dict = {
        "epoch": osd_summary.epoch,
        "update": get_time_delta(osd_summary.updated_at),
        "in_up": in_up,
        "in_down": in_down,
        "out_up": out_up,
        "out_down": out_down,
        "capacity_full_count": full_count,
        "capacity_near_full_count": near_full_count,
        "capacity_available_count": available_count
    }
    OSDdata = json.dumps(OSD_dict)
    return OSDdata
Пример #9
0
    def get_data(self):
        default_limit = 10000
        default_sort_dir = "asc"
        default_sort_keys = ['osd_name']
        marker = self.request.GET.get('marker', "")
        osd_id = self.request.GET.get('osdid', "-1")
        try:
            _osds = vsmapi.osd_status(self.request,
                                      paginate_opts={
                                          "limit": default_limit,
                                          "sort_dir": default_sort_dir,
                                          "marker": marker,
                                      })
        except:
            _osds = []
            exceptions.handle(self.request, _('Unable to retrieve osds. '))
        if _osds:
            logging.debug("resp osds in view: %s" % _osds)
        osds = []
        settings = vsmapi.get_setting_dict(self.request)
        host_near_full_threshold = settings['host_near_full_threshold']
        #host_full_threshold = settings['host_full_threshold']
        for _osd in _osds:
            osd = {
                    'id': _osd.id,
                    'osd': _osd.osd_name,
                    'vsm_status': _osd.operation_status,
                    'osd_state': _osd.state,
                    'osd_weight': _osd.weight,
                    'storage_group': _osd.device['device_type'],
                    'data_dev_path': _osd.device['path'],
                    'data_dev_status': _osd.device['state'],
                    'data_dev_capacity': 0 if not _osd.device['total_capacity_kb']\
            else int(_osd.device['total_capacity_kb']/1024),
                    'data_dev_used': 0 if not _osd.device['used_capacity_kb']\
            else int(_osd.device['used_capacity_kb']/1024),
                    'data_dev_available': 0 if not _osd.device['avail_capacity_kb']\
            else int(_osd.device['avail_capacity_kb']/1024),
                    'journal_device_path': _osd.device['journal'],
                    'journal_device_status': _osd.device['journal_state'],
                    'server': _osd.service['host'],
                    'zone': _osd.zone,
                    'full_warn': 0
                  }

            osd['full_status'] = round(
                osd['data_dev_used'] * 1.0 / osd['data_dev_capacity'] * 100, 2)
            if osd['full_status'] >= host_near_full_threshold:
                osd['full_warn'] = 1
            if osd_id == "-1":
                osds.append(osd)  #all of the deivces
            elif str(_osd.id) == str(osd_id):
                osds.append(osd)  #filter the devices by osd_id
            else:
                pass
        return osds
Пример #10
0
def get_OSD():
    #get the full or near full threshold
    settings = vsmapi.get_setting_dict(None)
    disk_near_full_threshold = int(settings['disk_near_full_threshold'])
    disk_full_threshold = int(settings['disk_full_threshold'])

    in_up = 0
    in_down = 0
    out_up = 0
    out_down = 0
    available_count = 0
    near_full_count = 0
    full_count = 0
    osd_summary = vsmapi.osd_summary(None)
    _osd_status = vsmapi.osd_status(None)

    for _osd in _osd_status:
        _osd_capacity_avaliable = 0 if not _osd.device['avail_capacity_kb']\
            else int(_osd.device['avail_capacity_kb']/1024)
        _osd_capacity_used = 0 if not _osd.device['used_capacity_kb']\
            else int(_osd.device['used_capacity_kb']/1024)
        _osd_capacity_total = 0 if not _osd.device['total_capacity_kb']\
            else int(_osd.device['total_capacity_kb']/1024)

        if _osd_capacity_total:
            _osd_capacity_status = round(_osd_capacity_used * 1.0 / _osd_capacity_total * 100, 2)
            if _osd_capacity_status >= disk_full_threshold:
                full_count = full_count + 1
            elif _osd_capacity_status >= disk_near_full_threshold:
                near_full_count = near_full_count + 1
            else:
                available_count = available_count + 1

        if _osd.state == "In-Up":
            in_up=in_up+1
        elif _osd.state == "In-Down":
            in_dowm=in_down+1
        elif _osd.state == "Out-Up":
            out_up=out_up+1
        elif _osd.state == "Out-Down":
            out_down=out_down+1

    OSD_dict = {"epoch":osd_summary.epoch
              ,"update":get_time_delta(osd_summary.updated_at)
              ,"in_up":in_up
              ,"in_down":in_down
              ,"out_up":out_up
              ,"out_down":out_down
              ,"capacity_full_count":full_count
              ,"capacity_near_full_count":near_full_count
              ,"capacity_available_count":available_count
              }
    OSDdata = json.dumps(OSD_dict)
    return OSDdata
Пример #11
0
    def get_data(self):
        _sgs = []
        #_sgs= vsmapi.get_sg_list(self.request,)
        try:
            _sgs = vsmapi.storage_group_status(self.request,)
            if _sgs:
                logging.debug("resp body in view: %s" % _sgs)
            settings = vsmapi.get_setting_dict(self.request)
            sg_near_full_threshold = settings['storage_group_near_full_threshold']
            sg_full_threshold = settings['storage_group_full_threshold']
        except:
            exceptions.handle(self.request,
                              _('Unable to retrieve sever list. '))

        storage_group_status = _sgs
        return storage_group_status
Пример #12
0
    def get_data(self):
        _sgs = []
        #_sgs= vsmapi.get_sg_list(self.request,)
        try:
            _sgs = vsmapi.storage_group_status(self.request,)
            if _sgs:
                logging.debug("resp body in view: %s" % _sgs)
            settings = vsmapi.get_setting_dict(self.request)
            sg_near_full_threshold = settings['storage_group_near_full_threshold']
            sg_full_threshold = settings['storage_group_full_threshold']
        except:
            exceptions.handle(self.request,
                              _('Unable to retrieve sever list. '))

        storage_group_status = _sgs
        return storage_group_status
Пример #13
0
    def get_chart(self):
        _sgs = vsmapi.storage_group_status(self.request, )
        charts = []
        _cfg = vsmapi.get_setting_dict(self.request)
        for _sg in _sgs:
            _sg.capacity_total = 1 if not _sg.capacity_total else _sg.capacity_total
            capacity_percent_used = 0 if not _sg.capacity_total else _sg.capacity_used * 10000.0 / _sg.capacity_total / 100.0
            capacity_percent_used = round(capacity_percent_used, 2)
            capacity_percent_avail = 100 - capacity_percent_used
            if capacity_percent_used < int(
                    _cfg["storage_group_near_full_threshold"]):
                index = 1
            elif capacity_percent_used < int(
                    _cfg["storage_group_full_threshold"]):
                index = 4
            else:
                index = 7

            chart = {
                "type":
                "pie",
                "name":
                _sg.name,
                "verbose_name":
                _sg.name,
                "used":
                capacity_percent_used,
                "datas": [{
                    "index": index,
                    "value": capacity_percent_used
                }, {
                    "index": 20,
                    "value": capacity_percent_avail
                }]
            }
            charts.append(chart)

        return charts
Пример #14
0
    def get_chart(self):
        _sgs = vsmapi.storage_group_status(self.request,)
        charts = []
        _cfg = vsmapi.get_setting_dict(self.request)
        for _sg in _sgs:
            _sg.capacity_total = 1 if not _sg.capacity_total else _sg.capacity_total
            capacity_percent_used = 0 if not _sg.capacity_total else _sg.capacity_used * 10000.0 / _sg.capacity_total / 100.0
            capacity_percent_used = round(capacity_percent_used, 2)
            capacity_percent_avail = 100 - capacity_percent_used
            if capacity_percent_used < int(_cfg["storage_group_near_full_threshold"]):
                index = 1
            elif capacity_percent_used < int(_cfg["storage_group_full_threshold"]):
                index = 4
            else:
                index = 7

            chart = {"type": "pie", "name": _sg.name,"verbose_name": _sg.name,
                     "used": capacity_percent_used,
                     "datas":[{"index": index,"value": capacity_percent_used},
                                          {"index":20,"value": capacity_percent_avail}]}
            charts.append(chart)

        return charts
Пример #15
0
 def get_text(self):
     _cfg = vsmapi.get_setting_dict(self.request)
     threshold = {}
     threshold['full_threshold'] = _cfg["storage_group_full_threshold"]
     threshold['near_full_threshold'] = _cfg["storage_group_near_full_threshold"]
     return json.dumps(threshold)
Пример #16
0
 def get_context_data(self, **kwargs):
      context = super(ModalChartMixin, self).get_context_data(**kwargs)
      context['settings'] = vsmapi.get_setting_dict(self.request)
      return context
Пример #17
0
 def get_context_data(self, **kwargs):
     context = super(ModalChartMixin, self).get_context_data(**kwargs)
     context['settings'] = vsmapi.get_setting_dict(self.request)
     return context