summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Vea <trygve.vea@gmail.com>2017-10-21 11:36:29 +0000
committerTrygve Vea <trygve.vea@gmail.com>2017-10-23 12:29:35 +0000
commit2949a9800f59b00c90a0eba23700a2adc5541ee3 (patch)
tree7b98d7d140c06d01675c36d09b7c911bfee79cb0
parentcb6fcc1d7a4d1436a791805178c0b0a1f41a17d7 (diff)
Implement network availability zone column in network list
If the 'network_availability_zone'-extension is enabled, this patch adds a column in the Networks-table named 'Availability Zones'. Change-Id: Iea2bac351b922a0d267c4a55e0d74f6c2639d967 Partial-Bug: #1725617
Notes
Notes (review): Code-Review+2: Akihiro Motoki <amotoki@gmail.com> Workflow+1: Akihiro Motoki <amotoki@gmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 24 Oct 2017 14:41:58 +0000 Reviewed-on: https://review.openstack.org/513920 Project: openstack/horizon Branch: refs/heads/master
-rw-r--r--openstack_dashboard/dashboards/admin/networks/subnets/tests.py3
-rw-r--r--openstack_dashboard/dashboards/admin/networks/tables.py18
-rw-r--r--openstack_dashboard/dashboards/admin/networks/tests.py33
-rw-r--r--openstack_dashboard/dashboards/project/networks/tables.py25
-rw-r--r--openstack_dashboard/dashboards/project/networks/tests.py69
5 files changed, 138 insertions, 10 deletions
diff --git a/openstack_dashboard/dashboards/admin/networks/subnets/tests.py b/openstack_dashboard/dashboards/admin/networks/subnets/tests.py
index 28b1816..14fc63f 100644
--- a/openstack_dashboard/dashboards/admin/networks/subnets/tests.py
+++ b/openstack_dashboard/dashboards/admin/networks/subnets/tests.py
@@ -429,6 +429,9 @@ class NetworkSubnetTests(test.BaseAdminViewTests):
429 IsA(http.HttpRequest), 429 IsA(http.HttpRequest),
430 'network-ip-availability').AndReturn(True) 430 'network-ip-availability').AndReturn(True)
431 api.neutron.is_extension_supported(IsA(http.HttpRequest), 431 api.neutron.is_extension_supported(IsA(http.HttpRequest),
432 'network_availability_zone')\
433 .MultipleTimes().AndReturn(True)
434 api.neutron.is_extension_supported(IsA(http.HttpRequest),
432 'dhcp_agent_scheduler')\ 435 'dhcp_agent_scheduler')\
433 .MultipleTimes().AndReturn(True) 436 .MultipleTimes().AndReturn(True)
434 quotas.tenant_quota_usages( 437 quotas.tenant_quota_usages(
diff --git a/openstack_dashboard/dashboards/admin/networks/tables.py b/openstack_dashboard/dashboards/admin/networks/tables.py
index 50f1505..d7c98ea 100644
--- a/openstack_dashboard/dashboards/admin/networks/tables.py
+++ b/openstack_dashboard/dashboards/admin/networks/tables.py
@@ -106,6 +106,13 @@ DISPLAY_CHOICES = (
106) 106)
107 107
108 108
109def get_availability_zones(network):
110 if 'availability_zones' in network and network.availability_zones:
111 return ', '.join(network.availability_zones)
112 else:
113 return _("-")
114
115
109class AdminNetworksFilterAction(project_tables.ProjectNetworksFilterAction): 116class AdminNetworksFilterAction(project_tables.ProjectNetworksFilterAction):
110 name = "filter_admin_networks" 117 name = "filter_admin_networks"
111 filter_choices = (('project', _("Project ="), True),) +\ 118 filter_choices = (('project', _("Project ="), True),) +\
@@ -131,6 +138,8 @@ class NetworksTable(tables.DataTable):
131 admin_state = tables.Column("admin_state", 138 admin_state = tables.Column("admin_state",
132 verbose_name=_("Admin State"), 139 verbose_name=_("Admin State"),
133 display_choices=DISPLAY_CHOICES) 140 display_choices=DISPLAY_CHOICES)
141 availability_zones = tables.Column(get_availability_zones,
142 verbose_name=_("Availability Zones"))
134 143
135 def get_object_display(self, network): 144 def get_object_display(self, network):
136 return network.name_or_id 145 return network.name_or_id
@@ -148,6 +157,15 @@ class NetworksTable(tables.DataTable):
148 needs_form_wrapper=needs_form_wrapper, 157 needs_form_wrapper=needs_form_wrapper,
149 **kwargs) 158 **kwargs)
150 try: 159 try:
160 if not api.neutron.is_extension_supported(
161 request, "network_availability_zone"):
162 del self.columns["availability_zones"]
163 except Exception:
164 msg = _("Unable to check if network availability zone extension "
165 "is supported")
166 exceptions.handle(self.request, msg)
167 del self.columns['availability_zones']
168 try:
151 if not api.neutron.is_extension_supported(request, 169 if not api.neutron.is_extension_supported(request,
152 'dhcp_agent_scheduler'): 170 'dhcp_agent_scheduler'):
153 del self.columns['num_agents'] 171 del self.columns['num_agents']
diff --git a/openstack_dashboard/dashboards/admin/networks/tests.py b/openstack_dashboard/dashboards/admin/networks/tests.py
index b147e72..f3e4312 100644
--- a/openstack_dashboard/dashboards/admin/networks/tests.py
+++ b/openstack_dashboard/dashboards/admin/networks/tests.py
@@ -43,6 +43,9 @@ class NetworkTests(test.BaseAdminViewTests):
43 .AndReturn(self.networks.list()) 43 .AndReturn(self.networks.list())
44 api.keystone.tenant_list(IsA(http.HttpRequest))\ 44 api.keystone.tenant_list(IsA(http.HttpRequest))\
45 .AndReturn([tenants, False]) 45 .AndReturn([tenants, False])
46 api.neutron.is_extension_supported(
47 IsA(http.HttpRequest),
48 'network_availability_zone').AndReturn(True)
46 for network in self.networks.list(): 49 for network in self.networks.list():
47 usage.quotas.tenant_quota_usages( 50 usage.quotas.tenant_quota_usages(
48 IsA(http.HttpRequest), tenant_id=network.tenant_id, 51 IsA(http.HttpRequest), tenant_id=network.tenant_id,
@@ -72,6 +75,9 @@ class NetworkTests(test.BaseAdminViewTests):
72 .AndRaise(self.exceptions.neutron) 75 .AndRaise(self.exceptions.neutron)
73 api.neutron.is_extension_supported( 76 api.neutron.is_extension_supported(
74 IsA(http.HttpRequest), 77 IsA(http.HttpRequest),
78 'network_availability_zone').AndReturn(True)
79 api.neutron.is_extension_supported(
80 IsA(http.HttpRequest),
75 'dhcp_agent_scheduler').AndReturn(True) 81 'dhcp_agent_scheduler').AndReturn(True)
76 82
77 self.mox.ReplayAll() 83 self.mox.ReplayAll()
@@ -119,6 +125,9 @@ class NetworkTests(test.BaseAdminViewTests):
119 125
120 api.neutron.is_extension_supported( 126 api.neutron.is_extension_supported(
121 IsA(http.HttpRequest), 127 IsA(http.HttpRequest),
128 'network_availability_zone').AndReturn(True)
129 api.neutron.is_extension_supported(
130 IsA(http.HttpRequest),
122 'dhcp_agent_scheduler').AndReturn(True) 131 'dhcp_agent_scheduler').AndReturn(True)
123 usage.quotas.tenant_quota_usages( 132 usage.quotas.tenant_quota_usages(
124 IsA(http.HttpRequest), tenant_id=network.tenant_id, 133 IsA(http.HttpRequest), tenant_id=network.tenant_id,
@@ -157,6 +166,9 @@ class NetworkTests(test.BaseAdminViewTests):
157 'network-ip-availability').AndReturn(True) 166 'network-ip-availability').AndReturn(True)
158 api.neutron.is_extension_supported( 167 api.neutron.is_extension_supported(
159 IsA(http.HttpRequest), 168 IsA(http.HttpRequest),
169 'network_availability_zone').AndReturn(True)
170 api.neutron.is_extension_supported(
171 IsA(http.HttpRequest),
160 'dhcp_agent_scheduler').AndReturn(True) 172 'dhcp_agent_scheduler').AndReturn(True)
161 usage.quotas.tenant_quota_usages( 173 usage.quotas.tenant_quota_usages(
162 IsA(http.HttpRequest), tenant_id=network.tenant_id, 174 IsA(http.HttpRequest), tenant_id=network.tenant_id,
@@ -194,6 +206,9 @@ class NetworkTests(test.BaseAdminViewTests):
194 .AndReturn(mac_learning) 206 .AndReturn(mac_learning)
195 api.neutron.is_extension_supported( 207 api.neutron.is_extension_supported(
196 IsA(http.HttpRequest), 208 IsA(http.HttpRequest),
209 'network_availability_zone').AndReturn(True)
210 api.neutron.is_extension_supported(
211 IsA(http.HttpRequest),
197 'dhcp_agent_scheduler').AndReturn(True) 212 'dhcp_agent_scheduler').AndReturn(True)
198 usage.quotas.tenant_quota_usages( 213 usage.quotas.tenant_quota_usages(
199 IsA(http.HttpRequest), tenant_id=network.tenant_id, 214 IsA(http.HttpRequest), tenant_id=network.tenant_id,
@@ -234,6 +249,9 @@ class NetworkTests(test.BaseAdminViewTests):
234 'dhcp_agent_scheduler').AndReturn(True) 249 'dhcp_agent_scheduler').AndReturn(True)
235 api.neutron.is_extension_supported( 250 api.neutron.is_extension_supported(
236 IsA(http.HttpRequest), 251 IsA(http.HttpRequest),
252 'network_availability_zone').AndReturn(True)
253 api.neutron.is_extension_supported(
254 IsA(http.HttpRequest),
237 'dhcp_agent_scheduler').AndReturn(True) 255 'dhcp_agent_scheduler').AndReturn(True)
238 usage.quotas.tenant_quota_usages( 256 usage.quotas.tenant_quota_usages(
239 IsA(http.HttpRequest), tenant_id=network.tenant_id, 257 IsA(http.HttpRequest), tenant_id=network.tenant_id,
@@ -335,6 +353,9 @@ class NetworkTests(test.BaseAdminViewTests):
335 'dhcp_agent_scheduler').AndReturn(True) 353 'dhcp_agent_scheduler').AndReturn(True)
336 api.neutron.is_extension_supported( 354 api.neutron.is_extension_supported(
337 IsA(http.HttpRequest), 355 IsA(http.HttpRequest),
356 'network_availability_zone').AndReturn(True)
357 api.neutron.is_extension_supported(
358 IsA(http.HttpRequest),
338 'dhcp_agent_scheduler').AndReturn(True) 359 'dhcp_agent_scheduler').AndReturn(True)
339 usage.quotas.tenant_quota_usages( 360 usage.quotas.tenant_quota_usages(
340 IsA(http.HttpRequest), tenant_id=network.tenant_id, 361 IsA(http.HttpRequest), tenant_id=network.tenant_id,
@@ -389,6 +410,9 @@ class NetworkTests(test.BaseAdminViewTests):
389 api.neutron.is_extension_supported( 410 api.neutron.is_extension_supported(
390 IsA(http.HttpRequest), 411 IsA(http.HttpRequest),
391 'network-ip-availability').AndReturn(True) 412 'network-ip-availability').AndReturn(True)
413 api.neutron.is_extension_supported(
414 IsA(http.HttpRequest),
415 'network_availability_zone').AndReturn(True)
392 api.neutron.is_extension_supported(IsA(http.HttpRequest), 416 api.neutron.is_extension_supported(IsA(http.HttpRequest),
393 'dhcp_agent_scheduler')\ 417 'dhcp_agent_scheduler')\
394 .AndReturn(True) 418 .AndReturn(True)
@@ -774,6 +798,9 @@ class NetworkTests(test.BaseAdminViewTests):
774 AndReturn(self.agents.list()) 798 AndReturn(self.agents.list())
775 api.neutron.is_extension_supported( 799 api.neutron.is_extension_supported(
776 IsA(http.HttpRequest), 800 IsA(http.HttpRequest),
801 'network_availability_zone').AndReturn(True)
802 api.neutron.is_extension_supported(
803 IsA(http.HttpRequest),
777 'dhcp_agent_scheduler').AndReturn(True) 804 'dhcp_agent_scheduler').AndReturn(True)
778 api.neutron.is_extension_supported( 805 api.neutron.is_extension_supported(
779 IsA(http.HttpRequest), 806 IsA(http.HttpRequest),
@@ -804,6 +831,9 @@ class NetworkTests(test.BaseAdminViewTests):
804 AndReturn(self.agents.list()) 831 AndReturn(self.agents.list())
805 api.neutron.is_extension_supported( 832 api.neutron.is_extension_supported(
806 IsA(http.HttpRequest), 833 IsA(http.HttpRequest),
834 'network_availability_zone').AndReturn(True)
835 api.neutron.is_extension_supported(
836 IsA(http.HttpRequest),
807 'dhcp_agent_scheduler').AndReturn(True) 837 'dhcp_agent_scheduler').AndReturn(True)
808 api.neutron.is_extension_supported( 838 api.neutron.is_extension_supported(
809 IsA(http.HttpRequest), 839 IsA(http.HttpRequest),
@@ -827,6 +857,9 @@ class NetworkTests(test.BaseAdminViewTests):
827 def test_networks_list_with_admin_filter_first(self): 857 def test_networks_list_with_admin_filter_first(self):
828 api.neutron.is_extension_supported( 858 api.neutron.is_extension_supported(
829 IsA(http.HttpRequest), 859 IsA(http.HttpRequest),
860 'network_availability_zone').AndReturn(True)
861 api.neutron.is_extension_supported(
862 IsA(http.HttpRequest),
830 'dhcp_agent_scheduler').AndReturn(True) 863 'dhcp_agent_scheduler').AndReturn(True)
831 self.mox.ReplayAll() 864 self.mox.ReplayAll()
832 res = self.client.get(reverse('horizon:admin:networks:index')) 865 res = self.client.get(reverse('horizon:admin:networks:index'))
diff --git a/openstack_dashboard/dashboards/project/networks/tables.py b/openstack_dashboard/dashboards/project/networks/tables.py
index b65926c..dbae012 100644
--- a/openstack_dashboard/dashboards/project/networks/tables.py
+++ b/openstack_dashboard/dashboards/project/networks/tables.py
@@ -150,6 +150,13 @@ STATUS_DISPLAY_CHOICES = (
150) 150)
151 151
152 152
153def get_availability_zones(network):
154 if 'availability_zones' in network and network.availability_zones:
155 return ', '.join(network.availability_zones)
156 else:
157 return _("-")
158
159
153class ProjectNetworksFilterAction(tables.FilterAction): 160class ProjectNetworksFilterAction(tables.FilterAction):
154 name = "filter_project_networks" 161 name = "filter_project_networks"
155 filter_type = "server" 162 filter_type = "server"
@@ -178,6 +185,24 @@ class NetworksTable(tables.DataTable):
178 admin_state = tables.Column("admin_state", 185 admin_state = tables.Column("admin_state",
179 verbose_name=_("Admin State"), 186 verbose_name=_("Admin State"),
180 display_choices=DISPLAY_CHOICES) 187 display_choices=DISPLAY_CHOICES)
188 availability_zones = tables.Column(get_availability_zones,
189 verbose_name=_("Availability Zones"))
190
191 def __init__(self, request, data=None, needs_form_wrapper=None, **kwargs):
192 super(NetworksTable, self).__init__(
193 request,
194 data=data,
195 needs_form_wrapper=needs_form_wrapper,
196 **kwargs)
197 try:
198 if not api.neutron.is_extension_supported(
199 request, "network_availability_zone"):
200 del self.columns["availability_zones"]
201 except Exception:
202 msg = _("Unable to check if network availability zone extension "
203 "is supported")
204 exceptions.handle(self.request, msg)
205 del self.columns['availability_zones']
181 206
182 def get_object_display(self, network): 207 def get_object_display(self, network):
183 return network.name_or_id 208 return network.name_or_id
diff --git a/openstack_dashboard/dashboards/project/networks/tests.py b/openstack_dashboard/dashboards/project/networks/tests.py
index da05879..ac097fe 100644
--- a/openstack_dashboard/dashboards/project/networks/tests.py
+++ b/openstack_dashboard/dashboards/project/networks/tests.py
@@ -123,7 +123,8 @@ class NetworkStubMixin(object):
123 123
124class NetworkTests(test.TestCase, NetworkStubMixin): 124class NetworkTests(test.TestCase, NetworkStubMixin):
125 125
126 @test.create_stubs({api.neutron: ('network_list',), 126 @test.create_stubs({api.neutron: ('network_list',
127 'is_extension_supported'),
127 quotas: ('tenant_quota_usages',)}) 128 quotas: ('tenant_quota_usages',)})
128 def test_index(self): 129 def test_index(self):
129 quota_data = self.quota_usages.first() 130 quota_data = self.quota_usages.first()
@@ -136,6 +137,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
136 quotas.tenant_quota_usages( 137 quotas.tenant_quota_usages(
137 IsA(http.HttpRequest), targets=('subnets', )) \ 138 IsA(http.HttpRequest), targets=('subnets', )) \
138 .MultipleTimes().AndReturn(quota_data) 139 .MultipleTimes().AndReturn(quota_data)
140 api.neutron.is_extension_supported(
141 IsA(http.HttpRequest), 'network_availability_zone')\
142 .MultipleTimes().AndReturn(True)
139 143
140 self.mox.ReplayAll() 144 self.mox.ReplayAll()
141 145
@@ -144,7 +148,8 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
144 networks = res.context['networks_table'].data 148 networks = res.context['networks_table'].data
145 self.assertItemsEqual(networks, self.networks.list()) 149 self.assertItemsEqual(networks, self.networks.list())
146 150
147 @test.create_stubs({api.neutron: ('network_list',), 151 @test.create_stubs({api.neutron: ('network_list',
152 'is_extension_supported'),
148 quotas: ('tenant_quota_usages',)}) 153 quotas: ('tenant_quota_usages',)})
149 def test_index_network_list_exception(self): 154 def test_index_network_list_exception(self):
150 quota_data = self.neutron_quota_usages.first() 155 quota_data = self.neutron_quota_usages.first()
@@ -155,6 +160,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
155 quotas.tenant_quota_usages( 160 quotas.tenant_quota_usages(
156 IsA(http.HttpRequest), targets=('networks', )) \ 161 IsA(http.HttpRequest), targets=('networks', )) \
157 .MultipleTimes().AndReturn(quota_data) 162 .MultipleTimes().AndReturn(quota_data)
163 api.neutron.is_extension_supported(
164 IsA(http.HttpRequest), 'network_availability_zone')\
165 .MultipleTimes().AndReturn(True)
158 self.mox.ReplayAll() 166 self.mox.ReplayAll()
159 167
160 res = self.client.get(INDEX_URL) 168 res = self.client.get(INDEX_URL)
@@ -194,6 +202,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
194 quotas.tenant_quota_usages( 202 quotas.tenant_quota_usages(
195 IsA(http.HttpRequest), targets=('subnets', )) \ 203 IsA(http.HttpRequest), targets=('subnets', )) \
196 .MultipleTimes().AndReturn(quota_data) 204 .MultipleTimes().AndReturn(quota_data)
205 api.neutron.is_extension_supported(
206 IsA(http.HttpRequest), 'network_availability_zone')\
207 .MultipleTimes().AndReturn(True)
197 208
198 self.mox.ReplayAll() 209 self.mox.ReplayAll()
199 url = urlunquote(reverse('horizon:project:networks:detail', 210 url = urlunquote(reverse('horizon:project:networks:detail',
@@ -219,6 +230,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
219 quotas.tenant_quota_usages( 230 quotas.tenant_quota_usages(
220 IsA(http.HttpRequest), targets=('subnets', )) \ 231 IsA(http.HttpRequest), targets=('subnets', )) \
221 .MultipleTimes().AndReturn(quota_data) 232 .MultipleTimes().AndReturn(quota_data)
233 api.neutron.is_extension_supported(
234 IsA(http.HttpRequest), 'network_availability_zone')\
235 .MultipleTimes().AndReturn(True)
222 self.mox.ReplayAll() 236 self.mox.ReplayAll()
223 237
224 url = urlunquote(reverse('horizon:project:networks:subnets_tab', 238 url = urlunquote(reverse('horizon:project:networks:subnets_tab',
@@ -290,6 +304,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
290 quotas.tenant_quota_usages( 304 quotas.tenant_quota_usages(
291 IsA(http.HttpRequest), targets=('subnets', )) \ 305 IsA(http.HttpRequest), targets=('subnets', )) \
292 .MultipleTimes().AndReturn(quota_data) 306 .MultipleTimes().AndReturn(quota_data)
307 api.neutron.is_extension_supported(
308 IsA(http.HttpRequest), 'network_availability_zone')\
309 .MultipleTimes().AndReturn(True)
293 self.mox.ReplayAll() 310 self.mox.ReplayAll()
294 311
295 url = urlunquote(reverse('horizon:project:networks:subnets_tab', 312 url = urlunquote(reverse('horizon:project:networks:subnets_tab',
@@ -330,6 +347,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
330 quotas.tenant_quota_usages( 347 quotas.tenant_quota_usages(
331 IsA(http.HttpRequest), targets=('subnets', )) \ 348 IsA(http.HttpRequest), targets=('subnets', )) \
332 .MultipleTimes().AndReturn(quota_data) 349 .MultipleTimes().AndReturn(quota_data)
350 api.neutron.is_extension_supported(
351 IsA(http.HttpRequest), 'network_availability_zone')\
352 .MultipleTimes().AndReturn(True)
333 self.mox.ReplayAll() 353 self.mox.ReplayAll()
334 354
335 url = urlunquote(reverse('horizon:project:networks:subnets_tab', 355 url = urlunquote(reverse('horizon:project:networks:subnets_tab',
@@ -911,7 +931,8 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
911 931
912 @test.create_stubs({api.neutron: ('network_get', 932 @test.create_stubs({api.neutron: ('network_get',
913 'network_list', 933 'network_list',
914 'network_delete')}) 934 'network_delete',
935 'is_extension_supported')})
915 def test_delete_network_no_subnet(self): 936 def test_delete_network_no_subnet(self):
916 network = self.networks.first() 937 network = self.networks.first()
917 network.subnets = [] 938 network.subnets = []
@@ -919,6 +940,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
919 network.id, 940 network.id,
920 expand_subnet=False)\ 941 expand_subnet=False)\
921 .AndReturn(network) 942 .AndReturn(network)
943 api.neutron.is_extension_supported(
944 IsA(http.HttpRequest), 'network_availability_zone')\
945 .MultipleTimes().AndReturn(True)
922 self._stub_net_list() 946 self._stub_net_list()
923 api.neutron.network_delete(IsA(http.HttpRequest), network.id) 947 api.neutron.network_delete(IsA(http.HttpRequest), network.id)
924 948
@@ -931,7 +955,8 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
931 @test.create_stubs({api.neutron: ('network_get', 955 @test.create_stubs({api.neutron: ('network_get',
932 'network_list', 956 'network_list',
933 'network_delete', 957 'network_delete',
934 'subnet_delete')}) 958 'subnet_delete',
959 'is_extension_supported')})
935 def test_delete_network_with_subnet(self): 960 def test_delete_network_with_subnet(self):
936 network = self.networks.first() 961 network = self.networks.first()
937 network.subnets = [subnet.id for subnet in network.subnets] 962 network.subnets = [subnet.id for subnet in network.subnets]
@@ -941,6 +966,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
941 network.id, 966 network.id,
942 expand_subnet=False)\ 967 expand_subnet=False)\
943 .AndReturn(network) 968 .AndReturn(network)
969 api.neutron.is_extension_supported(
970 IsA(http.HttpRequest), 'network_availability_zone')\
971 .MultipleTimes().AndReturn(True)
944 self._stub_net_list() 972 self._stub_net_list()
945 api.neutron.subnet_delete(IsA(http.HttpRequest), subnet_id) 973 api.neutron.subnet_delete(IsA(http.HttpRequest), subnet_id)
946 api.neutron.subnet_delete(IsA(http.HttpRequest), subnetv6_id) 974 api.neutron.subnet_delete(IsA(http.HttpRequest), subnetv6_id)
@@ -956,7 +984,8 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
956 @test.create_stubs({api.neutron: ('network_get', 984 @test.create_stubs({api.neutron: ('network_get',
957 'network_list', 985 'network_list',
958 'network_delete', 986 'network_delete',
959 'subnet_delete')}) 987 'subnet_delete',
988 'is_extension_supported')})
960 def test_delete_network_exception(self): 989 def test_delete_network_exception(self):
961 network = self.networks.first() 990 network = self.networks.first()
962 network.subnets = [subnet.id for subnet in network.subnets] 991 network.subnets = [subnet.id for subnet in network.subnets]
@@ -966,6 +995,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
966 network.id, 995 network.id,
967 expand_subnet=False)\ 996 expand_subnet=False)\
968 .AndReturn(network) 997 .AndReturn(network)
998 api.neutron.is_extension_supported(
999 IsA(http.HttpRequest), 'network_availability_zone')\
1000 .MultipleTimes().AndReturn(True)
969 self._stub_net_list() 1001 self._stub_net_list()
970 api.neutron.subnet_delete(IsA(http.HttpRequest), subnet_id) 1002 api.neutron.subnet_delete(IsA(http.HttpRequest), subnet_id)
971 api.neutron.subnet_delete(IsA(http.HttpRequest), subnetv6_id) 1003 api.neutron.subnet_delete(IsA(http.HttpRequest), subnetv6_id)
@@ -999,6 +1031,9 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin):
999 quotas.tenant_quota_usages( 1031 quotas.tenant_quota_usages(
1000 IsA(http.HttpRequest), targets=('subnets', )) \ 1032 IsA(http.HttpRequest), targets=('subnets', )) \
1001 .MultipleTimes().AndReturn(quota_data) 1033 .MultipleTimes().AndReturn(quota_data)
1034 api.neutron.is_extension_supported(
1035 IsA(http.HttpRequest), 'network_availability_zone')\
1036 .MultipleTimes().AndReturn(True)
1002 1037
1003 self.mox.ReplayAll() 1038 self.mox.ReplayAll()
1004 1039
@@ -1028,6 +1063,9 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin):
1028 quotas.tenant_quota_usages( 1063 quotas.tenant_quota_usages(
1029 IsA(http.HttpRequest), targets=('subnets', )) \ 1064 IsA(http.HttpRequest), targets=('subnets', )) \
1030 .MultipleTimes().AndReturn(quota_data) 1065 .MultipleTimes().AndReturn(quota_data)
1066 api.neutron.is_extension_supported(
1067 IsA(http.HttpRequest), 'network_availability_zone')\
1068 .MultipleTimes().AndReturn(True)
1031 1069
1032 self.mox.ReplayAll() 1070 self.mox.ReplayAll()
1033 1071
@@ -1042,7 +1080,8 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin):
1042 "The create button should be disabled") 1080 "The create button should be disabled")
1043 return button 1081 return button
1044 1082
1045 @test.create_stubs({api.neutron: ('network_list',), 1083 @test.create_stubs({api.neutron: ('network_list',
1084 'is_extension_supported'),
1046 quotas: ('tenant_quota_usages',)}) 1085 quotas: ('tenant_quota_usages',)})
1047 def test_network_create_button_disabled_when_quota_exceeded_index(self): 1086 def test_network_create_button_disabled_when_quota_exceeded_index(self):
1048 networks_tables.CreateNetwork() 1087 networks_tables.CreateNetwork()
@@ -1052,7 +1091,8 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin):
1052 self._test_create_button_disabled_when_quota_exceeded(_find_net_button, 1091 self._test_create_button_disabled_when_quota_exceeded(_find_net_button,
1053 network_quota=0) 1092 network_quota=0)
1054 1093
1055 @test.create_stubs({api.neutron: ('network_list',), 1094 @test.create_stubs({api.neutron: ('network_list',
1095 'is_extension_supported'),
1056 quotas: ('tenant_quota_usages',)}) 1096 quotas: ('tenant_quota_usages',)})
1057 def test_subnet_create_button_disabled_when_quota_exceeded_index(self): 1097 def test_subnet_create_button_disabled_when_quota_exceeded_index(self):
1058 network_id = self.networks.first().id 1098 network_id = self.networks.first().id
@@ -1065,7 +1105,8 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin):
1065 self._test_create_button_disabled_when_quota_exceeded( 1105 self._test_create_button_disabled_when_quota_exceeded(
1066 _find_subnet_button, subnet_quota=0) 1106 _find_subnet_button, subnet_quota=0)
1067 1107
1068 @test.create_stubs({api.neutron: ('network_list',), 1108 @test.create_stubs({api.neutron: ('network_list',
1109 'is_extension_supported'),
1069 quotas: ('tenant_quota_usages',)}) 1110 quotas: ('tenant_quota_usages',)})
1070 def test_network_create_button_shown_when_quota_disabled_index(self): 1111 def test_network_create_button_shown_when_quota_disabled_index(self):
1071 # if quota_data doesnt contain a networks["available"] key its disabled 1112 # if quota_data doesnt contain a networks["available"] key its disabled
@@ -1074,7 +1115,8 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin):
1074 lambda res: self.getAndAssertTableAction(res, 'networks', 'create') 1115 lambda res: self.getAndAssertTableAction(res, 'networks', 'create')
1075 ) 1116 )
1076 1117
1077 @test.create_stubs({api.neutron: ('network_list',), 1118 @test.create_stubs({api.neutron: ('network_list',
1119 'is_extension_supported'),
1078 quotas: ('tenant_quota_usages',)}) 1120 quotas: ('tenant_quota_usages',)})
1079 def test_subnet_create_button_shown_when_quota_disabled_index(self): 1121 def test_subnet_create_button_shown_when_quota_disabled_index(self):
1080 # if quota_data doesnt contain a subnets["available"] key, its disabled 1122 # if quota_data doesnt contain a subnets["available"] key, its disabled
@@ -1106,6 +1148,9 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin):
1106 quotas.tenant_quota_usages( 1148 quotas.tenant_quota_usages(
1107 IsA(http.HttpRequest), targets=('subnets', )) \ 1149 IsA(http.HttpRequest), targets=('subnets', )) \
1108 .MultipleTimes().AndReturn(quota_data) 1150 .MultipleTimes().AndReturn(quota_data)
1151 api.neutron.is_extension_supported(
1152 IsA(http.HttpRequest), 'network_availability_zone')\
1153 .MultipleTimes().AndReturn(True)
1109 1154
1110 self.mox.ReplayAll() 1155 self.mox.ReplayAll()
1111 1156
@@ -1135,7 +1180,8 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin):
1135 self.assertNotIn('disabled', create_action.classes, 1180 self.assertNotIn('disabled', create_action.classes,
1136 'The create button should be enabled') 1181 'The create button should be enabled')
1137 1182
1138 @test.create_stubs({api.neutron: ('network_list',), 1183 @test.create_stubs({api.neutron: ('network_list',
1184 'is_extension_supported'),
1139 quotas: ('tenant_quota_usages',)}) 1185 quotas: ('tenant_quota_usages',)})
1140 def test_create_button_attributes(self): 1186 def test_create_button_attributes(self):
1141 create_action = self._test_create_button_shown_when_quota_disabled( 1187 create_action = self._test_create_button_shown_when_quota_disabled(
@@ -1184,6 +1230,9 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin):
1184 quotas.tenant_quota_usages( 1230 quotas.tenant_quota_usages(
1185 IsA(http.HttpRequest), targets=('ports',)) \ 1231 IsA(http.HttpRequest), targets=('ports',)) \
1186 .MultipleTimes().AndReturn(quota_data) 1232 .MultipleTimes().AndReturn(quota_data)
1233 api.neutron.is_extension_supported(
1234 IsA(http.HttpRequest), 'network_availability_zone')\
1235 .MultipleTimes().AndReturn(True)
1187 1236
1188 self.mox.ReplayAll() 1237 self.mox.ReplayAll()
1189 1238