23 from cm.utils.decorators
import ctx_log
24 from cm.utils
import log
25 from actions
import VERSION
28 from common.states
import command_states
29 from common
import response
30 from cm.models.vm
import VM
31 from cm.models.command
import Command
44 vm = VM.get_by_ip(remote_ip)
45 log.info(vm.user_id,
"vm called hello")
46 Command.hello(remote_ip)
49 if int(kw.get(
'version', 0)) < VERSION:
50 f = file(os.path.join(os.path.abspath(os.path.dirname(__file__)),
'actions.py'),
'r')
51 r['actions_file'] = f.read()
64 vm = VM.get_by_ip(remote_ip)
66 log.debug(0,
"Get first command for %s" % vm.id)
67 command = vm.command_set.filter(state=command_states[
'pending']).order_by(
'id')
73 log.debug(0,
"First command is %s" % command.id)
74 command.state = command_states[
'executing']
80 if int(kw.get(
'version', 0)) < VERSION:
81 f = file(os.path.join(os.path.abspath(os.path.dirname(__file__)),
'actions.py'),
'r')
82 r['actions_file'] = f.read()
99 vm = VM.get_by_ip(remote_ip)
102 returns = json.dumps(returns)
104 log.debug(0,
"Select command %s %s" % (command_id, status))
106 command = vm.command_set.get(id=command_id)
107 except Command.DoesNotExist:
110 log.debug(0,
"Finish command %s" % command)
112 for c
in Command.objects.all():
113 log.debug(0,
'Finish - Available cmds id:%s, state:%s, name:%s, vmid:%s' % (c.id, c.state, c.name, c.vm_id))
115 log.debug(vm.user_id,
"command state %s" % command.state)
117 command.response = returns
118 command.state = command_states[status]
119 log.debug(vm.user_id,
"Finish command %s" % command.id)
123 if int(kw.get(
'version', 0)) < VERSION:
124 f = file(os.path.join(os.path.abspath(os.path.dirname(__file__)),
'actions.py'),
'r')
125 r['actions_file'] = f.read()