def post(self, request, sid): with self._handle_exception(request): share = Share.objects.get(id=sid) options = { "owner": "root", "group": "root", "perms": "755", "orecursive": True, "precursive": True, } options["owner"] = request.data.get("owner", options["owner"]) options["group"] = request.data.get("group", options["group"]) options["perms"] = request.data.get("perms", options["perms"]) options["orecursive"] = request.data.get( "orecursive", options["orecursive"] ) options["precursive"] = request.data.get( "precursive", options["precursive"] ) share.owner = options["owner"] share.group = options["group"] share.perms = options["perms"] share.save() mnt_pt = "%s%s" % (settings.MNT_PT, share.name) force_mount = False if not share.is_mounted: mount_share(share, mnt_pt) force_mount = True chown(mnt_pt, options["owner"], options["group"], options["orecursive"]) chmod(mnt_pt, options["perms"], options["precursive"]) if force_mount is True: umount_root(mnt_pt) return Response(ShareSerializer(share).data)
def post(self, request, sname): with self._handle_exception(request): share = Share.objects.get(name=sname) options = { 'owner': 'root', 'group': 'root', 'perms': '755', 'orecursive': True, 'precursive': True, } options['owner'] = request.data.get('owner', options['owner']) options['group'] = request.data.get('group', options['group']) options['perms'] = request.data.get('perms', options['perms']) options['orecursive'] = request.data.get('orecursive', options['orecursive']) options['precursive'] = request.data.get('precursive', options['precursive']) share.owner = options['owner'] share.group = options['group'] share.perms = options['perms'] share.save() mnt_pt = ('%s%s' % (settings.MNT_PT, share.name)) force_mount = False if (not is_share_mounted(share.name)): pool_device = Disk.objects.filter(pool=share.pool)[0].name mount_share(share, pool_device, mnt_pt) force_mount = True chown(mnt_pt, options['owner'], options['group'], options['orecursive']) chmod(mnt_pt, options['perms'], options['precursive']) if (force_mount is True): umount_root(mnt_pt) return Response(ShareSerializer(share).data)
def post(self, request, sname): with self._handle_exception(request): share = Share.objects.get(name=sname) options = { 'owner': 'root', 'group': 'root', 'perms': '755', 'orecursive': True, 'precursive': True, } options['owner'] = request.data.get('owner', options['owner']) options['group'] = request.data.get('group', options['group']) options['perms'] = request.data.get('perms', options['perms']) options['orecursive'] = request.data.get('orecursive', options['orecursive']) options['precursive'] = request.data.get('precursive', options['precursive']) share.owner = options['owner'] share.group = options['group'] share.perms = options['perms'] share.save() mnt_pt = ('%s%s' % (settings.MNT_PT, share.name)) force_mount = False if (not is_share_mounted(share.name)): mount_share(share, mnt_pt) force_mount = True chown(mnt_pt, options['owner'], options['group'], options['orecursive']) chmod(mnt_pt, options['perms'], options['precursive']) if (force_mount is True): umount_root(mnt_pt) return Response(ShareSerializer(share).data)
def post(self, request, sname): with self._handle_exception(request): share = Share.objects.get(name=sname) options = {"owner": "root", "group": "root", "perms": "755", "orecursive": True, "precursive": True} options["owner"] = request.data.get("owner", options["owner"]) options["group"] = request.data.get("group", options["group"]) options["perms"] = request.data.get("perms", options["perms"]) options["orecursive"] = request.data.get("orecursive", options["orecursive"]) options["precursive"] = request.data.get("precursive", options["precursive"]) share.owner = options["owner"] share.group = options["group"] share.perms = options["perms"] share.save() mnt_pt = "%s%s" % (settings.MNT_PT, share.name) force_mount = False if not is_share_mounted(share.name): pool_device = Disk.objects.filter(pool=share.pool)[0].name mount_share(share, pool_device, mnt_pt) force_mount = True chown(mnt_pt, options["owner"], options["group"], options["orecursive"]) chmod(mnt_pt, options["perms"], options["precursive"]) if force_mount is True: umount_root(mnt_pt) return Response(ShareSerializer(share).data)
def post(self, request, sname): try: share = Share.objects.get(name=sname) options = { 'owner': 'root', 'group': 'root', 'perms': '755', 'orecursive': False, 'precursive': False, } if ('owner' in request.DATA): options['owner'] = request.DATA['owner'] if ('group' in request.DATA): options['group'] = request.DATA['group'] else: options['group'] = options['owner'] if ('orecursive' in request.DATA): options['orecursive'] = True if ('perms' in request.DATA): options['perms'] = request.DATA['perms'] if ('precursive' in request.DATA): options['precursive'] = True share.owner = options['owner'] share.group = options['group'] share.perms = options['perms'] share.save() mnt_pt = ('%s%s' % (settings.MNT_PT, share.name)) force_mount = False if (not is_share_mounted(share.name)): pool_device = Disk.objects.filter(pool=share.pool)[0].name mount_share(share.subvol_name, pool_device, mnt_pt) force_mount = True chown(mnt_pt, options['owner'], options['group'], options['orecursive']) chmod(mnt_pt, options['perms'], options['precursive']) if (force_mount is True): umount_root(mnt_pt) return Response(ShareSerializer(share).data) except RockStorAPIException: raise except Exception, e: handle_exception(e, request)