Admin State is always UP whatever whether router Admin State is checked or not

On the project creation router page, if we don't check "Enable Admin
State" option, when the router is created, "Admin State" is displayed
as UP. This inconsistency is because the judgment condition of [1]
doesn't hold which causes the "admin_state_up" parameter not to be
passed by the call creation router interface. In this case, the
back-end defaults to "admin_state_up" to be UP.

Since the router "Enable Admin State" option has an initial value of
True, there is no need to check for [1].

[1] https://github.com/openstack/horizon/blob/master/openstack_dashboard/dashboards/project/routers/forms.py#L121

Change-Id: I6b95ffa680eab5c29d2bca6c91fc7f028f7f519a
Closes-Bug:#1748777
This commit is contained in:
wei.ying 2018-02-12 01:44:26 +08:00
parent 0039183879
commit 0cb96af3a2
2 changed files with 37 additions and 3 deletions

View File

@ -117,9 +117,8 @@ class CreateForm(forms.SelfHandlingForm):
def handle(self, request, data):
try:
params = {'name': data['name']}
if 'admin_state_up' in data and data['admin_state_up']:
params['admin_state_up'] = data['admin_state_up']
params = {'name': data['name'],
'admin_state_up': data['admin_state_up']}
if 'external_network' in data and data['external_network']:
params['external_gateway_info'] = {'network_id':
data['external_network']}

View File

@ -432,6 +432,41 @@ class RouterActionTests(RouterMixin, test.TestCase):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, self.INDEX_URL)
@test.create_stubs({api.neutron: ('router_create',
'get_feature_permission',
'network_list',
'is_extension_supported')})
def test_router_create_post_with_admin_state_up(self):
router = self.routers.first()
api.neutron.get_feature_permission(IsA(http.HttpRequest),
"ext-gw-mode",
"create_router_enable_snat")\
.AndReturn(False)
api.neutron.get_feature_permission(IsA(http.HttpRequest),
"dvr", "create")\
.MultipleTimes().AndReturn(False)
api.neutron.get_feature_permission(IsA(http.HttpRequest),
"l3-ha", "create")\
.MultipleTimes().AndReturn(False)
api.neutron.network_list(IsA(http.HttpRequest))\
.AndReturn(self.networks.list())
api.neutron.is_extension_supported(IsA(http.HttpRequest),
"router_availability_zone")\
.AndReturn(False)
param = {'name': router.name,
'admin_state_up': False}
api.neutron.router_create(IsA(http.HttpRequest), **param)\
.AndReturn(router)
self.mox.ReplayAll()
form_data = {'name': router.name,
'admin_state_up': False}
url = reverse('horizon:%s:routers:create' % self.DASHBOARD)
res = self.client.post(url, form_data)
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, self.INDEX_URL)
@test.create_stubs({api.neutron: ('router_create',
'get_feature_permission',
'network_list',