From aa5935ba34c99a7205a9831dd05d846ef6d585b2 Mon Sep 17 00:00:00 2001 From: Marc Aymerich Date: Tue, 19 Jul 2016 22:45:04 +0000 Subject: [PATCH] Added orchestration logging --- orchestra/contrib/orchestration/actions.py | 8 +++++++- orchestra/contrib/orchestration/admin.py | 4 +++- .../templates/admin/orchestration/orchestrate.html | 5 ++--- orchestra/templatetags/utils.py | 9 +++++++++ 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/orchestra/contrib/orchestration/actions.py b/orchestra/contrib/orchestration/actions.py index 9a36a1a1..3f8a0b39 100644 --- a/orchestra/contrib/orchestration/actions.py +++ b/orchestra/contrib/orchestration/actions.py @@ -29,6 +29,8 @@ def retry_backend(modeladmin, request, queryset): else: logs = Operation.execute(operations) message_user(request, logs) + for backendlog in queryset: + modeladmin.log_change(request, backendlog, 'Retried') return opts = modeladmin.model._meta display_objects = [] @@ -100,11 +102,14 @@ def orchestrate(modeladmin, request, queryset): result.append(operation) operations = result if not operations: - messages.warning(request, _("No operations.")) + messages.warning(request, _("No related operations.")) + return if request.POST.get('post') == 'generic_confirmation': logs = Operation.execute(operations) message_user(request, logs) + for obj in queryset: + modeladmin.log_change(request, obj, 'Orchestrated') return opts = modeladmin.model._meta @@ -126,3 +131,4 @@ def orchestrate(modeladmin, request, queryset): 'obj': get_object_from_url(modeladmin, request), } return render(request, 'admin/orchestration/orchestrate.html', context) +orchestrate.help_text = _("Execute all related operations on the server(s)") diff --git a/orchestra/contrib/orchestration/admin.py b/orchestra/contrib/orchestration/admin.py index 34a2f247..da9cfe01 100644 --- a/orchestra/contrib/orchestration/admin.py +++ b/orchestra/contrib/orchestration/admin.py @@ -40,6 +40,7 @@ class RouteAdmin(ExtendedModelAdmin): add_fields = ('backend', 'host', 'match', 'async', 'is_active') change_form = RouteForm actions = (orchestrate,) + change_view_actions = actions BACKEND_HELP_TEXT = helpers.get_backends_help_text(ServiceBackend.get_backends()) DEFAULT_MATCH = { @@ -171,10 +172,11 @@ class BackendLogAdmin(ChangeViewActionsMixin, admin.ModelAdmin): return False -class ServerAdmin(admin.ModelAdmin): +class ServerAdmin(ExtendedModelAdmin): list_display = ('name', 'address', 'os', 'display_ping', 'display_uptime') list_filter = ('os',) actions = (orchestrate,) + change_view_actions = actions def display_ping(self, instance): return self._remote_state[instance.pk][0] diff --git a/orchestra/contrib/orchestration/templates/admin/orchestration/orchestrate.html b/orchestra/contrib/orchestration/templates/admin/orchestration/orchestrate.html index 54803cba..df43832b 100644 --- a/orchestra/contrib/orchestration/templates/admin/orchestration/orchestrate.html +++ b/orchestra/contrib/orchestration/templates/admin/orchestration/orchestrate.html @@ -4,11 +4,10 @@ {% block display_objects %}