summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYing Zuo <yinzuo@cisco.com>2017-08-17 19:46:02 -0700
committerYing Zuo <yinzuo@cisco.com>2017-09-21 19:49:02 -0700
commita4aed76ab976ebfe83bf9bfeddee8fb28534296a (patch)
tree8f87110ea7a2a010e3866b48f2c8ffaf9fd3ab8d
parent20eaa031740521dbf23cd9bd6e007ee78be70ba4 (diff)
Include add subnet action on admin networks panel
Currently users can only add and delete networks on admin networks panel. This patch adds the add subnet action to the admin networks panel so it is consistent with the project networks panel. Change-Id: I84e2d51baa4d2adb81ca3fd36e35063a69097326 Closes-bug: #1710723
Notes
Notes (review): Code-Review+2: Akihiro Motoki <amotoki@gmail.com> Workflow+1: Akihiro Motoki <amotoki@gmail.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Fri, 22 Sep 2017 04:10:28 +0000 Reviewed-on: https://review.openstack.org/494773 Project: openstack/horizon Branch: refs/heads/master
-rw-r--r--openstack_dashboard/dashboards/admin/networks/subnets/tests.py14
-rw-r--r--openstack_dashboard/dashboards/admin/networks/tables.py6
-rw-r--r--openstack_dashboard/dashboards/admin/networks/tests.py56
3 files changed, 61 insertions, 15 deletions
diff --git a/openstack_dashboard/dashboards/admin/networks/subnets/tests.py b/openstack_dashboard/dashboards/admin/networks/subnets/tests.py
index ad4a10a..a16f4e9 100644
--- a/openstack_dashboard/dashboards/admin/networks/subnets/tests.py
+++ b/openstack_dashboard/dashboards/admin/networks/subnets/tests.py
@@ -22,6 +22,7 @@ from horizon.workflows import views
22from openstack_dashboard import api 22from openstack_dashboard import api
23from openstack_dashboard.dashboards.project.networks import tests 23from openstack_dashboard.dashboards.project.networks import tests
24from openstack_dashboard.test import helpers as test 24from openstack_dashboard.test import helpers as test
25from openstack_dashboard.usage import quotas
25 26
26DETAIL_URL = 'horizon:admin:networks:subnets:detail' 27DETAIL_URL = 'horizon:admin:networks:subnets:detail'
27 28
@@ -308,7 +309,8 @@ class NetworkSubnetTests(test.BaseAdminViewTests):
308 'port_list', 309 'port_list',
309 'is_extension_supported', 310 'is_extension_supported',
310 'show_network_ip_availability', 311 'show_network_ip_availability',
311 'list_dhcp_agent_hosting_networks',)}) 312 'list_dhcp_agent_hosting_networks',),
313 quotas: ('tenant_quota_usages',)})
312 def test_subnet_delete_with_mac_learning(self): 314 def test_subnet_delete_with_mac_learning(self):
313 self._test_subnet_delete(mac_learning=True) 315 self._test_subnet_delete(mac_learning=True)
314 316
@@ -390,7 +392,8 @@ class NetworkSubnetTests(test.BaseAdminViewTests):
390 'port_list', 392 'port_list',
391 'is_extension_supported', 393 'is_extension_supported',
392 'show_network_ip_availability', 394 'show_network_ip_availability',
393 'list_dhcp_agent_hosting_networks',)}) 395 'list_dhcp_agent_hosting_networks',),
396 quotas: ('tenant_quota_usages',)})
394 def test_network_detail_ip_availability_exception(self): 397 def test_network_detail_ip_availability_exception(self):
395 self._test_network_detail_ip_availability_exception() 398 self._test_network_detail_ip_availability_exception()
396 399
@@ -399,13 +402,15 @@ class NetworkSubnetTests(test.BaseAdminViewTests):
399 'port_list', 402 'port_list',
400 'is_extension_supported', 403 'is_extension_supported',
401 'show_network_ip_availability', 404 'show_network_ip_availability',
402 'list_dhcp_agent_hosting_networks',)}) 405 'list_dhcp_agent_hosting_networks',),
406 quotas: ('tenant_quota_usages',)})
403 def test_network_detail_ip_availability_exception_with_mac_learning(self): 407 def test_network_detail_ip_availability_exception_with_mac_learning(self):
404 self._test_network_detail_ip_availability_exception(mac_learning=True) 408 self._test_network_detail_ip_availability_exception(mac_learning=True)
405 409
406 def _test_network_detail_ip_availability_exception(self, 410 def _test_network_detail_ip_availability_exception(self,
407 mac_learning=False): 411 mac_learning=False):
408 network_id = self.networks.first().id 412 network_id = self.networks.first().id
413 quota_data = self.quota_usages.first()
409 api.neutron.is_extension_supported( 414 api.neutron.is_extension_supported(
410 IsA(http.HttpRequest), 415 IsA(http.HttpRequest),
411 'network-ip-availability').AndReturn(True) 416 'network-ip-availability').AndReturn(True)
@@ -426,6 +431,9 @@ class NetworkSubnetTests(test.BaseAdminViewTests):
426 api.neutron.is_extension_supported(IsA(http.HttpRequest), 431 api.neutron.is_extension_supported(IsA(http.HttpRequest),
427 'dhcp_agent_scheduler')\ 432 'dhcp_agent_scheduler')\
428 .MultipleTimes().AndReturn(True) 433 .MultipleTimes().AndReturn(True)
434 quotas.tenant_quota_usages(
435 IsA(http.HttpRequest), targets=('subnets',)) \
436 .MultipleTimes().AndReturn(quota_data)
429 self.mox.ReplayAll() 437 self.mox.ReplayAll()
430 from django.utils.http import urlunquote 438 from django.utils.http import urlunquote
431 url = urlunquote(reverse('horizon:admin:networks:subnets_tab', 439 url = urlunquote(reverse('horizon:admin:networks:subnets_tab',
diff --git a/openstack_dashboard/dashboards/admin/networks/tables.py b/openstack_dashboard/dashboards/admin/networks/tables.py
index fc35703..b0a649b 100644
--- a/openstack_dashboard/dashboards/admin/networks/tables.py
+++ b/openstack_dashboard/dashboards/admin/networks/tables.py
@@ -79,6 +79,10 @@ class EditNetwork(policy.PolicyTargetMixin, tables.LinkAction):
79 policy_rules = (("network", "update_network"),) 79 policy_rules = (("network", "update_network"),)
80 80
81 81
82class CreateSubnet(project_tables.CreateSubnet):
83 url = "horizon:admin:networks:createsubnet"
84
85
82DISPLAY_CHOICES = ( 86DISPLAY_CHOICES = (
83 ("up", pgettext_lazy("Admin state of a Network", u"UP")), 87 ("up", pgettext_lazy("Admin state of a Network", u"UP")),
84 ("down", pgettext_lazy("Admin state of a Network", u"DOWN")), 88 ("down", pgettext_lazy("Admin state of a Network", u"DOWN")),
@@ -119,7 +123,7 @@ class NetworksTable(tables.DataTable):
119 verbose_name = _("Networks") 123 verbose_name = _("Networks")
120 table_actions = (CreateNetwork, DeleteNetwork, 124 table_actions = (CreateNetwork, DeleteNetwork,
121 AdminNetworksFilterAction) 125 AdminNetworksFilterAction)
122 row_actions = (EditNetwork, DeleteNetwork) 126 row_actions = (EditNetwork, CreateSubnet, DeleteNetwork)
123 127
124 def __init__(self, request, data=None, needs_form_wrapper=None, **kwargs): 128 def __init__(self, request, data=None, needs_form_wrapper=None, **kwargs):
125 super(NetworksTable, self).__init__( 129 super(NetworksTable, self).__init__(
diff --git a/openstack_dashboard/dashboards/admin/networks/tests.py b/openstack_dashboard/dashboards/admin/networks/tests.py
index 962cfbf..a29c7f7 100644
--- a/openstack_dashboard/dashboards/admin/networks/tests.py
+++ b/openstack_dashboard/dashboards/admin/networks/tests.py
@@ -34,9 +34,11 @@ class NetworkTests(test.BaseAdminViewTests):
34 @test.create_stubs({api.neutron: ('network_list', 34 @test.create_stubs({api.neutron: ('network_list',
35 'list_dhcp_agent_hosting_networks', 35 'list_dhcp_agent_hosting_networks',
36 'is_extension_supported'), 36 'is_extension_supported'),
37 api.keystone: ('tenant_list',)}) 37 api.keystone: ('tenant_list',),
38 usage.quotas: ('tenant_quota_usages',)})
38 def test_index(self): 39 def test_index(self):
39 tenants = self.tenants.list() 40 tenants = self.tenants.list()
41 quota_data = self.quota_usages.first()
40 api.neutron.network_list(IsA(http.HttpRequest)) \ 42 api.neutron.network_list(IsA(http.HttpRequest)) \
41 .AndReturn(self.networks.list()) 43 .AndReturn(self.networks.list())
42 api.keystone.tenant_list(IsA(http.HttpRequest))\ 44 api.keystone.tenant_list(IsA(http.HttpRequest))\
@@ -52,6 +54,9 @@ class NetworkTests(test.BaseAdminViewTests):
52 api.neutron.is_extension_supported( 54 api.neutron.is_extension_supported(
53 IsA(http.HttpRequest), 55 IsA(http.HttpRequest),
54 'dhcp_agent_scheduler').AndReturn(True) 56 'dhcp_agent_scheduler').AndReturn(True)
57 usage.quotas.tenant_quota_usages(
58 IsA(http.HttpRequest), targets=('subnets', )) \
59 .MultipleTimes().AndReturn(quota_data)
55 self.mox.ReplayAll() 60 self.mox.ReplayAll()
56 61
57 res = self.client.get(INDEX_URL) 62 res = self.client.get(INDEX_URL)
@@ -82,7 +87,8 @@ class NetworkTests(test.BaseAdminViewTests):
82 'port_list', 87 'port_list',
83 'show_network_ip_availability', 88 'show_network_ip_availability',
84 'list_dhcp_agent_hosting_networks', 89 'list_dhcp_agent_hosting_networks',
85 'is_extension_supported')}) 90 'is_extension_supported'),
91 usage.quotas: ('tenant_quota_usages',)})
86 def test_network_detail_subnets_tab(self): 92 def test_network_detail_subnets_tab(self):
87 self._test_network_detail_subnets_tab() 93 self._test_network_detail_subnets_tab()
88 94
@@ -91,14 +97,17 @@ class NetworkTests(test.BaseAdminViewTests):
91 'port_list', 97 'port_list',
92 'is_extension_supported', 98 'is_extension_supported',
93 'show_network_ip_availability', 99 'show_network_ip_availability',
94 'list_dhcp_agent_hosting_networks',)}) 100 'list_dhcp_agent_hosting_networks',),
101 usage.quotas: ('tenant_quota_usages',)})
95 def test_network_detail_subnets_tab_with_mac_learning(self): 102 def test_network_detail_subnets_tab_with_mac_learning(self):
96 self._test_network_detail_subnets_tab(mac_learning=True) 103 self._test_network_detail_subnets_tab(mac_learning=True)
97 104
98 @test.create_stubs({api.neutron: ('network_get', 105 @test.create_stubs({api.neutron: ('network_get',
99 'is_extension_supported')}) 106 'is_extension_supported'),
107 usage.quotas: ('tenant_quota_usages',)})
100 def test_network_detail_new(self, mac_learning=False): 108 def test_network_detail_new(self, mac_learning=False):
101 network_id = self.networks.first().id 109 network_id = self.networks.first().id
110 quota_data = self.quota_usages.first()
102 api.neutron.network_get(IsA(http.HttpRequest), network_id) \ 111 api.neutron.network_get(IsA(http.HttpRequest), network_id) \
103 .MultipleTimes().AndReturn(self.networks.first()) 112 .MultipleTimes().AndReturn(self.networks.first())
104 api.neutron.is_extension_supported(IsA(http.HttpRequest), 113 api.neutron.is_extension_supported(IsA(http.HttpRequest),
@@ -111,6 +120,9 @@ class NetworkTests(test.BaseAdminViewTests):
111 api.neutron.is_extension_supported( 120 api.neutron.is_extension_supported(
112 IsA(http.HttpRequest), 121 IsA(http.HttpRequest),
113 'dhcp_agent_scheduler').AndReturn(True) 122 'dhcp_agent_scheduler').AndReturn(True)
123 usage.quotas.tenant_quota_usages(
124 IsA(http.HttpRequest), targets=('subnets',)) \
125 .MultipleTimes().AndReturn(quota_data)
114 self.mox.ReplayAll() 126 self.mox.ReplayAll()
115 url = urlunquote(reverse('horizon:admin:networks:detail', 127 url = urlunquote(reverse('horizon:admin:networks:detail',
116 args=[network_id])) 128 args=[network_id]))
@@ -125,6 +137,7 @@ class NetworkTests(test.BaseAdminViewTests):
125 def _test_network_detail_subnets_tab(self, mac_learning=False): 137 def _test_network_detail_subnets_tab(self, mac_learning=False):
126 network_id = self.networks.first().id 138 network_id = self.networks.first().id
127 ip_availability = self.ip_availability.get() 139 ip_availability = self.ip_availability.get()
140 quota_data = self.quota_usages.first()
128 api.neutron.show_network_ip_availability(IsA(http.HttpRequest), 141 api.neutron.show_network_ip_availability(IsA(http.HttpRequest),
129 network_id).\ 142 network_id).\
130 MultipleTimes().AndReturn(ip_availability) 143 MultipleTimes().AndReturn(ip_availability)
@@ -145,6 +158,9 @@ class NetworkTests(test.BaseAdminViewTests):
145 api.neutron.is_extension_supported( 158 api.neutron.is_extension_supported(
146 IsA(http.HttpRequest), 159 IsA(http.HttpRequest),
147 'dhcp_agent_scheduler').AndReturn(True) 160 'dhcp_agent_scheduler').AndReturn(True)
161 usage.quotas.tenant_quota_usages(
162 IsA(http.HttpRequest), targets=('subnets',)) \
163 .MultipleTimes().AndReturn(quota_data)
148 self.mox.ReplayAll() 164 self.mox.ReplayAll()
149 url = urlunquote(reverse('horizon:admin:networks:subnets_tab', 165 url = urlunquote(reverse('horizon:admin:networks:subnets_tab',
150 args=[network_id])) 166 args=[network_id]))
@@ -179,6 +195,9 @@ class NetworkTests(test.BaseAdminViewTests):
179 api.neutron.is_extension_supported( 195 api.neutron.is_extension_supported(
180 IsA(http.HttpRequest), 196 IsA(http.HttpRequest),
181 'dhcp_agent_scheduler').AndReturn(True) 197 'dhcp_agent_scheduler').AndReturn(True)
198 usage.quotas.tenant_quota_usages(
199 IsA(http.HttpRequest), targets=('subnets',)) \
200 .MultipleTimes().AndReturn(quota_data)
182 201
183 self.mox.ReplayAll() 202 self.mox.ReplayAll()
184 url = reverse('horizon:admin:networks:ports_tab', 203 url = reverse('horizon:admin:networks:ports_tab',
@@ -193,9 +212,11 @@ class NetworkTests(test.BaseAdminViewTests):
193 'subnet_list', 212 'subnet_list',
194 'port_list', 213 'port_list',
195 'is_extension_supported', 214 'is_extension_supported',
196 'list_dhcp_agent_hosting_networks',)}) 215 'list_dhcp_agent_hosting_networks',),
216 usage.quotas: ('tenant_quota_usages',)})
197 def test_network_detail_agents_tab(self, mac_learning=False): 217 def test_network_detail_agents_tab(self, mac_learning=False):
198 network_id = self.networks.first().id 218 network_id = self.networks.first().id
219 quota_data = self.quota_usages.first()
199 api.neutron.is_extension_supported(IsA(http.HttpRequest), 220 api.neutron.is_extension_supported(IsA(http.HttpRequest),
200 'network-ip-availability') \ 221 'network-ip-availability') \
201 .AndReturn(True) 222 .AndReturn(True)
@@ -214,6 +235,9 @@ class NetworkTests(test.BaseAdminViewTests):
214 api.neutron.is_extension_supported( 235 api.neutron.is_extension_supported(
215 IsA(http.HttpRequest), 236 IsA(http.HttpRequest),
216 'dhcp_agent_scheduler').AndReturn(True) 237 'dhcp_agent_scheduler').AndReturn(True)
238 usage.quotas.tenant_quota_usages(
239 IsA(http.HttpRequest), targets=('subnets', )) \
240 .MultipleTimes().AndReturn(quota_data)
217 self.mox.ReplayAll() 241 self.mox.ReplayAll()
218 url = reverse('horizon:admin:networks:agents_tab', args=[network_id]) 242 url = reverse('horizon:admin:networks:agents_tab', args=[network_id])
219 res = self.client.get(urlunquote(url)) 243 res = self.client.get(urlunquote(url))
@@ -277,7 +301,8 @@ class NetworkTests(test.BaseAdminViewTests):
277 'subnet_list', 301 'subnet_list',
278 'port_list', 302 'port_list',
279 'list_dhcp_agent_hosting_networks', 303 'list_dhcp_agent_hosting_networks',
280 'is_extension_supported')}) 304 'is_extension_supported'),
305 usage.quotas: ('tenant_quota_usages',)})
281 def test_network_detail_subnets_tab_subnet_exception(self): 306 def test_network_detail_subnets_tab_subnet_exception(self):
282 self._test_network_detail_subnets_tab_subnet_exception() 307 self._test_network_detail_subnets_tab_subnet_exception()
283 308
@@ -285,7 +310,8 @@ class NetworkTests(test.BaseAdminViewTests):
285 'subnet_list', 310 'subnet_list',
286 'port_list', 311 'port_list',
287 'is_extension_supported', 312 'is_extension_supported',
288 'list_dhcp_agent_hosting_networks',)}) 313 'list_dhcp_agent_hosting_networks',),
314 usage.quotas: ('tenant_quota_usages',)})
289 def test_network_detail_subnets_tab_subnet_exception_w_mac_learning(self): 315 def test_network_detail_subnets_tab_subnet_exception_w_mac_learning(self):
290 self._test_network_detail_subnets_tab_subnet_exception( 316 self._test_network_detail_subnets_tab_subnet_exception(
291 mac_learning=True) 317 mac_learning=True)
@@ -293,6 +319,7 @@ class NetworkTests(test.BaseAdminViewTests):
293 def _test_network_detail_subnets_tab_subnet_exception(self, 319 def _test_network_detail_subnets_tab_subnet_exception(self,
294 mac_learning=False): 320 mac_learning=False):
295 network_id = self.networks.first().id 321 network_id = self.networks.first().id
322 quota_data = self.quota_usages.first()
296 api.neutron.network_get(IsA(http.HttpRequest), network_id).\ 323 api.neutron.network_get(IsA(http.HttpRequest), network_id).\
297 AndReturn(self.networks.first()) 324 AndReturn(self.networks.first())
298 api.neutron.subnet_list(IsA(http.HttpRequest), network_id=network_id).\ 325 api.neutron.subnet_list(IsA(http.HttpRequest), network_id=network_id).\
@@ -309,7 +336,9 @@ class NetworkTests(test.BaseAdminViewTests):
309 api.neutron.is_extension_supported( 336 api.neutron.is_extension_supported(
310 IsA(http.HttpRequest), 337 IsA(http.HttpRequest),
311 'dhcp_agent_scheduler').AndReturn(True) 338 'dhcp_agent_scheduler').AndReturn(True)
312 339 usage.quotas.tenant_quota_usages(
340 IsA(http.HttpRequest), targets=('subnets',)) \
341 .MultipleTimes().AndReturn(quota_data)
313 self.mox.ReplayAll() 342 self.mox.ReplayAll()
314 url = urlunquote(reverse('horizon:admin:networks:subnets_tab', 343 url = urlunquote(reverse('horizon:admin:networks:subnets_tab',
315 args=[network_id])) 344 args=[network_id]))
@@ -324,7 +353,8 @@ class NetworkTests(test.BaseAdminViewTests):
324 'port_list', 353 'port_list',
325 'is_extension_supported', 354 'is_extension_supported',
326 'show_network_ip_availability', 355 'show_network_ip_availability',
327 'list_dhcp_agent_hosting_networks',)}) 356 'list_dhcp_agent_hosting_networks',),
357 usage.quotas: ('tenant_quota_usages',)})
328 def test_network_detail_port_exception(self): 358 def test_network_detail_port_exception(self):
329 self._test_network_detail_subnets_tab_port_exception() 359 self._test_network_detail_subnets_tab_port_exception()
330 360
@@ -333,7 +363,8 @@ class NetworkTests(test.BaseAdminViewTests):
333 'port_list', 363 'port_list',
334 'is_extension_supported', 364 'is_extension_supported',
335 'show_network_ip_availability', 365 'show_network_ip_availability',
336 'list_dhcp_agent_hosting_networks',)}) 366 'list_dhcp_agent_hosting_networks',),
367 usage.quotas: ('tenant_quota_usages',)})
337 def test_network_detail_subnets_tab_port_exception_with_mac_learning(self): 368 def test_network_detail_subnets_tab_port_exception_with_mac_learning(self):
338 self._test_network_detail_subnets_tab_port_exception(mac_learning=True) 369 self._test_network_detail_subnets_tab_port_exception(mac_learning=True)
339 370
@@ -341,6 +372,7 @@ class NetworkTests(test.BaseAdminViewTests):
341 mac_learning=False): 372 mac_learning=False):
342 network_id = self.networks.first().id 373 network_id = self.networks.first().id
343 ip_availability = self.ip_availability.get() 374 ip_availability = self.ip_availability.get()
375 quota_data = self.quota_usages.first()
344 api.neutron.show_network_ip_availability(IsA(http.HttpRequest), 376 api.neutron.show_network_ip_availability(IsA(http.HttpRequest),
345 network_id). \ 377 network_id). \
346 MultipleTimes().AndReturn(ip_availability) 378 MultipleTimes().AndReturn(ip_availability)
@@ -360,7 +392,9 @@ class NetworkTests(test.BaseAdminViewTests):
360 api.neutron.is_extension_supported(IsA(http.HttpRequest), 392 api.neutron.is_extension_supported(IsA(http.HttpRequest),
361 'dhcp_agent_scheduler')\ 393 'dhcp_agent_scheduler')\
362 .AndReturn(True) 394 .AndReturn(True)
363 395 usage.quotas.tenant_quota_usages(
396 IsA(http.HttpRequest), targets=('subnets',)) \
397 .MultipleTimes().AndReturn(quota_data)
364 self.mox.ReplayAll() 398 self.mox.ReplayAll()
365 url = urlunquote(reverse('horizon:admin:networks:subnets_tab', 399 url = urlunquote(reverse('horizon:admin:networks:subnets_tab',
366 args=[network_id])) 400 args=[network_id]))