Add a new column to display available volume group size

Currently there is no easy way for user to know the available
space in each logical volume group. This commit adds a new
column for each logical volume group to show the size of
available space.

Change-Id: Iba4c22587ba962596cf50e75cbc9cdd548301acc
Closes-Bug: 1804711
Depends-On: https://review.openstack.org/#/c/619656
Signed-off-by: Wei Zhou <wei.zhou@windriver.com>
This commit is contained in:
Wei Zhou 2018-11-22 17:54:37 -05:00
parent 6d44ca294b
commit f7b0ea1a5e
3 changed files with 20 additions and 6 deletions

View File

@ -394,6 +394,7 @@ class LocalVolumeGroup(base.APIResourceWrapper):
'lvm_max_pv',
'lvm_cur_pv',
'lvm_vg_size',
'lvm_vg_avail_size',
'lvm_vg_total_pe',
'lvm_vg_free_pe',
'created_at',
@ -402,6 +403,16 @@ class LocalVolumeGroup(base.APIResourceWrapper):
def __init__(self, apiresource):
super(LocalVolumeGroup, self).__init__(apiresource)
@property
def lvm_vg_size_gib(self):
return math.floor(float(
self.lvm_vg_size) / (1024 ** 3) * 1000) / 1000.0
@property
def lvm_vg_avail_size_gib(self):
return math.floor(float(
self.lvm_vg_avail_size) / (1024 ** 3) * 1000) / 1000.0
class LocalVolumeGroupParam(object):
def __init__(self, lvg_id, key, val):

View File

@ -9,7 +9,6 @@ import re
from django.core.urlresolvers import reverse # noqa
from django import template
from django.template import defaultfilters as filters
from django.utils.translation import string_concat # noqa
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy
@ -463,9 +462,10 @@ class LocalVolumeGroupsTable(tables.DataTable):
verbose_name=('State'))
access = tables.Column('lvm_vg_access',
verbose_name=('Access'))
size = tables.Column('lvm_vg_size',
verbose_name=('Size'),
filters=(filters.filesizeformat,))
size = tables.Column('lvm_vg_size_gib',
verbose_name=('Size (GiB)'))
avail_size = tables.Column('lvm_vg_avail_size_gib',
verbose_name=('Avail Size (GiB)'))
pvs = tables.Column('lvm_cur_pv',
verbose_name=('Current Physical Volumes'))
lvs = tables.Column('lvm_cur_lv',
@ -483,7 +483,8 @@ class LocalVolumeGroupsTable(tables.DataTable):
class Meta(object):
name = "localvolumegroups"
verbose_name = ("Local Volume Groups")
columns = ('name', 'state', 'access', 'size', 'pvs', 'lvs',)
columns = ('name', 'state', 'access', 'size', 'avail_size',
'pvs', 'lvs',)
multi_select = False
row_actions = (RemoveLocalVolumeGroup,)
table_actions = (AddLocalVolumeGroup, CreateDiskProfile)

View File

@ -17,7 +17,9 @@
</dl>
<dl>
<dt>{% trans "Size" %}</dt>
<dd>{{ lvg.lvm_vg_size | filesizeformat }}</dd>
<dd>{{ lvg.lvm_vg_size_gib }}</dd>
<dt>{% trans "Available Size" %}</dt>
<dd>{{ lvg.lvm_vg_avail_size_gib }}</dd>
<dt>{% trans "Max Local Volumes" %}</dt>
<dd>{{ lvg.lvm_max_lv }}</dd>
<dt>{% trans "Current Local Volumes" %}</dt>