Jump to: navigation, search

Cinder/VMwareVmdkDriver/snapshot-force

< Cinder
Revision as of 01:50, 2 December 2013 by Kartik (talk | contribs) (Work Flow)

Description

Support forceful snapshot of an attached volume

The VMDK driver in Havana would simply fail the operation when user tries to snapshot a volume that is attached to an instance with --force=True. This blueprint is to support and allow user to be able to perform snapshot of the volume when it is attached to an instance.

Work Flow

The snapshot of volume can be achieved using the following pseudo-code:

def create_snapshot(self, snapshot):
        volume = snapshot['volume']
        if volume['status'] == 'available':
            // Simply call vsphere API to snapshot
            self._create_snapshot_of_non_attached_volume(snapshot)
        elif volume['status'] == 'in-use':
            self._create_snapshot_of_attached_volume(snapshot)
        else:
            raise CinderException("Not supported")

def create_snapshot_of_attached_volume(self, snapshot):
    """Create snapshot of an attached volume.

        The method works in 5 steps as follows:
        1. Consolidate volume chains in-case it has moved.
        2. Snapshot the instance VM.
        3. Snapshot the volume backing.
        4. Delete the VMDK version that is attached to the volume backing
           and add the VMDK version that is with the instance VM to the
           volume backing.
        5. Delete the instance VM snapshot taken in point 2.
            retaining the disk chain.
    """
    volume = snapshot['volume']
    backing = volumeops.get_backing(volume['name'])
    instance = volumeops.get_backing(volume['instance_uuid'])
    self.consolidate_backing(volume, instance)
    volumeops.create_snapshot(instance, snapshot['name'])
    volumeops.create_snapshot(volume, snapshot['name'])
    volumeops.delete_vmdk(backing)
    volume_vmdk = volumeops.get_volume_vmdk(instance, volume)
    volumeops.add_vmdk(backing, volume_vmdk)
    volumeops.delete_snapshot(instance, consolidate=False)

The following image summarizes the above 5 steps for a simpler workflow of snapshotting an attached volume. We have VM instance and VOL volume that is attached to the VM.

Work-flow-1.jpg