Jump to: navigation, search

Difference between revisions of "Cinder/VMwareVmdkDriver/snapshot-force"

(Description)
(Description)
Line 27: Line 27:
 
             and add the VMDK version that is with the instance VM to the
 
             and add the VMDK version that is with the instance VM to the
 
             volume backing.
 
             volume backing.
         5. Delete the instance VM snapshot taken in point 2. retaining the disk chain.
+
         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'])
 +
    1. self.consolidate_backing(volume, instance)
 +
    2. volumeops.create_snapshot(instance, snapshot['name'])
 +
    3. volumeops.create_snapshot(volume, snapshot['name'])
 +
    4. volumeops.delete_vmdk(backing)
 +
        volume_vmdk = volumeops.get_volume_vmdk(instance, volume)
 +
        volumeops.add_vmdk(backing, volume_vmdk)
 +
    5. volumeops.delete_snapshot(instance, consolidate=False)
 
</nowiki>
 
</nowiki>

Revision as of 07:33, 29 November 2013

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.

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'])
    1. self.consolidate_backing(volume, instance)
    2. volumeops.create_snapshot(instance, snapshot['name'])
    3. volumeops.create_snapshot(volume, snapshot['name'])
    4. volumeops.delete_vmdk(backing)
        volume_vmdk = volumeops.get_volume_vmdk(instance, volume)
        volumeops.add_vmdk(backing, volume_vmdk)
    5. volumeops.delete_snapshot(instance, consolidate=False)