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,
18 from object_log
.models
import LogAction
21 def build_vm_cache(user
, object1
, object2
, object3
, data
):
23 if object1
is not None:
24 data
['cluster_slug']=object1
.cluster
.slug
25 data
['hostname']=object1
.hostname
26 if object2
is not None:
27 data
['job_id'] = object2
.job_id
31 def build_node_cache(user
, object1
, object2
, object3
, data
):
33 if object1
is not None:
34 data
['cluster_slug']=object1
.cluster
.slug
35 data
['hostname']=object1
.hostname
36 if object2
is not None:
37 data
['job_id'] = object2
.job_id
41 def build_cluster_cache(user
, object1
, object2
, object3
, data
):
43 if object1
is not None:
44 data
['cluster_slug']=object1
.slug
45 data
['hostname']=object1
.hostname
46 if object2
is not None:
47 data
['job_id'] = object2
.job_id
51 def build_op_cache(user
, object1
, object2
, object3
, data
):
53 'object_str':str(object1
)
56 data
['affected_user']=str(object2
)
57 data
['affected_user_class']=object2
.__class__
.__name
__
61 def register_log_actions():
62 # Register LogActions used within the Ganeti App
63 LogAction
.objects
.register('VM_REBOOT','ganeti/object_log/vm_reboot.html', build_vm_cache
)
64 LogAction
.objects
.register('VM_START','ganeti/object_log/vm_start.html', build_vm_cache
)
65 LogAction
.objects
.register('VM_STOP','ganeti/object_log/vm_stop.html', build_vm_cache
)
66 LogAction
.objects
.register('VM_MIGRATE','ganeti/object_log/vm_migrate.html', build_vm_cache
)
67 LogAction
.objects
.register('VM_REPLACE_DISKS','ganeti/object_log/vm_replace_disks.html', build_vm_cache
)
68 LogAction
.objects
.register('VM_REINSTALL','ganeti/object_log/vm_reinstall.html', build_vm_cache
)
69 LogAction
.objects
.register('VM_MODIFY','ganeti/object_log/vm_modify.html', build_vm_cache
)
70 LogAction
.objects
.register('VM_RENAME','ganeti/object_log/vm_rename.html', build_vm_cache
)
71 LogAction
.objects
.register('VM_RECOVER','ganeti/object_log/vm_recover.html', build_vm_cache
)
73 LogAction
.objects
.register('CLUSTER_REDISTRIBUTE','ganeti/object_log/cluster_redistribute.html', build_cluster_cache
)
75 LogAction
.objects
.register('NODE_EVACUATE','ganeti/object_log/node_evacuate.html', build_node_cache
)
76 LogAction
.objects
.register('NODE_MIGRATE','ganeti/object_log/node_migrate.html', build_node_cache
)
77 LogAction
.objects
.register('NODE_ROLE_CHANGE','ganeti/object_log/node_role_change.html', build_node_cache
)
79 # add log actions for permission actions here
80 LogAction
.objects
.register('ADD_USER', 'ganeti/object_log/permissions/add_user.html', build_op_cache
)
81 LogAction
.objects
.register('REMOVE_USER', 'ganeti/object_log/permissions/remove_user.html', build_op_cache
)
82 LogAction
.objects
.register('MODIFY_PERMS', 'ganeti/object_log/permissions/modify_perms.html', build_op_cache
)