Added Images panel

Change-Id: Icf80250df8af0fc4cf9b7d6a19a116734f786653
This commit is contained in:
Tzu-Mainn Chen 2014-08-01 23:21:44 +02:00
parent 651158dfea
commit f163e8b961
8 changed files with 159 additions and 0 deletions

View File

@ -24,6 +24,7 @@ class BasePanels(horizon.PanelGroup):
'plans',
'nodes',
'flavors',
'images',
'history',
)

View File

@ -0,0 +1,27 @@
# -*- coding: utf8 -*-
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django.utils.translation import ugettext_lazy as _
import horizon
from tuskar_ui.infrastructure import dashboard
class Images(horizon.Panel):
name = _("Provisioning Images")
slug = "images"
dashboard.Infrastructure.register(Images)

View File

@ -0,0 +1,32 @@
# -*- coding: utf8 -*-
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django.utils.translation import ugettext_lazy as _
from horizon import tables
class ImagesTable(tables.DataTable):
name = tables.Column('name',
verbose_name=_("Image Name"))
disk_format = tables.Column('disk_format',
verbose_name=_("Format"))
class Meta:
name = "images"
verbose_name = _("Provisioning Images")
multi_select = False
table_actions = ()
row_actions = ()

View File

@ -0,0 +1,17 @@
{% extends 'infrastructure/base.html' %}
{% load i18n %}
{% block title %}{% trans 'Provisioning Images' %}{% endblock %}
{% block page_header %}
{% include 'horizon/common/_page_header.html' with title=_('Provisioning Images') %}
{% endblock page_header %}
{% block main %}
<div class="row-fluid">
<div class="span12">
<h4>{% trans "Provisioning Images" %}</h4>
{{ table.render }}
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,33 @@
# -*- coding: utf8 -*-
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django.core import urlresolvers
from mock import patch, call # noqa
from tuskar_ui.test import helpers as test
INDEX_URL = urlresolvers.reverse(
'horizon:infrastructure:images:index')
class ImagesTest(test.BaseAdminViewTests):
def test_index(self):
with patch('openstack_dashboard.api.glance.image_list_detailed',
return_value=[self.images.list(), False, False]):
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'infrastructure/images/index.html')

View File

@ -0,0 +1,23 @@
# -*- coding: utf8 -*-
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django.conf import urls
from tuskar_ui.infrastructure.images import views
urlpatterns = urls.patterns(
'',
urls.url(r'^$', views.IndexView.as_view(), name='index'),
)

View File

@ -0,0 +1,26 @@
# -*- coding: utf8 -*-
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from horizon import tables as horizon_tables
from openstack_dashboard.api import glance
from tuskar_ui.infrastructure.images import tables
class IndexView(horizon_tables.DataTableView):
table_class = tables.ImagesTable
template_name = "infrastructure/images/index.html"
def get_data(self):
return glance.image_list_detailed(self.request)[0]