summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkihiro Motoki <motoki@da.jp.nec.com>2017-03-12 20:55:20 +0000
committerAkihiro Motoki <amotoki@gmail.com>2017-04-14 19:40:48 +0000
commitc8cd03189a7ea38ebdd97d613a88a50d255005c2 (patch)
tree7dfb32afb3d0687a13a54eeb86ae51e4f4070db6
parent3be6d7f88231bb2828352869c1557a3b8e2302b1 (diff)
Use BooleanField for admin_state_up form
admin_state_up is a boolean value but the network and port edit forms expected a string version of True/False. As a result, True/False string was shown as the default value in these forms. The field is implemented as ChoiceField, but there is no special reason not to use BooleanField for a boolean field and admin_state(_up) fields are the only exceptions in horizon. This commit replaces all admin_state(_up) fields to use BooleanField. As far as I checked, this pattern is used only in the networking related panels and this patch clean them up. Change-Id: I9286f6c29d67fec7a88b74661bc8eca945fd9061 Closes-Bug: #1672213
Notes
Notes (review): Code-Review+1: Julie Gravel <julie.gravel@suse.com> Code-Review+1: Jeremy Moffitt <jeremy.moffitt@suse.com> Code-Review+2: Kenji Ishii <ken-ishii@sx.jp.nec.com> Code-Review+2: Rob Cresswell <robert.cresswell@outlook.com> Workflow+1: Rob Cresswell <robert.cresswell@outlook.com> Code-Review+1: Zhaokun Fu <fuzk@inspur.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Sat, 22 Apr 2017 11:39:50 +0000 Reviewed-on: https://review.openstack.org/444670 Project: openstack/horizon Branch: refs/heads/master
-rw-r--r--openstack_dashboard/dashboards/admin/networks/forms.py16
-rw-r--r--openstack_dashboard/dashboards/admin/networks/ports/forms.py3
-rw-r--r--openstack_dashboard/dashboards/project/firewalls/forms.py7
-rw-r--r--openstack_dashboard/dashboards/project/firewalls/workflows.py11
-rw-r--r--openstack_dashboard/dashboards/project/networks/forms.py9
-rw-r--r--openstack_dashboard/dashboards/project/networks/ports/forms.py15
-rw-r--r--openstack_dashboard/dashboards/project/networks/workflows.py12
-rw-r--r--openstack_dashboard/dashboards/project/routers/forms.py14
-rw-r--r--openstack_dashboard/dashboards/project/routers/tests.py10
-rw-r--r--openstack_dashboard/dashboards/project/vpn/forms.py14
-rw-r--r--openstack_dashboard/dashboards/project/vpn/templates/vpn/_add_vpn_service_help.html4
-rw-r--r--openstack_dashboard/dashboards/project/vpn/workflows.py22
12 files changed, 55 insertions, 82 deletions
diff --git a/openstack_dashboard/dashboards/admin/networks/forms.py b/openstack_dashboard/dashboards/admin/networks/forms.py
index 3eec873..2796d13 100644
--- a/openstack_dashboard/dashboards/admin/networks/forms.py
+++ b/openstack_dashboard/dashboards/admin/networks/forms.py
@@ -118,10 +118,9 @@ class CreateNetwork(forms.SelfHandlingForm):
118 'class': 'switched', 118 'class': 'switched',
119 'data-switch-on': 'network_type', 119 'data-switch-on': 'network_type',
120 })) 120 }))
121 admin_state = forms.ThemableChoiceField( 121 admin_state = forms.BooleanField(label=_("Enable Admin State"),
122 choices=[('True', _('UP')), 122 initial=True,
123 ('False', _('DOWN'))], 123 required=False)
124 label=_("Admin State"))
125 shared = forms.BooleanField(label=_("Shared"), 124 shared = forms.BooleanField(label=_("Shared"),
126 initial=False, required=False) 125 initial=False, required=False)
127 external = forms.BooleanField(label=_("External Network"), 126 external = forms.BooleanField(label=_("External Network"),
@@ -250,7 +249,7 @@ class CreateNetwork(forms.SelfHandlingForm):
250 try: 249 try:
251 params = {'name': data['name'], 250 params = {'name': data['name'],
252 'tenant_id': data['tenant_id'], 251 'tenant_id': data['tenant_id'],
253 'admin_state_up': (data['admin_state'] == 'True'), 252 'admin_state_up': data['admin_state'],
254 'shared': data['shared'], 253 'shared': data['shared'],
255 'router:external': data['external']} 254 'router:external': data['external']}
256 if api.neutron.is_extension_supported(request, 'provider'): 255 if api.neutron.is_extension_supported(request, 'provider'):
@@ -312,9 +311,8 @@ class UpdateNetwork(forms.SelfHandlingForm):
312 network_id = forms.CharField(label=_("ID"), 311 network_id = forms.CharField(label=_("ID"),
313 widget=forms.TextInput( 312 widget=forms.TextInput(
314 attrs={'readonly': 'readonly'})) 313 attrs={'readonly': 'readonly'}))
315 admin_state = forms.ThemableChoiceField(choices=[(True, _('UP')), 314 admin_state = forms.BooleanField(label=_("Enable Admin State"),
316 (False, _('DOWN'))], 315 required=False)
317 label=_("Admin State"))
318 shared = forms.BooleanField(label=_("Shared"), required=False) 316 shared = forms.BooleanField(label=_("Shared"), required=False)
319 external = forms.BooleanField(label=_("External Network"), required=False) 317 external = forms.BooleanField(label=_("External Network"), required=False)
320 failure_url = 'horizon:admin:networks:index' 318 failure_url = 'horizon:admin:networks:index'
@@ -322,7 +320,7 @@ class UpdateNetwork(forms.SelfHandlingForm):
322 def handle(self, request, data): 320 def handle(self, request, data):
323 try: 321 try:
324 params = {'name': data['name'], 322 params = {'name': data['name'],
325 'admin_state_up': (data['admin_state'] == 'True'), 323 'admin_state_up': data['admin_state'],
326 'shared': data['shared'], 324 'shared': data['shared'],
327 'router:external': data['external']} 325 'router:external': data['external']}
328 network = api.neutron.network_update(request, 326 network = api.neutron.network_update(request,
diff --git a/openstack_dashboard/dashboards/admin/networks/ports/forms.py b/openstack_dashboard/dashboards/admin/networks/ports/forms.py
index 308bfa4..6fd9d8f 100644
--- a/openstack_dashboard/dashboards/admin/networks/ports/forms.py
+++ b/openstack_dashboard/dashboards/admin/networks/ports/forms.py
@@ -102,7 +102,7 @@ class CreatePort(project_forms.CreatePort):
102 params = { 102 params = {
103 'tenant_id': network.tenant_id, 103 'tenant_id': network.tenant_id,
104 'network_id': data['network_id'], 104 'network_id': data['network_id'],
105 'admin_state_up': data['admin_state'] == 'True', 105 'admin_state_up': data['admin_state'],
106 'name': data['name'], 106 'name': data['name'],
107 'device_id': data['device_id'], 107 'device_id': data['device_id'],
108 'device_owner': data['device_owner'], 108 'device_owner': data['device_owner'],
@@ -165,7 +165,6 @@ class UpdatePort(project_forms.UpdatePort):
165 try: 165 try:
166 LOG.debug('params = %s', data) 166 LOG.debug('params = %s', data)
167 extension_kwargs = {} 167 extension_kwargs = {}
168 data['admin_state'] = (data['admin_state'] == 'True')
169 if 'binding__vnic_type' in data: 168 if 'binding__vnic_type' in data:
170 extension_kwargs['binding__vnic_type'] = \ 169 extension_kwargs['binding__vnic_type'] = \
171 data['binding__vnic_type'] 170 data['binding__vnic_type']
diff --git a/openstack_dashboard/dashboards/project/firewalls/forms.py b/openstack_dashboard/dashboards/project/firewalls/forms.py
index 701ab8a..ec50456 100644
--- a/openstack_dashboard/dashboards/project/firewalls/forms.py
+++ b/openstack_dashboard/dashboards/project/firewalls/forms.py
@@ -134,10 +134,8 @@ class UpdateFirewall(forms.SelfHandlingForm):
134 label=_("Description"), 134 label=_("Description"),
135 required=False) 135 required=False)
136 firewall_policy_id = forms.ThemableChoiceField(label=_("Policy")) 136 firewall_policy_id = forms.ThemableChoiceField(label=_("Policy"))
137 admin_state_up = forms.ThemableChoiceField(choices=[(True, _('UP')), 137 admin_state_up = forms.BooleanField(label=_("Enable Admin State"),
138 (False, _('DOWN'))], 138 required=False)
139 label=_("Admin State"))
140
141 failure_url = 'horizon:project:firewalls:index' 139 failure_url = 'horizon:project:firewalls:index'
142 140
143 def __init__(self, request, *args, **kwargs): 141 def __init__(self, request, *args, **kwargs):
@@ -165,7 +163,6 @@ class UpdateFirewall(forms.SelfHandlingForm):
165 def handle(self, request, context): 163 def handle(self, request, context):
166 firewall_id = self.initial['firewall_id'] 164 firewall_id = self.initial['firewall_id']
167 name_or_id = context.get('name') or firewall_id 165 name_or_id = context.get('name') or firewall_id
168 context['admin_state_up'] = (context['admin_state_up'] == 'True')
169 try: 166 try:
170 firewall = api.fwaas.firewall_update(request, firewall_id, 167 firewall = api.fwaas.firewall_update(request, firewall_id,
171 **context) 168 **context)
diff --git a/openstack_dashboard/dashboards/project/firewalls/workflows.py b/openstack_dashboard/dashboards/project/firewalls/workflows.py
index 7e5fb12..1723a79 100644
--- a/openstack_dashboard/dashboards/project/firewalls/workflows.py
+++ b/openstack_dashboard/dashboards/project/firewalls/workflows.py
@@ -343,9 +343,9 @@ class AddFirewallAction(workflows.Action):
343 label=_("Description"), 343 label=_("Description"),
344 required=False) 344 required=False)
345 firewall_policy_id = forms.ThemableChoiceField(label=_("Policy")) 345 firewall_policy_id = forms.ThemableChoiceField(label=_("Policy"))
346 admin_state_up = forms.ThemableChoiceField(choices=[(True, _('UP')), 346 admin_state_up = forms.BooleanField(label=_("Enable Admin State"),
347 (False, _('DOWN'))], 347 initial=True,
348 label=_("Admin State")) 348 required=False)
349 349
350 def __init__(self, request, *args, **kwargs): 350 def __init__(self, request, *args, **kwargs):
351 super(AddFirewallAction, self).__init__(request, *args, **kwargs) 351 super(AddFirewallAction, self).__init__(request, *args, **kwargs)
@@ -380,11 +380,6 @@ class AddFirewallStep(workflows.Step):
380 contributes = ("name", "firewall_policy_id", "description", 380 contributes = ("name", "firewall_policy_id", "description",
381 "admin_state_up") 381 "admin_state_up")
382 382
383 def contribute(self, data, context):
384 context = super(AddFirewallStep, self).contribute(data, context)
385 context['admin_state_up'] = (context['admin_state_up'] == 'True')
386 return context
387
388 383
389class AddFirewall(workflows.Workflow): 384class AddFirewall(workflows.Workflow):
390 slug = "addfirewall" 385 slug = "addfirewall"
diff --git a/openstack_dashboard/dashboards/project/networks/forms.py b/openstack_dashboard/dashboards/project/networks/forms.py
index f28a211..3e2c3d3 100644
--- a/openstack_dashboard/dashboards/project/networks/forms.py
+++ b/openstack_dashboard/dashboards/project/networks/forms.py
@@ -38,11 +38,8 @@ class UpdateNetwork(forms.SelfHandlingForm):
38 network_id = forms.CharField(label=_("ID"), 38 network_id = forms.CharField(label=_("ID"),
39 widget=forms.TextInput( 39 widget=forms.TextInput(
40 attrs={'readonly': 'readonly'})) 40 attrs={'readonly': 'readonly'}))
41 admin_state = forms.ThemableChoiceField( 41 admin_state = forms.BooleanField(label=_("Enable Admin State"),
42 choices=[('True', _('UP')), 42 required=False)
43 ('False', _('DOWN'))],
44 required=False,
45 label=_("Admin State"))
46 shared = forms.BooleanField(label=_("Shared"), required=False) 43 shared = forms.BooleanField(label=_("Shared"), required=False)
47 failure_url = 'horizon:project:networks:index' 44 failure_url = 'horizon:project:networks:index'
48 45
@@ -54,7 +51,7 @@ class UpdateNetwork(forms.SelfHandlingForm):
54 51
55 def handle(self, request, data): 52 def handle(self, request, data):
56 try: 53 try:
57 params = {'admin_state_up': (data['admin_state'] == 'True'), 54 params = {'admin_state_up': data['admin_state'],
58 'name': data['name']} 55 'name': data['name']}
59 # Make sure we are not sending shared data when the user 56 # Make sure we are not sending shared data when the user
60 # doesnt'have admin rights because even if the user doesn't 57 # doesnt'have admin rights because even if the user doesn't
diff --git a/openstack_dashboard/dashboards/project/networks/ports/forms.py b/openstack_dashboard/dashboards/project/networks/ports/forms.py
index 8272a66..00d5cfd 100644
--- a/openstack_dashboard/dashboards/project/networks/ports/forms.py
+++ b/openstack_dashboard/dashboards/project/networks/ports/forms.py
@@ -44,9 +44,9 @@ class CreatePort(forms.SelfHandlingForm):
44 name = forms.CharField(max_length=255, 44 name = forms.CharField(max_length=255,
45 label=_("Name"), 45 label=_("Name"),
46 required=False) 46 required=False)
47 admin_state = forms.ChoiceField(choices=[('True', _('UP')), 47 admin_state = forms.BooleanField(label=_("Enable Admin State"),
48 ('False', _('DOWN'))], 48 initial=True,
49 label=_("Admin State")) 49 required=False)
50 device_id = forms.CharField(max_length=100, label=_("Device ID"), 50 device_id = forms.CharField(max_length=100, label=_("Device ID"),
51 help_text=_("Device ID attached to the port"), 51 help_text=_("Device ID attached to the port"),
52 required=False) 52 required=False)
@@ -132,7 +132,7 @@ class CreatePort(forms.SelfHandlingForm):
132 try: 132 try:
133 params = { 133 params = {
134 'network_id': data['network_id'], 134 'network_id': data['network_id'],
135 'admin_state_up': data['admin_state'] == 'True', 135 'admin_state_up': data['admin_state'],
136 'name': data['name'], 136 'name': data['name'],
137 'device_id': data['device_id'], 137 'device_id': data['device_id'],
138 'device_owner': data['device_owner'] 138 'device_owner': data['device_owner']
@@ -179,10 +179,8 @@ class UpdatePort(forms.SelfHandlingForm):
179 name = forms.CharField(max_length=255, 179 name = forms.CharField(max_length=255,
180 label=_("Name"), 180 label=_("Name"),
181 required=False) 181 required=False)
182 admin_state = forms.ThemableChoiceField( 182 admin_state = forms.BooleanField(label=_("Enable Admin State"),
183 choices=[('True', _('UP')), 183 required=False)
184 ('False', _('DOWN'))],
185 label=_("Admin State"))
186 failure_url = 'horizon:project:networks:detail' 184 failure_url = 'horizon:project:networks:detail'
187 185
188 def __init__(self, request, *args, **kwargs): 186 def __init__(self, request, *args, **kwargs):
@@ -232,7 +230,6 @@ class UpdatePort(forms.SelfHandlingForm):
232 exceptions.handle(self.request, msg) 230 exceptions.handle(self.request, msg)
233 231
234 def handle(self, request, data): 232 def handle(self, request, data):
235 data['admin_state'] = (data['admin_state'] == 'True')
236 try: 233 try:
237 LOG.debug('params = %s', data) 234 LOG.debug('params = %s', data)
238 extension_kwargs = {} 235 extension_kwargs = {}
diff --git a/openstack_dashboard/dashboards/project/networks/workflows.py b/openstack_dashboard/dashboards/project/networks/workflows.py
index 15a0c3d..12fa00e 100644
--- a/openstack_dashboard/dashboards/project/networks/workflows.py
+++ b/openstack_dashboard/dashboards/project/networks/workflows.py
@@ -37,13 +37,11 @@ class CreateNetworkInfoAction(workflows.Action):
37 net_name = forms.CharField(max_length=255, 37 net_name = forms.CharField(max_length=255,
38 label=_("Network Name"), 38 label=_("Network Name"),
39 required=False) 39 required=False)
40 admin_state = forms.ThemableChoiceField( 40 admin_state = forms.BooleanField(
41 choices=[(True, _('UP')), 41 label=_("Enable Admin State"),
42 (False, _('DOWN'))], 42 initial=True,
43 label=_("Admin State"),
44 required=False, 43 required=False,
45 help_text=_("The state to start" 44 help_text=_("The state to start the network in."))
46 " the network in."))
47 shared = forms.BooleanField(label=_("Shared"), initial=False, 45 shared = forms.BooleanField(label=_("Shared"), initial=False,
48 required=False) 46 required=False)
49 with_subnet = forms.BooleanField(label=_("Create Subnet"), 47 with_subnet = forms.BooleanField(label=_("Create Subnet"),
@@ -463,7 +461,7 @@ class CreateNetwork(workflows.Workflow):
463 def _create_network(self, request, data): 461 def _create_network(self, request, data):
464 try: 462 try:
465 params = {'name': data['net_name'], 463 params = {'name': data['net_name'],
466 'admin_state_up': (data['admin_state'] == 'True'), 464 'admin_state_up': data['admin_state'],
467 'shared': data['shared']} 465 'shared': data['shared']}
468 network = api.neutron.network_create(request, **params) 466 network = api.neutron.network_create(request, **params)
469 self.context['net_id'] = network.id 467 self.context['net_id'] = network.id
diff --git a/openstack_dashboard/dashboards/project/routers/forms.py b/openstack_dashboard/dashboards/project/routers/forms.py
index 9b5e726..51cd96a 100644
--- a/openstack_dashboard/dashboards/project/routers/forms.py
+++ b/openstack_dashboard/dashboards/project/routers/forms.py
@@ -34,10 +34,9 @@ LOG = logging.getLogger(__name__)
34class CreateForm(forms.SelfHandlingForm): 34class CreateForm(forms.SelfHandlingForm):
35 name = forms.CharField(max_length=255, label=_("Router Name"), 35 name = forms.CharField(max_length=255, label=_("Router Name"),
36 required=False) 36 required=False)
37 admin_state_up = forms.ThemableChoiceField(label=_("Admin State"), 37 admin_state_up = forms.BooleanField(label=_("Enable Admin State"),
38 choices=[(True, _('UP')), 38 initial=True,
39 (False, _('DOWN'))], 39 required=False)
40 required=False)
41 external_network = forms.ThemableChoiceField(label=_("External Network"), 40 external_network = forms.ThemableChoiceField(label=_("External Network"),
42 required=False) 41 required=False)
43 mode = forms.ChoiceField(label=_("Router Type")) 42 mode = forms.ChoiceField(label=_("Router Type"))
@@ -116,9 +115,8 @@ class CreateForm(forms.SelfHandlingForm):
116 115
117class UpdateForm(forms.SelfHandlingForm): 116class UpdateForm(forms.SelfHandlingForm):
118 name = forms.CharField(label=_("Name"), required=False) 117 name = forms.CharField(label=_("Name"), required=False)
119 admin_state = forms.ThemableChoiceField(choices=[(True, _('UP')), 118 admin_state = forms.BooleanField(label=_("Enable Admin State"),
120 (False, _('DOWN'))], 119 required=False)
121 label=_("Admin State"))
122 router_id = forms.CharField(label=_("ID"), 120 router_id = forms.CharField(label=_("ID"),
123 widget=forms.TextInput( 121 widget=forms.TextInput(
124 attrs={'readonly': 'readonly'})) 122 attrs={'readonly': 'readonly'}))
@@ -155,7 +153,7 @@ class UpdateForm(forms.SelfHandlingForm):
155 153
156 def handle(self, request, data): 154 def handle(self, request, data):
157 try: 155 try:
158 params = {'admin_state_up': (data['admin_state'] == 'True'), 156 params = {'admin_state_up': data['admin_state'],
159 'name': data['name']} 157 'name': data['name']}
160 if self.dvr_allowed: 158 if self.dvr_allowed:
161 params['distributed'] = (data['mode'] == 'distributed') 159 params['distributed'] = (data['mode'] == 'distributed')
diff --git a/openstack_dashboard/dashboards/project/routers/tests.py b/openstack_dashboard/dashboards/project/routers/tests.py
index ae2c271..2f60aed 100644
--- a/openstack_dashboard/dashboards/project/routers/tests.py
+++ b/openstack_dashboard/dashboards/project/routers/tests.py
@@ -264,7 +264,7 @@ class RouterActionTests(RouterMixin, test.TestCase):
264 api.neutron.network_list(IsA(http.HttpRequest))\ 264 api.neutron.network_list(IsA(http.HttpRequest))\
265 .AndReturn(self.networks.list()) 265 .AndReturn(self.networks.list())
266 params = {'name': router.name, 266 params = {'name': router.name,
267 'admin_state_up': str(router.admin_state_up)} 267 'admin_state_up': router.admin_state_up}
268 api.neutron.router_create(IsA(http.HttpRequest), **params)\ 268 api.neutron.router_create(IsA(http.HttpRequest), **params)\
269 .AndReturn(router) 269 .AndReturn(router)
270 270
@@ -291,7 +291,7 @@ class RouterActionTests(RouterMixin, test.TestCase):
291 api.neutron.network_list(IsA(http.HttpRequest))\ 291 api.neutron.network_list(IsA(http.HttpRequest))\
292 .AndReturn(self.networks.list()) 292 .AndReturn(self.networks.list())
293 params = {'name': router.name, 293 params = {'name': router.name,
294 'admin_state_up': str(router.admin_state_up)} 294 'admin_state_up': router.admin_state_up}
295 api.neutron.router_create(IsA(http.HttpRequest), **params)\ 295 api.neutron.router_create(IsA(http.HttpRequest), **params)\
296 .AndReturn(router) 296 .AndReturn(router)
297 297
@@ -322,7 +322,7 @@ class RouterActionTests(RouterMixin, test.TestCase):
322 param = {'name': router.name, 322 param = {'name': router.name,
323 'distributed': True, 323 'distributed': True,
324 'ha': True, 324 'ha': True,
325 'admin_state_up': str(router.admin_state_up)} 325 'admin_state_up': router.admin_state_up}
326 api.neutron.router_create(IsA(http.HttpRequest), **param)\ 326 api.neutron.router_create(IsA(http.HttpRequest), **param)\
327 .AndReturn(router) 327 .AndReturn(router)
328 328
@@ -352,7 +352,7 @@ class RouterActionTests(RouterMixin, test.TestCase):
352 api.neutron.network_list(IsA(http.HttpRequest))\ 352 api.neutron.network_list(IsA(http.HttpRequest))\
353 .MultipleTimes().AndReturn(self.networks.list()) 353 .MultipleTimes().AndReturn(self.networks.list())
354 params = {'name': router.name, 354 params = {'name': router.name,
355 'admin_state_up': str(router.admin_state_up)} 355 'admin_state_up': router.admin_state_up}
356 api.neutron.router_create(IsA(http.HttpRequest), **params)\ 356 api.neutron.router_create(IsA(http.HttpRequest), **params)\
357 .AndRaise(self.exceptions.neutron) 357 .AndRaise(self.exceptions.neutron)
358 self.mox.ReplayAll() 358 self.mox.ReplayAll()
@@ -380,7 +380,7 @@ class RouterActionTests(RouterMixin, test.TestCase):
380 api.neutron.network_list(IsA(http.HttpRequest))\ 380 api.neutron.network_list(IsA(http.HttpRequest))\
381 .MultipleTimes().AndReturn(self.networks.list()) 381 .MultipleTimes().AndReturn(self.networks.list())
382 params = {'name': router.name, 382 params = {'name': router.name,
383 'admin_state_up': str(router.admin_state_up)} 383 'admin_state_up': router.admin_state_up}
384 api.neutron.router_create(IsA(http.HttpRequest), **params)\ 384 api.neutron.router_create(IsA(http.HttpRequest), **params)\
385 .AndRaise(self.exceptions.neutron) 385 .AndRaise(self.exceptions.neutron)
386 self.mox.ReplayAll() 386 self.mox.ReplayAll()
diff --git a/openstack_dashboard/dashboards/project/vpn/forms.py b/openstack_dashboard/dashboards/project/vpn/forms.py
index 1ada5d8..e7b126f 100644
--- a/openstack_dashboard/dashboards/project/vpn/forms.py
+++ b/openstack_dashboard/dashboards/project/vpn/forms.py
@@ -34,15 +34,12 @@ class UpdateVPNService(forms.SelfHandlingForm):
34 widget=forms.TextInput(attrs={'readonly': 'readonly'})) 34 widget=forms.TextInput(attrs={'readonly': 'readonly'}))
35 description = forms.CharField( 35 description = forms.CharField(
36 required=False, max_length=80, label=_("Description")) 36 required=False, max_length=80, label=_("Description"))
37 admin_state_up = forms.ChoiceField(choices=[(True, _('UP')), 37 admin_state_up = forms.BooleanField(label=_("Enable Admin State"),
38 (False, _('DOWN'))], 38 required=False)
39 label=_("Admin State"),
40 required=False)
41 39
42 failure_url = 'horizon:project:vpn:index' 40 failure_url = 'horizon:project:vpn:index'
43 41
44 def handle(self, request, context): 42 def handle(self, request, context):
45 context['admin_state_up'] = (context['admin_state_up'] == 'True')
46 try: 43 try:
47 data = {'vpnservice': {'name': context['name'], 44 data = {'vpnservice': {'name': context['name'],
48 'description': context['description'], 45 'description': context['description'],
@@ -279,10 +276,8 @@ class UpdateIPSecSiteConnection(forms.SelfHandlingForm):
279 required=False, 276 required=False,
280 choices=[('bi-directional', _('bi-directional')), 277 choices=[('bi-directional', _('bi-directional')),
281 ('response-only', _('response-only'))]) 278 ('response-only', _('response-only'))])
282 admin_state_up = forms.ChoiceField(choices=[(True, _('UP')), 279 admin_state_up = forms.BooleanField(label=_("Enable Admin State"),
283 (False, _('DOWN'))], 280 required=False)
284 label=_("Admin State"),
285 required=False)
286 281
287 failure_url = 'horizon:project:vpn:index' 282 failure_url = 'horizon:project:vpn:index'
288 283
@@ -297,7 +292,6 @@ class UpdateIPSecSiteConnection(forms.SelfHandlingForm):
297 return cleaned_data 292 return cleaned_data
298 293
299 def handle(self, request, context): 294 def handle(self, request, context):
300 context['admin_state_up'] = (context['admin_state_up'] == 'True')
301 try: 295 try:
302 data = {'ipsec_site_connection': 296 data = {'ipsec_site_connection':
303 {'name': context['name'], 297 {'name': context['name'],
diff --git a/openstack_dashboard/dashboards/project/vpn/templates/vpn/_add_vpn_service_help.html b/openstack_dashboard/dashboards/project/vpn/templates/vpn/_add_vpn_service_help.html
index 3ce676b..4d682dc 100644
--- a/openstack_dashboard/dashboards/project/vpn/templates/vpn/_add_vpn_service_help.html
+++ b/openstack_dashboard/dashboards/project/vpn/templates/vpn/_add_vpn_service_help.html
@@ -3,5 +3,5 @@
3<p>{% trans "Create VPN service for current project." %}</p> 3<p>{% trans "Create VPN service for current project." %}</p>
4<p>{% trans "The VPN service is attached to a router and references to a single subnet to push to a remote site." %}</p> 4<p>{% trans "The VPN service is attached to a router and references to a single subnet to push to a remote site." %}</p>
5<p>{% trans "Specify a name, description, router, and subnet for the VPN Service." %}</p> 5<p>{% trans "Specify a name, description, router, and subnet for the VPN Service." %}</p>
6<p>{% trans "Admin State is UP (True) by default." %}</p> 6<p>{% trans "Admin State is enabled by default." %}</p>
7<p>{% trans "The router, subnet and admin state fields are required. All others are optional." %} </p> 7<p>{% trans "The router, subnet and admin state fields require to be enabled. All others are optional." %} </p>
diff --git a/openstack_dashboard/dashboards/project/vpn/workflows.py b/openstack_dashboard/dashboards/project/vpn/workflows.py
index f8b52aa..699089e 100644
--- a/openstack_dashboard/dashboards/project/vpn/workflows.py
+++ b/openstack_dashboard/dashboards/project/vpn/workflows.py
@@ -28,11 +28,11 @@ class AddVPNServiceAction(workflows.Action):
28 max_length=80, label=_("Description")) 28 max_length=80, label=_("Description"))
29 router_id = forms.ChoiceField(label=_("Router")) 29 router_id = forms.ChoiceField(label=_("Router"))
30 subnet_id = forms.ChoiceField(label=_("Subnet")) 30 subnet_id = forms.ChoiceField(label=_("Subnet"))
31 admin_state_up = forms.ChoiceField( 31 admin_state_up = forms.BooleanField(
32 choices=[(True, _('UP')), (False, _('DOWN'))], 32 label=_("Enable Admin State"),
33 label=_("Admin State"), 33 help_text=_("The state of VPN service to start in. If disabled "
34 help_text=_("The state of VPN service to start in. " 34 "(not checked), VPN service does not forward packets."),
35 "If DOWN (False) VPN service does not forward packets."), 35 initial=True,
36 required=False) 36 required=False)
37 37
38 def __init__(self, request, *args, **kwargs): 38 def __init__(self, request, *args, **kwargs):
@@ -426,13 +426,13 @@ class AddIPSecSiteConnectionOptionalAction(workflows.Action):
426 required=False, 426 required=False,
427 help_text=_("Valid integer greater than the DPD interval")) 427 help_text=_("Valid integer greater than the DPD interval"))
428 initiator = forms.ChoiceField(label=_("Initiator state"), required=False) 428 initiator = forms.ChoiceField(label=_("Initiator state"), required=False)
429 admin_state_up = forms.ChoiceField( 429 admin_state_up = forms.BooleanField(
430 choices=[(True, _('UP')), (False, _('DOWN'))], 430 label=_("Enable Admin State"),
431 label=_("Admin State"),
432 required=False,
433 help_text=_("The state of IPSec site connection to start in. " 431 help_text=_("The state of IPSec site connection to start in. "
434 "If DOWN (False), IPSec site connection " 432 "If disabled (not checked), IPSec site connection "
435 "does not forward packets.")) 433 "does not forward packets."),
434 initial=True,
435 required=False)
436 436
437 def __init__(self, request, *args, **kwargs): 437 def __init__(self, request, *args, **kwargs):
438 super(AddIPSecSiteConnectionOptionalAction, self).__init__( 438 super(AddIPSecSiteConnectionOptionalAction, self).__init__(