Introduce a get_groups function openstack topology and let list_openstack_nodes accept group lists
Currently some tests wrongfully call list_openstack_nodes(group='controller') in order to run tests on the whole control plane. That assumption does not hold true in case of composable HA where the control plane consists of 3 controller nodes (w/ haproxy+vip), 3 database nodes and 3 messaging nodes. In such cases we'd have to filter three times for the group of the node (aka resource class). Let's allow list_openstack_nodes to have a list of group, so all its users are allowed to pass a list of groups instead. Instead of overloading the get_group() function directly, we add a simple get_groups() function and use that inside list_openstack_nodes() when group is a list. Tested this on a composable HA and we correctly get all the nodes when calling the following: groups = ['controller', 'messaging', 'database'] nodes = topology.list_openstack_nodes(group=groups) Co-Authored-By: Luca Miccini <lmiccini@redhat.com> Change-Id: I6995a73c482ba7b654d089316f47668d86c495e1
This commit is contained in:
parent
7b59745844
commit
608ceab04b
@ -51,10 +51,13 @@ def get_openstack_topology(topology_class=None):
|
|||||||
|
|
||||||
def list_openstack_nodes(topology=None, group=None, hostnames=None, **kwargs):
|
def list_openstack_nodes(topology=None, group=None, hostnames=None, **kwargs):
|
||||||
topology = topology or get_openstack_topology()
|
topology = topology or get_openstack_topology()
|
||||||
if group:
|
if group is None:
|
||||||
|
nodes = topology.nodes
|
||||||
|
elif isinstance(group, str):
|
||||||
nodes = topology.get_group(group=group)
|
nodes = topology.get_group(group=group)
|
||||||
else:
|
else:
|
||||||
nodes = topology.nodes
|
nodes = topology.get_groups(groups=group)
|
||||||
|
|
||||||
if hostnames:
|
if hostnames:
|
||||||
names = {node_name_from_hostname(hostname)
|
names = {node_name_from_hostname(hostname)
|
||||||
for hostname in hostnames}
|
for hostname in hostnames}
|
||||||
@ -297,6 +300,12 @@ class OpenStackTopology(tobiko.SharedFixture):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
raise _exception.NoSuchOpenStackTopologyNodeGroup(group=group)
|
raise _exception.NoSuchOpenStackTopologyNodeGroup(group=group)
|
||||||
|
|
||||||
|
def get_groups(self, groups):
|
||||||
|
nodes = []
|
||||||
|
for i in groups:
|
||||||
|
nodes.extend(self.get_group(i))
|
||||||
|
return nodes
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def groups(self):
|
def groups(self):
|
||||||
return list(self._nodes_by_group)
|
return list(self._nodes_by_group)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user