Merge "Use constants from networking_odl project"

This commit is contained in:
Jenkins 2015-01-22 13:19:26 +00:00 committed by Gerrit Code Review
commit ffe91ecad5
2 changed files with 21 additions and 27 deletions

View File

@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from networking_odl.common import constants as odl_const
from networking_odl.ml2 import mech_driver
from oslo.config import cfg
@ -24,10 +25,6 @@ from neutron.plugins.ml2 import driver_api as api
LOG = log.getLogger(__name__)
ODL_NETWORKS = 'networks'
ODL_SUBNETS = 'subnets'
ODL_PORTS = 'ports'
odl_opts = [
cfg.StrOpt('url',
help=_("HTTP URL of OpenDaylight REST interface.")),
@ -69,31 +66,31 @@ class OpenDaylightMechanismDriver(api.MechanismDriver):
# Postcommit hooks are used to trigger synchronization.
def create_network_postcommit(self, context):
self.odl_drv.synchronize('create', ODL_NETWORKS, context)
self.odl_drv.synchronize('create', odl_const.ODL_NETWORKS, context)
def update_network_postcommit(self, context):
self.odl_drv.synchronize('update', ODL_NETWORKS, context)
self.odl_drv.synchronize('update', odl_const.ODL_NETWORKS, context)
def delete_network_postcommit(self, context):
self.odl_drv.synchronize('delete', ODL_NETWORKS, context)
self.odl_drv.synchronize('delete', odl_const.ODL_NETWORKS, context)
def create_subnet_postcommit(self, context):
self.odl_drv.synchronize('create', ODL_SUBNETS, context)
self.odl_drv.synchronize('create', odl_const.ODL_SUBNETS, context)
def update_subnet_postcommit(self, context):
self.odl_drv.synchronize('update', ODL_SUBNETS, context)
self.odl_drv.synchronize('update', odl_const.ODL_SUBNETS, context)
def delete_subnet_postcommit(self, context):
self.odl_drv.synchronize('delete', ODL_SUBNETS, context)
self.odl_drv.synchronize('delete', odl_const.ODL_SUBNETS, context)
def create_port_postcommit(self, context):
self.odl_drv.synchronize('create', ODL_PORTS, context)
self.odl_drv.synchronize('create', odl_const.ODL_PORTS, context)
def update_port_postcommit(self, context):
self.odl_drv.synchronize('update', ODL_PORTS, context)
self.odl_drv.synchronize('update', odl_const.ODL_PORTS, context)
def delete_port_postcommit(self, context):
self.odl_drv.synchronize('delete', ODL_PORTS, context)
self.odl_drv.synchronize('delete', odl_const.ODL_PORTS, context)
def bind_port(self, context):
LOG.debug("Attempting to bind port %(port)s on "

View File

@ -20,14 +20,11 @@ from neutron import context
from neutron.tests.unit.ml2 import test_ml2_plugin as test_plugin
ODL_NETWORKS = 'networks'
ODL_SUBNETS = 'subnets'
ODL_PORTS = 'ports'
with mock.patch.dict(sys.modules,
{'networking_odl': mock.Mock(),
'networking_odl.common': mock.Mock(),
'networking_odl.ml2': mock.Mock()}):
from networking_odl.common import constants as const
from neutron.plugins.ml2.drivers import mechanism_odl
@ -43,53 +40,53 @@ class TestODLShim(test_plugin.Ml2PluginV2TestCase):
def test_create_network_postcommit(self):
self.driver.create_network_postcommit(self.context)
self.driver.odl_drv.synchronize.assert_called_with('create',
ODL_NETWORKS,
const.ODL_NETWORKS,
self.context)
def test_update_network_postcommit(self):
self.driver.update_network_postcommit(self.context)
self.driver.odl_drv.synchronize.assert_called_with('update',
ODL_NETWORKS,
const.ODL_NETWORKS,
self.context)
def test_delete_network_postcommit(self):
self.driver.delete_network_postcommit(self.context)
self.driver.odl_drv.synchronize.assert_called_with('delete',
ODL_NETWORKS,
const.ODL_NETWORKS,
self.context)
def test_create_subnet_postcommit(self):
self.driver.create_subnet_postcommit(self.context)
self.driver.odl_drv.synchronize.assert_called_with('create',
ODL_SUBNETS,
const.ODL_SUBNETS,
self.context)
def test_update_subnet_postcommit(self):
self.driver.update_subnet_postcommit(self.context)
self.driver.odl_drv.synchronize.assert_called_with('update',
ODL_SUBNETS,
const.ODL_SUBNETS,
self.context)
def test_delete_subnet_postcommit(self):
self.driver.delete_subnet_postcommit(self.context)
self.driver.odl_drv.synchronize.assert_called_with('delete',
ODL_SUBNETS,
const.ODL_SUBNETS,
self.context)
def test_create_port_postcommit(self):
self.driver.create_port_postcommit(self.context)
self.driver.odl_drv.synchronize.assert_called_with('create',
ODL_PORTS,
const.ODL_PORTS,
self.context)
def test_update_port_postcommit(self):
self.driver.update_port_postcommit(self.context)
self.driver.odl_drv.synchronize.assert_called_with('update',
ODL_PORTS,
const.ODL_PORTS,
self.context)
def test_delete_port_postcommit(self):
self.driver.delete_port_postcommit(self.context)
self.driver.odl_drv.synchronize.assert_called_with('delete',
ODL_PORTS,
const.ODL_PORTS,
self.context)