From d403b31d70e06d784bc644c525e89a7e1b0b549d Mon Sep 17 00:00:00 2001 From: Ivan Kolodyazhny Date: Wed, 22 Apr 2020 17:41:13 +0300 Subject: [PATCH] Show all os-extended-server-attributes Patch I0cfe9090e8263f983fa5f42f42616a26407be47a adds hypervisor hostname to the instance details view. This patch adds the rest of instance attributes allowed by 'os_compute_api:os-extended-server-attributes' policy. Change-Id: Id39ee14e3054422a96248f8cdd0a5bf07c27f2fc Closes-Bug: #1874273 --- openstack_dashboard/api/_nova.py | 56 +++++++++++++++++-- .../templates/instances/_detail_overview.html | 20 ++++++- 2 files changed, 69 insertions(+), 7 deletions(-) diff --git a/openstack_dashboard/api/_nova.py b/openstack_dashboard/api/_nova.py index 2773446dc0..0c6779d5ac 100644 --- a/openstack_dashboard/api/_nova.py +++ b/openstack_dashboard/api/_nova.py @@ -50,6 +50,10 @@ class Server(base.APIResourceWrapper): 'tenant_id', 'user_id', 'created', 'locked', 'OS-EXT-STS:power_state', 'OS-EXT-STS:task_state', 'OS-EXT-SRV-ATTR:instance_name', 'OS-EXT-SRV-ATTR:host', + 'OS-EXT-SRV-ATTR:hostname', 'OS-EXT-SRV-ATTR:kernel_id', + 'OS-EXT-SRV-ATTR:ramdisk_id', 'OS-EXT-SRV-ATTR:root_device_name', + 'OS-EXT-SRV-ATTR:root_device_name', 'OS-EXT-SRV-ATTR:user_data', + 'OS-EXT-SRV-ATTR:reservation_id', 'OS-EXT-SRV-ATTR:launch_index', 'OS-EXT-AZ:availability_zone', 'OS-DCF:diskConfig'] def __init__(self, apiresource, request): @@ -75,17 +79,59 @@ class Server(base.APIResourceWrapper): self.image['name'] = None return None - @property - def internal_name(self): - return getattr(self, 'OS-EXT-SRV-ATTR:instance_name', "") - @property def availability_zone(self): return getattr(self, 'OS-EXT-AZ:availability_zone', "") + @property + def has_extended_attrs(self): + return any(getattr(self, attr) for attr in [ + 'OS-EXT-SRV-ATTR:instance_name', 'OS-EXT-SRV-ATTR:host', + 'OS-EXT-SRV-ATTR:hostname', 'OS-EXT-SRV-ATTR:kernel_id', + 'OS-EXT-SRV-ATTR:ramdisk_id', 'OS-EXT-SRV-ATTR:root_device_name', + 'OS-EXT-SRV-ATTR:root_device_name', 'OS-EXT-SRV-ATTR:user_data', + 'OS-EXT-SRV-ATTR:reservation_id', 'OS-EXT-SRV-ATTR:launch_index', + ]) + + @property + def internal_name(self): + return getattr(self, 'OS-EXT-SRV-ATTR:instance_name', "") + @property def host_server(self): - return getattr(self, 'OS-EXT-SRV-ATTR:host', '') + return getattr(self, 'OS-EXT-SRV-ATTR:host', "") + + @property + def instance_name(self): + return getattr(self, 'OS-EXT-SRV-ATTR:instance_name', "") + + @property + def reservation_id(self): + return getattr(self, 'OS-EXT-SRV-ATTR:reservation_id', "") + + @property + def launch_index(self): + return getattr(self, 'OS-EXT-SRV-ATTR:launch_index', "") + + @property + def hostname(self): + return getattr(self, 'OS-EXT-SRV-ATTR:hostname', "") + + @property + def kernel_id(self): + return getattr(self, 'OS-EXT-SRV-ATTR:kernel_id', "") + + @property + def ramdisk_id(self): + return getattr(self, 'OS-EXT-SRV-ATTR:ramdisk_id', "") + + @property + def root_device_name(self): + return getattr(self, 'OS-EXT-SRV-ATTR:root_device_name', "") + + @property + def user_data(self): + return getattr(self, 'OS-EXT-SRV-ATTR:user_data', "") @memoized.memoized diff --git a/openstack_dashboard/dashboards/project/instances/templates/instances/_detail_overview.html b/openstack_dashboard/dashboards/project/instances/templates/instances/_detail_overview.html index 55427f7d58..4033f23fbd 100644 --- a/openstack_dashboard/dashboards/project/instances/templates/instances/_detail_overview.html +++ b/openstack_dashboard/dashboards/project/instances/templates/instances/_detail_overview.html @@ -22,9 +22,25 @@
{{ instance.created|parse_isotime }}
{% trans "Age" %}
{{ instance.created|parse_isotime|timesince }}
- {% if instance.host_server %} + {% if instance.has_extended_attrs %}
{% trans "Host" %}
-
{{ instance.host_server }}
+
{{ instance.host_server|default:_("-") }}
+
{% trans "Instance Name" %}
+
{{ instance.instance_name|default:_("-") }}
+
{% trans "Reservation ID" %}
+
{{ instance.reservation_id|default:_("-") }}
+
{% trans "Launch Index" %}
+
{{ instance.launch_index|default:_("-") }}
+
{% trans "Hostname" %}
+
{{ instance.hostname|default:_("-") }}
+
{% trans "Kernel ID" %}
+
{{ instance.kernel_id|default:_("-") }}
+
{% trans "Ramdisk ID" %}
+
{{ instance.ramdisk_id|default:_("-") }}
+
{% trans "Device Name" %}
+
{{ instance.root_device_name|default:_("-") }}
+
{% trans "User Data" %}
+
{{ instance.user_data|default:_("-") }}
{% endif %}