def get_sg_list():
    _sgs = []
    try:
        _sgs = vsmapi.storage_group_status(None,)
        # _sg1 = {
        #     "id":1,
        #     "name":"sg1",
        #     "storage_class":"class1",
        #     "friendly_name":"name1",
        #     "marker":"#50f50f",
        #     "take_list":[
        #         {
        #             "id":-7,
        #             "name":"ceph03_performance_zone0",
        #             "??":1,
        #             "choose_type":"type1",
        #             "choose_num":12
        #         },
        #         {
        #             "id":-12,
        #             "name":"zone0_capacity",
        #             "type_id":1,
        #             "type_name":"type1",
        #             "choose_num":34
        #         }
        #     ]
        # }
        # _sgs.append(_sg1)
        if _sgs:
            logging.debug("resp body in view: %s" % _sgs)
    except:
        exceptions.handle(None,'Unable to retrieve storage group list.')
    return _sgs
def get_sg_list():
    _sgs = []
    try:
        _sgs = vsmapi.storage_group_status(None, )
        # _sg1 = {
        #     "id":1,
        #     "name":"sg1",
        #     "storage_class":"class1",
        #     "friendly_name":"name1",
        #     "marker":"#50f50f",
        #     "take_list":[
        #         {
        #             "id":-7,
        #             "name":"ceph03_performance_zone0",
        #             "??":1,
        #             "choose_type":"type1",
        #             "choose_num":12
        #         },
        #         {
        #             "id":-12,
        #             "name":"zone0_capacity",
        #             "type_id":1,
        #             "type_name":"type1",
        #             "choose_num":34
        #         }
        #     ]
        # }
        # _sgs.append(_sg1)
        if _sgs:
            logging.debug("resp body in view: %s" % _sgs)
    except:
        exceptions.handle(None, 'Unable to retrieve storage group list.')
    return _sgs
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)
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)
Exemple #5
0
def get_storage():
    _sgs = vsmapi.storage_group_status(None)
    _cfg = {
        "nearfull_threshold": 65,
        "full_threshold": 85,
    }
    _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 < _cfg["nearfull_threshold"]:
            _num_normal += 1
        elif capcity_percent_used < _cfg["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
    def get_context_data(self, **kwargs):
        context = {}
        storage_group_list = vsmapi.storage_group_status(None,)

        storage_group = []
        for _sg in storage_group_list:
            sg = {
                "id":_sg.id
                ,"name":_sg.name
            }
            storage_group.append(sg)
        context["storage_group"] = storage_group

        servers = vsmapi.get_server_list(None, )
        context["servers"] = servers;

        if len(servers) > 0:
            context["OSDList"] = vsmapi.osd_status(self.request, paginate_opts={
                "service_id": servers[0].service_id
            })
            ret = vsmapi.get_available_disks(self.request, search_opts={
                "server_id": servers[0].id ,
                "result_mode":"get_disks",
            })
            disks = ret['disks'] or []
            disks_list = [disk for disk in disks if disk.find('by-path') != -1]
            context["available_disks"] = disks_list
        
        return context
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
    def get_summary(self):

        _sgs = vsmapi.storage_group_status(self.request,)
        _cfg = {"storage_group_near_full_threshold":65,
            "storage_group_full_threshold":85,}
        _num = 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 <_cfg["storage_group_near_full_threshold"]:
                pass
            elif capcity_percent_used < _cfg["storage_group_full_threshold"]:
                _num_near_full += 1
            else:
                _num_full += 1
            _num += 1

        data = SortedDict()
        data["Total Storage Groups"] = _num
        data["Storage Groups Near Full"] = _num_near_full
        data["Storage Groups Full"] = _num_full
        try:
            data["Last Updated"] = get_time_delta(_sgs[0].updated_at)
        except:
            pass
        return data
    def get_summary(self):

        _sgs = vsmapi.storage_group_status(self.request,)
        _cfg = {"storage_group_near_full_threshold":65,
            "storage_group_full_threshold":85,}
        _num = 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 <_cfg["storage_group_near_full_threshold"]:
                pass
            elif capcity_percent_used < _cfg["storage_group_full_threshold"]:
                _num_near_full += 1
            else:
                _num_full += 1
            _num += 1

        data = SortedDict()
        data["Total Storage Groups"] = _num
        data["Storage Groups Near Full"] = _num_near_full
        data["Storage Groups Full"] = _num_full
        try:
            data["Last Updated"] = get_time_delta(_sgs[0].updated_at)
        except:
            pass
        return data
Exemple #10
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
Exemple #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 = []
        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 get_storage_group_list():
    #get the storage group
    storage_group_list = vsmapi.storage_group_status(None, )
    storage_group = []
    for _sg in storage_group_list:
        sg = {"id": _sg.id, "name": _sg.name}
        storage_group.append(sg)
    return storage_group
def get_sg_list():
    _sgs = []
    try:
        _sgs = vsmapi.storage_group_status(None,)
        if _sgs:
            logging.debug("resp body in view: %s" % _sgs)
    except:
        exceptions.handle(None,'Unable to retrieve storage group list.')
    return _sgs
Exemple #14
0
def get_sg_list():
    _sgs = []
    try:
        _sgs = vsmapi.storage_group_status(None, )
        if _sgs:
            logging.debug("resp body in view: %s" % _sgs)
    except:
        exceptions.handle(None, 'Unable to retrieve storage group list.')
    return _sgs
def get_storage_group_list(request):
    #get the storage group
    storage_group_list = vsmapi.storage_group_status(request)
    storage_group = []
    for _sg in storage_group_list:
        sg = {
            "id":_sg.id
            ,"name":_sg.name
        }
        storage_group.append(sg)
    return storage_group
Exemple #16
0
 def get_text(self):
     storage_groups = vsmapi.storage_group_status(self.request)
     storage_group_list = []
     for _storage_group in storage_groups:
         storage_group = {
             "storage_group_name": _storage_group.name,
             "capacity_total": _storage_group.capacity_total,
             "capacity_used": _storage_group.capacity_used,
             "capacity_avail": _storage_group.capacity_avail,
             }
         storage_group_list.append(storage_group)
     return json.dumps(storage_group_list) 
 def get_text(self):
     storage_groups = vsmapi.storage_group_status(self.request)
     storage_group_list = []
     for _storage_group in storage_groups:
         storage_group = {
             "storage_group_name": _storage_group.name,
             "capacity_total": _storage_group.capacity_total,
             "capacity_used": _storage_group.capacity_used,
             "capacity_avail": _storage_group.capacity_avail,
             }
         storage_group_list.append(storage_group)
     return json.dumps(storage_group_list) 
    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
    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
    def get_context_data(self, **kwargs):
        context = {}
        storage_group_list = vsmapi.storage_group_status(None, )

        storage_group = []
        for _sg in storage_group_list:
            sg = {"id": _sg.id, "storage_class": _sg.storage_class}
            storage_group.append(sg)
        context["storage_group"] = storage_group

        servers = vsmapi.get_server_list(None, )
        context["servers"] = servers

        if len(servers) > 0:
            context["OSDList"] = vsmapi.osd_status(
                self.request,
                paginate_opts={"service_id": servers[0].service_id})

        return context
    def get_context_data(self, **kwargs):
        context = {}
        storage_group_list = vsmapi.storage_group_status(None,)

        storage_group = []
        for _sg in storage_group_list:
            sg = {
                "id":_sg.id
                ,"storage_class":_sg.storage_class
            }
            storage_group.append(sg)
        context["storage_group"] = storage_group

        servers = vsmapi.get_server_list(None, )
        context["servers"] = servers;

        if len(servers) > 0:
            context["OSDList"] = vsmapi.osd_status(self.request, paginate_opts={
                "service_id": servers[0].service_id
            })
        
        return context
    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
    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