Skip to content

Commit

Permalink
Merge pull request #133 from stackhpc/upstream/wallaby-2023-06-05
Browse files Browse the repository at this point in the history
Synchronise wallaby with upstream
  • Loading branch information
markgoddard authored Jun 5, 2023
2 parents dad23f4 + 8fb45c0 commit 99dd0ec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kayobe/plugins/filter/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,11 @@ def net_libvirt_network_name(context, name, inventory_hostname=None):

@jinja2.contextfilter
def net_bridge_ports(context, name, inventory_hostname=None):
return net_attr(context, name, 'bridge_ports', inventory_hostname)
ports = net_attr(context, name, 'bridge_ports', inventory_hostname)
if ports and not isinstance(ports, list):
raise errors.AnsibleFilterError("Bridge ports for network '%s' should"
" be a list", name)
return ports


net_bond_mode = _make_attr_filter('bond_mode')
Expand Down
6 changes: 6 additions & 0 deletions kayobe/tests/unit/plugins/filter/test_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import jinja2

from ansible import errors
from kayobe.plugins.filter import networks


Expand Down Expand Up @@ -197,3 +198,8 @@ def test_get_ovs_veths_bridge_vlan_multiple_mtu(self):
}
]
self.assertEqual(expected, veths)

def test_ensure_bridge_ports_is_list(self):
self._update_context({"net3_bridge_ports": "ens3"})
self.assertRaises(errors.AnsibleFilterError, networks.net_bridge_ports,
self.context, "net3")

0 comments on commit 99dd0ec

Please sign in to comment.