Exemplo n.º 1
0
 def get_context_data(self, request):
     volume_id = self.tab_group.kwargs['volume_id']
     try:
         volume = cinder.volume_get(request, volume_id)
         for att in volume.attachments:
             att['instance'] = nova.server_get(request, att['server_id'])
     except Exception:
         redirect = reverse('horizon:hpcloud:volumes:index')
         exceptions.handle(self.request,
                           _('Unable to retrieve volume details.'),
                           redirect=redirect)
     return {'volume': volume}
Exemplo n.º 2
0
def volume_get(request, volume_id):
    volume_data = cinderclient(request).volumes.get(volume_id)

    for attachment in volume_data.attachments:
        if "server_id" in attachment:
            instance = nova.server_get(request, attachment['server_id'])
            attachment['instance_name'] = instance.name
        else:
            # Nova volume can occasionally send back error'd attachments
            # the lack a server_id property; to work around that we'll
            # give the attached instance a generic name.
            attachment['instance_name'] = _("Unknown instance")
    return volume_data