Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Node List Function With Baremetal and Lease Info #6

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion esi/lib/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,48 @@
from esi.lib import networks


def node_list_full_info(connection):
"""Get a list of nodes with more attributes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd clarify this as "list of nodes with information from Ironic and ESI-Leap"


: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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I admit that this sort of implicit matching makes me nervous, especially because I think Ironic node names don't actually have to be unique. In addition it depends on the two services returning the same list of nodes - which they should do, but if the behavior changes in one then the results will be messed up.


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

Expand Down Expand Up @@ -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 [],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this effect python-esiclient?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not affect python-esiclient, just a documentation error

'networks': {
'parent': openstack.network.v2.network.Network or None,
'trunk': [openstack.network.v2.network.Network] or [],
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading