Add project in hashmap ressources
Change-Id: I51405847d557bdd07f46a18b8c79e99d6946e2bb
This commit is contained in:
parent
7bd52099e5
commit
86ed62ce33
@ -20,6 +20,8 @@ from horizon import forms
|
|||||||
from cloudkittydashboard.api import cloudkitty as api
|
from cloudkittydashboard.api import cloudkitty as api
|
||||||
from cloudkittydashboard.dashboards import common
|
from cloudkittydashboard.dashboards import common
|
||||||
|
|
||||||
|
from openstack_dashboard import api as api_keystone
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -64,6 +66,8 @@ class BaseForm(forms.SelfHandlingForm, common.OrderFieldsMixin):
|
|||||||
group_id = forms.DynamicChoiceField(label=_("Group"),
|
group_id = forms.DynamicChoiceField(label=_("Group"),
|
||||||
required=False,
|
required=False,
|
||||||
add_item_link=url)
|
add_item_link=url)
|
||||||
|
tenant_id = forms.ChoiceField(label=_("Project"),
|
||||||
|
required=False)
|
||||||
fields_order = ['type', 'cost', 'group_id']
|
fields_order = ['type', 'cost', 'group_id']
|
||||||
|
|
||||||
def __init__(self, request, *args, **kwargs):
|
def __init__(self, request, *args, **kwargs):
|
||||||
@ -75,10 +79,15 @@ class BaseForm(forms.SelfHandlingForm, common.OrderFieldsMixin):
|
|||||||
choices.insert(0, ('', ' '))
|
choices.insert(0, ('', ' '))
|
||||||
self.fields['group_id'].choices = choices
|
self.fields['group_id'].choices = choices
|
||||||
|
|
||||||
|
tenants, __ = api_keystone.keystone.tenant_list(request)
|
||||||
|
choices_tenants = [(tenant.id, tenant.name) for tenant in tenants]
|
||||||
|
choices_tenants.insert(0, (None, ' '))
|
||||||
|
self.fields['tenant_id'].choices = choices_tenants
|
||||||
|
|
||||||
|
|
||||||
class BaseThresholdForm(BaseForm):
|
class BaseThresholdForm(BaseForm):
|
||||||
level = forms.DecimalField(label=_("Level"))
|
level = forms.DecimalField(label=_("Level"))
|
||||||
fields_order = ['level', 'type', 'cost', 'group_id']
|
fields_order = ['level', 'type', 'cost', 'group_id', 'tenant_id']
|
||||||
|
|
||||||
def handle(self, request, data):
|
def handle(self, request, data):
|
||||||
thresholds_mgr = api.cloudkittyclient(request).hashmap.thresholds
|
thresholds_mgr = api.cloudkittyclient(request).hashmap.thresholds
|
||||||
@ -93,14 +102,16 @@ class CreateServiceThresholdForm(BaseThresholdForm):
|
|||||||
service_id = forms.CharField(label=_("Service ID"),
|
service_id = forms.CharField(label=_("Service ID"),
|
||||||
widget=forms.TextInput(
|
widget=forms.TextInput(
|
||||||
attrs={'readonly': 'readonly'}))
|
attrs={'readonly': 'readonly'}))
|
||||||
fields_order = ['service_id', 'level', 'type', 'cost', 'group_id']
|
fields_order = ['service_id', 'level', 'type', 'cost', 'group_id',
|
||||||
|
'tenant_id']
|
||||||
|
|
||||||
|
|
||||||
class CreateFieldThresholdForm(BaseThresholdForm):
|
class CreateFieldThresholdForm(BaseThresholdForm):
|
||||||
field_id = forms.CharField(label=_("Field"),
|
field_id = forms.CharField(label=_("Field"),
|
||||||
widget=forms.TextInput(
|
widget=forms.TextInput(
|
||||||
attrs={'readonly': 'readonly'}))
|
attrs={'readonly': 'readonly'}))
|
||||||
fields_order = ['field_id', 'level', 'type', 'cost', 'group_id']
|
fields_order = ['field_id', 'level', 'type', 'cost', 'group_id',
|
||||||
|
'tenant_id']
|
||||||
|
|
||||||
|
|
||||||
class BaseMappingForm(BaseForm):
|
class BaseMappingForm(BaseForm):
|
||||||
@ -120,7 +131,8 @@ class CreateFieldMappingForm(BaseMappingForm):
|
|||||||
widget=forms.TextInput(
|
widget=forms.TextInput(
|
||||||
attrs={'readonly': 'readonly'}),
|
attrs={'readonly': 'readonly'}),
|
||||||
required=False)
|
required=False)
|
||||||
fields_order = ['field_id', 'value', 'type', 'cost', 'group_id']
|
fields_order = ['field_id', 'value', 'type', 'cost', 'group_id',
|
||||||
|
'tenant_id']
|
||||||
|
|
||||||
|
|
||||||
class CreateServiceMappingForm(BaseMappingForm):
|
class CreateServiceMappingForm(BaseMappingForm):
|
||||||
@ -128,13 +140,16 @@ class CreateServiceMappingForm(BaseMappingForm):
|
|||||||
widget=forms.TextInput(
|
widget=forms.TextInput(
|
||||||
attrs={'readonly': 'readonly'}),
|
attrs={'readonly': 'readonly'}),
|
||||||
required=False)
|
required=False)
|
||||||
fields_order = ['service_id', 'type', 'cost', 'group_id']
|
fields_order = ['service_id', 'type', 'cost', 'group_id',
|
||||||
|
'tenant_id']
|
||||||
|
|
||||||
|
|
||||||
class BaseEditMappingForm(BaseMappingForm):
|
class BaseEditMappingForm(BaseMappingForm):
|
||||||
mapping_id = forms.CharField(label=_("Mapping ID"),
|
mapping_id = forms.CharField(label=_("Mapping ID"),
|
||||||
widget=forms.TextInput(
|
widget=forms.TextInput(
|
||||||
attrs={'readonly': 'readonly'}))
|
attrs={'readonly': 'readonly'}))
|
||||||
|
tenant_id = forms.ChoiceField(label=_("Project"),
|
||||||
|
required=False)
|
||||||
|
|
||||||
def handle(self, request, data):
|
def handle(self, request, data):
|
||||||
mapping_mgr = api.cloudkittyclient(request).hashmap.mappings
|
mapping_mgr = api.cloudkittyclient(request).hashmap.mappings
|
||||||
@ -147,7 +162,8 @@ class BaseEditMappingForm(BaseMappingForm):
|
|||||||
|
|
||||||
|
|
||||||
class EditServiceMappingForm(BaseEditMappingForm, CreateServiceMappingForm):
|
class EditServiceMappingForm(BaseEditMappingForm, CreateServiceMappingForm):
|
||||||
fields_order = ['service_id', 'mapping_id', 'type', 'cost', 'group_id']
|
fields_order = ['service_id', 'mapping_id', 'type', 'cost', 'group_id',
|
||||||
|
'tenant_id']
|
||||||
|
|
||||||
|
|
||||||
class EditFieldMappingForm(BaseEditMappingForm, CreateFieldMappingForm):
|
class EditFieldMappingForm(BaseEditMappingForm, CreateFieldMappingForm):
|
||||||
@ -157,7 +173,8 @@ class EditFieldMappingForm(BaseEditMappingForm, CreateFieldMappingForm):
|
|||||||
'value',
|
'value',
|
||||||
'type',
|
'type',
|
||||||
'cost',
|
'cost',
|
||||||
'group_id']
|
'group_id',
|
||||||
|
'tenant_id']
|
||||||
|
|
||||||
|
|
||||||
class BaseEditThresholdForm(BaseThresholdForm):
|
class BaseEditThresholdForm(BaseThresholdForm):
|
||||||
@ -183,7 +200,8 @@ class EditServiceThresholdForm(BaseEditThresholdForm,
|
|||||||
'level',
|
'level',
|
||||||
'type',
|
'type',
|
||||||
'cost',
|
'cost',
|
||||||
'group_id']
|
'group_id',
|
||||||
|
'tenant_id']
|
||||||
|
|
||||||
|
|
||||||
class EditFieldThresholdForm(BaseEditThresholdForm,
|
class EditFieldThresholdForm(BaseEditThresholdForm,
|
||||||
@ -194,4 +212,5 @@ class EditFieldThresholdForm(BaseEditThresholdForm,
|
|||||||
'level',
|
'level',
|
||||||
'type',
|
'type',
|
||||||
'cost',
|
'cost',
|
||||||
'group_id']
|
'group_id',
|
||||||
|
'tenant_id']
|
||||||
|
@ -216,6 +216,7 @@ class BaseThresholdsTable(tables.DataTable):
|
|||||||
group_name = tables.Column(get_groupname,
|
group_name = tables.Column(get_groupname,
|
||||||
verbose_name=_("Group Name"),
|
verbose_name=_("Group Name"),
|
||||||
link=get_detail_link)
|
link=get_detail_link)
|
||||||
|
tenant_id = tables.Column('tenant_id', verbose_name=_("Project"))
|
||||||
|
|
||||||
|
|
||||||
class ServiceThresholdsTable(BaseThresholdsTable):
|
class ServiceThresholdsTable(BaseThresholdsTable):
|
||||||
@ -389,6 +390,7 @@ class BaseMappingsTable(tables.DataTable):
|
|||||||
group_name = tables.Column(get_groupname,
|
group_name = tables.Column(get_groupname,
|
||||||
verbose_name=_("Group Name"),
|
verbose_name=_("Group Name"),
|
||||||
link=get_detail_link)
|
link=get_detail_link)
|
||||||
|
tenant_id = tables.Column('tenant_id', verbose_name=_("Project"))
|
||||||
|
|
||||||
|
|
||||||
class ServiceMappingsTable(BaseMappingsTable):
|
class ServiceMappingsTable(BaseMappingsTable):
|
||||||
|
Loading…
Reference in New Issue
Block a user