Example #1
0
    def post(self, request):
        if ('entries' not in request.DATA):
            e_msg = ('Cannot export without specifying entries')
            handle_exception(Exception(e_msg), request)

        try:
            AdvancedNFSExport.objects.all().delete()
            cur_entries = []
            for e in request.DATA['entries']:
                logger.debug('adv export entry -- %s' % e)
                ce = AdvancedNFSExport(export_str=e)
                ce.save()
                cur_entries.append(ce)
            exports_d = create_adv_nfs_export_input(request.DATA['entries'],
                                                    request)
            cur_exports = list(NFSExport.objects.all())
            exports = create_nfs_export_input(cur_exports)
            exports.update(exports_d)
            refresh_wrapper(exports, request, logger)
            nfs_serializer = AdvancedNFSExportSerializer(cur_entries)
            return Response(nfs_serializer.data)
        except RockStorAPIException:
            raise
        except Exception, e:
            handle_exception(e, request)
Example #2
0
    def get_queryset(self, *args, **kwargs):
        if ('export_id' in kwargs):
            self.paginate_by = 0
            try:
                return AdvancedNFSExport(id=kwargs['export_id'])
            except:
                return []

        conventional_exports = []
        exports_by_share = {}
        for e in NFSExport.objects.all():
            eg = e.export_group
            export_str = (
                '%s(%s,%s,%s)' %
                (eg.host_str, eg.editable, eg.syncable, eg.mount_security))
            if (e.share.name in exports_by_share):
                exports_by_share[e.share.name] += (' %s' % export_str)
            else:
                exports_by_share[e.share.name] = ('%s %s' %
                                                  (e.mount, export_str))
        for e in exports_by_share:
            exports_by_share[e] = ('Normally added -- %s' %
                                   exports_by_share[e])
            conventional_exports.append(
                AdvancedNFSExport(export_str=exports_by_share[e]))

        for ae in AdvancedNFSExport.objects.all():
            conventional_exports.append(ae)
        return conventional_exports
    def post(self, request):
        if ('entries' not in request.DATA):
            e_msg = ('Cannot export without specifying entries')
            handle_exception(Exception(e_msg), request)

        try:
            AdvancedNFSExport.objects.all().delete()
            cur_entries = []
            for e in request.DATA['entries']:
                logger.debug('adv export entry -- %s' % e)
                ce = AdvancedNFSExport(export_str=e)
                ce.save()
                cur_entries.append(ce)
            exports_d = create_adv_nfs_export_input(request.DATA['entries'],
                                                    request)
            cur_exports = list(NFSExport.objects.all())
            exports = create_nfs_export_input(cur_exports)
            exports.update(exports_d)
            refresh_wrapper(exports, request, logger)
            nfs_serializer = AdvancedNFSExportSerializer(cur_entries)
            return Response(nfs_serializer.data)
        except RockStorAPIException:
            raise
        except Exception, e:
            handle_exception(e, request)
    def post(self, request):
        with self._handle_exception(request):
            if ('entries' not in request.data):
                e_msg = ('Cannot export without specifying entries')
                handle_exception(Exception(e_msg), request)

            AdvancedNFSExport.objects.all().delete()
            cur_entries = []
            for e in request.data.get('entries'):
                ce = AdvancedNFSExport(export_str=e)
                ce.save()
                cur_entries.append(ce)
            exports_d = create_adv_nfs_export_input(request.data['entries'],
                                                    request)
            cur_exports = list(NFSExport.objects.all())
            exports = create_nfs_export_input(cur_exports)
            exports.update(exports_d)
            refresh_wrapper(exports, request, logger)
            nfs_serializer = AdvancedNFSExportSerializer(cur_entries, many=True)
            return Response(nfs_serializer.data)
Example #5
0
    def post(self, request):
        with self._handle_exception(request):
            if ('entries' not in request.data):
                e_msg = ('Cannot export without specifying entries')
                handle_exception(Exception(e_msg), request)

            AdvancedNFSExport.objects.all().delete()
            cur_entries = []
            for e in request.data.get('entries'):
                ce = AdvancedNFSExport(export_str=e)
                ce.save()
                cur_entries.append(ce)
            exports_d = self.create_adv_nfs_export_input(
                request.data['entries'], request)
            cur_exports = list(NFSExport.objects.all())
            exports = self.create_nfs_export_input(cur_exports)
            exports.update(exports_d)
            self.refresh_wrapper(exports, request, logger)
            nfs_serializer = AdvancedNFSExportSerializer(cur_entries,
                                                         many=True)
            return Response(nfs_serializer.data)
    def get_queryset(self, *args, **kwargs):
        conventional_exports = []
        exports_by_share = {}
        for e in NFSExport.objects.all():
            eg = e.export_group
            export_str = (
                '%s(%s,%s,%s)' %
                (eg.host_str, eg.editable, eg.syncable, eg.mount_security))
            if (e.mount in exports_by_share):
                exports_by_share[e.mount] += (' %s' % export_str)
            else:
                exports_by_share[e.mount] = ('%s %s' % (e.mount, export_str))
        for e in exports_by_share:
            exports_by_share[e] = ('Normally added -- %s' %
                                   exports_by_share[e])
            conventional_exports.append(
                AdvancedNFSExport(export_str=exports_by_share[e]))

        for ae in AdvancedNFSExport.objects.all():
            conventional_exports.append(ae)
        return conventional_exports