Revision f5b4f2a3 snf-cyclades-app/synnefo/api/servers.py

b/snf-cyclades-app/synnefo/api/servers.py
31 31
# interpreted as representing official policies, either expressed
32 32
# or implied, of GRNET S.A.
33 33

  
34
import random
35

  
34 36
from base64 import b64decode
35 37
from logging import getLogger
36 38

  
......
43 45
from synnefo.api import faults, util
44 46
from synnefo.api.actions import server_actions
45 47
from synnefo.api.common import method_not_allowed
46
from synnefo.db.models import VirtualMachine, VirtualMachineMetadata
48
from synnefo.db.models import Backend, VirtualMachine, VirtualMachineMetadata
47 49
from synnefo.logic.backend import create_instance, delete_instance
48 50
from synnefo.logic.utils import get_rsapi_state
49 51
from synnefo.util.rapi import GanetiApiError
......
251 253
    if count >= vms_limit_for_user:
252 254
        raise faults.OverLimit("Server count limit exceeded for your account.")
253 255

  
256
    backend = random.choice(Backend.objects.all())
254 257
    # We must save the VM instance now, so that it gets a
255 258
    # valid vm.backend_vm_id.
256 259
    vm = VirtualMachine.objects.create(
257 260
        name=name,
261
        backend=backend,
258 262
        userid=request.user_uniq,
259 263
        imageid=image_id,
260 264
        flavor=flavor)

Also available in: Unified diff