Skip to content

Commit

Permalink
Fix case with no host_id in BigSwitch plugin
Browse files Browse the repository at this point in the history
This correctly checks for the case where nova does not
provide the host_id in port creation/updates.

Fixes: bug #1195903
Change-Id: Ic0d714a3977810c6b1144c1e25488f75cc95d0f0
  • Loading branch information
Kevin Benton committed Jun 29, 2013
1 parent 8e6def1 commit a87a7c2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions quantum/plugins/bigswitch/db/porttracker_db.py
Expand Up @@ -17,6 +17,7 @@

import sqlalchemy as sa

from quantum.api.v2 import attributes
from quantum.db import model_base
from quantum.openstack.common import log as logging

Expand All @@ -38,6 +39,9 @@ def get_port_hostid(context, port_id):


def put_port_hostid(context, port_id, host_id):
if not attributes.is_attr_set(host_id):
LOG.warning(_("No host_id in port request to track port location."))
return
if port_id == '':
LOG.warning(_("Received an empty port ID for host '%s'"), host_id)
return
Expand Down
17 changes: 17 additions & 0 deletions quantum/tests/unit/bigswitch/test_restproxy_plugin.py
Expand Up @@ -107,6 +107,23 @@ def setUp(self):
cfg.CONF.set_override('vif_type', 'ivs', 'NOVA')


class TestNoHostIDVIFOverride(test_plugin.TestPortsV2,
BigSwitchProxyPluginV2TestCase,
test_bindings.PortBindingsTestCase):
VIF_TYPE = portbindings.VIF_TYPE_OVS
HAS_PORT_FILTER = False

def setUp(self):
super(TestNoHostIDVIFOverride, self).setUp()
cfg.CONF.set_override('vif_type', 'ovs', 'NOVA')

def test_port_vif_details(self):
kwargs = {'name': 'name', 'device_id': 'override_dev'}
with self.port(**kwargs) as port:
self.assertEqual(port['port']['binding:vif_type'],
portbindings.VIF_TYPE_OVS)


class TestBigSwitchVIFOverride(test_plugin.TestPortsV2,
BigSwitchProxyPluginV2TestCase,
test_bindings.PortBindingsTestCase):
Expand Down

0 comments on commit a87a7c2

Please sign in to comment.