Commit 83969d4f authored by Vangelis Koukis's avatar Vangelis Koukis
Browse files

Fix breakage caused by the logic-refactoring merge

This commit fixes some breakage caused by the recent merge of
the logic-refactoring branch, mainly related to db/db_controller.py.

The main reason was the different value of import path, fixed by
making sure all imports are rooted in synnefo.

All db and API tests run properly.
parent 5210a3d1
......@@ -28,12 +28,9 @@ import getpass
import traceback
from threading import Thread, Event, currentThread
from synnefo.db.models import VirtualMachine
from synnefo.settings import GANETI_ZMQ_PUBLISHER
from logic import utils, backend
from synnefo.logic import utils, backend
class StoppableThread(Thread):
"""Thread class with a stop() method.
......@@ -74,8 +71,7 @@ def zmq_sub_thread(subscriber):
vm = VirtualMachine.objects.get(id=vmid)
logging.debug("Processing msg: %s" % (msg,))
backend.process_backend_msg(msg["jobId"], msg["operation"], msg["status"], msg["logmsg"])
vm.save()
backend.process_backend_msg(vm, msg["jobId"], msg["operation"], msg["status"], msg["logmsg"])
logging.debug("Done processing msg for vm %s." % (msg["instance"]))
except KeyError:
......
#
# Business Logic for communication with the Ganeti backend
#
# Copyright 2010 Greek Research and Technology Network
#
from db.models import VirtualMachine
import utils
from synnefo.db.models import VirtualMachine
from synnefo.logic import utils
def process_backend_msg(vm, jobid, opcode, status, logmsg):
"""Process a job progress notification from the backend.
......@@ -21,10 +26,10 @@ def process_backend_msg(vm, jobid, opcode, status, logmsg):
# Notifications of success change the operating state
if status == 'success':
utils.update_state(VirtualMachine.OPER_STATE_FROM_OPCODE[opcode])
utils.update_state(vm, VirtualMachine.OPER_STATE_FROM_OPCODE[opcode])
# Special cases OP_INSTANCE_CREATE fails --> ERROR
if status in ('canceled', 'error') and opcode == 'OP_INSTANCE_CREATE':
utils.update_state('ERROR')
utils.update_state(vm, 'ERROR')
# Any other notification of failure leaves the operating state unchanged
vm.save()
......
......@@ -5,11 +5,10 @@
#
from datetime import datetime
from db.models import Debit, FlavorCost
from django.db import transaction
from synnefo.db.models import Debit, FlavorCost
@transaction.commit_on_success
def debit_account(user , amount, vm, description):
"""Charges the user with the specified amount of credits for a vm (resource)"""
......
......@@ -6,9 +6,8 @@
# Copyright 2010 Greek Research and Technology Network
#
from db.models import VirtualMachine
from logic import credits
from synnefo.db.models import VirtualMachine
from synnefo.logic import credits
import synnefo.settings as settings
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment