Fix client side versions in dhcp rpc API

The dhcp rpc API has two version (1.0 and 1.1).  The proper way to use
versioning for this is to only specify '1.1' from the client side when
you require that the remote side implements at least version '1.1' for
the method to work.  Otherwise, '1.0' should still be specified.  The
previous code specified '1.1' always.

Related to blueprint drop-rpc-compat.

Change-Id: I9468f8f67d80c5d064137f917fc04f9335a3ed55
This commit is contained in:
Russell Bryant 2014-11-07 15:31:15 +01:00
parent 0b924798ff
commit 12324cbde1
2 changed files with 7 additions and 7 deletions

View File

@ -413,12 +413,12 @@ class DhcpPluginApi(object):
self.context = context
self.host = cfg.CONF.host
self.use_namespaces = use_namespaces
target = messaging.Target(topic=topic, version='1.1')
target = messaging.Target(topic=topic, version='1.0')
self.client = n_rpc.get_client(target)
def get_active_networks_info(self):
"""Make a remote process call to retrieve all network info."""
cctxt = self.client.prepare()
cctxt = self.client.prepare(version='1.1')
networks = cctxt.call(self.context, 'get_active_networks_info',
host=self.host)
return [dhcp.NetModel(self.use_namespaces, n) for n in networks]
@ -442,7 +442,7 @@ class DhcpPluginApi(object):
def create_dhcp_port(self, port):
"""Make a remote process call to create the dhcp port."""
cctxt = self.client.prepare()
cctxt = self.client.prepare(version='1.1')
port = cctxt.call(self.context, 'create_dhcp_port',
port=port, host=self.host)
if port:
@ -450,7 +450,7 @@ class DhcpPluginApi(object):
def update_dhcp_port(self, port_id, port):
"""Make a remote process call to update the dhcp port."""
cctxt = self.client.prepare()
cctxt = self.client.prepare(version='1.1')
port = cctxt.call(self.context, 'update_dhcp_port',
port_id=port_id, port=port, host=self.host)
if port:

View File

@ -957,7 +957,7 @@ class TestDhcpPluginApiProxy(base.BaseTestCase):
rpc_mock.assert_called_once_with(ctxt, method, **kwargs)
def test_get_active_networks_info(self):
self._test_dhcp_api('get_active_networks_info')
self._test_dhcp_api('get_active_networks_info', version='1.1')
def test_get_network_info(self):
self._test_dhcp_api('get_network_info', network_id='fake_id',
@ -969,11 +969,11 @@ class TestDhcpPluginApiProxy(base.BaseTestCase):
def test_create_dhcp_port(self):
self._test_dhcp_api('create_dhcp_port', port='fake_port',
return_value=None)
return_value=None, version='1.1')
def test_update_dhcp_port(self):
self._test_dhcp_api('update_dhcp_port', port_id='fake_id',
port='fake_port', return_value=None)
port='fake_port', return_value=None, version='1.1')
def test_release_dhcp_port(self):
self._test_dhcp_api('release_dhcp_port', network_id='fake_id',