Remove hack for discovery novaclients extension

novaclient provides a common way to discover all extensions, so we can
remove import based on novaclient versioned client object.

Closes-Bug: #1493886
Change-Id: I7ae2eeb2d7e5c56e9284f3b059ff6e3545f42d5f
This commit is contained in:
Andrey Kurilin 2015-09-09 16:48:59 +03:00
parent 5d5aa1b045
commit ce5761f153
1 changed files with 6 additions and 11 deletions

View File

@ -20,7 +20,6 @@ from novaclient import client as nova_client
from novaclient import exceptions as nova_exceptions
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import importutils
from oslo_utils import uuidutils
from sqlalchemy.orm import attributes as sql_attr
@ -94,18 +93,14 @@ class Notifier(object):
'nova',
auth=auth)
# NOTE(andreykurilin): novaclient.v1_1 was renamed to v2 and there is
# no way to import the contrib module directly without referencing v2,
# which would only work for novaclient >= 2.21.0.
novaclient_cls = nova_client.get_client_class(NOVA_API_VERSION)
server_external_events = importutils.import_module(
novaclient_cls.__module__.replace(
".client", ".contrib.server_external_events"))
self.nclient = novaclient_cls(
extensions = [
ext for ext in nova_client.discover_extensions(NOVA_API_VERSION)
if ext.name == "server_external_events"]
self.nclient = nova_client.Client(
NOVA_API_VERSION,
session=session,
region_name=cfg.CONF.nova.region_name,
extensions=[server_external_events])
extensions=extensions)
self.batch_notifier = batch_notifier.BatchNotifier(
cfg.CONF.send_events_interval, self.send_events)