Beispiel #1
0
 def delete(self, request, export_id):
     try:
         eg = validate_export_group(export_id, request)
         cur_exports = list(NFSExport.objects.all())
         for e in NFSExport.objects.filter(export_group=eg):
             export_pt = ('%s%s' % (settings.NFS_EXPORT_ROOT, e.share.name))
             if (e.export_group.nohide):
                 snap_name = e.mount.split(e.share.name + '_')[-1]
                 export_pt = ('%s/%s' % (export_pt, snap_name))
             teardown_wrapper(export_pt, request, logger)
             cur_exports.remove(e)
             e.delete()
         eg.delete()
         exports = create_nfs_export_input(cur_exports)
         adv_entries = [
             e.export_str for e in AdvancedNFSExport.objects.all()
         ]
         exports_d = create_adv_nfs_export_input(adv_entries, request)
         exports.update(exports_d)
         refresh_wrapper(exports, request, logger)
         return Response()
     except RockStorAPIException:
         raise
     except Exception, e:
         handle_exception(e, request)
Beispiel #2
0
 def delete(self, request, sname, export_id):
     try:
         share = validate_share(sname, request)
         eg = validate_export_group(export_id, request)
         cur_exports = list(NFSExport.objects.all())
         export = NFSExport.objects.get(export_group=eg, share=share)
         for e in NFSExport.objects.filter(share=share):
             if (e.export_group.host_str == eg.host_str):
                 export_pt = ('%s%s' % (settings.NFS_EXPORT_ROOT,
                                        share.name))
                 if (e.export_group.nohide):
                     snap_name = e.mount.split(e.share.name + '_')[-1]
                     export_pt = ('%s%s/%s' % (settings.NFS_EXPORT_ROOT,
                                               e.share.name, snap_name))
                 teardown_wrapper(export_pt, request, logger)
                 cur_exports.remove(e)
         exports = create_nfs_export_input(cur_exports)
         export.delete()
         if (NFSExport.objects.filter(export_group=eg).count() == 0):
             #delete only when this is the only share in the group
             eg.delete()
         refresh_wrapper(exports, request, logger)
         return Response()
     except RockStorAPIException:
         raise
     except Exception, e:
         handle_exception(e, request)
Beispiel #3
0
 def delete(self, request, sname, export_id):
     try:
         share = validate_share(sname, request)
         eg = validate_export_group(export_id, request)
         cur_exports = list(NFSExport.objects.all())
         export = NFSExport.objects.get(export_group=eg, share=share)
         for e in NFSExport.objects.filter(share=share):
             if (e.export_group.host_str == eg.host_str):
                 export_pt = ('%s%s' %
                              (settings.NFS_EXPORT_ROOT, share.name))
                 if (e.export_group.nohide):
                     snap_name = e.mount.split(e.share.name + '_')[-1]
                     export_pt = ('%s%s/%s' % (settings.NFS_EXPORT_ROOT,
                                               e.share.name, snap_name))
                 teardown_wrapper(export_pt, request, logger)
                 cur_exports.remove(e)
         exports = create_nfs_export_input(cur_exports)
         export.delete()
         if (NFSExport.objects.filter(export_group=eg).count() == 0):
             #delete only when this is the only share in the group
             eg.delete()
         refresh_wrapper(exports, request, logger)
         return Response()
     except RockStorAPIException:
         raise
     except Exception, e:
         handle_exception(e, request)
Beispiel #4
0
 def put(self, request, sname, export_id):
     with self._handle_exception(request):
         share = validate_share(sname, request)
         eg = validate_export_group(export_id, request)
         options = parse_options(request)
         dup_export_check(share, options["host_str"], request, export_id=int(export_id))
         NFSExportGroup.objects.filter(id=export_id).update(**options)
         NFSExportGroup.objects.filter(id=export_id)[0].save()
         cur_exports = list(NFSExport.objects.all())
         exports = create_nfs_export_input(cur_exports)
         refresh_wrapper(exports, request, logger)
         nfs_serializer = NFSExportGroupSerializer(eg)
         return Response(nfs_serializer.data)
Beispiel #5
0
 def put(self, request, sname, export_id):
     with self._handle_exception(request):
         share = validate_share(sname, request)
         eg = validate_export_group(export_id, request)
         options = parse_options(request)
         dup_export_check(share, options['host_str'], request,
                          export_id=int(export_id))
         NFSExportGroup.objects.filter(id=export_id).update(**options)
         NFSExportGroup.objects.filter(id=export_id)[0].save()
         cur_exports = list(NFSExport.objects.all())
         exports = create_nfs_export_input(cur_exports)
         refresh_wrapper(exports, request, logger)
         nfs_serializer = NFSExportGroupSerializer(eg)
         return Response(nfs_serializer.data)
