Added orchestration logging
This commit is contained in:
parent
df99f8d745
commit
aa5935ba34
|
@ -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)")
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -4,11 +4,10 @@
|
|||
{% block display_objects %}
|
||||
<ul>
|
||||
{% for backend, operations in display_objects.items %}
|
||||
<li>{{ backend }}
|
||||
<li>Backend: {{ backend }}
|
||||
<ul>
|
||||
{% for operation in operations %}
|
||||
<li><a href="{{ operation.instance|admin_url }}">{{ operation.instance }}</a>:
|
||||
into {% for route in operation.routes %}<a href="{{ route.host|admin_url }}">{{ route.host }}</a>{% if not forloop.last %},{% endif %} {% endfor %}</li>
|
||||
<li>{{ operation.instance|admin_link }} @ {% for route in operation.routes %}{{ route.host|admin_link }}</a>{% if not forloop.last %},{% endif %} {% endfor %}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
|
|
|
@ -96,6 +96,15 @@ def admin_url(obj):
|
|||
return change_url(obj)
|
||||
|
||||
|
||||
@register.filter
|
||||
def admin_link(obj):
|
||||
try:
|
||||
url = change_url(obj)
|
||||
except NoReverseMatch:
|
||||
return str(obj)
|
||||
return mark_safe('<a href="%s">%s</a>' % (url, obj))
|
||||
|
||||
|
||||
@register.filter
|
||||
def isactive(obj):
|
||||
return getattr(obj, 'is_active', True)
|
||||
|
|
Loading…
Reference in New Issue