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