Display host address on row update
The host colume of the database table is calculated from the ip address and / or hostname of the instance. Currently this is calculated when the table is first populated but not re-calculated when a row is updated Re-factor the code to use the same calculation to determine the instance host information during row update Change-Id: Ic7b5e14918ea9d3196e0b591a8e57ccf6c0a71f1 Closes-Bug: #1336823
This commit is contained in:
parent
fd20346ab0
commit
04045d6fda
@ -136,6 +136,7 @@ class UpdateRow(tables.Row):
|
||||
instance.full_flavor = api.trove.flavor_get(request, flavor_id)
|
||||
except Exception:
|
||||
pass
|
||||
instance.host = get_host(instance)
|
||||
return instance
|
||||
|
||||
|
||||
@ -151,6 +152,14 @@ def get_datastore_version(instance):
|
||||
return _("Not available")
|
||||
|
||||
|
||||
def get_host(instance):
|
||||
if hasattr(instance, "hostname"):
|
||||
return instance.hostname
|
||||
elif hasattr(instance, "ip") and instance.ip:
|
||||
return instance.ip[0]
|
||||
return _("Not Assigned")
|
||||
|
||||
|
||||
def get_size(instance):
|
||||
if hasattr(instance, "full_flavor"):
|
||||
size_string = _("%(name)s | %(RAM)s RAM")
|
||||
@ -189,7 +198,7 @@ class InstancesTable(tables.DataTable):
|
||||
verbose_name=_("Datastore"))
|
||||
datastore_version = tables.Column(get_datastore_version,
|
||||
verbose_name=_("Datastore Version"))
|
||||
host = tables.Column("host", verbose_name=_("Host"))
|
||||
host = tables.Column(get_host, verbose_name=_("Host"))
|
||||
size = tables.Column(get_size,
|
||||
verbose_name=_("Size"),
|
||||
attrs={'data-type': 'size'})
|
||||
|
@ -39,14 +39,6 @@ from openstack_dashboard.dashboards.project.databases import workflows
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_host(instance):
|
||||
if hasattr(instance, "hostname"):
|
||||
return instance.hostname
|
||||
elif hasattr(instance, "ip") and instance.ip:
|
||||
return instance.ip[0]
|
||||
return None
|
||||
|
||||
|
||||
class IndexView(horizon_tables.DataTableView):
|
||||
table_class = tables.InstancesTable
|
||||
template_name = 'project/databases/index.html'
|
||||
@ -68,7 +60,7 @@ class IndexView(horizon_tables.DataTableView):
|
||||
flavor = self.get_flavors().get(instance.flavor["id"])
|
||||
if flavor is not None:
|
||||
instance.full_flavor = flavor
|
||||
instance.host = get_host(instance)
|
||||
instance.host = tables.get_host(instance)
|
||||
return instance
|
||||
|
||||
def get_data(self):
|
||||
@ -113,7 +105,7 @@ class DetailView(horizon_tabs.TabbedTableView):
|
||||
LOG.info("Obtaining instance for detailed view ")
|
||||
instance_id = self.kwargs['instance_id']
|
||||
instance = api.trove.instance_get(self.request, instance_id)
|
||||
instance.host = get_host(instance)
|
||||
instance.host = tables.get_host(instance)
|
||||
except Exception:
|
||||
redirect = reverse('horizon:project:databases:index')
|
||||
msg = _('Unable to retrieve details '
|
||||
|
Loading…
Reference in New Issue
Block a user