summaryrefslogtreecommitdiff
path: root/openstack_dashboard/dashboards/admin/networks/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'openstack_dashboard/dashboards/admin/networks/forms.py')
-rw-r--r--openstack_dashboard/dashboards/admin/networks/forms.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/openstack_dashboard/dashboards/admin/networks/forms.py b/openstack_dashboard/dashboards/admin/networks/forms.py
index ae5dbca..b95bff2 100644
--- a/openstack_dashboard/dashboards/admin/networks/forms.py
+++ b/openstack_dashboard/dashboards/admin/networks/forms.py
@@ -139,6 +139,12 @@ class CreateNetwork(forms.SelfHandlingForm):
139 }), 139 }),
140 initial=True, 140 initial=True,
141 required=False) 141 required=False)
142 az_hints = forms.MultipleChoiceField(
143 label=_("Availability Zone Hints"),
144 required=False,
145 help_text=_("Availability zones where the DHCP agents may be "
146 "scheduled. Leaving this unset is equivalent to "
147 "selecting all availability zones"))
142 148
143 @classmethod 149 @classmethod
144 def _instantiate(cls, request, *args, **kwargs): 150 def _instantiate(cls, request, *args, **kwargs):
@@ -237,6 +243,20 @@ class CreateNetwork(forms.SelfHandlingForm):
237 else: 243 else:
238 self.fields['network_type'].choices = network_type_choices 244 self.fields['network_type'].choices = network_type_choices
239 245
246 try:
247 if api.neutron.is_extension_supported(request,
248 'network_availability_zone'):
249 zones = api.neutron.list_availability_zones(
250 self.request, 'network', 'available')
251 self.fields['az_hints'].choices = [(zone['name'], zone['name'])
252 for zone in zones]
253 else:
254 del self.fields['az_hints']
255 except Exception:
256 msg = _('Failed to get availability zone list.')
257 messages.warning(request, msg)
258 del self.fields['az_hints']
259
240 def _hide_provider_network_type(self): 260 def _hide_provider_network_type(self):
241 self.fields['network_type'].widget = forms.HiddenInput() 261 self.fields['network_type'].widget = forms.HiddenInput()
242 self.fields['physical_network'].widget = forms.HiddenInput() 262 self.fields['physical_network'].widget = forms.HiddenInput()
@@ -261,6 +281,8 @@ class CreateNetwork(forms.SelfHandlingForm):
261 if network_type in self.nettypes_with_seg_id: 281 if network_type in self.nettypes_with_seg_id:
262 params['provider:segmentation_id'] = ( 282 params['provider:segmentation_id'] = (
263 data['segmentation_id']) 283 data['segmentation_id'])
284 if 'az_hints' in data and data['az_hints']:
285 params['availability_zone_hints'] = data['az_hints']
264 network = api.neutron.network_create(request, **params) 286 network = api.neutron.network_create(request, **params)
265 LOG.debug('Network %s was successfully created.', data['name']) 287 LOG.debug('Network %s was successfully created.', data['name'])
266 return network 288 return network