mark oslo.vmware as optional dependency

Driver-specific requirements are not hard requirements, since the
choice of drivers is up to the operator. The oslo.vmware module is
herein moved out of requirements.txt and instead listed as an optional
dependency using the extras functionality in setup.cfg.

A check is added to the vmdk driver to gracefully handle import errors
if the vmdk driver is used and oslo.vmware is not found.

Change-Id: I9b00edc38f0700304a1a164f0679a734f8701ebe
Closes-Bug: #1475739
This commit is contained in:
Matthew Edmonds 2015-07-17 16:42:35 -04:00
parent 110cac181c
commit e67adc385c
4 changed files with 20 additions and 6 deletions

View File

@ -32,11 +32,16 @@ from oslo_log import log as logging
from oslo_utils import excutils
from oslo_utils import units
from oslo_utils import uuidutils
from oslo_vmware import api
from oslo_vmware import exceptions
from oslo_vmware import image_transfer
from oslo_vmware import pbm
from oslo_vmware import vim_util
try:
import oslo_vmware
except ImportError:
oslo_vmware = None
else:
from oslo_vmware import api
from oslo_vmware import exceptions
from oslo_vmware import image_transfer
from oslo_vmware import pbm
from oslo_vmware import vim_util
import six
from cinder import exception
@ -268,6 +273,11 @@ class VMwareEsxVmdkDriver(driver.VolumeDriver):
:param context: Context information
"""
if oslo_vmware is None:
msg = _("Missing 'oslo_vmware' python module, ensure the library"
" is installed and available.")
raise exception.VolumeDriverException(message=msg)
# Throw error if required parameters are not set.
required_params = ['vmware_host_ip',
'vmware_host_username',

View File

@ -50,5 +50,4 @@ stevedore>=1.5.0 # Apache-2.0
suds-jurko>=0.6
WebOb>=1.2.3
oslo.i18n>=1.5.0 # Apache-2.0
oslo.vmware>=1.16.0 # Apache-2.0
os-brick>=0.3.2 # Apache-2.0

View File

@ -25,6 +25,10 @@ setup-hooks =
packages =
cinder
[extras]
vmdk =
oslo.vmware>=1.16.0 # Apache-2.0
[entry_points]
cinder.scheduler.filters =
AvailabilityZoneFilter = cinder.openstack.common.scheduler.filters.availability_zone_filter:AvailabilityZoneFilter

View File

@ -13,6 +13,7 @@ install_command = pip install {opts} {packages}
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
.[vmdk]
# By default ostestr will set concurrency
# to ncpu, to specify something else use