예제 #1
0
def ls_dir(request):
    if 'root_dir' in request.GET:
        root = request.GET['root_dir']
    else:
        root = "/"
    if 'depth' in request.GET:
        depth = int(request.GET['depth'])
    else:
        depth = 1
    if depth > 5:
        logger.warning("Limiting depth to maximum value of 5: input depth=%s", depth)
        depth = 5
    root = '{}/'.format(root) if not root.endswith('/') else root

    try:
        cluster = FsidContext(request=request, module_name='ceph_nfs').cluster
        paths = CephFSUtil.instance(cluster).get_dir_list(root, depth)
        paths = [p[:-1] for p in paths if p != root]
        return Response({'paths': paths})
    except libcephfs.ObjectNotFound, libcephfs.PermissionError:
        return Response({'paths': []})
예제 #2
0
def fsals(request):
    res = DeepSea.instance().nfs_get_fsals_available()
    if 'CEPH' in res:
        if not CephFSUtil:
            res = [f for f in res if f != 'CEPH']
        else:
            cluster = FsidContext(request=request, module_name='ceph_nfs').cluster
            try:
                if not CephFSUtil.instance(cluster).status():
                    res = [f for f in res if f != 'CEPH']
            except libcephfs.PermissionError:
                res = [f for f in res if f != 'CEPH']
    if 'RGW' in res:
        try:
            if not RGWClient.admin_instance().is_service_online():
                res = [f for f in res if f != 'RGW']
            if not RGWClient.admin_instance().is_system_user():
                res = [f for f in res if f != 'RGW']
        except (RGWClient.NoCredentialsException, RequestException):
            res = [f for f in res if f != 'RGW']
    return Response({'fsals': res})
 def __init__(self, **kwargs):
     super(iSCSITargetViewSet, self).__init__(**kwargs)
     self.set_nodb_context(FsidContext(self, 'ceph_iscsi'))
 def __init__(self, **kwargs):
     super(GaneshaExportViewSet, self).__init__(**kwargs)
     self.set_nodb_context(FsidContext(self, 'ceph_nfs'))