Commit 77b7f1ae authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Pass arbitrary params to ext providers

Add 'GANETI_DISK_PROVIDER_KWARGS' setting, which contains a dictionary
of arbitrary parameters for each of Ganeti's ExtStorage providers and
which will be passed to the 'disks' option of CreateInstance Ganeti job.
parent 38730188
......@@ -45,3 +45,9 @@
## Maximum number of NICs per Ganeti instance. This value must be less or equal
## than 'max:nic-count' option of Ganeti's ipolicy.
#GANETI_MAX_NICS_PER_INSTANCE = 8
#
## The following setting defines a dictionary with key-value parameters to be
## passed to each Ganeti ExtStorage provider. The setting defines a mapping
## from the provider name, e.g. 'archipelago' to a dictionary with the actual
## arbitrary parameters.
#GANETI_DISK_PROVIDER_KWARGS = {}
......@@ -45,3 +45,9 @@ BACKEND_REFRESH_MIN = 15
# Maximum number of NICs per Ganeti instance. This value must be less or equal
# than 'max:nic-count' option of Ganeti's ipolicy.
GANETI_MAX_NICS_PER_INSTANCE = 8
# The following setting defines a dictionary with key-value parameters to be
# passed to each Ganeti ExtStorage provider. The setting defines a mapping from
# the provider name, e.g. 'archipelago' to a dictionary with the actual
# arbitrary parameters.
GANETI_DISK_PROVIDER_KWARGS = {}
......@@ -627,6 +627,9 @@ def create_instance(vm, nics, flavor, image):
if provider:
kw['disks'][0]['provider'] = provider
kw['disks'][0]['origin'] = flavor.disk_origin
extra_disk_params = settings.GANETI_DISK_PROVIDER_KWARGS.get(provider)
if extra_disk_params is not None:
kw["disks"][0].update(extra_disk_params)
kw['nics'] = [{"name": nic.backend_uuid,
"network": nic.network.backend_id,
......
......@@ -52,6 +52,7 @@ class ServerCreationTest(TransactionTestCase):
"password": "1234",
"flavor": flavor,
"image": {"id": "foo", "backend_id": "foo", "format": "diskdump",
"checksum": "test_checksum",
"metadata": "{}"},
"networks": [],
"metadata": {"foo": "bar"},
......@@ -64,7 +65,7 @@ class ServerCreationTest(TransactionTestCase):
mfactory.IPv4SubnetFactory(network__public=True)
mfactory.IPv6SubnetFactory(network__public=True)
mfactory.BackendFactory()
backend = mfactory.BackendFactory()
# error in nics
req = deepcopy(kwargs)
......@@ -82,6 +83,32 @@ class ServerCreationTest(TransactionTestCase):
for nic in vm.nics.all():
self.assertEqual(nic.state, "ERROR")
# test ext settings:
req = deepcopy(kwargs)
ext_flavor = mfactory.FlavorFactory(disk_template="ext_archipelago",
disk=1)
req["flavor"] = ext_flavor
mrapi().CreateInstance.return_value = 42
backend.disk_templates = ["ext"]
backend.save()
osettings = {
"GANETI_DISK_PROVIDER_KWARGS": {
"archipelago": {
"foo": "mpaz",
"lala": "lolo"
}
}
}
with mocked_quotaholder():
with override_settings(settings, **osettings):
vm = servers.create(**req)
name, args, kwargs = mrapi().CreateInstance.mock_calls[-1]
self.assertEqual(kwargs["disks"][0], {"provider": "archipelago",
"origin": "test_checksum",
"foo": "mpaz",
"lala": "lolo",
"size": 1024})
@patch("synnefo.logic.rapi_pool.GanetiRapiClient")
class ServerTest(TransactionTestCase):
......
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