Implementation of volume migration for detached volumes with no snapshots. Migration is initiated by an admin API. The scheduler confirms that the specified destination host can accept the volume. The source driver is given the opportunity to migrate the volume on their own. Otherwise, a new volume is created on the destination, both volumes are attached, the data is copied over, the volumes are detached, the source is deleted, and the destination is renamed. In the database, the destination volume's attributes are copied to the source so that the volume-id remains unchanged, and the destination volume row is deleted. DocImpact Implements: bp volume-migration Change-Id: Ib6fcf27051f45e60aa3ba5f599e88c1421db753e
53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
#
|
|
# Copyright 2011 OpenStack LLC
|
|
#
|
|
# 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.
|
|
#
|
|
|
|
|
|
import os
|
|
|
|
from cinder import context
|
|
from cinder import db
|
|
|
|
|
|
def get_test_admin_context():
|
|
return context.get_admin_context()
|
|
|
|
|
|
def is_cinder_installed():
|
|
if os.path.exists('../../cinder.cinder.egg-info'):
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
|
|
def create_volume(ctxt,
|
|
host='test_host',
|
|
display_name='test_volume',
|
|
display_description='this is a test volume',
|
|
status='available',
|
|
size=1):
|
|
"""Create a volume object in the DB."""
|
|
vol = {}
|
|
vol['size'] = size
|
|
vol['host'] = host
|
|
vol['user_id'] = ctxt.user_id
|
|
vol['project_id'] = ctxt.project_id
|
|
vol['status'] = status
|
|
vol['display_name'] = display_name
|
|
vol['display_description'] = display_description
|
|
vol['attach_status'] = 'detached'
|
|
return db.volume_create(ctxt, vol)
|