summaryrefslogtreecommitdiff
path: root/openstack_dashboard/dashboards/project/networks/workflows.py
diff options
context:
space:
mode:
Diffstat (limited to 'openstack_dashboard/dashboards/project/networks/workflows.py')
-rw-r--r--openstack_dashboard/dashboards/project/networks/workflows.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/openstack_dashboard/dashboards/project/networks/workflows.py b/openstack_dashboard/dashboards/project/networks/workflows.py
index 8cde19e..58a3974 100644
--- a/openstack_dashboard/dashboards/project/networks/workflows.py
+++ b/openstack_dashboard/dashboards/project/networks/workflows.py
@@ -58,12 +58,31 @@ class CreateNetworkInfoAction(workflows.Action):
58 }), 58 }),
59 initial=True, 59 initial=True,
60 required=False) 60 required=False)
61 az_hints = forms.MultipleChoiceField(
62 label=_("Availability Zone Hints"),
63 required=False,
64 help_text=_("Availability zones where the DHCP agents may be "
65 "scheduled. Leaving this unset is equivalent to "
66 "selecting all availability zones"))
61 67
62 def __init__(self, request, *args, **kwargs): 68 def __init__(self, request, *args, **kwargs):
63 super(CreateNetworkInfoAction, self).__init__(request, 69 super(CreateNetworkInfoAction, self).__init__(request,
64 *args, **kwargs) 70 *args, **kwargs)
65 if not policy.check((("network", "create_network:shared"),), request): 71 if not policy.check((("network", "create_network:shared"),), request):
66 self.fields['shared'].widget = forms.HiddenInput() 72 self.fields['shared'].widget = forms.HiddenInput()
73 try:
74 if api.neutron.is_extension_supported(request,
75 'network_availability_zone'):
76 zones = api.neutron.list_availability_zones(
77 self.request, 'network', 'available')
78 self.fields['az_hints'].choices = [(zone['name'], zone['name'])
79 for zone in zones]
80 else:
81 del self.fields['az_hints']
82 except Exception:
83 msg = _('Failed to get availability zone list.')
84 messages.warning(request, msg)
85 del self.fields['az_hints']
67 86
68 class Meta(object): 87 class Meta(object):
69 name = _("Network") 88 name = _("Network")
@@ -74,7 +93,8 @@ class CreateNetworkInfoAction(workflows.Action):
74 93
75class CreateNetworkInfo(workflows.Step): 94class CreateNetworkInfo(workflows.Step):
76 action_class = CreateNetworkInfoAction 95 action_class = CreateNetworkInfoAction
77 contributes = ("net_name", "admin_state", "with_subnet", "shared") 96 contributes = ("net_name", "admin_state", "with_subnet", "shared",
97 "az_hints")
78 98
79 99
80class CreateSubnetInfoAction(workflows.Action): 100class CreateSubnetInfoAction(workflows.Action):
@@ -463,6 +483,8 @@ class CreateNetwork(workflows.Workflow):
463 params = {'name': data['net_name'], 483 params = {'name': data['net_name'],
464 'admin_state_up': data['admin_state'], 484 'admin_state_up': data['admin_state'],
465 'shared': data['shared']} 485 'shared': data['shared']}
486 if 'az_hints' in data and data['az_hints']:
487 params['availability_zone_hints'] = data['az_hints']
466 network = api.neutron.network_create(request, **params) 488 network = api.neutron.network_create(request, **params)
467 self.context['net_id'] = network.id 489 self.context['net_id'] = network.id
468 LOG.debug('Network "%s" was successfully created.', 490 LOG.debug('Network "%s" was successfully created.',