Commit d039ad8a by Dudás Ádám

vm: make the employed scheduler a config parameter

parent a262e19a
......@@ -298,6 +298,8 @@ CRISPY_TEMPLATE_PACK = 'bootstrap3'
# format: id: (name, port, protocol)
'''{"nx": ["nx", 22, "tcp"],
'''{"nx": ["nx", 22, "tcp"],
"rdp": ["rdp", 3389, "tcp"],
"ssh": ["ssh", 22, "tcp"]}'''))
VM_SCHEDULER = 'manager.scheduler'
def get_node(instance):
''' Select a node for an hosting an instance
based on requirements.
def get_node(instance, nodes):
''' Select a node for hosting an instance based on its requirements.
# Return first Node or None
models = __import__('vm.models')
return models.models.Node.objects.all()[0]
return nodes[0]
return None
from datetime import timedelta
import django.conf
from importlib import import_module
import logging
import django.conf.settings
from django.contrib.auth.models import User
from django.db import models
from django.db.models.signals import pre_delete
......@@ -13,12 +14,13 @@ from netaddr import EUI
from . import tasks
from firewall.models import Vlan, Host
from manager import vm_manager, scheduler
from manager import vm_manager
from storage.models import Disk
logger = logging.getLogger(__name__)
pwgen = User.objects.make_random_password
scheduler = import_module(name=django.conf.settings.VM_SCHEDULER)
ACCESS_METHODS = [(k, ap[0]) for k, ap in ACCESS_PROTOCOLS.iteritems()]
......@@ -443,7 +445,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
# Schedule
self.node = scheduler.get_node(self)
self.node = scheduler.get_node(self, Node.objects.all())
# Create virtual images
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 sign in to comment