28
from django.utils.translation import ugettext_lazy as _
28
from django.utils.translation import ugettext_lazy as _ # noqa
30
30
from horizon import exceptions
31
31
from horizon import tables
32
32
from horizon import tabs
34
34
from openstack_dashboard import api
35
from openstack_dashboard.api.base import is_service_enabled
35
from openstack_dashboard.api import base
37
from openstack_dashboard.dashboards.project.images_and_snapshots.\
38
images.tables import ImagesTable
39
from openstack_dashboard.dashboards.project.images_and_snapshots.\
40
volume_snapshots.tables import VolumeSnapshotsTable
41
from openstack_dashboard.dashboards.project.images_and_snapshots.\
42
volume_snapshots.tabs import SnapshotDetailTabs
37
from openstack_dashboard.dashboards.project.images_and_snapshots.images \
38
import tables as images_tables
39
from openstack_dashboard.dashboards.project.images_and_snapshots.\
40
volume_snapshots import tables as vol_snsh_tables
41
from openstack_dashboard.dashboards.project.images_and_snapshots.\
42
volume_snapshots import tabs as vol_snsh_tabs
44
44
LOG = logging.getLogger(__name__)
47
47
class IndexView(tables.MultiTableView):
48
table_classes = (ImagesTable, VolumeSnapshotsTable)
48
table_classes = (images_tables.ImagesTable,
49
vol_snsh_tables.VolumeSnapshotsTable)
49
50
template_name = 'project/images_and_snapshots/index.html'
51
52
def has_more_data(self, table):
52
53
return getattr(self, "_more_%s" % table.name, False)
54
55
def get_images_data(self):
55
marker = self.request.GET.get(ImagesTable._meta.pagination_param, None)
56
marker = self.request.GET.get(
57
images_tables.ImagesTable._meta.pagination_param, None)
57
59
# FIXME(gabriel): The paging is going to be strange here due to
58
60
# our filtering after the fact.
62
64
images = [im for im in all_images
63
65
if im.container_format not in ['aki', 'ari']]
66
68
exceptions.handle(self.request, _("Unable to retrieve images."))
69
71
def get_volume_snapshots_data(self):
70
if is_service_enabled(self.request, 'volume'):
72
if base.is_service_enabled(self.request, 'volume'):
72
74
snapshots = api.cinder.volume_snapshot_list(self.request)
75
77
exceptions.handle(self.request, _("Unable to retrieve "
76
78
"volume snapshots."))