Show all instance IP addresses on databases list

Story: 2008228
Task: 41068
Change-Id: Ibb7a08dcad6cb1a19ff6c0fd680c64584ef3cf34
This commit is contained in:
Ivan Kolodyazhny 2020-12-21 18:35:04 +02:00
parent d0e1f82d90
commit a8b7786d1c
2 changed files with 24 additions and 1 deletions

View File

@ -15,6 +15,7 @@
from urllib import parse as urlparse
from django.conf import settings
from django import template
from django.template import defaultfilters as d_filters
from django import urls
from django.urls import reverse
@ -573,11 +574,28 @@ def get_datastore_version(instance):
return _("Not available")
# NOTE(e0ne): the logic is based on
# openstack_dashboard.dashboards.project.instances.tables.get_ips
# Trove has a different instance addresses structure so we can't re-use
# nova-related code as is.
def get_ips(instance):
template_name = 'project/instances/_instance_ips.html'
ip_groups = {}
for address in getattr(instance, 'addresses', []):
ip_groups[address["type"]] = [address["address"]]
context = {
"ip_groups": ip_groups,
}
return template.loader.render_to_string(template_name, context)
def get_host(instance):
if hasattr(instance, "hostname"):
return instance.hostname
elif hasattr(instance, "ip") and instance.ip:
return instance.ip[0]
return get_ips(instance)
return _("Not Assigned")

View File

@ -148,6 +148,8 @@ DATABASE_DATA_ONE = {
"ip": [
"10.0.0.3",
],
"addresses": [{"type": "private",
"address": "10.0.0.3"}],
"volume": {
"used": 0.13,
"size": 1,
@ -171,6 +173,7 @@ DATABASE_DATA_TWO = {
"links": [],
"created": "2013-08-12T22:00:03",
"hostname": "trove.instance-2.com",
"addresses": [],
"volume": {
"used": 0.13,
"size": 1,
@ -195,6 +198,8 @@ DATABASE_DATA_THREE = {
"ip": [
"10.0.0.3",
],
"addresses": [{"type": "private",
"address": "10.0.0.3"}],
"volume": {
"used": 0.13,
"size": 1,