Commit 63c066a1 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Fix snapshots of attached volumes

Fix major bug when taking snapshots of non-root volumes. The custom
'SnapshotInstance' method of 'GanetiRAPIClient' always took a snapshot
of the root volume (index=0) of an instance, ignoring the volume that
the user requested. This resulted in always taking a snapshot of the
root volume which in many cases did not fail.
parent 38e733e4
......@@ -1247,12 +1247,12 @@ def detach_volume(vm, volume, depends=[]):
return client.ModifyInstance(**kwargs)
def snapshot_instance(vm, snapshot_name, snapshot_id):
#volume = instance.volumes.all()[0]
def snapshot_instance(vm, volume, snapshot_name, snapshot_id):
reason = json.dumps({"snapshot_id": snapshot_id})
disks = [(volume.backend_volume_uuid, {"snapshot_name": snapshot_name})]
with pooled_rapi_client(vm) as client:
return client.SnapshotInstance(instance=vm.backend_vm_id,
......@@ -546,23 +546,20 @@ class GanetiRapiClient(object): # pylint: disable=R0904
("/%s/instances/%s/deactivate-disks" %
(GANETI_RAPI_VERSION, instance)), None, None)
def SnapshotInstance(self, instance, snapshot_name, dry_run=False,
"""Replaces disks on an instance.
def SnapshotInstance(self, instance, disks, dry_run=False, reason=None):
"""Takes snapshot of instance's disks.
@type instance: str
@param instance: instance whose disks to replace
@type snapshot_name: str
@param snapshot_name: name of the new snapshot
More details for parameters can be found in the RAPI documentation.
@type instance: string
@param instance: Instance name
@type disks: list of tuples
@param disks: The disks to snapshot
@rtype: string
@return: job id
body = {
"disks": [(0, {"snapshot_name": snapshot_name})],
body = {"disks": disks}
query = []
_AppendIf(query, reason, ("reason", reason))
......@@ -102,7 +102,7 @@ def create(user_id, volume, name, description, metadata, force=False):
" %s size." %, "bytes", "gb"))
raise faults.OverLimit(msg)
backend.snapshot_instance(volume.machine, 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