Revision f15bf3d9

b/Changelog
60 60
  setting.
61 61
* Change --dhcp option of network management commands from a flag to a boolean
62 62
  value, e.g. --dhcp=True
63
* Remove 'ARCHIPELAGO_BACKENDS' setting used to distinquish between backends
64
  that hosted only archipelago backends. Instead allocation is based on which
65
  disk-templates are enabled in each backend.
63 66

  
64 67
Pithos
65 68
------
b/snf-cyclades-app/conf/20-snf-cyclades-app-api.conf
62 62
## e.g. BACKEND_PER_USER = {'example@synnefo.org': 2}
63 63
#BACKEND_PER_USER = {}
64 64
#
65
## List of backend IDs used *only* for archipelago.
66
#ARCHIPELAGO_BACKENDS = []
67
#
68 65
#
69 66
## URL templates for the stat graphs.
70 67
## The API implementation replaces '%s' with the encrypted backend id.
b/snf-cyclades-app/synnefo/app_settings/default/api.py
61 61
# e.g. BACKEND_PER_USER = {'example@synnefo.org': 2}
62 62
BACKEND_PER_USER = {}
63 63

  
64
# List of backend IDs used *only* for archipelago.
65
ARCHIPELAGO_BACKENDS = []
66

  
67 64

  
68 65
# URL templates for the stat graphs.
69 66
# The API implementation replaces '%s' with the encrypted backend id.
b/snf-cyclades-app/synnefo/logic/backend_allocator.py
32 32
from django.utils import importlib
33 33

  
34 34
from synnefo.settings import (BACKEND_ALLOCATOR_MODULE, BACKEND_REFRESH_MIN,
35
                              BACKEND_PER_USER, ARCHIPELAGO_BACKENDS,
35
                              BACKEND_PER_USER,
36 36
                              DEFAULT_INSTANCE_NETWORKS)
37 37
from synnefo.db.models import Backend
38 38
from synnefo.logic.backend import update_backend_resources
......
72 72
        log.debug("Allocating VM: %r", vm)
73 73

  
74 74
        # Get available backends
75
        available_backends = get_available_backends()
75
        available_backends = get_available_backends(flavor)
76 76

  
77
        # Temporary fix for distinquishing archipelagos capable backends
78
        available_backends = filter_archipelagos_backends(available_backends,
79
                                                          flavor.disk_template)
80 77
        # Refresh backends, if needed
81 78
        refresh_backends_stats(available_backends)
82 79

  
......
96 93
        return backend
97 94

  
98 95

  
99
def get_available_backends():
100
    """Get available backends from db.
96
def get_available_backends(flavor):
97
    """Get the list of available backends that can host a new VM of a flavor.
98

  
99
    The list contains the backends that are online and that have enabled
100
    the disk_template of the new VM.
101

  
102
    Also, if the new VM will be automatically connected to a public network,
103
    the backends that do not have an available public IPv4 address are
104
    excluded.
101 105

  
102 106
    """
103
    backends = list(Backend.objects.select_for_update().filter(drained=False,
104
                                                               offline=False))
107
    backends = Backend.objects.select_for_update()
108
    backends = backends.filter(offline=False, drained=False,
109
                               disk_templates__contains=flavor.disk_template)
110
    backends = list(backends)
105 111
    if "SNF:ANY_PUBLIC" in DEFAULT_INSTANCE_NETWORKS:
106 112
        backends = filter(lambda x: has_free_ip(x), backends)
107 113
    return backends
108 114

  
109 115

  
110
def filter_archipelagos_backends(available_backends, disk_template):
111
    if disk_template == "ext":
112
        available_backends = filter(lambda x: x.id in ARCHIPELAGO_BACKENDS,
113
                                    available_backends)
114
    else:
115
        available_backends = filter(lambda x: x.id not in ARCHIPELAGO_BACKENDS,
116
                                    available_backends)
117
    return available_backends
118

  
119

  
120 116
def has_free_ip(backend):
121 117
    """Find if Backend has any free public IP."""
122 118
    for network in backend_public_networks(backend):

Also available in: Unified diff