Portbinding extension moved to neutron_lib

Modifying UCSM driver to import portbindings from backwards_compatibility.py.
Modifying backwards_compatibility.py to take of importing portbinding extension
correctly for each release.

Change-Id: Ib17fe9361bf6ee25d52825fb7223b734aa00fdba
Closes-Bug: 1686438
This commit is contained in:
Sandhya Dasu 2017-04-25 10:03:12 -04:00
parent 597b25cc77
commit e7f2cab359
3 changed files with 19 additions and 18 deletions

View File

@ -52,6 +52,7 @@ else:
if NEUTRON_VERSION >= NEUTRON_OCATA_VERSION:
from neutron.db.models import agent as agent_model
from neutron.db.models import l3 as l3_models
from neutron_lib.api.definitions import portbindings
from neutron_lib.api import extensions
from neutron_lib.db import model_base
from neutron_lib.plugins import directory
@ -84,6 +85,7 @@ else:
from neutron.db import l3_db
from neutron.db import model_base # noqa
from neutron.db import models_v2
from neutron.extensions import portbindings # noqa
from neutron import manager
from neutron.plugins.common import constants as svc_constants

View File

@ -16,7 +16,6 @@
from oslo_log import log as logging
from neutron.extensions import portbindings
from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2 import driver_api as api
@ -36,7 +35,7 @@ class CiscoUcsmMechanismDriver(api.MechanismDriver):
def initialize(self):
self.vif_type = const.VIF_TYPE_802_QBH
self.vif_details = {portbindings.CAP_PORT_FILTER: False}
self.vif_details = {bc.portbindings.CAP_PORT_FILTER: False}
self.ucsm_db = ucsm_db.UcsmDbModel()
self.driver = ucsm_network_driver.CiscoUcsmDriver()
self.ucsm_conf = config.UcsmConfig()
@ -72,12 +71,12 @@ class CiscoUcsmMechanismDriver(api.MechanismDriver):
4. If no, create a new port profile with this vlan_id and
associate with this port
"""
vnic_type = context.current.get(portbindings.VNIC_TYPE,
portbindings.VNIC_NORMAL)
vnic_type = context.current.get(bc.portbindings.VNIC_TYPE,
bc.portbindings.VNIC_NORMAL)
profile = context.current.get(portbindings.PROFILE, {})
profile = context.current.get(bc.portbindings.PROFILE, {})
host_id = self._get_host_id(
context.current.get(portbindings.HOST_ID))
context.current.get(bc.portbindings.HOST_ID))
if not host_id:
LOG.warning(_LW('Host id from port context is None. '
'Ignoring this port'))
@ -170,7 +169,7 @@ class CiscoUcsmMechanismDriver(api.MechanismDriver):
# Checks to perform before UCS Manager can create a Port Profile.
# 1. Make sure this host is on a known UCS Manager.
host_id = self._get_host_id(
context.current.get(portbindings.HOST_ID))
context.current.get(bc.portbindings.HOST_ID))
if not host_id:
LOG.warning(_LW('Host id from port context is None. '
'Ignoring this port'))
@ -182,9 +181,9 @@ class CiscoUcsmMechanismDriver(api.MechanismDriver):
'Manager'), str(host_id))
return
profile = context.current.get(portbindings.PROFILE, {})
vnic_type = context.current.get(portbindings.VNIC_TYPE,
portbindings.VNIC_NORMAL)
profile = context.current.get(bc.portbindings.PROFILE, {})
vnic_type = context.current.get(bc.portbindings.VNIC_TYPE,
bc.portbindings.VNIC_NORMAL)
# 2. Make sure this is a vm_fex_port.(Port profiles are created
# only for VM-FEX ports.)
@ -296,8 +295,8 @@ class CiscoUcsmMechanismDriver(api.MechanismDriver):
in ACTIVE state and provide the Port Profile or Vlan Id as part
vif_details.
"""
vnic_type = context.current.get(portbindings.VNIC_TYPE,
portbindings.VNIC_NORMAL)
vnic_type = context.current.get(bc.portbindings.VNIC_TYPE,
bc.portbindings.VNIC_NORMAL)
LOG.debug('Attempting to bind port %(port)s with vnic_type '
'%(vnic_type)s on network %(network)s ',
@ -305,7 +304,7 @@ class CiscoUcsmMechanismDriver(api.MechanismDriver):
'vnic_type': vnic_type,
'network': context.network.current['id']})
profile = context.current.get(portbindings.PROFILE, {})
profile = context.current.get(bc.portbindings.PROFILE, {})
if not self.driver.check_vnic_type_and_vendor_info(vnic_type,
profile):
@ -328,7 +327,7 @@ class CiscoUcsmMechanismDriver(api.MechanismDriver):
const.VIF_DETAILS_PROFILEID] = profile_name
else:
self.vif_details[
portbindings.VIF_DETAILS_VLAN] = str(vlan_id)
bc.portbindings.VIF_DETAILS_VLAN] = str(vlan_id)
context.set_binding(segment[api.ID],
self.vif_type,

View File

@ -19,12 +19,12 @@ import sys
from threading import Timer
from contextlib import contextmanager
from neutron.extensions import portbindings
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import importutils
from networking_cisco._i18n import _LE, _LI, _LW
from networking_cisco import backwards_compatibility as bc
from networking_cisco.plugins.ml2.drivers.cisco.ucsm import config
from networking_cisco.plugins.ml2.drivers.cisco.ucsm import constants as const
from networking_cisco.plugins.ml2.drivers.cisco.ucsm import exceptions as cexc
@ -41,8 +41,8 @@ class CiscoUcsmDriver(object):
def __init__(self):
LOG.debug("UCS Manager Network driver found")
self.ucsmsdk = None
self.supported_sriov_vnic_types = [portbindings.VNIC_DIRECT,
portbindings.VNIC_MACVTAP]
self.supported_sriov_vnic_types = [bc.portbindings.VNIC_DIRECT,
bc.portbindings.VNIC_MACVTAP]
self.supported_pci_devs = config.parse_pci_vendor_config()
self.ucsm_conf = config.UcsmConfig()
self.ucsm_db = ucsm_db.UcsmDbModel()
@ -326,7 +326,7 @@ class CiscoUcsmDriver(object):
self.ucsm_db.remove_port_profile_to_delete(profile_name, ucsm_ip)
# Check if direct or macvtap mode
if vnic_type == portbindings.VNIC_DIRECT:
if vnic_type == bc.portbindings.VNIC_DIRECT:
port_mode = const.HIGH_PERF
else:
port_mode = const.NONE