Quick fix for backups
backups views now are wrapped in try except block readme was updated to point to openstack repos remove sys.path from _50_freezer.py Change-Id: I917c33a1d8df04173acddc8eecf23f8bf8a22390
This commit is contained in:
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::
|
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
|
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::
|
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
|
API registration
|
||||||
================
|
================
|
||||||
|
|
||||||
Register freezer api endpoint::
|
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::
|
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::
|
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
|
# cd freezer-web-ui
|
||||||
|
|
||||||
@@ -59,14 +61,12 @@ Production Installation
|
|||||||
|
|
||||||
To deploy freezer dashboard in production you need to do the following::
|
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
|
# cd freezer-web-ui
|
||||||
|
|
||||||
# cp _50_freezer.py /opt/stack/horizon/openstack_dashboard/enabled/
|
# 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
|
# restart apache2 service
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,6 @@ DASHBOARD = 'freezer_ui'
|
|||||||
# If set to True, this dashboard will not be added to the settings.
|
# If set to True, this dashboard will not be added to the settings.
|
||||||
DISABLED = False
|
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.
|
# A list of applications to be added to INSTALLED_APPS.
|
||||||
ADD_INSTALLED_APPS = [
|
ADD_INSTALLED_APPS = [
|
||||||
'freezer_ui',
|
'freezer_ui',
|
||||||
|
|||||||
@@ -38,16 +38,27 @@ class IndexView(tables.DataTableView):
|
|||||||
template_name = "freezer_ui/backups/index.html"
|
template_name = "freezer_ui/backups/index.html"
|
||||||
|
|
||||||
def get_data(self):
|
def get_data(self):
|
||||||
|
try:
|
||||||
backups, self._has_more = freezer_api.backups_list(self.request)
|
backups, self._has_more = freezer_api.backups_list(self.request)
|
||||||
return backups
|
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):
|
class DetailView(generic.TemplateView):
|
||||||
template_name = 'freezer_ui/backups/detail.html'
|
template_name = 'freezer_ui/backups/detail.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
backup = freezer_api.backup_get(self.request, kwargs['backup_id'])
|
try:
|
||||||
|
backup = freezer_api.backup_get(self.request,
|
||||||
|
kwargs['backup_id'])
|
||||||
return {'data': pprint.pformat(backup.data_dict)}
|
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):
|
class RestoreView(workflows.WorkflowView):
|
||||||
@@ -66,19 +77,30 @@ class RestoreView(workflows.WorkflowView):
|
|||||||
return 'name' in self.kwargs and bool(self.kwargs['name'])
|
return 'name' in self.kwargs and bool(self.kwargs['name'])
|
||||||
|
|
||||||
def get_workflow_name(self):
|
def get_workflow_name(self):
|
||||||
|
try:
|
||||||
backup_id = self.kwargs['backup_id']
|
backup_id = self.kwargs['backup_id']
|
||||||
backup = freezer_api.backup_get(self.request, backup_id)
|
backup = freezer_api.backup_get(self.request, backup_id)
|
||||||
backup_date = datetime.datetime.fromtimestamp(
|
backup_date = datetime.datetime.fromtimestamp(
|
||||||
int(backup.data_dict['backup_metadata']['time_stamp']))
|
int(backup.data_dict['backup_metadata']['time_stamp']))
|
||||||
backup_date_str = django_date(backup_date, 'SHORT_DATETIME_FORMAT')
|
backup_date_str = django_date(backup_date,
|
||||||
|
'SHORT_DATETIME_FORMAT')
|
||||||
return "Restore '{}' from {}".format(
|
return "Restore '{}' from {}".format(
|
||||||
backup.data_dict['backup_metadata']['backup_name'],
|
backup.data_dict['backup_metadata']['backup_name'],
|
||||||
backup_date_str)
|
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):
|
def get_initial(self):
|
||||||
return {"backup_id": self.kwargs['backup_id']}
|
return {"backup_id": self.kwargs['backup_id']}
|
||||||
|
|
||||||
def get_workflow(self, *args, **kwargs):
|
def get_workflow(self, *args, **kwargs):
|
||||||
|
try:
|
||||||
workflow = super(RestoreView, self).get_workflow(*args, **kwargs)
|
workflow = super(RestoreView, self).get_workflow(*args, **kwargs)
|
||||||
workflow.name = self.get_workflow_name()
|
workflow.name = self.get_workflow_name()
|
||||||
return workflow
|
return workflow
|
||||||
|
except Exception:
|
||||||
|
redirect = reverse("horizon:freezer_ui:backups:index")
|
||||||
|
msg = _('Unable to retrieve backups.')
|
||||||
|
exceptions.handle(self.request, msg, redirect=redirect)
|
||||||
|
|||||||
Reference in New Issue
Block a user