Make libvirt-python an extra requirement

This patch moves libvirt-python to extras.

Change-Id: Id129ab0a280b12e1bd0bfc1214c76a087c572a0d
This commit is contained in:
Anton Studenov 2016-10-12 15:14:31 +03:00
parent b6486ce340
commit e2e0320e4f
6 changed files with 32 additions and 4 deletions

View File

@ -14,6 +14,20 @@ IPMI driver).
* Source: https://github.com/openstack/os-faults * Source: https://github.com/openstack/os-faults
* Bugs: http://bugs.launchpad.net/os-faults * Bugs: http://bugs.launchpad.net/os-faults
Installation
------------
Reqular installation::
pip install os-faults
The library contains optional libvirt driver, if you plan to use it,
please use the following command to install os-faults with extra dependencies::
pip install os-faults[libvirt]
Configuration Configuration
------------- -------------

View File

@ -10,3 +10,8 @@ Or, if you have virtualenvwrapper installed::
$ mkvirtualenv os-faults $ mkvirtualenv os-faults
$ pip install os-faults $ pip install os-faults
The library contains optional libvirt driver, if you plan to use it,
please use the following command to install os-faults with extra dependencies::
pip install os-faults[libvirt]

View File

@ -13,8 +13,6 @@
import logging import logging
import libvirt
from os_faults.api import error from os_faults.api import error
from os_faults.api import power_management from os_faults.api import power_management
from os_faults import utils from os_faults import utils
@ -44,6 +42,11 @@ class LibvirtDriver(power_management.PowerManagement):
def _get_connection(self): def _get_connection(self):
if self._cached_conn is None: if self._cached_conn is None:
try:
import libvirt
except ImportError:
raise error.OSFError('libvirt-python is required '
'to use LibvirtDriver')
self._cached_conn = libvirt.open(self.connection_uri) self._cached_conn = libvirt.open(self.connection_uri)
return self._cached_conn return self._cached_conn

View File

@ -12,7 +12,6 @@ oslo.i18n>=1.5.0 # Apache-2.0
oslo.log>=1.12.0 # Apache-2.0 oslo.log>=1.12.0 # Apache-2.0
oslo.serialization>=1.10.0 # Apache-2.0 oslo.serialization>=1.10.0 # Apache-2.0
oslo.utils!=2.6.0,>=2.4.0 # Apache-2.0 oslo.utils!=2.6.0,>=2.4.0 # Apache-2.0
libvirt-python>=1.2.5 # LGPLv2+
pyghmi>=1.0.3 # Apache-2.0 pyghmi>=1.0.3 # Apache-2.0
PyYAML>=3.1.0 # MIT PyYAML>=3.1.0 # MIT
six>=1.9.0 six>=1.9.0

View File

@ -24,6 +24,10 @@ packages =
console_scripts = console_scripts =
os-inject-fault = os_faults.cmd.cmd:main os-inject-fault = os_faults.cmd.cmd:main
[extras]
libvirt =
libvirt-python>=1.2.5 # LGPLv2+
[build_sphinx] [build_sphinx]
source-dir = doc/source source-dir = doc/source
build-dir = doc/build build-dir = doc/build

View File

@ -11,7 +11,10 @@ install_command =
setenv = setenv =
VIRTUAL_ENV={envdir} VIRTUAL_ENV={envdir}
whitelist_externals = find whitelist_externals = find
deps = -r{toxinidir}/test-requirements.txt # TODO(astudenov): replace libvirt-python with extras option from tox 2.4
deps =
-r{toxinidir}/test-requirements.txt
libvirt-python>=1.2.5
commands = commands =
find . -type f -name "*.pyc" -delete find . -type f -name "*.pyc" -delete
py.test -vvvv --html={envlogdir}/pytest_results.html --self-contained-html --durations=10 "os_faults/tests/unit" {posargs} py.test -vvvv --html={envlogdir}/pytest_results.html --self-contained-html --durations=10 "os_faults/tests/unit" {posargs}