summaryrefslogtreecommitdiff
path: root/openstack_dashboard/dashboards/project/routers/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'openstack_dashboard/dashboards/project/routers/forms.py')
-rw-r--r--openstack_dashboard/dashboards/project/routers/forms.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/openstack_dashboard/dashboards/project/routers/forms.py b/openstack_dashboard/dashboards/project/routers/forms.py
index 27e9d95..f5ad224 100644
--- a/openstack_dashboard/dashboards/project/routers/forms.py
+++ b/openstack_dashboard/dashboards/project/routers/forms.py
@@ -41,6 +41,12 @@ class CreateForm(forms.SelfHandlingForm):
41 required=False) 41 required=False)
42 mode = forms.ChoiceField(label=_("Router Type")) 42 mode = forms.ChoiceField(label=_("Router Type"))
43 ha = forms.ChoiceField(label=_("High Availability Mode")) 43 ha = forms.ChoiceField(label=_("High Availability Mode"))
44 az_hints = forms.MultipleChoiceField(
45 label=_("Availability Zone Hints"),
46 required=False,
47 help_text=_("Availability Zones where the router may be scheduled. "
48 "Leaving this unset is equivalent to selecting all "
49 "Availability Zones"))
44 failure_url = 'horizon:project:routers:index' 50 failure_url = 'horizon:project:routers:index'
45 51
46 def __init__(self, request, *args, **kwargs): 52 def __init__(self, request, *args, **kwargs):
@@ -70,6 +76,17 @@ class CreateForm(forms.SelfHandlingForm):
70 else: 76 else:
71 del self.fields['external_network'] 77 del self.fields['external_network']
72 78
79 az_supported = api.neutron.is_extension_supported(
80 self.request, 'router_availability_zone')
81
82 if az_supported:
83 zones = api.neutron.list_availability_zones(self.request, 'router',
84 'available')
85 self.fields['az_hints'].choices = [(zone['name'], zone['name'])
86 for zone in zones]
87 else:
88 del self.fields['az_hints']
89
73 def _get_network_list(self, request): 90 def _get_network_list(self, request):
74 search_opts = {'router:external': True} 91 search_opts = {'router:external': True}
75 try: 92 try:
@@ -94,6 +111,8 @@ class CreateForm(forms.SelfHandlingForm):
94 if 'external_network' in data and data['external_network']: 111 if 'external_network' in data and data['external_network']:
95 params['external_gateway_info'] = {'network_id': 112 params['external_gateway_info'] = {'network_id':
96 data['external_network']} 113 data['external_network']}
114 if 'az_hints' in data and data['az_hints']:
115 params['availability_zone_hints'] = data['az_hints']
97 if (self.dvr_allowed and data['mode'] != 'server_default'): 116 if (self.dvr_allowed and data['mode'] != 'server_default'):
98 params['distributed'] = (data['mode'] == 'distributed') 117 params['distributed'] = (data['mode'] == 'distributed')
99 if (self.ha_allowed and data['ha'] != 'server_default'): 118 if (self.ha_allowed and data['ha'] != 'server_default'):