'Returns the list of interface attachments for a given instance.'

@extensions.expected_errors((404, 501))
def index(self, req, server_id):

    context = req.environ['nova.context']
    context.can(ai_policies.BASE_POLICY_NAME)
    instance = common.get_instance(self.compute_api, context, server_id)
    search_opts = {'device_id': instance.uuid}
    try:
        data = self.network_api.list_ports(context, **search_opts)
    except exception.NotFound as e:
        raise exc.HTTPNotFound(explanation=e.format_message())
    except NotImplementedError:
        common.raise_feature_not_supported()
    ports = data.get('ports', [])
    entity_maker = _translate_interface_attachment_view
    results = [entity_maker(port) for port in ports]
    return {'interfaceAttachments': results}
