Ticket #3957 (partial) - ganeti_webmgr uses ganeti python namespace:
[ganeti_webmgr.git] / ganeti_web / logs.py
blob59d63e73bdc8a5e7be1cb170d24805787152db0e
1 # Copyright (C) 2010 Oregon State University et al.
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
16 # USA.
18 from object_log.models import LogAction
21 def build_vm_cache(user, object1, object2, object3, data):
22 data = {'cluster_slug':object1.cluster.slug,
23 'hostname':object1.hostname}
24 if object2 is not None:
25 data['job_id'] = object2.job_id
26 return data
29 def build_node_cache(user, object1, object2, object3, data):
30 data = {'cluster_slug':object1.cluster.slug,
31 'hostname':object1.hostname}
32 if object2 is not None:
33 data['job_id'] = object2.job_id
34 return data
37 def build_op_cache(user, object1, object2, object3, data):
38 return {
39 'object_str':str(object1),
40 'affected_user':str(object2),
41 'affected_user_id':object2.pk,
42 'affected_user_class':object2.__class__.__name__
46 def register_log_actions():
47 # Register LogActions used within the Ganeti App
48 LogAction.objects.register('VM_REBOOT','ganeti/object_log/vm_reboot.html', build_vm_cache)
49 LogAction.objects.register('VM_START','ganeti/object_log/vm_start.html', build_vm_cache)
50 LogAction.objects.register('VM_STOP','ganeti/object_log/vm_stop.html', build_vm_cache)
51 LogAction.objects.register('VM_MIGRATE','ganeti/object_log/vm_migrate.html', build_vm_cache)
52 LogAction.objects.register('VM_REINSTALL','ganeti/object_log/vm_reinstall.html', build_vm_cache)
53 LogAction.objects.register('VM_MODIFY','ganeti/object_log/vm_modify.html', build_vm_cache)
54 LogAction.objects.register('VM_RENAME','ganeti/object_log/vm_rename.html', build_vm_cache)
55 LogAction.objects.register('VM_RECOVER','ganeti/object_log/vm_recover.html', build_vm_cache)
57 LogAction.objects.register('CLUSTER_REDISTRIBUTE','ganeti/object_log/cluster_redistribute.html')
59 LogAction.objects.register('NODE_EVACUATE','ganeti/object_log/node_evacuate.html', build_node_cache)
60 LogAction.objects.register('NODE_MIGRATE','ganeti/object_log/node_migrate.html', build_node_cache)
61 LogAction.objects.register('NODE_ROLE_CHANGE','ganeti/object_log/node_role_change.html', build_node_cache)
63 # add log actions for permission actions here
64 LogAction.objects.register('ADD_USER', 'ganeti/object_log/permissions/add_user.html', build_op_cache)
65 LogAction.objects.register('REMOVE_USER', 'ganeti/object_log/permissions/remove_user.html', build_op_cache)
66 LogAction.objects.register('MODIFY_PERMS', 'ganeti/object_log/permissions/modify_perms.html', build_op_cache)