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

Fix alignment when listing jails with more than one IP address #691

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vrachnis
Copy link

When a VNET jail has more than IP address configured on its primary interface, invoking bastille list -a will now display all addresses vertically aligned. This is to address a misalignment issue where the fields following the ip addresses were no longer in the same line as the jail name.

For instance:

 JID     State  IP Address       Published Ports  Hostname  Release          Path
 foo     Up     10.10.10.10
10.10.10.11   -                foo              14.0-RELEASE-p5  /usr/local/bastille/jails/foo/root
 hello1  Up     10.10.10.13      -                hello1                 14.0-RELEASE-p5  /usr/local/bastille/jails/hello1/root
 hello   Up     10.10.10.12      -                hello                14.0-RELEASE-p5  /usr/local/bastille/jails/hello/root
 test    Up     10.10.10.14      -                test               14.0-RELEASE-p5  /usr/local/bastille/jails/test/root

With this change, all additional IPs for a given jail are aligned vertically, and the fields following the IP (ports, hostname, release, path) are all in the same line as the jail name:

 JID     State  IP Address       Published Ports  Hostname  Release          Path
 foo     Up     10.10.10.10      -                foo              14.0-RELEASE-p5  /usr/local/bastille/jails/foo/root
                10.10.10.11
 hello1  Up     10.10.10.13      -                hello1                 14.0-RELEASE-p5  /usr/local/bastille/jails/hello1/root
 hello   Up     10.10.10.12      -                hello                14.0-RELEASE-p5  /usr/local/bastille/jails/hello/root
 test    Up     10.10.10.14      -                test               14.0-RELEASE-p5  /usr/local/bastille/jails/test/root

Considerations

Grouping of IPs

Initially I attempted to use line-drawing characters to visualize the fact that all addresses belong to the same jail:

 JID     State  IP Address       Published Ports  Hostname  Release          Path
 foo     Up     ┬ 10.10.10.10    -                foo              14.0-RELEASE-p5  /usr/local/bastille/jails/foo/root
                └ 10.10.10.11
 hello1  Up     10.10.10.13      -                hello1                 14.0-RELEASE-p5  /usr/local/bastille/jails/hello1/root
 hello   Up     10.10.10.12      -                hello                14.0-RELEASE-p5  /usr/local/bastille/jails/hello/root
 test    Up     10.10.10.14      -                test               14.0-RELEASE-p5  /usr/local/bastille/jails/test/root

While the result was making it clear to the user where the extra line comes from, the implementation became unnecessarily complex. More importantly, it meant that if anyone parses the output of bastille list -a in their script, would have to account for the fact that the "primary" IP address would be in either the third or fourth field of the line.

This highlights the fact that with this, the first and second/third/etc addresses will still be on different fields. The first address will be on field number 3, while the following addresses will be on field number 1. I could potentially modify the output to put some dummy characters in the first two columns, although I'm not sure that I like the result. Let me know if something like the following is preferable.

 JID     State  IP Address       Published Ports  Hostname  Release          Path
 foo     Up     10.10.10.10      -                foo              14.0-RELEASE-p5  /usr/local/bastille/jails/foo/root
 └─────  ─────  10.10.10.11
 hello1  Up     10.10.10.13      -                hello1                 14.0-RELEASE-p5  /usr/local/bastille/jails/hello1/root
 hello   Up     10.10.10.12      -                hello                14.0-RELEASE-p5  /usr/local/bastille/jails/hello/root
 test    Up     10.10.10.14      -                test               14.0-RELEASE-p5  /usr/local/bastille/jails/test/root

Dependencies

No new dependencies were introduced.

When a VNET jail has more than IP address configured on its primary interface, invoking "bastille list -a" will now display all addresses vertically aligned.
@yaazkal yaazkal added the enhancement New feature or request label Jul 8, 2024
@yaazkal
Copy link
Collaborator

yaazkal commented Jul 14, 2024

Thanks, I personally prefer the space instead of the extra characters for the first two columns. Now, does this support printing the published ports corresponding to each IP? does this support different hostname per IP?

Regards

@bmac2
Copy link
Collaborator

bmac2 commented Dec 17, 2024

two questions. How do you add a second ip to a jail?? I want to test this one. AND the code here is just the spaces and not the extra characters,right? @vrachnis @yaazkal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants