27 from cm.models.template
import Template
28 from cm.utils.exception
import CMException
29 from common.states
import template_states
30 from cm.utils.decorators
import admin_cm_log
44 templates = [t.dict
for t
in Template.objects.filter(state__exact=template_states[
'active']).order_by(
'cpu',
'memory')]
46 raise CMException(
"template_list")
62 t = Template.objects.get(id=template_id)
65 raise CMException(
"template_get")
83 def add(caller_id, name, memory, cpu, description, points, ec2name):
88 template.memory = memory
90 template.description = description
91 template.points = points
92 template.ec2name = ec2name
93 template.state = template_states[
'active']
97 raise CMException(
'template_create')
111 template = Template.objects.get(pk=template_id)
112 template.state = template_states[
'deleted']
115 raise CMException(
'template_delete')
132 def edit(caller_id, template_id, name=None, memory=None, cpu=None, description=None, points=None, ec2name=None):
135 template = Template.objects.get(pk=template_id)
136 template.name = name
or template.name
137 template.memory = memory
or template.memory
138 template.cpu = cpu
or template.cpu
139 template.description = description
or template.description
140 template.points = points
or template.points
141 template.ec2name = ec2name
or template.ec2name
144 raise CMException(
'template_edit')