Skip to content

Conversation

@tzumainn
Copy link
Contributor

No description provided.

@tzumainn
Copy link
Contributor Author

The output is a bit ugly; esi node network list essentially breaks up the node port information into multiple columns, but we can't do that for a show command if we want to keep the single attribute/value pair that other OpenStack show command use. Instead, I just dump all the port information into a dict, which looks gross when using the default output, but is fine if you specify json output.

@tzumainn tzumainn requested a review from larsks January 22, 2025 18:16
return ["Node", "Node UUID", "Node Ports"], [
node_network["node"].name,
node_network["node"].id,
node_ports,
Copy link
Member

Choose a reason for hiding this comment

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

What if we did this?

Suggested change
node_ports,
node_ports if parsed_args.formatter == "json" else json.dumps(node_ports, indent=2),

That gets us:

+-------+--------------------------------------------------------------------+
| Field | Value                                                              |
+-------+--------------------------------------------------------------------+
| Node  | MOC-R4PAC22U33-S3A                                                 |
| UUID  | a94f0a86-4b37-4cf1-bd53-3107d60e72f8                               |
| Ports | [                                                                  |
|       |   {                                                                |
|       |     "mac_address": "a8:99:69:ae:d6:db",                            |
|       |     "baremetal_port_uuid": "e043ce6d-21b1-439f-9d3b-488994b85cbb", |
|       |     "network_port": {                                              |
|       |       "name": "esi-MOC-R4PAC22U33-S3A-hypershift-pool",            |
|       |       "uuid": "8646e75a-2b30-4eb4-aef8-da35e8c143ca",              |
|       |       "fixed_ips": [                                               |
|       |         "10.219.1.168"                                             |
|       |       ]                                                            |
|       |     },                                                             |
|       |     "network": {                                                   |
|       |       "name": "hypershift-pool",                                   |
|       |       "uuid": "610f12a1-10be-4dd7-92fc-9d6f63a9227a",              |
|       |       "vlan_id": 464                                               |
|       |     }                                                              |
|       |   },                                                               |
|       |   {                                                                |
|       |     "mac_address": "a8:99:69:ae:d6:de",                            |
|       |     "baremetal_port_uuid": "c1d44f2a-3754-4a12-a394-3e20b44cff03"  |
|       |   }                                                                |
|       | ]                                                                  |
+-------+--------------------------------------------------------------------+

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I like this a lot - good idea!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll probably make it a bit more exclusionary, since I don't think we want this formatting for, say, csv output.

@tzumainn tzumainn force-pushed the esi-node-network-show branch from aa10953 to 58967b1 Compare January 23, 2025 15:21
@tzumainn
Copy link
Contributor Author

I've made the suggested changes - let me know what you think!

@larsks larsks merged commit 75d6644 into CCI-MOC:master Jan 23, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants