Add image data for instance with volume
If an instance was created with a volume from an image, there is no image details in instance overview page. This patch adds image info from volume image-metadata. Change-Id: I1da69eb4a65ab13f77d610b870bada994de876f2 Closes-Bug: 1833267
This commit is contained in:
parent
b068440330
commit
5de6df19dc
@ -35,7 +35,18 @@ class OverviewTab(tabs.Tab):
|
||||
"_detail_overview.html")
|
||||
|
||||
def get_context_data(self, request):
|
||||
return {"instance": self.tab_group.kwargs['instance']}
|
||||
instance = self.tab_group.kwargs['instance']
|
||||
if instance.volumes and not instance.image:
|
||||
try:
|
||||
volume = api.cinder.volume_get(
|
||||
self.request, volume_id=instance.volumes[0].volumeId)
|
||||
instance.image = {
|
||||
'id': volume.volume_image_metadata['image_id'],
|
||||
'name': volume.volume_image_metadata['image_name']}
|
||||
except Exception:
|
||||
exceptions.handle(self.request,
|
||||
_('Failed to get attached volume.'))
|
||||
return {"instance": instance}
|
||||
|
||||
|
||||
class InterfacesTab(tabs.TableTab):
|
||||
|
Loading…
x
Reference in New Issue
Block a user