check for ovs agent is running on a host

while retreving the information from port details which belongs to specific host,
we are checking whether ovs agent is running on that host or not. if not,
exception is raised saying ovs agent not found in the host.

Closes-Bug:1515877

Change-Id: I23fccd8751ce791e1c6fd6920a0510c943714126
changes/81/291081/4
vikas 7 years ago
parent d74b22f012
commit dfa79b3cf6

@ -28,6 +28,10 @@ class L2GatewayNotFound(exceptions.NotFound):
message = _("L2 Gateway %(gateway_id)s could not be found")
class OvsAgentNotFound(exceptions.NotFound):
message = _("ovs agent not found in host %(host)s")
class L2GatewayDeviceInUse(exceptions.InUse):
message = _("L2 Gateway Device '%(device_id)s' is still used by "
"one or more network gateways.")
@ -119,4 +123,5 @@ base.FAULT_MAP.update({L2GatewayInUse: web_exc.HTTPConflict,
L2GatewaySegmentationRequired: web_exc.HTTPConflict,
L2MultipleGatewayConnections: web_exc.HTTPConflict,
L2GatewayDuplicateSegmentationID: web_exc.HTTPConflict,
OvsAgentNotFound: web_exc.HTTPNotFound,
OVSDBError: web_exc.HTTPConflict})

@ -470,11 +470,14 @@ class L2gwRpcDriver(service_drivers.L2gwDriver):
def _get_ip_details(self, context, port):
host = port[portbindings.HOST_ID]
agent = self._get_agent_details(context, host)
conf_dict = agent[0].get("configurations")
dst_ip = conf_dict.get("tunneling_ip")
fixed_ip_list = port.get('fixed_ips')
fixed_ip_list = fixed_ip_list[0]
return dst_ip, fixed_ip_list.get('ip_address')
if agent:
conf_dict = agent[0].get("configurations")
dst_ip = conf_dict.get("tunneling_ip")
fixed_ip_list = port.get('fixed_ips')
fixed_ip_list = fixed_ip_list[0]
return dst_ip, fixed_ip_list.get('ip_address')
else:
raise l2gw_exc.OvsAgentNotFound(host=host)
def _get_network_details(self, context, network_id):
network = self.service_plugin._core_plugin.get_network(context,

@ -272,6 +272,17 @@ class TestL2gwRpcDriver(base.BaseTestCase):
self.assertEqual(ret_dst_ip, 'fake_tun_ip')
self.assertEqual(ret_ip_add, 'fake_ip')
def test_get_ip_details_for_no_ovs_agent(self):
fake_port = {'binding:host_id': 'fake_host',
'fixed_ips': [{'ip_address': 'fake_ip'}]}
with mock.patch.object(self.plugin,
'_get_agent_details',
return_value=None):
self.assertRaises(l2gw_exc.OvsAgentNotFound,
self.plugin._get_ip_details,
self.context,
fake_port)
def test_get_network_details(self):
fake_network = {'id': 'fake_network_id',
'name': 'fake_network_name',

Loading…
Cancel
Save