From 0c80639805e8c07a3556de6dd378a8f332611993 Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Sat, 8 Sep 2018 21:52:13 +0000 Subject: [PATCH] Improve IP address formatting in Instance table Previously

and

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 --- .../dashboards/project/instances/tables.py | 14 ++++---------- .../templates/instances/_instance_ips.html | 18 ++++-------------- 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/openstack_dashboard/dashboards/project/instances/tables.py b/openstack_dashboard/dashboards/project/instances/tables.py index 324430bafc..5ae25e01f5 100644 --- a/openstack_dashboard/dashboards/project/instances/tables.py +++ b/openstack_dashboard/dashboards/project/instances/tables.py @@ -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, diff --git a/openstack_dashboard/dashboards/project/instances/templates/instances/_instance_ips.html b/openstack_dashboard/dashboards/project/instances/templates/instances/_instance_ips.html index 7b4226b90c..b19e83fed5 100644 --- a/openstack_dashboard/dashboards/project/instances/templates/instances/_instance_ips.html +++ b/openstack_dashboard/dashboards/project/instances/templates/instances/_instance_ips.html @@ -1,19 +1,9 @@ {% load i18n %} +