Beispiel #6
0
 def put(self, request, export_id):
     if ('shares' not in request.DATA):
         e_msg = ('Cannot export without specifying shares')
         handle_exception(Exception(e_msg), request)
     shares = [validate_share(s, request) for s in request.DATA['shares']]
     try:
         eg = validate_export_group(export_id, request)
         options = parse_options(request)
         for s in shares:
             dup_export_check(s,
                              options['host_str'],
                              request,
                              export_id=int(export_id))
         NFSExportGroup.objects.filter(id=export_id).update(**options)
         NFSExportGroup.objects.filter(id=export_id)[0].save()
         cur_exports = list(NFSExport.objects.all())
         for e in NFSExport.objects.filter(export_group=eg):
             if (e.share not in shares):
                 cur_exports.remove(e)
                 e.delete()
             else:
                 shares.remove(e.share)
         for s in shares:
             mnt_pt = ('%s%s' % (settings.MNT_PT, s.name))
             export_pt = ('%s%s' % (settings.NFS_EXPORT_ROOT, s.name))
             if (not is_share_mounted(s.name)):
                 pool_device = Disk.objects.filter(pool=s.pool)[0].name
                 mount_share(s.subvol_name, pool_device, mnt_pt)
             export = NFSExport(export_group=eg, share=s, mount=export_pt)
             export.full_clean()
             export.save()
             cur_exports.append(export)
         exports = create_nfs_export_input(cur_exports)
         adv_entries = [
             e.export_str for e in AdvancedNFSExport.objects.all()
         ]
         exports_d = create_adv_nfs_export_input(adv_entries, request)
         exports.update(exports_d)
         refresh_wrapper(exports, request, logger)
         nfs_serializer = NFSExportGroupSerializer(eg)
         return Response(nfs_serializer.data)
     except RockStorAPIException:
         raise
     except Exception, e:
         handle_exception(e, request)
 def put(self, request, export_id):
     if ('shares' not in request.DATA):
         e_msg = ('Cannot export without specifying shares')
         handle_exception(Exception(e_msg), request)
     shares = [validate_share(s, request) for s in request.DATA['shares']]
     try:
         eg = validate_export_group(export_id, request)
         options = parse_options(request)
         for s in shares:
             dup_export_check(s, options['host_str'], request,
                              export_id=int(export_id))
         NFSExportGroup.objects.filter(id=export_id).update(**options)
         NFSExportGroup.objects.filter(id=export_id)[0].save()
         cur_exports = list(NFSExport.objects.all())
         for e in NFSExport.objects.filter(export_group=eg):
             if (e.share not in shares):
                 cur_exports.remove(e)
                 e.delete()
             else:
                 shares.remove(e.share)
         for s in shares:
             mnt_pt = ('%s%s' % (settings.MNT_PT, s.name))
             export_pt = ('%s%s' % (settings.NFS_EXPORT_ROOT, s.name))
             if (not is_share_mounted(s.name)):
                 pool_device = Disk.objects.filter(pool=s.pool)[0].name
                 mount_share(s.subvol_name, pool_device, mnt_pt)
             export = NFSExport(export_group=eg, share=s, mount=export_pt)
             export.full_clean()
             export.save()
             cur_exports.append(export)
         exports = create_nfs_export_input(cur_exports)
         adv_entries = [e.export_str for e in
                        AdvancedNFSExport.objects.all()]
         exports_d = create_adv_nfs_export_input(adv_entries, request)
         exports.update(exports_d)
         refresh_wrapper(exports, request, logger)
         nfs_serializer = NFSExportGroupSerializer(eg)
         return Response(nfs_serializer.data)
     except RockStorAPIException:
         raise
     except Exception, e:
         handle_exception(e, request)
Beispiel #8
0
 def delete(self, request, export_id):
     with self._handle_exception(request):
         eg = validate_export_group(export_id, request)
         cur_exports = list(NFSExport.objects.all())
         for e in NFSExport.objects.filter(export_group=eg):
             export_pt = ('%s%s' % (settings.NFS_EXPORT_ROOT, e.share.name))
             if (e.export_group.nohide):
                 snap_name = e.mount.split(e.share.name + '_')[-1]
                 export_pt = ('%s/%s' % (export_pt, snap_name))
             teardown_wrapper(export_pt, request, logger)
             cur_exports.remove(e)
             e.delete()
         eg.delete()
         exports = create_nfs_export_input(cur_exports)
         adv_entries = [e.export_str for e in
                        AdvancedNFSExport.objects.all()]
         exports_d = create_adv_nfs_export_input(adv_entries, request)
         exports.update(exports_d)
         refresh_wrapper(exports, request, logger)
         return Response()
Beispiel #9
0
 def delete(self, request, export_id):
     try:
         eg = validate_export_group(export_id, request)
         cur_exports = list(NFSExport.objects.all())
         for e in NFSExport.objects.filter(export_group=eg):
             export_pt = ('%s%s' % (settings.NFS_EXPORT_ROOT, e.share.name))
             if (e.export_group.nohide):
                 snap_name = e.mount.split(e.share.name + '_')[-1]
                 export_pt = ('%s/%s' % (export_pt, snap_name))
             teardown_wrapper(export_pt, request, logger)
             cur_exports.remove(e)
             e.delete()
         eg.delete()
         exports = create_nfs_export_input(cur_exports)
         refresh_wrapper(exports, request, logger)
         return Response()
     except RockStorAPIException:
         raise
     except Exception, e:
         handle_exception(e, request)
Beispiel #10
0
 def delete(self, request, sname, export_id):
     with self._handle_exception(request):
         share = validate_share(sname, request)
         eg = validate_export_group(export_id, request)
         cur_exports = list(NFSExport.objects.all())
         export = NFSExport.objects.get(export_group=eg, share=share)
         for e in NFSExport.objects.filter(share=share):
             if e.export_group.host_str == eg.host_str:
                 export_pt = "%s%s" % (settings.NFS_EXPORT_ROOT, share.name)
                 if e.export_group.nohide:
                     snap_name = e.mount.split(e.share.name + "_")[-1]
                     export_pt = "%s%s/%s" % (settings.NFS_EXPORT_ROOT, e.share.name, snap_name)
                 nfs4_mount_teardown(export_pt)
                 cur_exports.remove(e)
         exports = create_nfs_export_input(cur_exports)
         export.delete()
         if NFSExport.objects.filter(export_group=eg).count() == 0:
             # delete only when this is the only share in the group
             eg.delete()
         refresh_wrapper(exports, request, logger)
         return Response()