Merge "Refactor modal forms for Volumes"

This commit is contained in:
Jenkins 2015-03-11 16:54:46 +00:00 committed by Gerrit Code Review
commit da699e6ca6
30 changed files with 217 additions and 478 deletions

View File

@ -30,7 +30,11 @@ from openstack_dashboard.dashboards.project.volumes.snapshots \
class UpdateStatusView(forms.ModalFormView): class UpdateStatusView(forms.ModalFormView):
form_class = vol_snapshot_forms.UpdateStatus form_class = vol_snapshot_forms.UpdateStatus
modal_header = _("Update Volume Snapshot Status")
modal_id = "update_volume_snapshot_status"
template_name = 'admin/volumes/snapshots/update_status.html' template_name = 'admin/volumes/snapshots/update_status.html'
submit_label = _("Update Status")
submit_url = "horizon:admin:volumes:snapshots:update_status"
success_url = reverse_lazy("horizon:admin:volumes:snapshots_tab") success_url = reverse_lazy("horizon:admin:volumes:snapshots_tab")
page_title = _("Update Volume Snapshot Status") page_title = _("Update Volume Snapshot Status")
@ -49,6 +53,8 @@ class UpdateStatusView(forms.ModalFormView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(UpdateStatusView, self).get_context_data(**kwargs) context = super(UpdateStatusView, self).get_context_data(**kwargs)
context['snapshot_id'] = self.kwargs["snapshot_id"] context['snapshot_id'] = self.kwargs["snapshot_id"]
args = (self.kwargs['snapshot_id'],)
context['submit_url'] = reverse(self.submit_url, args=args)
return context return context
def get_initial(self): def get_initial(self):

View File

@ -1,30 +1,11 @@
{% extends "horizon/common/_modal_form.html" %} {% extends "horizon/common/_modal_form.html" %}
{% load i18n %} {% load i18n %}
{% load url from future %}
{% block form_id %}{% endblock %} {% block modal-body-right %}
{% block form_action %}{% url 'horizon:admin:volumes:snapshots:update_status' snapshot_id %}{% endblock %}
{% block modal_id %}update_volume_snapshot_status_modal{% endblock %}
{% block modal-header %}{% trans "Update Volume Snapshot Status" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3> <h3>{% trans "Description:" %}</h3>
<p>{% blocktrans %} <p>{% blocktrans %}
The status of a volume snapshot is normally managed automatically. In some circumstances The status of a volume snapshot is normally managed automatically. In some circumstances
an administrator may need to explicitly update the status value. This is equivalent to an administrator may need to explicitly update the status value. This is equivalent to
the <tt>cinder snapshot-reset-state</tt> command. the <tt>cinder snapshot-reset-state</tt> command.
{% endblocktrans %}</p> {% endblocktrans %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Update Status" %}" />
<a href="{% url 'horizon:admin:volumes:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %} {% endblock %}

View File

@ -1,36 +1,9 @@
{% extends "horizon/common/_modal_form.html" %} {% extends "horizon/common/_modal_form.html" %}
{% load i18n %} {% load i18n %}
{% load url from future %}
{% block form_id %}{% endblock %} {% block modal-body-right %}
{% block form_action %}{% url 'horizon:admin:volumes:volume_types:manage_qos_spec_association' type_id %}{% endblock %}
{% block modal_id %}associate_qos_spec_modal{% endblock %}
{% block modal-header %}{% trans "Associate QoS Spec with Volume Type"%}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3> <h3>{% trans "Description:" %}</h3>
<p>{% blocktrans %} <p>{% trans "Add, modify or remove the QoS Spec associated with this volume type." %}</p>
Add, modify or remove the QoS Spec associated with this volume type. <p>{% blocktrans %}"None" indicates that no QoS Spec is currently associated. Conversely, setting the QoS Spec to "None" will remove the current association.{% endblocktrans %}</p>
<br> <p>{% blocktrans %}This is equivalent to the <tt>cinder qos-associate</tt> and <tt>cinder qos-disassociate</tt> commands.{% endblocktrans %}</p>
<br>
"None" indicates that no QoS Spec is currently associated. Conversely, setting
the QoS Spec to "None" will remove the current association.
<br>
<br>
This is equivalent to the <tt>cinder qos-associate</tt> and <tt>cinder qos-disassociate</tt>
commands.
{% endblocktrans %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Associate" %}" />
<a href="{% url 'horizon:admin:volumes:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %} {% endblock %}

View File

@ -1,20 +1,7 @@
{% extends "horizon/common/_modal_form.html" %} {% extends "horizon/common/_modal_form.html" %}
{% load i18n %} {% load i18n %}
{% load url from future %}
{% block form_id %}{% endblock %} {% block modal-body-right %}
{% block form_action %}{% url 'horizon:admin:volumes:volume_types:create_qos_spec' %}{% endblock %}
{% block modal_id %}create_volume_type_modal{% endblock %}
{% block modal-header %}{% trans "Create QoS Spec" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3> <h3>{% trans "Description:" %}</h3>
<p>{% blocktrans %} <p>{% blocktrans %}
QoS Specs can be associated with volume types. QoS Specs can be associated with volume types.
@ -27,12 +14,5 @@
Each QoS Specs entity will have a "Consumer" value which indicates where the Each QoS Specs entity will have a "Consumer" value which indicates where the
administrator would like the QoS policy to be enforced. This value can be "front-end" administrator would like the QoS policy to be enforced. This value can be "front-end"
(Nova Compute), "back-end" (Cinder back-end), or "both". (Nova Compute), "back-end" (Cinder back-end), or "both".
{% endblocktrans %} {% endblocktrans %}</p>
</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Create" %}" />
<a href="{% url 'horizon:admin:volumes:volume_types_tab' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %} {% endblock %}

View File

@ -1,20 +1,7 @@
{% extends "horizon/common/_modal_form.html" %} {% extends "horizon/common/_modal_form.html" %}
{% load i18n %} {% load i18n %}
{% load url from future %}
{% block form_id %}{% endblock %} {% block modal-body-right %}
{% block form_action %}{% url 'horizon:admin:volumes:volume_types:create_type' %}{% endblock %}
{% block modal_id %}create_volume_type_modal{% endblock %}
{% block modal-header %}{% trans "Create Volume Type" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3> <h3>{% trans "Description:" %}</h3>
<p>{% blocktrans %} <p>{% blocktrans %}
Volume type is a type or label that can be selected at volume creation Volume type is a type or label that can be selected at volume creation
@ -26,10 +13,4 @@
pair(s) for that volume type. pair(s) for that volume type.
{% endblocktrans %} {% endblocktrans %}
</p> </p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Create Volume Type" %}" />
<a href="{% url 'horizon:admin:volumes:volume_types_tab' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %} {% endblock %}

View File

@ -1,20 +1,7 @@
{% extends "horizon/common/_modal_form.html" %} {% extends "horizon/common/_modal_form.html" %}
{% load i18n %} {% load i18n %}
{% load url from future %}
{% block form_id %}create_volume_form{% endblock %} {% block modal-body-right %}
{% block form_action %}{% url 'horizon:admin:volumes:volume_types:create_type_encryption' volume_type_id %}{% endblock %}
{% block modal_id %}create_volume_type_modal{% endblock %}
{% block modal-header %}{% trans "Create Volume Type Encryption" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3> <h3>{% trans "Description:" %}</h3>
<p> <p>
{% trans "Creating encryption for a volume type causes all volumes with that volume type to be encrypted. Encryption information cannot be added to a volume type if volumes are currently in use with that volume type." %} {% trans "Creating encryption for a volume type causes all volumes with that volume type to be encrypted. Encryption information cannot be added to a volume type if volumes are currently in use with that volume type." %}
@ -31,10 +18,4 @@
<p> <p>
{% blocktrans %}The <strong>Key Size</strong> is the size of the encryption key, in bits (e.g., 128, 256). If the field is left empty, the provider default will be used.{% endblocktrans %} {% blocktrans %}The <strong>Key Size</strong> is the size of the encryption key, in bits (e.g., 128, 256). If the field is left empty, the provider default will be used.{% endblocktrans %}
</p> </p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Create Volume Type Encryption" %}" />
<a href="{% url 'horizon:admin:volumes:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %} {% endblock %}

View File

@ -1,30 +1,11 @@
{% extends "horizon/common/_modal_form.html" %} {% extends "horizon/common/_modal_form.html" %}
{% load i18n %} {% load i18n %}
{% load url from future %}
{% block form_id %}{% endblock %} {% block modal-body-right %}
{% block form_action %}{% url 'horizon:admin:volumes:volume_types:edit_qos_spec_consumer' qos_spec_id %}{% endblock %}
{% block modal_id %}associate_qos_spec_modal{% endblock %}
{% block modal-header %}{% trans "Edit Consumer of QoS Spec" %} {% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3> <h3>{% trans "Description:" %}</h3>
<p>{% blocktrans %} <p>{% blocktrans %}
Each QoS Specs entity will have a "Consumer" value which indicates where the Each QoS Specs entity will have a "Consumer" value which indicates where the
administrator would like the QoS policy to be enforced. This value can be "front-end" administrator would like the QoS policy to be enforced. This value can be "front-end"
(Nova Compute), "back-end" (Cinder back-end), or "both". (Nova Compute), "back-end" (Cinder back-end), or "both".
{% endblocktrans %}</p> {% endblocktrans %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Modify Consumer" %}" />
<a href="{% url 'horizon:admin:volumes:volume_types_tab' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %} {% endblock %}

View File

@ -1,28 +1,7 @@
{% extends "horizon/common/_modal_form.html" %} {% extends "horizon/common/_modal_form.html" %}
{% load i18n %} {% load i18n %}
{% load url from future %}
{% block form_id %}extra_spec_create_form{% endblock %} {% block modal-body-right %}
{% block form_action %}{% url 'horizon:admin:volumes:volume_types:extras:create' vol_type.id %}{% endblock %} <h3>{% trans "Description:" %}</h3>
<p>{% trans 'Create a new "extra spec" key-value pair for a volume type.' %}</p>
{% block modal_id %}extra_spec_create_modal{% endblock %}
{% block modal-header %}{% trans "Create Volume Type Extra Spec" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans 'Create a new "extra spec" key-value pair for a volume type.' %}</p>
</div>
{% endblock %} {% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Create" %}" />
<a href="{% url 'horizon:admin:volumes:volume_types:extras:index' vol_type.id %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@ -1,28 +1,7 @@
{% extends "horizon/common/_modal_form.html" %} {% extends "horizon/common/_modal_form.html" %}
{% load i18n %} {% load i18n %}
{% load url from future %}
{% block form_id %}extra_spec_edit_form{% endblock %} {% block modal-body-right %}
{% block form_action %}{% url 'horizon:admin:volumes:volume_types:extras:edit' vol_type.id key %}{% endblock %} <h3>{% trans "Description:" %}</h3>
<p>{% blocktrans with key=key %}Update the "extra spec" value for "{{ key }}"{% endblocktrans %}</p>
{% block modal_id %}extra_spec_edit_modal{% endblock %}
{% block modal-header %}{% blocktrans %}Edit Extra Spec Value: {{ key }}{% endblocktrans %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% blocktrans with key=key %}Update the "extra spec" value for "{{ key }}"{% endblocktrans %}</p>
</div>
{% endblock %} {% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save" %}" />
<a href="{% url 'horizon:admin:volumes:volume_types:extras:index' vol_type.id %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@ -1,28 +1,7 @@
{% extends "horizon/common/_modal_form.html" %} {% extends "horizon/common/_modal_form.html" %}
{% load i18n %} {% load i18n %}
{% load url from future %}
{% block form_id %}extra_spec_create_form{% endblock %} {% block modal-body-right %}
{% block form_action %}{% url 'horizon:admin:volumes:volume_types:qos_specs:create' qos_spec_id %}{% endblock %} <h3>{% trans "Description:" %}</h3>
<p>{% blocktrans with key=qos_spec_name %}Create a new "spec" key-value pair for QoS Spec "{{ qos_spec_name }}"{% endblocktrans %}</p>
{% block modal_id %}qos_spec_create_modal{% endblock %}
{% block modal-header %}{% trans "Create Spec" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% blocktrans with key=qos_spec_name %}Create a new "spec" key-value pair for QoS Spec "{{ qos_spec_name }}"{% endblocktrans %}</p>
</div>
{% endblock %} {% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Create" %}" />
<a href="{% url 'horizon:admin:volumes:volume_types:qos_specs:index' qos_spec_id %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@ -1,27 +1,7 @@
{% extends "horizon/common/_modal_form.html" %} {% extends "horizon/common/_modal_form.html" %}
{% load i18n %} {% load i18n %}
{% load url from future %}
{% block form_id %}qos_spec_edit_form{% endblock %} {% block modal-body-right %}
{% block form_action %}{% url 'horizon:admin:volumes:volume_types:qos_specs:edit' qos_spec_id key %}{% endblock %} <h3>{% trans "Description:" %}</h3>
<p>{% blocktrans with key=key %}Update the spec value for "{{ key }}"{% endblocktrans %}</p>
{% block modal_id %}qos_spec_edit_modal{% endblock %}
{% block modal-header %}{% trans "Edit Spec Value: " %} {{ key }}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% blocktrans with key=key %}Update the spec value for "{{ key }}"{% endblocktrans %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save" %}" />
<a href="{% url 'horizon:admin:volumes:volume_types:qos_specs:index' qos_spec_id %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %} {% endblock %}

View File

@ -1,30 +1,11 @@
{% extends "horizon/common/_modal_form.html" %} {% extends "horizon/common/_modal_form.html" %}
{% load i18n %} {% load i18n %}
{% load url from future %}
{% block form_id %}{% endblock %} {% block modal-body-right %}
{% block form_action %} {% url 'horizon:admin:volumes:volumes:update_status' volume_id %}{% endblock %}
{% block modal_id %}update_volume_status_modal{% endblock %}
{% block modal-header %}{% trans "Update Volume Status" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3> <h3>{% trans "Description:" %}</h3>
<p>{% blocktrans %} <p>{% blocktrans %}
The status of a volume is normally managed automatically. In some circumstances an The status of a volume is normally managed automatically. In some circumstances an
administrator may need to explicitly update the status value. This is equivalent to administrator may need to explicitly update the status value. This is equivalent to
the <tt>cinder reset-state</tt> command. the <tt>cinder reset-state</tt> command.
{% endblocktrans %}</p> {% endblocktrans %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Update Status" %}" />
<a href="{% url 'horizon:admin:volumes:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %} {% endblock %}

View File

@ -58,6 +58,11 @@ class IndexView(ExtraSpecMixin, forms.ModalFormMixin, tables.DataTableView):
class CreateView(ExtraSpecMixin, forms.ModalFormView): class CreateView(ExtraSpecMixin, forms.ModalFormView):
form_class = project_forms.CreateExtraSpec form_class = project_forms.CreateExtraSpec
form_id = "extra_spec_create_form"
modal_header = _("Create Volume Type Extra Spec")
modal_id = "extra_spec_create_modal"
submit_label = _("Create")
submit_url = "horizon:admin:volumes:volume_types:extras:create"
template_name = 'admin/volumes/volume_types/extras/create.html' template_name = 'admin/volumes/volume_types/extras/create.html'
success_url = 'horizon:admin:volumes:volume_types:extras:index' success_url = 'horizon:admin:volumes:volume_types:extras:index'
@ -68,9 +73,20 @@ class CreateView(ExtraSpecMixin, forms.ModalFormView):
return reverse(self.success_url, return reverse(self.success_url,
args=(self.kwargs['type_id'],)) args=(self.kwargs['type_id'],))
def get_context_data(self, **kwargs):
context = super(CreateView, self).get_context_data(**kwargs)
args = (self.kwargs['type_id'],)
context['submit_url'] = reverse(self.submit_url, args=args)
return context
class EditView(ExtraSpecMixin, forms.ModalFormView): class EditView(ExtraSpecMixin, forms.ModalFormView):
form_class = project_forms.EditExtraSpec form_class = project_forms.EditExtraSpec
form_id = "extra_spec_edit_form"
modal_header = _('Edit Extra Spec Value: %s')
modal_id = "extra_spec_edit_modal"
submit_label = _("Save")
submit_url = "horizon:admin:volumes:volume_types:extras:edit"
template_name = 'admin/volumes/volume_types/extras/edit.html' template_name = 'admin/volumes/volume_types/extras/edit.html'
success_url = 'horizon:admin:volumes:volume_types:extras:index' success_url = 'horizon:admin:volumes:volume_types:extras:index'
@ -93,3 +109,10 @@ class EditView(ExtraSpecMixin, forms.ModalFormView):
return {'type_id': type_id, return {'type_id': type_id,
'key': key, 'key': key,
'value': extra_specs.get(key, '')} 'value': extra_specs.get(key, '')}
def get_context_data(self, **kwargs):
context = super(EditView, self).get_context_data(**kwargs)
args = (self.kwargs['type_id'], self.kwargs['key'],)
context['submit_url'] = reverse(self.submit_url, args=args)
context['modal_header'] = self.modal_header % self.kwargs['key']
return context

View File

@ -68,7 +68,12 @@ class IndexView(QosSpecMixin, forms.ModalFormMixin, tables.DataTableView):
class CreateKeyValuePairView(QosSpecMixin, forms.ModalFormView): class CreateKeyValuePairView(QosSpecMixin, forms.ModalFormView):
# this for creating a spec key-value pair for an existing QOS Spec # this for creating a spec key-value pair for an existing QOS Spec
form_class = project_forms.CreateKeyValuePair form_class = project_forms.CreateKeyValuePair
form_id = "extra_spec_create_form"
modal_header = _("Create Spec")
modal_id = "qos_spec_create_modal"
template_name = 'admin/volumes/volume_types/qos_specs/create.html' template_name = 'admin/volumes/volume_types/qos_specs/create.html'
submit_label = _("Create")
submit_url = "horizon:admin:volumes:volume_types:qos_specs:create"
success_url = 'horizon:admin:volumes:volume_types:qos_specs:index' success_url = 'horizon:admin:volumes:volume_types:qos_specs:index'
def get_initial(self): def get_initial(self):
@ -79,10 +84,22 @@ class CreateKeyValuePairView(QosSpecMixin, forms.ModalFormView):
return reverse(self.success_url, return reverse(self.success_url,
args=(self.kwargs['qos_spec_id'],)) args=(self.kwargs['qos_spec_id'],))
def get_context_data(self, **kwargs):
context = super(CreateKeyValuePairView, self).\
get_context_data(**kwargs)
args = (self.kwargs['qos_spec_id'],)
context['submit_url'] = reverse(self.submit_url, args=args)
return context
class EditKeyValuePairView(QosSpecMixin, forms.ModalFormView): class EditKeyValuePairView(QosSpecMixin, forms.ModalFormView):
form_class = project_forms.EditKeyValuePair form_class = project_forms.EditKeyValuePair
form_id = "qos_spec_edit_form"
modal_header = _("Edit Spec Value")
modal_id = "qos_spec_edit_modal"
template_name = 'admin/volumes/volume_types/qos_specs/edit.html' template_name = 'admin/volumes/volume_types/qos_specs/edit.html'
submit_label = _("Save")
submit_url = "horizon:admin:volumes:volume_types:qos_specs_edit"
success_url = 'horizon:admin:volumes:volume_types:qos_specs:index' success_url = 'horizon:admin:volumes:volume_types:qos_specs:index'
def get_success_url(self): def get_success_url(self):
@ -102,3 +119,9 @@ class EditKeyValuePairView(QosSpecMixin, forms.ModalFormView):
return {'qos_spec_id': qos_spec_id, return {'qos_spec_id': qos_spec_id,
'key': key, 'key': key,
'value': qos_specs.specs.get(key, '')} 'value': qos_specs.specs.get(key, '')}
def get_context_data(self, **kwargs):
context = super(EditKeyValuePairView, self).get_context_data(**kwargs)
args = (self.kwargs['qos_spec_id'], self.kwargs['key'],)
context['submit_url'] = reverse(self.submit_url, args=args)
return context

View File

@ -32,7 +32,11 @@ from openstack_dashboard.dashboards.admin.volumes.volumes \
class CreateVolumeTypeView(forms.ModalFormView): class CreateVolumeTypeView(forms.ModalFormView):
form_class = volumes_forms.CreateVolumeType form_class = volumes_forms.CreateVolumeType
modal_header = _("Create Volume Type")
modal_id = "create_volume_type_modal"
template_name = 'admin/volumes/volume_types/create_volume_type.html' template_name = 'admin/volumes/volume_types/create_volume_type.html'
submit_label = _("Create Volume Type")
submit_url = reverse_lazy("horizon:admin:volumes:volume_types:create_type")
success_url = 'horizon:admin:volumes:volume_types_tab' success_url = 'horizon:admin:volumes:volume_types_tab'
page_title = _("Create a Volume Type") page_title = _("Create a Volume Type")
@ -75,8 +79,13 @@ class VolumeTypeEncryptionDetailView(generic.TemplateView):
class CreateVolumeTypeEncryptionView(forms.ModalFormView): class CreateVolumeTypeEncryptionView(forms.ModalFormView):
form_class = volume_types_forms.CreateVolumeTypeEncryption form_class = volume_types_forms.CreateVolumeTypeEncryption
form_id = "create_volume_form"
modal_header = _("Create Volume Type Encryption")
modal_id = "create_volume_type_modal"
template_name = ("admin/volumes/volume_types/" template_name = ("admin/volumes/volume_types/"
"create_volume_type_encryption.html") "create_volume_type_encryption.html")
submit_label = _("Create Volume Type Encryption")
submit_url = "horizon:admin:volumes:volume_types:create_type_encryption"
success_url = reverse_lazy('horizon:admin:volumes:index') success_url = reverse_lazy('horizon:admin:volumes:index')
page_title = _("Create an Encrypted Volume Type") page_title = _("Create an Encrypted Volume Type")
@ -97,6 +106,8 @@ class CreateVolumeTypeEncryptionView(forms.ModalFormView):
context = super(CreateVolumeTypeEncryptionView, self).\ context = super(CreateVolumeTypeEncryptionView, self).\
get_context_data(**kwargs) get_context_data(**kwargs)
context['volume_type_id'] = self.kwargs['volume_type_id'] context['volume_type_id'] = self.kwargs['volume_type_id']
args = (self.kwargs['volume_type_id'],)
context['submit_url'] = reverse(self.submit_url, args=args)
return context return context
def get_initial(self): def get_initial(self):
@ -107,9 +118,14 @@ class CreateVolumeTypeEncryptionView(forms.ModalFormView):
class CreateQosSpecView(forms.ModalFormView): class CreateQosSpecView(forms.ModalFormView):
form_class = volumes_forms.CreateQosSpec form_class = volumes_forms.CreateQosSpec
modal_header = _("Create QoS Spec")
modal_id = "create_volume_type_modal"
template_name = 'admin/volumes/volume_types/create_qos_spec.html' template_name = 'admin/volumes/volume_types/create_qos_spec.html'
success_url = 'horizon:admin:volumes:volume_types_tab' success_url = 'horizon:admin:volumes:volume_types_tab'
page_title = _("Create a QoS Spec") page_title = _("Create a QoS Spec")
submit_label = _("Create")
submit_url = reverse_lazy(
"horizon:admin:volumes:volume_types:create_qos_spec")
def get_success_url(self): def get_success_url(self):
return reverse(self.success_url) return reverse(self.success_url)
@ -117,7 +133,11 @@ class CreateQosSpecView(forms.ModalFormView):
class EditQosSpecConsumerView(forms.ModalFormView): class EditQosSpecConsumerView(forms.ModalFormView):
form_class = volume_types_forms.EditQosSpecConsumer form_class = volume_types_forms.EditQosSpecConsumer
modal_header = _("Edit Consumer of QoS Spec")
modal_id = "edit_qos_spec_modal"
template_name = 'admin/volumes/volume_types/edit_qos_spec_consumer.html' template_name = 'admin/volumes/volume_types/edit_qos_spec_consumer.html'
submit_label = _("Modify Consumer")
submit_url = "horizon:admin:volumes:volume_types:edit_qos_spec_consumer"
success_url = 'horizon:admin:volumes:volume_types_tab' success_url = 'horizon:admin:volumes:volume_types_tab'
page_title = _("Edit QoS Spec Consumer") page_title = _("Edit QoS Spec Consumer")
@ -128,6 +148,8 @@ class EditQosSpecConsumerView(forms.ModalFormView):
context = super(EditQosSpecConsumerView, self).\ context = super(EditQosSpecConsumerView, self).\
get_context_data(**kwargs) get_context_data(**kwargs)
context['qos_spec_id'] = self.kwargs["qos_spec_id"] context['qos_spec_id'] = self.kwargs["qos_spec_id"]
args = (self.kwargs['qos_spec_id'],)
context['submit_url'] = reverse(self.submit_url, args=args)
return context return context
@memoized.memoized_method @memoized.memoized_method
@ -150,7 +172,12 @@ class EditQosSpecConsumerView(forms.ModalFormView):
class ManageQosSpecAssociationView(forms.ModalFormView): class ManageQosSpecAssociationView(forms.ModalFormView):
form_class = volume_types_forms.ManageQosSpecAssociation form_class = volume_types_forms.ManageQosSpecAssociation
modal_header = _("Associate QoS Spec with Volume Type")
modal_id = "associate_qos_spec_modal"
template_name = 'admin/volumes/volume_types/associate_qos_spec.html' template_name = 'admin/volumes/volume_types/associate_qos_spec.html'
submit_label = _("Associate")
submit_url = "horizon:admin:volumes:volume_types:"\
"manage_qos_spec_association"
success_url = 'horizon:admin:volumes:volume_types_tab' success_url = 'horizon:admin:volumes:volume_types_tab'
page_title = _("Associate QoS Spec with Volume Type") page_title = _("Associate QoS Spec with Volume Type")
@ -161,6 +188,8 @@ class ManageQosSpecAssociationView(forms.ModalFormView):
context = super(ManageQosSpecAssociationView, self).\ context = super(ManageQosSpecAssociationView, self).\
get_context_data(**kwargs) get_context_data(**kwargs)
context['type_id'] = self.kwargs["type_id"] context['type_id'] = self.kwargs["type_id"]
args = (self.kwargs['type_id'],)
context['submit_url'] = reverse(self.submit_url, args=args)
return context return context
@memoized.memoized_method @memoized.memoized_method

View File

@ -92,13 +92,19 @@ class CreateVolumeTypeView(forms.ModalFormView):
class UpdateStatusView(forms.ModalFormView): class UpdateStatusView(forms.ModalFormView):
form_class = volumes_forms.UpdateStatus form_class = volumes_forms.UpdateStatus
modal_header = _("Update Volume Status")
modal_id = "update_volume_status_modal"
template_name = 'admin/volumes/volumes/update_status.html' template_name = 'admin/volumes/volumes/update_status.html'
submit_label = _("Update Status")
submit_url = "horizon:admin:volumes:volumes:update_status"
success_url = reverse_lazy('horizon:admin:volumes:index') success_url = reverse_lazy('horizon:admin:volumes:index')
page_title = _("Update Volume Status") page_title = _("Update Volume Status")
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(UpdateStatusView, self).get_context_data(**kwargs) context = super(UpdateStatusView, self).get_context_data(**kwargs)
context["volume_id"] = self.kwargs['volume_id'] context["volume_id"] = self.kwargs['volume_id']
args = (self.kwargs['volume_id'],)
context['submit_url'] = reverse(self.submit_url, args=args)
return context return context
@memoized.memoized_method @memoized.memoized_method

View File

@ -30,12 +30,17 @@ from openstack_dashboard.dashboards.project.volumes.backups \
class CreateBackupView(forms.ModalFormView): class CreateBackupView(forms.ModalFormView):
form_class = backup_forms.CreateBackupForm form_class = backup_forms.CreateBackupForm
modal_header = _("Create Volume Backup")
template_name = 'project/volumes/backups/create_backup.html' template_name = 'project/volumes/backups/create_backup.html'
submit_label = _("Create Volume Backup")
submit_url = "horizon:project:volumes:volumes:create_backup"
success_url = reverse_lazy("horizon:project:volumes:backups_tab") success_url = reverse_lazy("horizon:project:volumes:backups_tab")
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(CreateBackupView, self).get_context_data(**kwargs) context = super(CreateBackupView, self).get_context_data(**kwargs)
context['volume_id'] = self.kwargs['volume_id'] context['volume_id'] = self.kwargs['volume_id']
args = (self.kwargs['volume_id'],)
context['submit_url'] = reverse(self.submit_url, args=args)
return context return context
def get_initial(self): def get_initial(self):
@ -79,12 +84,17 @@ class BackupDetailView(tabs.TabView):
class RestoreBackupView(forms.ModalFormView): class RestoreBackupView(forms.ModalFormView):
form_class = backup_forms.RestoreBackupForm form_class = backup_forms.RestoreBackupForm
modal_header = _("Restore Volume Backup")
template_name = 'project/volumes/backups/restore_backup.html' template_name = 'project/volumes/backups/restore_backup.html'
submit_label = _("Restore Backup to Volume")
submit_url = "horizon:project:volumes:volumes:create_backup"
success_url = reverse_lazy('horizon:project:volumes:index') success_url = reverse_lazy('horizon:project:volumes:index')
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(RestoreBackupView, self).get_context_data(**kwargs) context = super(RestoreBackupView, self).get_context_data(**kwargs)
context['backup_id'] = self.kwargs['backup_id'] context['backup_id'] = self.kwargs['backup_id']
args = (self.kwargs['backup_id'],)
context['submit_url'] = reverse(self.submit_url, args=args)
return context return context
def get_initial(self): def get_initial(self):

View File

@ -31,7 +31,11 @@ from openstack_dashboard.dashboards.project.volumes \
class UpdateView(forms.ModalFormView): class UpdateView(forms.ModalFormView):
form_class = vol_snapshot_forms.UpdateForm form_class = vol_snapshot_forms.UpdateForm
form_id = "update_snapshot_form"
modal_header = _("Edit Snapshot")
template_name = 'project/volumes/snapshots/update.html' template_name = 'project/volumes/snapshots/update.html'
submit_label = _("Save Changes")
submit_url = "horizon:project:volumes:snapshots:update"
success_url = reverse_lazy("horizon:project:volumes:index") success_url = reverse_lazy("horizon:project:volumes:index")
@memoized.memoized_method @memoized.memoized_method
@ -49,6 +53,8 @@ class UpdateView(forms.ModalFormView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(UpdateView, self).get_context_data(**kwargs) context = super(UpdateView, self).get_context_data(**kwargs)
context['snapshot'] = self.get_object() context['snapshot'] = self.get_object()
args = (self.kwargs['snapshot_id'],)
context['submit_url'] = reverse(self.submit_url, args=args)
return context return context
def get_initial(self): def get_initial(self):

View File

@ -1,26 +1,7 @@
{% extends "horizon/common/_modal_form.html" %} {% extends "horizon/common/_modal_form.html" %}
{% load i18n %} {% load i18n %}
{% load url from future %}
{% block form_id %}{% endblock %} {% block modal-body-right %}
{% block form_action %}{% url 'horizon:project:volumes:volumes:create_backup' volume_id %}{% endblock %} <p><strong>{% trans "Volume Backup:" %}</strong> {% trans "Volume Backups are stored using the Object Storage service. You must have this service activated in order to create a backup." %}</p>
<p>{% trans "If no container name is provided, a default container named volumebackups will be provisioned for you. Backups will be the same size as the volume they originate from." %}</p>
{% block modal_id %}create_volume_backup_modal{% endblock %}
{% block modal-header %}{% trans "Create Volume Backup" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<p><strong>{% trans "Volume Backup:" %}</strong> {% trans "Volume Backups are stored using the Object Storage service. You must have this service activated in order to create a backup." %}</p>
<p>{% trans "If no container name is provided, a default container named volumebackups will be provisioned for you. Backups will be the same size as the volume they originate from." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Create Volume Backup" %}" />
<a href="{% url 'horizon:project:volumes:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %} {% endblock %}

View File

@ -1,26 +1,7 @@
{% extends "horizon/common/_modal_form.html" %} {% extends "horizon/common/_modal_form.html" %}
{% load i18n %} {% load i18n %}
{% load url from future %}
{% block form_id %}{% endblock %} {% block modal-body-right %}
{% block form_action %}{% url 'horizon:project:volumes:backups:restore' backup_id %}{% endblock %} <p><strong>{% trans "Restore Backup:" %}</strong> {% trans "Select a volume to restore to." %}</p>
<p>{% trans "Optionally, you may choose to create a new volume." %}</p>
{% block modal_id %}restore_volume_backup_modal{% endblock %}
{% block modal-header %}{% trans "Restore Volume Backup" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<p><strong>{% trans "Restore Backup:" %}</strong> {% trans "Select a volume to restore to." %}</p>
<p>{% trans "Optionally, you may choose to create a new volume." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Restore Backup to Volume"%}" />
<a href="{% url 'horizon:project:volumes:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %} {% endblock %}

View File

@ -1,26 +1,7 @@
{% extends "horizon/common/_modal_form.html" %} {% extends "horizon/common/_modal_form.html" %}
{% load i18n %} {% load i18n %}
{% load url from future %}
{% block form_id %}update_snapshot_form{% endblock %} {% block modal-body-right %}
{% block form_action %}{% url 'horizon:project:volumes:snapshots:update' snapshot.id %}{% endblock %} <h3>{% trans "Description:" %}</h3>
<p>{% trans "Modify the name and description of a snapshot." %}</p>
{% block modal_id %}update_snapshot_modal{% endblock %}
{% block modal-header %}{% trans "Edit Snapshot" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Modify the name and description of a snapshot." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Edit Snapshot" %}" />
<a href="{% url 'horizon:project:volumes:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %} {% endblock %}

View File

@ -2,20 +2,15 @@
{% load i18n %} {% load i18n %}
{% load url from future %} {% load url from future %}
{% block form_id %}attach_volume_form{% endblock %}
{% block form_action %}{% url 'horizon:project:volumes:volumes:attach' volume.id %}{% endblock %}
{% block form_class %}{{ block.super }} horizontal {% if show_attach %}split_half{% else %} no_split{% endif %}{% endblock %} {% block form_class %}{{ block.super }} horizontal {% if show_attach %}split_half{% else %} no_split{% endif %}{% endblock %}
{% block modal_id %}attach_volume_modal{% endblock %}
{% block modal-header %}{% trans "Manage Volume Attachments" %}{% endblock %}
{% block modal-body %} {% block modal-body %}
{% if show_attach %} {% if show_attach %}
<h3>{% trans "Attach To Instance" %}</h3> <h3>{% trans "Attach To Instance" %}</h3>
<fieldset> <fieldset>
{% include "horizon/common/_form_fields.html" %} {% include "horizon/common/_form_fields.html" %}
</fieldset> </fieldset>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block modal-footer %} {% block modal-footer %}

View File

@ -1,26 +1,8 @@
{% extends "horizon/common/_modal_form.html" %} {% extends "horizon/common/_modal_form.html" %}
{% load i18n %} {% load i18n %}
{% load url from future %}
{% block form_id %}{% endblock %} {% block modal-body-right %}
{% block form_action %}{% url 'horizon:project:volumes:volumes:create' %}?{{ request.GET.urlencode }}{% endblock %} <div class="quota-dynamic">
{% block modal_id %}create_volume_modal{% endblock %}
{% block modal-header %}{% trans "Create Volume" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right quota-dynamic">
{% include "project/volumes/volumes/_limits.html" with usages=usages %} {% include "project/volumes/volumes/_limits.html" with usages=usages %}
</div> </div>
{% endblock %} {% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Create Volume" %}" />
<a href="{% url 'horizon:project:volumes:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@ -2,19 +2,8 @@
{% load i18n %} {% load i18n %}
{% load url from future %} {% load url from future %}
{% block form_id %}{% endblock %} {% block modal-body-right %}
{% block form_action %}{% url 'horizon:project:volumes:volumes:create_snapshot' volume_id %}{% endblock %} <div class="quota-dynamic">
{% block modal_id %}create_volume_snapshot_modal{% endblock %}
{% block modal-header %}{% trans "Create Volume Snapshot" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right quota-dynamic">
{% include "project/volumes/volumes/_snapshot_limits.html" with usages=usages snapshot_quota=True %} {% include "project/volumes/volumes/_snapshot_limits.html" with usages=usages snapshot_quota=True %}
</div> </div>
{% endblock %} {% endblock %}

View File

@ -1,26 +1,8 @@
{% extends "horizon/common/_modal_form.html" %} {% extends "horizon/common/_modal_form.html" %}
{% load i18n %} {% load i18n %}
{% load url from future %}
{% block form_id %}{% endblock %} {% block modal-body-right %}
{% block form_action %}{% url 'horizon:project:volumes:volumes:extend' volume.id %}{% endblock %} <div class="quota-dynamic">
{% block modal_id %}extend_volume_modal{% endblock %}
{% block modal-header %}{% trans "Extend Volume" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right quota-dynamic">
{% include "project/volumes/volumes/_extend_limits.html" with usages=usages %} {% include "project/volumes/volumes/_extend_limits.html" with usages=usages %}
</div> </div>
{% endblock %} {% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Extend Volume" %}" />
<a href="{% url 'horizon:project:volumes:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@ -1,41 +1,22 @@
{% extends "horizon/common/_modal_form.html" %} {% extends "horizon/common/_modal_form.html" %}
{% load i18n %} {% load i18n %}
{% load url from future %}
{% block form_id %}{% endblock %} {% block modal-body-right %}
{% block form_action %}{% url 'horizon:project:volumes:volumes:retype' volume.id %}{% endblock %} <h3>{% trans "Description:" %}</h3>
<p>{% blocktrans %}
{% block modal_id %}retype_volume_modal{% endblock %} Change the volume type of a volume after its creation.
{% block modal-header %}{% trans "Change Volume Type" %}{% endblock %} This is equivalent to the <tt>cinder retype</tt> command.
{% endblocktrans %}
{% block modal-body %} </p>
<div class="left"> <p>{% blocktrans %}
<fieldset> The "Volume Type" selected must be different from the current volume type.
{% include "horizon/common/_form_fields.html" %} {% endblocktrans %}
</fieldset> </p>
</div> <p>{% blocktrans %}
<div class="right"> The "Migration Policy" is only used if the volume retype cannot be
<h3>{% trans "Description:" %}</h3> completed. If the "Migration Policy" is "On Demand", the back end will
<p>{% blocktrans %} perform volume migration. Note that migration may take a significant
Change the volume type of a volume after its creation. amount of time to complete, in some cases hours.
This is equivalent to the <tt>cinder retype</tt> command. {% endblocktrans %}
{% endblocktrans %} </p>
</p>
<p>{% blocktrans %}
The "Volume Type" selected must be different from the current volume type.
{% endblocktrans %}
</p>
<p>{% blocktrans %}
The "Migration Policy" is only used if the volume retype cannot be
completed. If the "Migration Policy" is "On Demand", the back end will
perform volume migration. Note that migration may take a significant
amount of time to complete, in some cases hours.
{% endblocktrans %}
</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Change Volume Type" %}" />
<a href="{% url 'horizon:project:volumes:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %} {% endblock %}

View File

@ -6,7 +6,3 @@
<p>{% trans "The Transfer ID and the Authorization Key are needed by the recipient in order to accept the transfer. Please capture both the Transfer ID and the Authorization Key and provide them to your transfer recipient." %}</p> <p>{% trans "The Transfer ID and the Authorization Key are needed by the recipient in order to accept the transfer. Please capture both the Transfer ID and the Authorization Key and provide them to your transfer recipient." %}</p>
<p class="alert alert-warning">{% trans "The Authorization Key will not be available after closing this page, so you must capture it now, or else you will be unable to use the transfer." %}</p> <p class="alert alert-warning">{% trans "The Authorization Key will not be available after closing this page, so you must capture it now, or else you will be unable to use the transfer." %}</p>
{% endblock %} {% endblock %}
{% block modal-footer %}
<a href="{% url 'horizon:project:volumes:volumes_tab' %}" class="btn btn-default secondary cancel close">{% trans "Close" %}</a>
{% endblock %}

View File

@ -1,29 +1,8 @@
{% extends "horizon/common/_modal_form.html" %} {% extends "horizon/common/_modal_form.html" %}
{% load i18n %} {% load i18n %}
{% load url from future %}
{% block form_id %}{% endblock %} {% block modal-body-right %}
{% block form_action %}{% url 'horizon:project:volumes:volumes:update' volume.id %}{% endblock %} <h3>{% trans "Description:" %}</h3>
<p>{% trans "Modify name and description of a volume." %}</p>
{% block modal_id %}update_volume_modal{% endblock %} <p>{% trans 'The "Bootable" flag specifies that this volume can be used to launch an instance.' %}</p>
{% block modal-header %}{% trans "Edit Volume" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Modify name and description of a volume." %}
</p>
<p>{% trans 'The "Bootable" flag specifies that this volume can be used to launch an instance.' %}
</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save" %}" />
<a href="{% url 'horizon:project:volumes:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %} {% endblock %}

View File

@ -1,42 +1,23 @@
{% extends "horizon/common/_modal_form.html" %} {% extends "horizon/common/_modal_form.html" %}
{% load i18n %} {% load i18n %}
{% load url from future %}
{% block form_id %}{% endblock %} {% block modal-body-right %}
{% block form_action %}{% url 'horizon:project:volumes:volumes:upload_to_image' volume.id %}{% endblock %} <h3>{% trans "Description:" %}</h3>
<p>{% blocktrans %}
{% block modal_id %}update_volume_modal{% endblock %} Upload the volume to the Image Service as an image.
{% block modal-header %}{% trans "Upload Volume to Image" %}{% endblock %} This is equivalent to the <tt>cinder upload-to-image</tt> command.
{% endblocktrans %}
{% block modal-body %} </p>
<div class="left"> <p>{% blocktrans %}
<fieldset> Choose "Disk Format" for the image. The volume images are created with
{% include "horizon/common/_form_fields.html" %} the QEMU disk image utility.
</fieldset> {% endblocktrans %}
</div> </p>
<div class="right"> {% if volume.status == 'in-use' %}
<h3>{% trans "Description:" %}</h3>
<p>{% blocktrans %} <p>{% blocktrans %}
Upload the volume to the Image Service as an image. When the volume status is "in-use", you can use "Force" to upload the
This is equivalent to the <tt>cinder upload-to-image</tt> command. volume to an image.
{% endblocktrans %} {% endblocktrans %}
</p> </p>
<p>{% blocktrans %} {% endif %}
Choose "Disk Format" for the image. The volume images are created with
the QEMU disk image utility.
{% endblocktrans %}
</p>
{% if volume.status == 'in-use' %}
<p>{% blocktrans %}
When the volume status is "in-use", you can use "Force" to upload the
volume to an image.
{% endblocktrans %}
</p>
{% endif %}
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Upload" %}" />
<a href="{% url 'horizon:project:volumes:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %} {% endblock %}

View File

@ -79,7 +79,10 @@ class DetailView(tabs.TabView):
class CreateView(forms.ModalFormView): class CreateView(forms.ModalFormView):
form_class = project_forms.CreateForm form_class = project_forms.CreateForm
modal_header = _("Create Volume")
template_name = 'project/volumes/volumes/create.html' template_name = 'project/volumes/volumes/create.html'
submit_label = _("Create Volume")
submit_url = reverse_lazy("horizon:project:volumes:volumes:create")
success_url = reverse_lazy('horizon:project:volumes:volumes_tab') success_url = reverse_lazy('horizon:project:volumes:volumes_tab')
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
@ -93,7 +96,10 @@ class CreateView(forms.ModalFormView):
class ExtendView(forms.ModalFormView): class ExtendView(forms.ModalFormView):
form_class = project_forms.ExtendForm form_class = project_forms.ExtendForm
modal_header = _("Extend Volume")
template_name = 'project/volumes/volumes/extend.html' template_name = 'project/volumes/volumes/extend.html'
submit_label = _("Extend Volume")
submit_url = "horizon:project:volumes:volumes:extend"
success_url = reverse_lazy("horizon:project:volumes:index") success_url = reverse_lazy("horizon:project:volumes:index")
def get_object(self): def get_object(self):
@ -110,6 +116,8 @@ class ExtendView(forms.ModalFormView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(ExtendView, self).get_context_data(**kwargs) context = super(ExtendView, self).get_context_data(**kwargs)
context['volume'] = self.get_object() context['volume'] = self.get_object()
args = (self.kwargs['volume_id'],)
context['submit_url'] = reverse(self.submit_url, args=args)
try: try:
usages = quotas.tenant_limit_usages(self.request) usages = quotas.tenant_limit_usages(self.request)
usages['gigabytesUsed'] = (usages['gigabytesUsed'] usages['gigabytesUsed'] = (usages['gigabytesUsed']
@ -128,12 +136,16 @@ class ExtendView(forms.ModalFormView):
class CreateSnapshotView(forms.ModalFormView): class CreateSnapshotView(forms.ModalFormView):
form_class = project_forms.CreateSnapshotForm form_class = project_forms.CreateSnapshotForm
modal_header = _("Create Volume Snapshot")
template_name = 'project/volumes/volumes/create_snapshot.html' template_name = 'project/volumes/volumes/create_snapshot.html'
submit_url = "horizon:project:volumes:volumes:create_snapshot"
success_url = reverse_lazy('horizon:project:volumes:snapshots_tab') success_url = reverse_lazy('horizon:project:volumes:snapshots_tab')
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(CreateSnapshotView, self).get_context_data(**kwargs) context = super(CreateSnapshotView, self).get_context_data(**kwargs)
context['volume_id'] = self.kwargs['volume_id'] context['volume_id'] = self.kwargs['volume_id']
args = (self.kwargs['volume_id'],)
context['submit_url'] = reverse(self.submit_url, args=args)
try: try:
volume = cinder.volume_get(self.request, context['volume_id']) volume = cinder.volume_get(self.request, context['volume_id'])
if (volume.status == 'in-use'): if (volume.status == 'in-use'):
@ -156,7 +168,10 @@ class CreateSnapshotView(forms.ModalFormView):
class UploadToImageView(forms.ModalFormView): class UploadToImageView(forms.ModalFormView):
form_class = project_forms.UploadToImageForm form_class = project_forms.UploadToImageForm
modal_header = _("Upload Volume to Image")
template_name = 'project/volumes/volumes/upload_to_image.html' template_name = 'project/volumes/volumes/upload_to_image.html'
submit_label = _("Upload")
submit_url = "horizon:project:volumes:volumes:upload_to_image"
success_url = reverse_lazy("horizon:project:volumes:index") success_url = reverse_lazy("horizon:project:volumes:index")
@memoized.memoized_method @memoized.memoized_method
@ -177,7 +192,8 @@ class UploadToImageView(forms.ModalFormView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(UploadToImageView, self).get_context_data(**kwargs) context = super(UploadToImageView, self).get_context_data(**kwargs)
context['volume'] = self.get_data() context['volume'] = self.get_data()
args = (self.kwargs['volume_id'],)
context['submit_url'] = reverse(self.submit_url, args=args)
return context return context
def get_initial(self): def get_initial(self):
@ -256,7 +272,11 @@ class ShowTransferView(forms.ModalFormView):
class UpdateView(forms.ModalFormView): class UpdateView(forms.ModalFormView):
form_class = project_forms.UpdateForm form_class = project_forms.UpdateForm
modal_header = _("Edit Volume")
modal_id = "update_volume_modal"
template_name = 'project/volumes/volumes/update.html' template_name = 'project/volumes/volumes/update.html'
submit_label = _("Save")
submit_url = "horizon:project:volumes:volumes:update"
success_url = reverse_lazy("horizon:project:volumes:index") success_url = reverse_lazy("horizon:project:volumes:index")
def get_object(self): def get_object(self):
@ -273,6 +293,8 @@ class UpdateView(forms.ModalFormView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(UpdateView, self).get_context_data(**kwargs) context = super(UpdateView, self).get_context_data(**kwargs)
context['volume'] = self.get_object() context['volume'] = self.get_object()
args = (self.kwargs['volume_id'],)
context['submit_url'] = reverse(self.submit_url, args=args)
return context return context
def get_initial(self): def get_initial(self):
@ -286,7 +308,11 @@ class UpdateView(forms.ModalFormView):
class EditAttachmentsView(tables.DataTableView, forms.ModalFormView): class EditAttachmentsView(tables.DataTableView, forms.ModalFormView):
table_class = project_tables.AttachmentsTable table_class = project_tables.AttachmentsTable
form_class = project_forms.AttachForm form_class = project_forms.AttachForm
form_id = "attach_volume_form"
modal_header = _("Manage Volume Attachments")
modal_id = "attach_volume_modal"
template_name = 'project/volumes/volumes/attach.html' template_name = 'project/volumes/volumes/attach.html'
submit_url = "horizon:project:volumes:volumes:attach"
success_url = reverse_lazy("horizon:project:volumes:index") success_url = reverse_lazy("horizon:project:volumes:index")
@memoized.memoized_method @memoized.memoized_method
@ -327,6 +353,8 @@ class EditAttachmentsView(tables.DataTableView, forms.ModalFormView):
context = super(EditAttachmentsView, self).get_context_data(**kwargs) context = super(EditAttachmentsView, self).get_context_data(**kwargs)
context['form'] = self.get_form() context['form'] = self.get_form()
volume = self.get_object() volume = self.get_object()
args = (self.kwargs['volume_id'],)
context['submit_url'] = reverse(self.submit_url, args=args)
if volume and volume.status == 'available': if volume and volume.status == 'available':
context['show_attach'] = True context['show_attach'] = True
else: else:
@ -353,7 +381,11 @@ class EditAttachmentsView(tables.DataTableView, forms.ModalFormView):
class RetypeView(forms.ModalFormView): class RetypeView(forms.ModalFormView):
form_class = project_forms.RetypeForm form_class = project_forms.RetypeForm
modal_id = "retype_volume_modal"
modal_header = _("Change Volume Type")
template_name = 'project/volumes/volumes/retype.html' template_name = 'project/volumes/volumes/retype.html'
submit_label = _("Change Volume Type")
submit_url = "horizon:project:volumes:volumes:retype"
success_url = reverse_lazy("horizon:project:volumes:index") success_url = reverse_lazy("horizon:project:volumes:index")
@memoized.memoized_method @memoized.memoized_method
@ -374,7 +406,8 @@ class RetypeView(forms.ModalFormView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(RetypeView, self).get_context_data(**kwargs) context = super(RetypeView, self).get_context_data(**kwargs)
context['volume'] = self.get_data() context['volume'] = self.get_data()
args = (self.kwargs['volume_id'],)
context['submit_url'] = reverse(self.submit_url, args=args)
return context return context
def get_initial(self): def get_initial(self):