Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # views.py
- from horizon import views
- from horizon import exceptions
- from horizon import tabs
- from tables import InstanceTable,PackagesForUpgradeTable
- from horizon import tables, exceptions
- from django.utils.translation import ugettext_lazy as _
- from openstack_dashboard.api.salt_api import minions_list_custom,pkg_list_for_upgrade
- class IndexView(tables.DataTableView):
- # A very simple class-based view...
- template_name = 'patch_management/instances/index.html'
- table_class = InstanceTable
- def get_data(self):
- # Add data to the context here...
- minions = []
- try:
- minions = minions_list_custom()
- except exceptions.NotAvailable:
- exceptions.handle(self.request,_('Unable to connect to Salt-master:'))
- return minions
- class PackagesToUpgradeView(tables.DataTableView):
- template_name = 'patch_management/instances/packages_index.html'
- page_title = _("Packages available to upgrade on {{ instance.id }}")
- table_class = PackagesForUpgradeTable
- def get_data(self):
- try:
- instance_id = self.kwargs['instance_id']
- pkgs_list = pkg_list_for_upgrade(instance_name=instance_id)
- except Exception:
- redirect = self.get_redirect_url()
- exceptions.handle(self.request,
- _('Unable to retrieve packages to upgrade'),
- redirect=redirect)
- return pkgs_list
- def get_redirect_url(self):
- # we may ignore this function because it is never running
- return reverse('horizon:patch_management:index')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement