cinder/cinder/tests/unit/fake_volume.py
Xing Yang e78018bd05 Non-disruptive backup
This patch adds support for non-disruptive backup for
volumes in 'in-use' status as follows:

Adds a force flag in create backup API when backing up
an 'in-use' volume.

For the default implementation in volume/driver.py:
* Create a temporary volume from the original volume
* Backup the temporary volume
* Clean up the temporary volume

For the LVM driver:
* Create a temporary snapshot
* Obtain local_path for the temporary snapshot
* Backup the temporary snapshot
* Cleanup the temporary snapshot

Attach snapshot will be implemented in another patch.

Partial-implements blueprint non-disruptive-backup
Change-Id: I915c279b526e7268d68ab18ce01200ae22deabdd
2015-07-22 16:59:19 -04:00

50 lines
1.5 KiB
Python

# Copyright 2015 SimpliVity Corp.
#
# 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.
from oslo_versionedobjects import fields
from cinder import objects
def fake_db_volume(**updates):
db_volume = {
'id': '1',
'size': 1,
'name': 'volume-1',
'availability_zone': 'fake_availability_zone',
'status': 'available',
'attach_status': 'detached',
'previous_status': None
}
for name, field in objects.Volume.fields.items():
if name in db_volume:
continue
if field.nullable:
db_volume[name] = None
elif field.default != fields.UnspecifiedDefault:
db_volume[name] = field.default
else:
raise Exception('fake_db_volume needs help with %s' % name)
if updates:
db_volume.update(updates)
return db_volume
def fake_volume_obj(context, **updates):
return objects.Volume._from_db_object(context, objects.Volume(),
fake_db_volume(**updates))