Add snapshots to minimum driver interface

Snapshot functionality was excluded from the base volume
driver functionality while issues were being worked on
with NFS based drivers. Those have since been resolved
and we should now include the snapshot calls in the base
interface for volume backend drivers.

Change-Id: Ic7d6ca1de84d36f54a00e3afe3647865d6edd211
This commit is contained in:
Sean McGinnis 2018-05-09 23:21:08 +00:00
parent d2b3e1011e
commit 147dac80b9
4 changed files with 76 additions and 84 deletions

View File

@ -256,3 +256,31 @@ class VolumeDriverCore(base.CinderInterface):
:param volume: The volume to extend.
:param new_size: The new desired size of the volume.
"""
def create_snapshot(self, snapshot):
"""Creates a snapshot.
:param snapshot: Information for the snapshot to be created.
"""
def delete_snapshot(self, snapshot):
"""Deletes a snapshot.
:param snapshot: The snapshot to delete.
"""
def create_volume_from_snapshot(self, volume, snapshot):
"""Creates a volume from a snapshot.
If volume_type extra specs includes 'replication: <is> True'
the driver needs to create a volume replica (secondary),
and setup replication between the newly created volume and
the secondary volume.
An optional larger size for the new snapshot can be specified. Drivers
should check this value and create or expand the new volume to match.
:param volume: The volume to be created.
:param snapshot: The snapshot from which to create the volume.
:returns: A dict of database updates for the new volume.
"""

View File

@ -1,70 +0,0 @@
# Copyright 2016 Dell Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
"""
Snapshot capable volume driver interface.
"""
from cinder.interface import base
class VolumeSnapshotDriver(base.CinderInterface):
"""Interface for drivers that support snapshots.
TODO(smcginnis) Merge into VolumeDriverBase once NFS driver supports
snapshots.
"""
def create_snapshot(self, snapshot):
"""Creates a snapshot.
:param snapshot: Information for the snapshot to be created.
"""
def delete_snapshot(self, snapshot):
"""Deletes a snapshot.
:param snapshot: The snapshot to delete.
"""
def create_volume_from_snapshot(self, volume, snapshot):
"""Creates a volume from a snapshot.
If volume_type extra specs includes 'replication: <is> True'
the driver needs to create a volume replica (secondary),
and setup replication between the newly created volume and
the secondary volume.
An optional larger size for the new snapshot can be specified. Drivers
should check this value and create or expand the new volume to match.
:param volume: The volume to be created.
:param snapshot: The snapshot from which to create the volume.
:returns: A dict of database updates for the new volume.
"""
def revert_to_snapshot(self, context, volume, snapshot):
"""Revert volume to snapshot.
Note: the revert process should not change the volume's
current size, that means if the driver shrank
the volume during the process, it should extend the
volume internally.
:param context: the context of the caller.
:param volume: The volume to be reverted.
:param snapshot: The snapshot used for reverting.
"""

View File

@ -0,0 +1,38 @@
# Copyright 2018 Huawei
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
"""
Revert to snapshot capable volume driver interface.
"""
from cinder.interface import base
class VolumeSnapshotRevertDriver(base.CinderInterface):
"""Interface for drivers that support revert to snapshot."""
def revert_to_snapshot(self, context, volume, snapshot):
"""Revert volume to snapshot.
Note: the revert process should not change the volume's
current size, that means if the driver shrank
the volume during the process, it should extend the
volume internally.
:param context: the context of the caller.
:param volume: The volume to be reverted.
:param snapshot: The snapshot used for reverting.
"""

View File

@ -125,20 +125,6 @@ in order to be an official Cinder volume driver.
:members:
:noindex:
Snapshot Interface
``````````````````
Another required interface for a volume driver to be fully compatible is the
ability to create and manage snapshots. Due to legacy constraints, this
interface is not included in the base driver interface above.
Work is being done to address those legacy issues. Once that is complete, this
interface will be merged with the base driver interface.
.. automodule:: cinder.interface.volume_snapshot_driver
:members:
:noindex:
Manage/Unmanage Support
```````````````````````
An optional feature a volume backend can support is the ability to manage
@ -186,3 +172,13 @@ need the volume consistency groups interface listed above.
:members:
:noindex:
Revert To Snapshot
``````````````````
Some storage backends support the ability to revert a volume to the last
snapshot. To support snapshot revert, the following interface must be
implemented by the driver.
.. automodule:: cinder.interface.volume_snapshot_revert
:members:
:noindex: