Commit 1716bb42 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Pass the size of volume's origin

..to Archipelago, as 'origin_size' parameter.

Currently, the volume object is annotated with the size of the origin,
but this information is not stored in DB. This will have to be changed
when Synnefo supports detachable volumes.
parent 55eafcab
......@@ -792,6 +792,7 @@ def create_instance(vm, nics, volumes, flavor, image):
disk["provider"] = provider
if provider in settings.GANETI_CLONE_PROVIDERS:
disk["origin"] = volume.origin
disk["origin_size"] = volume.origin_size
extra_disk_params = settings.GANETI_DISK_PROVIDER_KWARGS\
.get(provider)
if extra_disk_params is not None:
......@@ -1198,6 +1199,7 @@ def attach_volume(vm, volume, depends=[]):
if volume.origin is not None:
disk["origin"] = volume.origin
disk["origin_size"] = volume.origin_size
extra_disk_params = settings.GANETI_DISK_PROVIDER_KWARGS\
.get(disk_provider)
......
......@@ -36,7 +36,7 @@ fixed_image.return_value = {'location': 'pithos://foo',
"is_public": True,
"owner": "user2",
"status": "AVAILABLE",
"size": 1024,
"size": 1000,
"is_snapshot": False,
'disk_format': 'diskdump'}
......@@ -105,6 +105,7 @@ class ServerCreationTest(TransactionTestCase):
self.assertEqual(kwargs["disks"][0],
{"provider": "archipelago",
"origin": "test_mapfile",
"origin_size": 1000,
"name": vm.volumes.all()[0].backend_volume_uuid,
"foo": "mpaz",
"lala": "lolo",
......
......@@ -135,6 +135,7 @@ def _create_volume(server, user_id, project, size, source_type, source_uuid,
raise faults.BadRequest(msg)
source_version = None
origin_size = None
# TODO: Check Volume/Snapshot Status
if source_type == "snapshot":
source_snapshot = util.get_snapshot(user_id, source_uuid,
......@@ -154,6 +155,7 @@ def _create_volume(server, user_id, project, size, source_type, source_uuid,
% (size << 30, source_snapshot["size"]))
source_version = source_snapshot["version"]
origin = source_snapshot["mapfile"]
origin_size = source_snapshot["size"]
elif source_type == "image":
source_image = util.get_image(user_id, source_uuid,
exception=faults.BadRequest)
......@@ -170,6 +172,7 @@ def _create_volume(server, user_id, project, size, source_type, source_uuid,
source = Volume.prefix_source(source_uuid, source_type="image")
source_version = source_image["version"]
origin = source_image["mapfile"]
origin_size = source_image["size"]
elif source_type == "blank":
if size is None:
raise faults.BadRequest("Volume size is required")
......@@ -207,6 +210,11 @@ def _create_volume(server, user_id, project, size, source_type, source_uuid,
origin=origin,
index=index,
status="CREATING")
# Store the size of the origin in the volume object but not in the DB.
# We will have to change this in order to support detachable volumes.
volume.origin_size = origin_size
return volume
......
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