From 9bcce699f85f5a9ad1e2798077b5fc8c1dabec29 Mon Sep 17 00:00:00 2001 From: Austin Jamias Date: Fri, 5 Jul 2024 08:53:07 -0400 Subject: [PATCH 1/2] Add Node List Function With Baremetal and Lease Info --- esi/lib/nodes.py | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/esi/lib/nodes.py b/esi/lib/nodes.py index 79a2ea5..1074b43 100644 --- a/esi/lib/nodes.py +++ b/esi/lib/nodes.py @@ -16,6 +16,48 @@ from esi.lib import networks +def node_list_full_info(connection): + """Get a list of nodes with more attributes + + :param connection: An ESI connection + :type connection: :class:`~esi.connection.ESIConnection` + + :returns: A list of dictionaries containing baremetal and lease information + """ + + esi_nodes = [] + baremetal_nodes = [] + + with concurrent.futures.ThreadPoolExecutor() as executor: + f1 = executor.submit(connection.list_nodes) + f2 = executor.submit(connection.baremetal.nodes, details=True) + esi_nodes = f1.result() + baremetal_nodes = list(f2.result()) + + esi_nodes.sort(key=lambda node: node.name) + baremetal_nodes.sort(key=lambda node: node.name) + + return [ + { + 'uuid': bm.id, + 'name': bm.name, + 'maintenance': bm.is_maintenance, + 'provision_state': bm.provision_state, + 'target_provision_state': bm.target_provision_state, + 'power_state': bm.power_state, + 'target_power_state': bm.target_power_state, + 'properties': bm.properties, + 'lease_uuid': e.lease_uuid, + 'owner': e.owner, + 'lessee': e.lessee, + 'resource_class': e.resource_class, + 'future_offers': e.future_offers, + 'future_leases': e.future_leases, + } + for e, bm in zip(esi_nodes, baremetal_nodes) + ] + + def node_and_port_list(connection, filter_node=None): """Get lists baremetal nodes and ports @@ -61,7 +103,7 @@ def network_list(connection, filter_node=None, filter_network=None): 'network_info': [ { 'baremetal_port': openstack.baremetal.v1.port.Port, - 'network_port': [openstack.network.v2.port.Port] or [], + 'network_ports': [openstack.network.v2.port.Port] or [], 'networks': { 'parent': openstack.network.v2.network.Network or None, 'trunk': [openstack.network.v2.network.Network] or [], From 01773a65ec49d0baddc8cc95b65d57fffb836931 Mon Sep 17 00:00:00 2001 From: Austin Jamias Date: Wed, 10 Jul 2024 09:30:49 -0400 Subject: [PATCH 2/2] Update openstacksdk requirements.txt version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c40b260..d92af95 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,7 @@ requestsexceptions>=1.2.0 # Apache-2.0 jsonpatch!=1.20,>=1.16 # BSD os-service-types>=1.7.0 # Apache-2.0 keystoneauth1>=3.18.0 # Apache-2.0 -openstacksdk<1.3.0 +openstacksdk>=3.2.0 # Apache-2.0 decorator>=4.4.1 # BSD jmespath>=0.9.0 # MIT iso8601>=0.1.11 # MIT