allow building docs without ceilometer client

CeilometerClient has been deprecated and is no longer available for
master. Without ceilometer client installed docs fail to build with
an exception [1].

This patch marks the import optional.

1 -
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/sphinx/config.py", line 368, in
eval_config_file
    execfile_(filename, namespace)
  File "/usr/lib/python2.7/site-packages/sphinx/util/pycompat.py", line
150, in execfile_
    exec_(code, _globals)
  File "/usr/lib/python2.7/site-packages/six.py", line 709, in exec_
    exec(""exec _code_ in _globs_, _locs_"")
  File "<string>", line 1, in <module>
  File
"/home/abuild/rpmbuild/BUILD/python-watcher-2.1.0.dev45/doc/source/conf.py",
line 20, in <module>
    objects.register_all()
  File
"/home/abuild/rpmbuild/BUILD/python-watcher-2.1.0.dev45/watcher/objects/__init__.py",
line 31, in register_all
    __import__('watcher.objects.action_plan')
  File
"/home/abuild/rpmbuild/BUILD/python-watcher-2.1.0.dev45/watcher/objects/action_plan.py",
line 78, in <module>
    from watcher import conf
  File
"/home/abuild/rpmbuild/BUILD/python-watcher-2.1.0.dev45/watcher/conf/__init__.py",
line 28, in <module>
    from watcher.conf import datasources
  File
"/home/abuild/rpmbuild/BUILD/python-watcher-2.1.0.dev45/watcher/conf/datasources.py",
line 21, in <module>
    from watcher.datasources import manager
  File
"/home/abuild/rpmbuild/BUILD/python-watcher-2.1.0.dev45/watcher/datasources/manager.py",
line 19, in <module>
    from watcher.datasources import ceilometer as ceil
  File
"/home/abuild/rpmbuild/BUILD/python-watcher-2.1.0.dev45/watcher/datasources/ceilometer.py",
line 21, in <module>
    from ceilometerclient import exc
ImportError: No module named ceilometerclient
)

Change-Id: Idcf582c2495aab39aacf691b687759405bb94dca
This commit is contained in:
Sumit Jamgade 2019-05-13 14:23:43 +02:00
parent 64d841b3f2
commit 241df0d5f4

View File

@ -18,7 +18,6 @@
import datetime
from ceilometerclient import exc
from oslo_log import log
from oslo_utils import timeutils
@ -31,6 +30,13 @@ from watcher.datasources import base
LOG = log.getLogger(__name__)
try:
from ceilometerclient import exc
HAS_CEILCLIENT = True
except ImportError:
HAS_CEILCLIENT = False
class CeilometerHelper(base.DataSourceBase):
NAME = 'ceilometer'