Removing image forms
Removing the forms for creating images and updating image metadata, as discussed. Change-Id: Iaa2c625957ef4dc15741b44d1880946c424e62ae
This commit is contained in:
parent
9242e1f40b
commit
5172c82b18
@ -10,17 +10,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from openstack_dashboard.dashboards.admin.images import forms as admin_forms
|
||||
from openstack_dashboard.dashboards.project.images.images import forms
|
||||
|
||||
|
||||
class CreateImageForm(forms.CreateImageForm):
|
||||
pass
|
||||
|
||||
|
||||
class UpdateImageForm(forms.UpdateImageForm):
|
||||
pass
|
||||
|
||||
|
||||
class UpdateMetadataForm(admin_forms.UpdateMetadataForm):
|
||||
pass
|
||||
|
@ -19,10 +19,6 @@ from openstack_dashboard.dashboards.project.images.images import (
|
||||
tables as project_tables)
|
||||
|
||||
|
||||
class CreateImage(project_tables.CreateImage):
|
||||
url = "horizon:infrastructure:images:create"
|
||||
|
||||
|
||||
class DeleteImage(project_tables.DeleteImage):
|
||||
def allowed(self, request, image=None):
|
||||
if image and image.protected:
|
||||
@ -55,14 +51,6 @@ class EditImage(project_tables.EditImage):
|
||||
return True
|
||||
|
||||
|
||||
class UpdateMetadata(tables.LinkAction):
|
||||
url = "horizon:infrastructure:images:update_metadata"
|
||||
name = "update_metadata"
|
||||
verbose_name = _("Update Metadata")
|
||||
classes = ("ajax-modal",)
|
||||
icon = "pencil"
|
||||
|
||||
|
||||
class ImagesTable(tables.DataTable):
|
||||
|
||||
name = tables.Column('name',
|
||||
@ -78,6 +66,6 @@ class ImagesTable(tables.DataTable):
|
||||
row_class = UpdateRow
|
||||
verbose_name = _("Provisioning Images")
|
||||
multi_select = False
|
||||
table_actions = (CreateImage, DeleteImage,
|
||||
table_actions = (DeleteImage,
|
||||
ImageFilterAction)
|
||||
row_actions = (EditImage, UpdateMetadata, DeleteImage)
|
||||
row_actions = (EditImage, DeleteImage)
|
||||
|
@ -1,35 +0,0 @@
|
||||
{% extends "horizon/common/_modal_form.html" %}
|
||||
{% load i18n %}
|
||||
{% load url from future %}
|
||||
|
||||
{% block form_id %}create_image_form{% endblock %}
|
||||
{% block form_action %}{% url 'horizon:infrastructure:images:create' %}{% endblock %}
|
||||
{% block form_attrs %}enctype="multipart/form-data"{% endblock %}
|
||||
|
||||
{% block modal-header %}{% trans "Create An Image" %}{% 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 "Specify an image to upload to the Image Service." %}
|
||||
</p>
|
||||
<p>
|
||||
{% trans "Currently only images available via an HTTP URL are supported. The image location must be accessible to the Image Service. Compressed image binaries are supported (.zip and .tar.gz.)" %}
|
||||
</p>
|
||||
<p>
|
||||
<strong>{% trans "Please note: " %}</strong>
|
||||
{% trans "The Image Location field MUST be a valid and direct URL to the image binary. URLs that redirect or serve error pages will result in unusable images." %}
|
||||
</p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block modal-footer %}
|
||||
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Create Image" %}" />
|
||||
<a href="{% url 'horizon:infrastructure:images:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
|
||||
{% endblock %}
|
@ -1,11 +0,0 @@
|
||||
{% extends 'horizon/common/_modal_form_update_metadata.html' %}
|
||||
{% load i18n %}
|
||||
{% load url from future %}
|
||||
{% block title %}{% trans "Update Image Metadata" %}{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Update Image Metadata") %}
|
||||
{% endblock page_header %}
|
||||
|
||||
{% block form_action %}{% url 'horizon:infrastructure:images:update_metadata' id %}{% endblock %}
|
||||
{% block modal-header %}{% trans "Update Metadata" %}{% endblock %}
|
@ -1,11 +0,0 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Create An Image" %}{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Create An Image") %}
|
||||
{% endblock page_header %}
|
||||
|
||||
{% block main %}
|
||||
{% include 'infrastructure/images/_create.html' %}
|
||||
{% endblock %}
|
@ -1,11 +0,0 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Update Image Metadata" %}{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Update Image Metadata") %}
|
||||
{% endblock page_header %}
|
||||
|
||||
{% block main %}
|
||||
{% include 'infrastructure/images/_update_metadata.html' %}
|
||||
{% endblock %}
|
@ -13,7 +13,6 @@
|
||||
# under the License.
|
||||
|
||||
import contextlib
|
||||
import json
|
||||
|
||||
import mock
|
||||
from mock import patch, call # noqa
|
||||
@ -25,10 +24,7 @@ from tuskar_ui.test import helpers as test
|
||||
|
||||
INDEX_URL = urlresolvers.reverse(
|
||||
'horizon:infrastructure:images:index')
|
||||
CREATE_URL = urlresolvers.reverse(
|
||||
'horizon:infrastructure:images:create')
|
||||
UPDATE_URL = 'horizon:infrastructure:images:update'
|
||||
IMAGE_METADATA_URL = 'horizon:infrastructure:images:update_metadata'
|
||||
|
||||
|
||||
class ImagesTest(test.BaseAdminViewTests):
|
||||
@ -51,11 +47,6 @@ class ImagesTest(test.BaseAdminViewTests):
|
||||
|
||||
self.assertTemplateUsed(res, 'infrastructure/images/index.html')
|
||||
|
||||
def test_create_get(self):
|
||||
res = self.client.get(CREATE_URL)
|
||||
|
||||
self.assertTemplateUsed(res, 'infrastructure/images/create.html')
|
||||
|
||||
def test_update_get(self):
|
||||
image = self.images.list()[0]
|
||||
|
||||
@ -69,39 +60,6 @@ class ImagesTest(test.BaseAdminViewTests):
|
||||
mocked_get.assert_called_once_with(mock.ANY, image.id)
|
||||
self.assertTemplateUsed(res, 'infrastructure/images/update.html')
|
||||
|
||||
def test_create_post(self):
|
||||
image = self.images.list()[0]
|
||||
data = {
|
||||
'name': 'Fedora',
|
||||
'description': 'Login with admin/admin',
|
||||
'source_type': 'url',
|
||||
'copy_from': 'http://test_url.com',
|
||||
'disk_format': 'qcow2',
|
||||
'architecture': 'x86-64',
|
||||
'minimum_disk': 15,
|
||||
'minimum_ram': 512,
|
||||
'is_public': True,
|
||||
'protected': False}
|
||||
|
||||
forms.IMAGE_FORMAT_CHOICES = [('qcow2', 'qcow2')]
|
||||
|
||||
with contextlib.nested(
|
||||
patch('openstack_dashboard.api.glance.image_create',
|
||||
return_value=image),) as (mocked_create,):
|
||||
|
||||
res = self.client.post(CREATE_URL, data)
|
||||
|
||||
self.assertNoFormErrors(res)
|
||||
self.assertEqual(res.status_code, 302)
|
||||
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||
|
||||
mocked_create.assert_called_once_with(
|
||||
mock.ANY, name=u'Fedora', container_format='bare', min_ram=512,
|
||||
disk_format=u'qcow2', copy_from=u'http://test_url.com',
|
||||
protected=False, min_disk=15, is_public=True,
|
||||
properties={'description': u'Login with admin/admin',
|
||||
'architecture': u'x86-64'})
|
||||
|
||||
def test_update_post(self):
|
||||
image = self.images.list()[0]
|
||||
data = {
|
||||
@ -168,54 +126,3 @@ class ImagesTest(test.BaseAdminViewTests):
|
||||
call(mock.ANY, images[1].id))
|
||||
self.assertNoFormErrors(res)
|
||||
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||
|
||||
def test_images_metadata_get(self):
|
||||
image = self.images.first()
|
||||
namespaces = self.metadata_defs.list()
|
||||
|
||||
with contextlib.nested(
|
||||
patch('openstack_dashboard.api.glance.image_get',
|
||||
return_value=image),
|
||||
patch('openstack_dashboard.api.glance.metadefs_namespace_list',
|
||||
return_value=(namespaces, False, False)),
|
||||
patch('openstack_dashboard.api.glance.metadefs_namespace_get',
|
||||
return_value=namespaces[0]),) as (
|
||||
mocked_get, mocked_namespaces_list, mocked_namespace_get,):
|
||||
|
||||
res = self.client.get(
|
||||
urlresolvers.reverse(IMAGE_METADATA_URL, args=(image.id,)))
|
||||
|
||||
mocked_get.assert_called_once_with(mock.ANY, image.id)
|
||||
mocked_namespaces_list.assert_called_once_with(
|
||||
mock.ANY, filters={'resource_types': ['OS::Glance::Image']})
|
||||
|
||||
self.assertEqual(mocked_namespace_get.call_count, 4)
|
||||
|
||||
self.assertTemplateUsed(
|
||||
res, 'infrastructure/images/update_metadata.html')
|
||||
|
||||
def test_images_metadata_update(self):
|
||||
image = self.images.first()
|
||||
|
||||
metadata = [{"value": "mock_value", "key": "hw_machine_type"}]
|
||||
formData = {"metadata": json.dumps(metadata)}
|
||||
|
||||
with contextlib.nested(
|
||||
patch('openstack_dashboard.api.glance.image_get',
|
||||
return_value=image),
|
||||
patch('openstack_dashboard.api.glance.image_update_properties',
|
||||
return_value=None),) as (
|
||||
|
||||
mocked_get, mocked_update,):
|
||||
|
||||
res = self.client.post(
|
||||
urlresolvers.reverse(IMAGE_METADATA_URL, args=(image.id,)),
|
||||
formData)
|
||||
|
||||
mocked_get.assert_called_once_with(mock.ANY, image.id)
|
||||
mocked_update.assert_called_once_with(
|
||||
mock.ANY, image.id, ['image_type'], hw_machine_type='mock_value')
|
||||
|
||||
self.assertEqual(res.status_code, 302)
|
||||
self.assertNoFormErrors(res)
|
||||
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||
|
@ -19,9 +19,6 @@ from tuskar_ui.infrastructure.images import views
|
||||
urlpatterns = urls.patterns(
|
||||
'',
|
||||
urls.url(r'^$', views.IndexView.as_view(), name='index'),
|
||||
urls.url(r'^create/$', views.CreateView.as_view(), name='create'),
|
||||
urls.url(r'^(?P<id>[^/]+)/update_metadata/$',
|
||||
views.UpdateMetadataView.as_view(), name='update_metadata'),
|
||||
urls.url(r'^(?P<image_id>[^/]+)/update/$',
|
||||
views.UpdateView.as_view(), name='update'),
|
||||
)
|
||||
|
@ -20,7 +20,6 @@ from horizon import exceptions
|
||||
from horizon import tables as horizon_tables
|
||||
from horizon.utils import memoized
|
||||
from openstack_dashboard import api
|
||||
from openstack_dashboard.dashboards.admin.images import views as admin_views
|
||||
from openstack_dashboard.dashboards.project.images.images import views
|
||||
|
||||
from tuskar_ui import api as tuskar_api
|
||||
@ -102,12 +101,6 @@ class IndexView(horizon_tables.DataTableView):
|
||||
return filters
|
||||
|
||||
|
||||
class CreateView(views.CreateView):
|
||||
template_name = 'infrastructure/images/create.html'
|
||||
form_class = forms.CreateImageForm
|
||||
success_url = reverse_lazy('horizon:infrastructure:images:index')
|
||||
|
||||
|
||||
class UpdateView(views.UpdateView):
|
||||
template_name = 'infrastructure/images/update.html'
|
||||
form_class = forms.UpdateImageForm
|
||||
@ -121,9 +114,3 @@ class UpdateView(views.UpdateView):
|
||||
msg = _('Unable to retrieve image.')
|
||||
url = reverse_lazy('horizon:infrastructure:images:index')
|
||||
exceptions.handle(self.request, msg, redirect=url)
|
||||
|
||||
|
||||
class UpdateMetadataView(admin_views.UpdateMetadataView):
|
||||
template_name = "infrastructure/images/update_metadata.html"
|
||||
form_class = forms.UpdateMetadataForm
|
||||
success_url = reverse_lazy('horizon:infrastructure:images:index')
|
||||
|
Loading…
x
Reference in New Issue
Block a user