Initial refactoring for Volume Driver

The volume driver is a new construct that will connect the I/O Server to
a backing Cinder Volume.  This is a bit different from a standard
localdisk that will be provided via Glance.

This change set refactors the Glance disk work into a disk directory.
The cinder volume driver is then defined in a new 'volume' directory.
This will contain the driver volumes, such as NPIV and vSCSI.

The volume driver is built off the LibvirtBaseVolumeDriver model, but
can't extend that directly as that does contain libvirt specific code.
Eventually, we may be able to provide a common volume driver super class
that all drivers can utilize.

Change-Id: I2aafe2a97da8b195b74d57e8e88cb72389f69ac2
This commit is contained in:
Drew Thorstensen 2015-02-24 10:21:34 -06:00
parent eac2203bdb
commit a754bcc07c
10 changed files with 49 additions and 15 deletions

View File

@ -26,7 +26,7 @@ from pypowervm.wrappers import virtual_io_server as vios_w
from nova_powervm.tests.virt import powervm
from nova_powervm.tests.virt.powervm import fixtures as fx
from nova_powervm.virt.powervm import localdisk as ld
from nova_powervm.virt.powervm.disk import localdisk as ld
VOL_GRP_WITH_VIOS = 'fake_volume_group_with_vio_data.txt'
@ -41,7 +41,7 @@ class TestLocalDisk(test.TestCase):
# Find directory for response file(s)
data_dir = os.path.dirname(os.path.abspath(__file__))
data_dir = os.path.join(data_dir, 'data')
data_dir = os.path.join(data_dir, "..", 'data')
def resp(file_name):
file_path = os.path.join(data_dir, file_name)
@ -60,11 +60,12 @@ class TestLocalDisk(test.TestCase):
return local
@mock.patch('pypowervm.jobs.upload_lv.upload_new_vdisk')
@mock.patch('nova_powervm.virt.powervm.localdisk.LocalStorage.'
@mock.patch('nova_powervm.virt.powervm.disk.localdisk.LocalStorage.'
'_get_vg_uuid')
@mock.patch('nova_powervm.virt.powervm.localdisk.LocalStorage.'
@mock.patch('nova_powervm.virt.powervm.disk.localdisk.LocalStorage.'
'_get_disk_name')
@mock.patch('nova_powervm.virt.powervm.localdisk.IterableToFileAdapter')
@mock.patch('nova_powervm.virt.powervm.disk.localdisk.'
'IterableToFileAdapter')
@mock.patch('nova.image.API')
def test_create_volume_from_image(self, mock_img_api, mock_file_adpt,
mock_get_dname, mock_vg_uuid,
@ -80,9 +81,9 @@ class TestLocalDisk(test.TestCase):
self.assertEqual('fake_vol', vol_name.get('device_name'))
@mock.patch('pypowervm.wrappers.storage.VolumeGroup')
@mock.patch('nova_powervm.virt.powervm.localdisk.LocalStorage.'
@mock.patch('nova_powervm.virt.powervm.disk.localdisk.LocalStorage.'
'_get_vg_uuid')
@mock.patch('nova_powervm.virt.powervm.localdisk.LocalStorage.'
@mock.patch('nova_powervm.virt.powervm.disk.localdisk.LocalStorage.'
'_get_vg')
def test_capacity(self, mock_get_vg, mock_vg_uuid, mock_vg):
"""Tests the capacity methods."""
@ -98,7 +99,7 @@ class TestLocalDisk(test.TestCase):
self.assertEqual(5120.0, local.capacity)
self.assertEqual(3072.0, local.capacity_used)
@mock.patch('nova_powervm.virt.powervm.localdisk.LocalStorage.'
@mock.patch('nova_powervm.virt.powervm.disk.localdisk.LocalStorage.'
'_get_vg_uuid')
def test_disconnect_image_volume(self, mock_vg_uuid):
"""Tests the disconnect_image_volume method."""
@ -121,7 +122,7 @@ class TestLocalDisk(test.TestCase):
local.disconnect_image_volume(mock.MagicMock(), mock.MagicMock(), '2')
self.assertEqual(1, self.apt.update.call_count)
@mock.patch('nova_powervm.virt.powervm.localdisk.LocalStorage.'
@mock.patch('nova_powervm.virt.powervm.disk.localdisk.LocalStorage.'
'_get_vg_uuid')
def test_delete_volumes(self, mock_vg_uuid):
# Mocks
@ -140,9 +141,9 @@ class TestLocalDisk(test.TestCase):
self.assertEqual(1, self.apt.update.call_count)
@mock.patch('pypowervm.wrappers.storage.VolumeGroup')
@mock.patch('nova_powervm.virt.powervm.localdisk.LocalStorage.'
@mock.patch('nova_powervm.virt.powervm.disk.localdisk.LocalStorage.'
'_get_vg_uuid')
@mock.patch('nova_powervm.virt.powervm.localdisk.LocalStorage.'
@mock.patch('nova_powervm.virt.powervm.disk.localdisk.LocalStorage.'
'_get_disk_name')
def test_extend_volume(self, mock_dsk_name, mock_vg_uuid, mock_vg):
local = self.get_ls(self.apt)

View File

@ -48,7 +48,7 @@ class PowerVMComputeDriver(fixtures.Fixture):
def __init__(self):
pass
@mock.patch('nova_powervm.virt.powervm.localdisk.LocalStorage')
@mock.patch('nova_powervm.virt.powervm.disk.localdisk.LocalStorage')
@mock.patch('pypowervm.wrappers.managed_system.find_entry_by_mtms')
def _init_host(self, *args):
self.drv.init_host('FakeHost')

View File

@ -70,7 +70,7 @@ class TestPowerVMDriver(test.TestCase):
self.assertIsNotNone(test_drv)
@mock.patch('pypowervm.wrappers.managed_system.find_entry_by_mtms')
@mock.patch('nova_powervm.virt.powervm.localdisk.LocalStorage')
@mock.patch('nova_powervm.virt.powervm.disk.localdisk.LocalStorage')
def test_driver_init(self, mock_disk, mock_find):
"""Validates the PowerVM driver can be initialized for the host."""
drv = driver.PowerVMDriver(fake.FakeVirtAPI())

View File

@ -31,7 +31,7 @@ from pypowervm.wrappers import constants as pvm_consts
from pypowervm.wrappers import storage as pvm_st
from pypowervm.wrappers import virtual_io_server as pvm_vios
from nova_powervm.virt.powervm import blockdev
from nova_powervm.virt.powervm.disk import blockdev
from nova_powervm.virt.powervm import vios
localdisk_opts = [

View File

@ -35,8 +35,8 @@ from pypowervm.utils import retry as pvm_retry
from pypowervm.wrappers import constants as pvm_consts
from pypowervm.wrappers import managed_system as msentry_wrapper
from nova_powervm.virt.powervm.disk import localdisk as blk_lcl
from nova_powervm.virt.powervm import host as pvm_host
from nova_powervm.virt.powervm import localdisk as blk_lcl
from nova_powervm.virt.powervm.tasks import destroy as tf_destroy
from nova_powervm.virt.powervm.tasks import spawn as tf_spawn
from nova_powervm.virt.powervm import vios

View File

@ -0,0 +1,33 @@
# Copyright 2015 IBM Corp.
#
# 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.
class PowerVMVolumeDriver(object):
"""The basic operations for a Cinder Backed Volume Driver.
The role of the volume driver is to perform the connection between the
compute node and the backing physical fabric.
This is built similarly to the LibvirtBaseVolumeDriver.
"""
def connect_volume(self, connection_info, disk_info):
"""Connects the volume."""
pass
def disconnect_volume(self, connection_info, disk_dev):
"""Disconnect the volume."""
pass