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 object1: VirtualMachine
28 if object1
is not None:
29 data
['cluster_slug'] = object1
.cluster
.slug
30 data
['hostname'] = object1
.hostname
31 if hasattr(object1
, 'newname'):
32 data
['newname'] = object1
.newname
33 if object2
is not None:
34 data
['job_id'] = object2
.job_id
38 def build_node_cache(user
, object1
, object2
, object3
, data
):
40 if object1
is not None:
41 data
['cluster_slug'] = object1
.cluster
.slug
42 data
['hostname'] = object1
.hostname
43 if object2
is not None:
44 data
['job_id'] = object2
.job_id
48 def build_cluster_cache(user
, object1
, object2
, object3
, data
):
50 if object1
is not None:
51 data
['cluster_slug'] = object1
.slug
52 data
['hostname'] = object1
.hostname
53 if object2
is not None:
54 data
['job_id'] = object2
.job_id
58 def build_op_cache(user
, object1
, object2
, object3
, data
):
60 'object_str': str(object1
)
63 data
['affected_user'] = str(object2
)
64 data
['affected_user_class'] = object2
.__class__
.__name
__
68 def register_log_actions():
69 # Register LogActions used within the Ganeti App
70 LogAction
.objects
.register('VM_REBOOT', 'ganeti/object_log/vm_reboot.html',
72 LogAction
.objects
.register('VM_START', 'ganeti/object_log/vm_start.html',
74 LogAction
.objects
.register('VM_STOP', 'ganeti/object_log/vm_stop.html',
76 LogAction
.objects
.register('VM_MIGRATE',
77 'ganeti/object_log/vm_migrate.html',
79 LogAction
.objects
.register('VM_REPLACE_DISKS',
80 'ganeti/object_log/vm_replace_disks.html',
82 LogAction
.objects
.register('VM_REINSTALL',
83 'ganeti/object_log/vm_reinstall.html',
85 LogAction
.objects
.register('VM_MODIFY',
86 'ganeti/object_log/vm_modify.html',
88 LogAction
.objects
.register('VM_RENAME',
89 'ganeti/object_log/vm_rename.html',
91 LogAction
.objects
.register('VM_RECOVER',
92 'ganeti/object_log/vm_recover.html',
95 LogAction
.objects
.register('CLUSTER_REDISTRIBUTE',
96 'ganeti/object_log/cluster_redistribute.html',
99 LogAction
.objects
.register('NODE_EVACUATE',
100 'ganeti/object_log/node_evacuate.html',
102 LogAction
.objects
.register('NODE_MIGRATE',
103 'ganeti/object_log/node_migrate.html',
105 LogAction
.objects
.register('NODE_ROLE_CHANGE',
106 'ganeti/object_log/node_role_change.html',
109 # add log actions for permission actions here
110 LogAction
.objects
.register('ADD_USER',
111 'ganeti/object_log/permissions/add_user.html',
113 LogAction
.objects
.register('REMOVE_USER',
114 'ganeti/object_log/permissions'
117 LogAction
.objects
.register('MODIFY_PERMS',
118 'ganeti/object_log/permissions'
119 '/modify_perms.html',