Merge "Quick fix for backups"
This commit is contained in:
commit
a81c493ee0
16
README.rst
16
README.rst
|
@ -7,20 +7,22 @@ Requirements
|
|||
|
||||
Freezer Freezer Dashboard requires a freezer API client to be installed in the same environment as horizon::
|
||||
|
||||
git clone https://github.com/stackforge/freezer
|
||||
pip install parsedatetime>=1.4
|
||||
git clone https://github.com/openstack/freezer
|
||||
cd freezer
|
||||
python setup.py install (is important that freezer is installed from source and not with pip)
|
||||
python setup.py install (is important that freezer is installed from source and not with pip and
|
||||
is installed on horizon virtual environment)
|
||||
|
||||
Freezer Dashboard requires a freezer API endpoint which you can install following this steps::
|
||||
|
||||
https://github.com/stackforge/freezer-api/blob/master/README.rst
|
||||
https://github.com/openstack/freezer-api/blob/master/README.rst
|
||||
|
||||
API registration
|
||||
================
|
||||
|
||||
Register freezer api endpoint::
|
||||
|
||||
https://github.com/stackforge/freezer-api/blob/master/README.rst#3-api-registration
|
||||
https://github.com/openstack/freezer-api/blob/master/README.rst#3-api-registration
|
||||
|
||||
If keystone service-create and endpoint-create are not available you can set as a fallback the following on::
|
||||
|
||||
|
@ -38,7 +40,7 @@ directory is /opt/stack/horizon/openstack_dashboard/dashboards/.
|
|||
|
||||
To install freezer dashboard for development you need to do the following::
|
||||
|
||||
# git clone https://github.com/stackforge/freezer-web-ui
|
||||
# git clone https://github.com/openstack/freezer-web-ui
|
||||
|
||||
# cd freezer-web-ui
|
||||
|
||||
|
@ -59,14 +61,12 @@ Production Installation
|
|||
|
||||
To deploy freezer dashboard in production you need to do the following::
|
||||
|
||||
# git clone https://github.com/stackforge/freezer-web-ui
|
||||
# git clone https://github.com/openstack/freezer-web-ui
|
||||
|
||||
# cd freezer-web-ui
|
||||
|
||||
# cp _50_freezer.py /opt/stack/horizon/openstack_dashboard/enabled/
|
||||
|
||||
# modify _50_freezer.py (line 9) and point the path to the freezer repo.
|
||||
|
||||
# restart apache2 service
|
||||
|
||||
|
||||
|
|
|
@ -4,10 +4,6 @@ DASHBOARD = 'freezer_ui'
|
|||
# If set to True, this dashboard will not be added to the settings.
|
||||
DISABLED = False
|
||||
|
||||
# Until there is a more elegant SYSPATH var scheme...
|
||||
import sys
|
||||
sys.path.append('/opt/stack/freezer')
|
||||
|
||||
# A list of applications to be added to INSTALLED_APPS.
|
||||
ADD_INSTALLED_APPS = [
|
||||
'freezer_ui',
|
||||
|
|
|
@ -38,16 +38,27 @@ class IndexView(tables.DataTableView):
|
|||
template_name = "freezer_ui/backups/index.html"
|
||||
|
||||
def get_data(self):
|
||||
backups, self._has_more = freezer_api.backups_list(self.request)
|
||||
return backups
|
||||
try:
|
||||
backups, self._has_more = freezer_api.backups_list(self.request)
|
||||
return backups
|
||||
except Exception:
|
||||
redirect = reverse("horizon:freezer_ui:backups:index")
|
||||
msg = _('Unable to retrieve backups.')
|
||||
exceptions.handle(self.request, msg, redirect=redirect)
|
||||
|
||||
|
||||
class DetailView(generic.TemplateView):
|
||||
template_name = 'freezer_ui/backups/detail.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
backup = freezer_api.backup_get(self.request, kwargs['backup_id'])
|
||||
return {'data': pprint.pformat(backup.data_dict)}
|
||||
try:
|
||||
backup = freezer_api.backup_get(self.request,
|
||||
kwargs['backup_id'])
|
||||
return {'data': pprint.pformat(backup.data_dict)}
|
||||
except Exception:
|
||||
redirect = reverse("horizon:freezer_ui:backups:index")
|
||||
msg = _('Unable to retrieve backup.')
|
||||
exceptions.handle(self.request, msg, redirect=redirect)
|
||||
|
||||
|
||||
class RestoreView(workflows.WorkflowView):
|
||||
|
@ -66,19 +77,30 @@ class RestoreView(workflows.WorkflowView):
|
|||
return 'name' in self.kwargs and bool(self.kwargs['name'])
|
||||
|
||||
def get_workflow_name(self):
|
||||
backup_id = self.kwargs['backup_id']
|
||||
backup = freezer_api.backup_get(self.request, backup_id)
|
||||
backup_date = datetime.datetime.fromtimestamp(
|
||||
int(backup.data_dict['backup_metadata']['time_stamp']))
|
||||
backup_date_str = django_date(backup_date, 'SHORT_DATETIME_FORMAT')
|
||||
return "Restore '{}' from {}".format(
|
||||
backup.data_dict['backup_metadata']['backup_name'],
|
||||
backup_date_str)
|
||||
try:
|
||||
backup_id = self.kwargs['backup_id']
|
||||
backup = freezer_api.backup_get(self.request, backup_id)
|
||||
backup_date = datetime.datetime.fromtimestamp(
|
||||
int(backup.data_dict['backup_metadata']['time_stamp']))
|
||||
backup_date_str = django_date(backup_date,
|
||||
'SHORT_DATETIME_FORMAT')
|
||||
return "Restore '{}' from {}".format(
|
||||
backup.data_dict['backup_metadata']['backup_name'],
|
||||
backup_date_str)
|
||||
except Exception:
|
||||
redirect = reverse("horizon:freezer_ui:backups:index")
|
||||
msg = _('Unable to retrieve backups.')
|
||||
exceptions.handle(self.request, msg, redirect=redirect)
|
||||
|
||||
def get_initial(self):
|
||||
return {"backup_id": self.kwargs['backup_id']}
|
||||
|
||||
def get_workflow(self, *args, **kwargs):
|
||||
workflow = super(RestoreView, self).get_workflow(*args, **kwargs)
|
||||
workflow.name = self.get_workflow_name()
|
||||
return workflow
|
||||
try:
|
||||
workflow = super(RestoreView, self).get_workflow(*args, **kwargs)
|
||||
workflow.name = self.get_workflow_name()
|
||||
return workflow
|
||||
except Exception:
|
||||
redirect = reverse("horizon:freezer_ui:backups:index")
|
||||
msg = _('Unable to retrieve backups.')
|
||||
exceptions.handle(self.request, msg, redirect=redirect)
|
||||
|
|
Loading…
Reference in New Issue