Fix VM and IP alignment in tenant list output#5
Merged
Conversation
When displaying tenants with multiple VMs (like mspina with restvm-mspina-01
and restvm-mspina-02), the IP addresses were not correctly aligned with their
corresponding VM names. All IPs were displayed in sequence without grouping,
causing the second VM name to appear next to the second IP of the first VM
instead of its own first IP.
Changes:
- Modified TenantManager.get_tenant_info() to include vm_ip_map, a dictionary
mapping VM names to their IP addresses
- Updated create_tenant_table() in ui.py to properly align VM names with
their corresponding IPs by iterating through VMs and displaying each VM's
IPs grouped together
- For each VM with multiple IPs, the first IP appears on the same line as
the VM name, with subsequent IPs on following lines with blank VM names
The alignment now correctly shows:
restvm-mspina-01 10.10.0.21/24
10.10.0.22/24
restvm-mspina-02 10.10.0.11/24
10.10.0.12/24
Instead of the previous misaligned:
restvm-mspina-01 10.10.0.21/24
restvm-mspina-02 10.10.0.22/24
10.10.0.11/24
10.10.0.12/24
Fixes #2
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2 - Corrects the misalignment of VM names and their corresponding IP addresses in the
p4tenant listcommand output.Problem
When displaying tenants with multiple VMs (e.g., user
mspinawithrestvm-mspina-01andrestvm-mspina-02), the IP addresses were not correctly aligned with their VM names. All IPs from all VMs were displayed in sequence without grouping, causing visual misalignment where the second VM name would appear next to an IP address from the first VM.Before:
Solution
Modified the tenant information structure and table rendering logic to:
In
tenant.py: Addedvm_ip_mapdictionary toget_tenant_info()that maps each VM name to its list of IP addresses, preserving the association between VMs and their IPs.In
ui.py: Updatedcreate_tenant_table()to use thevm_ip_mapfor proper alignment:After:
Testing
Tested with the current configuration where user
mspinahas two VMs, each with 2 IP addresses. The alignment now correctly groups each VM with its corresponding IPs.Files Changed
p4tenant/src/p4tenant/tenant.py: Addedvm_ip_mapto tenant info structurep4tenant/src/p4tenant/ui.py: Implemented proper alignment logic in table rendering🤖 Generated with Claude Code