Fix service_mapped_to_host filter
The service_mapped_to_host filter is used to check if a service is mapped to a host, based on the group for the service or its host_in_groups attribute if one exists. We check if the service's group is in the 'groups' list. However, to get the list of groups to which a host belongs, we should use the 'group_names' list. This filter is currently only used in neutron IPv6 module loading, so the effects are minimal. Change-Id: I37409ca8d273b0426df0a648db222dc5432e738a Closes-Bug: #1868285
This commit is contained in:
parent
9643dd54e2
commit
35966c9186
@ -63,7 +63,7 @@ def service_mapped_to_host(context, service):
|
|||||||
|
|
||||||
group = service.get("group")
|
group = service.get("group")
|
||||||
if group is not None:
|
if group is not None:
|
||||||
return group in context.get("groups")
|
return group in context.get("group_names")
|
||||||
|
|
||||||
raise exception.FilterError(
|
raise exception.FilterError(
|
||||||
"Service definition for '%s' does not have a 'group' or "
|
"Service definition for '%s' does not have a 'group' or "
|
||||||
|
@ -104,14 +104,14 @@ class TestFilters(unittest.TestCase):
|
|||||||
service = {
|
service = {
|
||||||
'group': 'foo'
|
'group': 'foo'
|
||||||
}
|
}
|
||||||
context = self._make_context({'groups': ['foo', 'bar']})
|
context = self._make_context({'group_names': ['foo', 'bar']})
|
||||||
self.assertTrue(filters.service_mapped_to_host(context, service))
|
self.assertTrue(filters.service_mapped_to_host(context, service))
|
||||||
|
|
||||||
def test_service_mapped_to_host_not_in_group(self):
|
def test_service_mapped_to_host_not_in_group(self):
|
||||||
service = {
|
service = {
|
||||||
'group': 'foo'
|
'group': 'foo'
|
||||||
}
|
}
|
||||||
context = self._make_context({'groups': ['bar']})
|
context = self._make_context({'group_names': ['bar']})
|
||||||
self.assertFalse(filters.service_mapped_to_host(context, service))
|
self.assertFalse(filters.service_mapped_to_host(context, service))
|
||||||
|
|
||||||
def test_service_mapped_to_host_no_attr(self):
|
def test_service_mapped_to_host_no_attr(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user