SnapshotVolume


 * Launchpad Entry: NovaSpec:snapshot-volume
 * Created: 2011-4-19
 * Contributors: Kazutaka Morita

Summary
Snapshot nova volumes with the EC2 api

Release Note
This adds support for taking snapshots of volumes (EBS snapshot). The OpenStack API doesn't support a volume snapshot, so we start from implementing the feature with the EC2 API.

This only invokes a snapshot command of the backend block storage system. In future, we should backup the created volume snapshots to Swift as Amazon EBS backups the snapshots to S3.

Rationale
This is necessary to take a consistent image of a volume, which is used for backups or golden volume creation.

User stories

 * User takes snapshots to backup volumes
 * User creates golden volumes to provide services quickly

$ euca-create-volume -s 4 -z 0 VOLUME vol-00000001    4       creating (admin, None, None, None)      2011-04-19T20:18:10Z $ euca-create-snapshot vol-00000001 SNAPSHOT       snap-00000001   vol-00000001    creating        2011-04-19T20:18:19Z    0%

Assumptions
A backend storage of nova-volume must support instant snapshotting.

Implementation
This adds a new table 'snapshots' to the database

snapshots = Table('snapshots', meta,       Column('created_at', DateTime(timezone=False)),        Column('updated_at', DateTime(timezone=False)),        Column('deleted_at', DateTime(timezone=False)),        Column('deleted', Boolean(create_constraint=True, name=None)),        Column('id', Integer,  primary_key=True, nullable=False),        Column('volume_id', Integer, nullable=False),        Column('user_id', String(length=255, convert_unicode=False, assert_unicode=None,                     unicode_error=None, _warn_on_bytestring=False)),        Column('project_id', String(length=255, convert_unicode=False, assert_unicode=None,                     unicode_error=None, _warn_on_bytestring=False)),        Column('status', String(length=255, convert_unicode=False, assert_unicode=None,                     unicode_error=None, _warn_on_bytestring=False)),        Column('progress', String(length=255, convert_unicode=False, assert_unicode=None,                     unicode_error=None, _warn_on_bytestring=False)),        Column('volume_size', Integer),        Column('scheduled_at', DateTime(timezone=False)),        Column('display_name', String(length=255, convert_unicode=False, assert_unicode=None,                     unicode_error=None, _warn_on_bytestring=False)),        Column('display_description', String(length=255, convert_unicode=False, assert_unicode=None,                     unicode_error=None, _warn_on_bytestring=False))        )

and adds two interfaces in the volume driver

class VolumeDriver(object):

...

def create_snapshot(self, snapshot): """Creates a snapshot.""" raise NotImplementedError

def delete_snapshot(self, snapshot): """Deletes a snapshot.""" raise NotImplementedError