26 from cm.models.node
import Node
27 from cm.utils
import log
28 from cm.utils.decorators
import admin_cm_log
29 from cm.utils.exception
import CMException
30 from common.states
import node_states
31 from cm.tools
import node
as node_tools
55 def add(caller_id, address, username, transport, driver, suffix, cpu, memory, disk):
57 node_tools.add(address, username, transport, driver, suffix, cpu, memory, disk)
59 log.error(caller_id,
'Cannot add node: %s' % str(e))
60 raise CMException(str(e))
72 def install(caller_id, node_id, distribution):
74 node_tools.install(node_id, distribution)
76 log.error(caller_id,
'Cannot install node: %s' % str(e))
77 raise CMException(str(e))
92 node_tools.configure(node_id, interfaces)
94 log.error(caller_id,
'Cannot configure node: %s' % str(e))
95 raise CMException(str(e))
110 for node_id
in node_id_list:
111 node_tools.check(node_id)
113 log.error(caller_id,
'Cannot check node: %s' % str(e))
114 raise CMException(str(e))
125 return [node.dict
for node
in Node.objects.exclude(state__exact=node_states[
'deleted'])]
138 node = Node.get(caller_id, node_id)
139 return node.long_dict
152 node = Node.get(caller_id, node_id)
153 return node.long_long_dict
168 def lock(caller_id, node_id_list):
169 for node_id
in node_id_list:
170 node = Node.get(caller_id, node_id)
171 node.state = node_states[
'locked']
178 raise CMException(
'node_lock')
196 for node_id
in node_id_list:
197 node = Node.get(caller_id, node_id)
198 node.state = node_states[
'ok']
205 raise CMException(
'node_unlock')
223 node = Node.get(caller_id, node_id)
226 if node.vm_set.exists():
227 raise CMException(
'node_has_vms')
234 raise CMException(
'node_delete')
249 def edit(caller_id, node_id, **node_info):
250 node = Node.get(caller_id, node_id)
253 for k, v
in node_info.iteritems():
262 raise CMException(
'node_edit')