Improve IP address formatting in Instance table
Previously <h4> and <h5> were used for network names and the title "Floating IPs". It caused these strings are displayed using larger fonts. This commit changes they are rendered with same font as for others. The following changes are also made to save spaces. * Network name and IP addresses are displayed in a single line. * IP addresses are sorted in the order of IPv4 first. * The title "Floating IP" is no longer displayed (I believe an floating IPs are still clear as they have global addresses) Closes-Bug: #1789325 Change-Id: I5bfae9b10609628d16a5919840a56ae135739924
This commit is contained in:
parent
62d90a49ad
commit
0c80639805
|
@ -27,6 +27,7 @@ from django.utils.translation import pgettext_lazy
|
|||
from django.utils.translation import string_concat
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ungettext_lazy
|
||||
import netaddr
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import messages
|
||||
|
@ -969,16 +970,9 @@ def get_ips(instance):
|
|||
ip_groups = {}
|
||||
|
||||
for ip_group, addresses in instance.addresses.items():
|
||||
ip_groups[ip_group] = {}
|
||||
ip_groups[ip_group]["floating"] = []
|
||||
ip_groups[ip_group]["non_floating"] = []
|
||||
|
||||
for address in addresses:
|
||||
if ('OS-EXT-IPS:type' in address and
|
||||
address['OS-EXT-IPS:type'] == "floating"):
|
||||
ip_groups[ip_group]["floating"].append(address)
|
||||
else:
|
||||
ip_groups[ip_group]["non_floating"].append(address)
|
||||
ips = [addr['addr'] for addr in addresses]
|
||||
ips.sort(key=lambda ip: netaddr.IPAddress(ip).version)
|
||||
ip_groups[ip_group] = ips
|
||||
|
||||
context = {
|
||||
"ip_groups": ip_groups,
|
||||
|
|
|
@ -1,19 +1,9 @@
|
|||
{% load i18n %}
|
||||
<ul class="list-unstyled">
|
||||
{% for ip_group, ips in ip_groups.items %}
|
||||
{% if ip_groups.keys|length > 1 %}
|
||||
<h4>{{ ip_group }}</h4>
|
||||
{% endif %}
|
||||
<ul class="list-unstyled">
|
||||
{% for address in ips.non_floating %}
|
||||
<li>{{ address.addr }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% if ips.floating|length > 0 %}
|
||||
<h5>{% trans 'Floating IPs:' %}</h5>
|
||||
<ul class="list-unstyled">
|
||||
{% for address in ips.floating %}
|
||||
<li>{{ address.addr }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<li><b>{{ ip_group }}</b>
|
||||
{% endif %}
|
||||
{{ ips|join:", " }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue