Add option to specify --kind while creating policy
This commits allows user to specify the kind of policy while creating policy through horizon Change-Id: I1f78670afb3aa27ed58e59aba1ccd23d89125e95 Closes-Bug:#1525836
This commit is contained in:
parent
1c2513397f
commit
e688881b47
|
@ -24,9 +24,17 @@ from openstack_dashboard.api import congress
|
|||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
POLICY_KIND_CHOICES = (
|
||||
('nonrecursive', _('Nonrecursive')),
|
||||
('action', _('Action')),
|
||||
('database', _('Database')),
|
||||
('materialized', _('Materialized')),
|
||||
)
|
||||
|
||||
class CreatePolicy(forms.SelfHandlingForm):
|
||||
name = forms.CharField(max_length=255, label=_("Policy Name"))
|
||||
kind = forms.ChoiceField(choices=POLICY_KIND_CHOICES, label=_("Kind"),
|
||||
initial='nonrecursive')
|
||||
description = forms.CharField(label=_("Description"), required=False,
|
||||
widget=forms.Textarea(attrs={'rows': 4}))
|
||||
failure_url = 'horizon:admin:policies:index'
|
||||
|
@ -34,13 +42,15 @@ class CreatePolicy(forms.SelfHandlingForm):
|
|||
def handle(self, request, data):
|
||||
policy_name = data['name']
|
||||
policy_description = data.get('description')
|
||||
LOG.info('User %s creating policy "%s" in tenant %s' %
|
||||
(request.user.username, policy_name,
|
||||
policy_kind = data.pop('kind')
|
||||
LOG.info('User %s creating policy "%s" of type %s in tenant %s' %
|
||||
(request.user.username, policy_name, policy_kind,
|
||||
request.user.tenant_name))
|
||||
try:
|
||||
params = {
|
||||
'name': policy_name,
|
||||
'description': policy_description,
|
||||
'kind': policy_kind,
|
||||
}
|
||||
policy = congress.policy_create(request, params)
|
||||
msg = _('Created policy "%s"') % policy_name
|
||||
|
|
Loading…
Reference in New Issue