Merge "Remove versioning import of novaclient"

This commit is contained in:
Jenkins 2015-02-20 23:23:08 +00:00 committed by Gerrit Code Review
commit 6b472caf80
2 changed files with 16 additions and 5 deletions

View File

@ -14,10 +14,10 @@
# under the License.
import eventlet
from novaclient import client as nova_client
from novaclient import exceptions as nova_exceptions
import novaclient.v1_1.client as nclient
from novaclient.v1_1.contrib import server_external_events
from oslo_config import cfg
from oslo_utils import importutils
from sqlalchemy.orm import attributes as sql_attr
from neutron.common import constants
@ -35,6 +35,7 @@ VIF_PLUGGED = 'network-vif-plugged'
NEUTRON_NOVA_EVENT_STATUS_MAP = {constants.PORT_STATUS_ACTIVE: 'completed',
constants.PORT_STATUS_ERROR: 'failed',
constants.PORT_STATUS_DOWN: 'completed'}
NOVA_API_VERSION = "2"
class Notifier(object):
@ -48,7 +49,15 @@ class Notifier(object):
else:
bypass_url = None
self.nclient = nclient.Client(
# 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(
username=cfg.CONF.nova_admin_username,
api_key=cfg.CONF.nova_admin_password,
project_id=cfg.CONF.nova_admin_tenant_name,

View File

@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from novaclient import client
from novaclient import exceptions as nova_exc
from novaclient import utils as n_utils
from novaclient.v1_1 import client
from oslo_config import cfg
from neutron.i18n import _LE
@ -23,6 +23,7 @@ from neutron.openstack.common import log as logging
from neutron.plugins.cisco.common import cisco_constants as c_constants
LOG = logging.getLogger(__name__)
NOVA_API_VERSION = "2"
SERVICE_VM_LIB_OPTS = [
@ -41,7 +42,8 @@ class ServiceVMManager(object):
def __init__(self, user=None, passwd=None, l3_admin_tenant=None,
auth_url=''):
self._nclient = client.Client(user, passwd, l3_admin_tenant, auth_url,
self._nclient = client.Client(NOVA_API_VERSION, user, passwd,
l3_admin_tenant, auth_url,
service_type="compute")
@property