Skip to content

Fix VM and IP alignment in tenant list output#5

Merged
alessandrocornacchia merged 1 commit into
masterfrom
fix/issue-2
Jan 29, 2026
Merged

Fix VM and IP alignment in tenant list output#5
alessandrocornacchia merged 1 commit into
masterfrom
fix/issue-2

Conversation

@alessandrocornacchia

Copy link
Copy Markdown
Member

Summary

Fixes #2 - Corrects the misalignment of VM names and their corresponding IP addresses in the p4tenant list command output.

Problem

When displaying tenants with multiple VMs (e.g., user mspina with restvm-mspina-01 and restvm-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:

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

Solution

Modified the tenant information structure and table rendering logic to:

  1. In tenant.py: Added vm_ip_map dictionary to get_tenant_info() that maps each VM name to its list of IP addresses, preserving the association between VMs and their IPs.

  2. In ui.py: Updated create_tenant_table() to use the vm_ip_map for proper alignment:

    • For tenants with multiple VMs, iterate through each VM
    • Display the VM name with its first IP on the same line
    • Show remaining IPs for that VM on subsequent lines with blank VM names
    • Then move to the next VM

After:

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

Testing

Tested with the current configuration where user mspina has 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: Added vm_ip_map to tenant info structure
  • p4tenant/src/p4tenant/ui.py: Implemented proper alignment logic in table rendering

🤖 Generated with Claude Code

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>
@alessandrocornacchia alessandrocornacchia merged commit a62edc6 into master Jan 29, 2026
1 check passed
@claude

claude Bot commented Jan 29, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.


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.

Tenant list output

1 participant