Merge "[Sahara] Support Nova availability zones"
This commit is contained in:
commit
f69571b850
@ -95,7 +95,8 @@ def nodegroup_template_create(request, name, plugin_name, hadoop_version,
|
||||
volumes_per_node=None, volumes_size=None,
|
||||
node_processes=None, node_configs=None,
|
||||
floating_ip_pool=None, security_groups=None,
|
||||
auto_security_group=False):
|
||||
auto_security_group=False,
|
||||
availability_zone=False):
|
||||
return client(request).node_group_templates.create(name, plugin_name,
|
||||
hadoop_version,
|
||||
flavor_id, description,
|
||||
@ -105,7 +106,8 @@ def nodegroup_template_create(request, name, plugin_name, hadoop_version,
|
||||
node_configs,
|
||||
floating_ip_pool,
|
||||
security_groups,
|
||||
auto_security_group)
|
||||
auto_security_group,
|
||||
availability_zone)
|
||||
|
||||
|
||||
def nodegroup_template_list(request):
|
||||
@ -128,7 +130,9 @@ def nodegroup_template_update(request, ngt_id, name, plugin_name,
|
||||
hadoop_version, flavor_id,
|
||||
description=None, volumes_per_node=None,
|
||||
volumes_size=None, node_processes=None,
|
||||
node_configs=None, floating_ip_pool=None):
|
||||
node_configs=None, floating_ip_pool=None,
|
||||
security_groups=None, auto_security_group=False,
|
||||
availability_zone=False):
|
||||
return client(request).node_group_templates.update(ngt_id, name,
|
||||
plugin_name,
|
||||
hadoop_version,
|
||||
@ -138,7 +142,10 @@ def nodegroup_template_update(request, ngt_id, name, plugin_name,
|
||||
volumes_size,
|
||||
node_processes,
|
||||
node_configs,
|
||||
floating_ip_pool)
|
||||
floating_ip_pool,
|
||||
security_groups,
|
||||
auto_security_group,
|
||||
availability_zone)
|
||||
|
||||
|
||||
def cluster_template_create(request, name, plugin_name, hadoop_version,
|
||||
|
@ -18,6 +18,11 @@
|
||||
<dd>{% trans "Template not specified" %}</dd>
|
||||
{% endif %}
|
||||
|
||||
{% if node_group.availability_zone %}
|
||||
<dt>{% trans "Availability Zone" %}</dt>
|
||||
<dd>{{ node_group.availability_zone }}</dd>
|
||||
{% endif %}
|
||||
|
||||
<dt>{% trans "Auto Security Group" %}</dt>
|
||||
<dd>{{ node_group.auto_security_group|yesno }}</dd>
|
||||
|
||||
@ -64,4 +69,4 @@
|
||||
{% endif %}
|
||||
</dl>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -14,6 +14,12 @@
|
||||
<dt>{% trans "Flavor" %}</dt>
|
||||
<dd>{{ flavor.name }}</dd>
|
||||
</dl>
|
||||
{% if template.availability_zone %}
|
||||
<dl>
|
||||
<dt>{% trans "Availability Zone" %}</dt>
|
||||
<dd>{{ template.availability_zone }}</dd>
|
||||
</dl>
|
||||
{% endif %}
|
||||
{% if template.floating_ip_pool %}
|
||||
<dl>
|
||||
<dt>{% trans "Floating IP Pool" %}</dt>
|
||||
|
@ -52,6 +52,7 @@ class CopyNodegroupTemplate(create_flow.ConfigureNodegroupTemplate):
|
||||
fields["nodegroup_name"].initial = template.name + "-copy"
|
||||
fields["description"].initial = template.description
|
||||
fields["flavor"].initial = template.flavor_id
|
||||
fields["availability_zone"].initial = template.availability_zone
|
||||
|
||||
storage = "cinder_volume" if template.volumes_per_node > 0 \
|
||||
else "ephemeral_drive"
|
||||
|
@ -42,6 +42,13 @@ class GeneralConfigAction(workflows.Action):
|
||||
|
||||
flavor = forms.ChoiceField(label=_("OpenStack Flavor"))
|
||||
|
||||
availability_zone = forms.ChoiceField(
|
||||
label=_("Availability Zone"),
|
||||
help_text=_("Launch instances in this availability zone."),
|
||||
required=False,
|
||||
widget=forms.Select(attrs={"class": "availability_zone_field"})
|
||||
)
|
||||
|
||||
storage = forms.ChoiceField(
|
||||
label=_("Storage location"),
|
||||
help_text=_("Choose a storage location"),
|
||||
@ -92,7 +99,7 @@ class GeneralConfigAction(workflows.Action):
|
||||
pool_choices.insert(0, (None, "Do not assign floating IPs"))
|
||||
|
||||
self.fields['floating_ip_pool'] = forms.ChoiceField(
|
||||
label=_("Floating IP pool"),
|
||||
label=_("Floating IP Pool"),
|
||||
choices=pool_choices,
|
||||
required=False)
|
||||
|
||||
@ -137,6 +144,14 @@ class GeneralConfigAction(workflows.Action):
|
||||
return nova_utils.sort_flavor_list(request, flavors)
|
||||
return []
|
||||
|
||||
def populate_availability_zone_choices(self, request, context):
|
||||
# The default is None, i.e. not specifying any availability zone
|
||||
az_list = [(None, _('No availability zone specified'))]
|
||||
az_list.extend([(az.zoneName, az.zoneName)
|
||||
for az in nova_utils.availability_zone_list(request)
|
||||
if az.zoneState['available']])
|
||||
return az_list
|
||||
|
||||
def get_help_text(self):
|
||||
extra = dict()
|
||||
plugin, hadoop_version = (
|
||||
@ -257,7 +272,8 @@ class ConfigureNodegroupTemplate(workflow_helpers.ServiceParametersWorkflow,
|
||||
node_configs=configs_dict,
|
||||
floating_ip_pool=context.get("general_floating_ip_pool"),
|
||||
security_groups=context["general_groups"],
|
||||
auto_security_group=context["general_autogroup"])
|
||||
auto_security_group=context["general_autogroup"],
|
||||
availability_zone=context["general_availability_zone"])
|
||||
return True
|
||||
except api_base.APIException as e:
|
||||
self.error_description = str(e)
|
||||
|
@ -61,3 +61,13 @@ def sort_flavor_list(request, flavors):
|
||||
exceptions.handle(request,
|
||||
_('Unable to sort instance flavors.'))
|
||||
return []
|
||||
|
||||
|
||||
def availability_zone_list(request):
|
||||
"""Utility method to retrieve a list of availability zones."""
|
||||
try:
|
||||
return api.nova.availability_zone_list(request)
|
||||
except Exception:
|
||||
exceptions.handle(request,
|
||||
_('Unable to retrieve Nova availability zones.'))
|
||||
return []
|
||||
|
Loading…
x
Reference in New Issue
Block a user