예제 #1
0
    def test_dir_operation(self):
        mgr = fs_mgr()
        f = mgr.get_fs_by_name("test_dir")

        f.create_dir("test")
        dir_list = f.ls_dir()
        found = False
        for each_dir in dir_list:
            if each_dir["name"] == "test":
                found = True
                self.assertEquals(each_dir["mode"], 0777)
                self.assertEquals(each_dir["abspath"], "/mnt/test_dir/test")
                self.assertEquals(each_dir["relpath"], "test")
                self.assertEquals(each_dir["user"], "root")
                self.assertEquals(each_dir["group"], "root")
        self.assertTrue(found)
        f.mod_dir_mode("test", 0666)
        dir_list = f.ls_dir()
        for each_dir in dir_list:
            if each_dir["name"] == "test":
                self.assertEquals(each_dir["mode"], 0666)

        f.mod_dir_owner("test", "root", "root")

        usage_list = f.dir_usage_stat("test")
        found = False
        for each_usage in usage_list:
            if each_usage["abspath"] == "/mnt/test_dir/test":
                found = True
        self.assertTrue(found)

        f.delete_dir("test")
예제 #2
0
 def setUp(self):
     mgr = fs_mgr()
     dev_file = get_block_dev()
     if dev_file == "":
         return
     mgr.mkfs_on_dev("ext4", dev_file)
     mgr.add_fs("test_dir", "ext4", dev_file, comment="test")
예제 #3
0
 def setUp(self):
     mgr = fs_mgr()
     dev_file = get_block_dev()
     if dev_file == "":
         return
     mgr.mkfs_on_dev("ext4", dev_file)
     mgr.add_fs("test_dir", "ext4", dev_file, comment="test")
예제 #4
0
    def test_dir_operation(self):
        mgr = fs_mgr()
        f = mgr.get_fs_by_name("test_dir")

        f.create_dir("test")
        dir_list = f.ls_dir()
        found = False
        for each_dir in dir_list:
            if each_dir["name"] == "test":
                found = True
                self.assertEquals(each_dir["mode"], 0777)
                self.assertEquals(each_dir["abspath"], "/mnt/test_dir/test")
                self.assertEquals(each_dir["relpath"], "test")
                self.assertEquals(each_dir["user"], "root")
                self.assertEquals(each_dir["group"], "root")
        self.assertTrue(found)
        f.mod_dir_mode("test", 0666)
        dir_list = f.ls_dir()
        for each_dir in dir_list:
            if each_dir["name"] == "test":
                self.assertEquals(each_dir["mode"], 0666)

        f.mod_dir_owner("test", "root", "root")

        usage_list = f.dir_usage_stat("test")
        found = False
        for each_usage in usage_list:
            if each_usage["abspath"] == "/mnt/test_dir/test":
                found = True
        self.assertTrue(found)

        f.delete_dir("test")
예제 #5
0
def del_fs(request):
    user = request.client_addr
    fs_name = request.matchdict['fsname']

    fs_mrg = fsmgr.fs_mgr()
    fs_mrg.del_fs(fs_name, user)
    return Response(status=200)
예제 #6
0
파일: fs.py 프로젝트: OpenSight/StorLever
def del_fs(request):
    user=request.client_addr
    fs_name = request.matchdict['fsname']
    
    fs_mrg = fsmgr.fs_mgr()
    fs_mrg.del_fs(fs_name,user)
    return Response(status=200)
예제 #7
0
파일: fs.py 프로젝트: OpenSight/StorLever
def get_fs_ls(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    params = get_params_from_request(request, get_fs_ls_schema)
    path = params["path"]
    ls_info = fs.ls_dir(path)
    return ls_info
예제 #8
0
파일: fs.py 프로젝트: OpenSight/StorLever
def del_quota_user(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    params = get_params_from_request(request, del_quoat_group_schema)
    user = params["user"]
    fs.quota_group_set(user,0,0,0,0)
    return Response(status=200)
예제 #9
0
def get_fs_ls(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    params = get_params_from_request(request, get_fs_ls_schema)
    path = params["path"]
    ls_info = fs.ls_dir(path)
    return ls_info
예제 #10
0
def del_quota_user(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    params = get_params_from_request(request, del_quoat_group_schema)
    user = params["user"]
    fs.quota_group_set(user, 0, 0, 0, 0)
    return Response(status=200)
예제 #11
0
def get_fs(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    fs_info = {
        'name': fs.name,
        'conf': fs.fs_conf,
        'available': fs.is_available(),
        'usage': fs.usage_info()
    }
    return fs_info
예제 #12
0
def change_fs(request):
    params = get_params_from_request(request, change_fs_schema)
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)

    if (params['opt']) == 'grow':
        fs.grow_size()
        return Response(status=200)
    else:
        return Response(status=403)
예제 #13
0
파일: fs.py 프로젝트: OpenSight/StorLever
def get_fs(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    fs_info = {
                   'name':fs.name,
                   'conf':fs.fs_conf,
                   'available':fs.is_available(),
                   'usage': fs.usage_info()
                   }
    return fs_info
예제 #14
0
파일: fs.py 프로젝트: OpenSight/StorLever
def change_fs(request):
    params = get_params_from_request(request, change_fs_schema)
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    
    if(params['opt']) == 'grow' :
        fs.grow_size()
        return Response(status=200) 
    else :
        return Response(status=403)
예제 #15
0
    def test_quota_operation(self):
        mgr = fs_mgr()
        f = mgr.get_fs_by_name("test_quota")

        f.quota_check()
        ureport = f.quota_user_report()
        found = False
        for uquota in ureport:
            if uquota["name"] == "root":
                found = True
                self.assertEquals(uquota["block_softlimit"], 0)
                self.assertEquals(uquota["block_hardlimit"], 0)
                self.assertEquals(uquota["inode_softlimit"], 0)
                self.assertEquals(uquota["inode_hardlimit"], 0)
        self.assertTrue(found)


        greport = f.quota_group_report()
        found = False
        for gquota in greport:
            if gquota["name"] == "root":
                found = True
                self.assertEquals(gquota["block_softlimit"], 0)
                self.assertEquals(gquota["block_hardlimit"], 0)
                self.assertEquals(gquota["inode_softlimit"], 0)
                self.assertEquals(gquota["inode_hardlimit"], 0)
        self.assertTrue(found)

        f.quota_user_set("root", 1000, 1500, 2000, 2500)
        f.quota_group_set("root", 3000, 3500, 4000, 4500)


        f.quota_check()
        ureport = f.quota_user_report()
        found = False
        for uquota in ureport:
            if uquota["name"] == "root":
                found = True
                self.assertEquals(uquota["block_softlimit"], 1000)
                self.assertEquals(uquota["block_hardlimit"], 1500)
                self.assertEquals(uquota["inode_softlimit"], 2000)
                self.assertEquals(uquota["inode_hardlimit"], 2500)
        self.assertTrue(found)

        greport = f.quota_group_report()
        found = False
        for gquota in greport:
            if gquota["name"] == "root":
                found = True
                self.assertEquals(gquota["block_softlimit"], 3000)
                self.assertEquals(gquota["block_hardlimit"], 3500)
                self.assertEquals(gquota["inode_softlimit"], 4000)
                self.assertEquals(gquota["inode_hardlimit"], 4500)
        self.assertTrue(found)
예제 #16
0
파일: fs.py 프로젝트: OpenSight/StorLever
def get_fs_list(request):
    fs_mrg = fsmgr.fs_mgr()
    files = fs_mrg.get_fs_list()
    fs_dict = []
    for fs in files:
        fs_info = {
                   'name':fs.name,
                   'conf':fs.fs_conf,
                   'available':fs.is_available(),
                   }
        fs_dict.append(fs_info)
    return fs_dict
예제 #17
0
파일: fs.py 프로젝트: OpenSight/StorLever
def put_quota_user(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    params = get_params_from_request(request, put_quoat_group_schema)
    user = params["user"]
    block_softlimit = params["block_softlimit"]
    block_hardlimit = params["block_hardlimit"]
    inode_softlimit = params["inode_softlimit"]
    inode_hardlimit = params["inode_hardlimit"]
    fs.quota_user_set(user,block_softlimit,block_hardlimit,inode_softlimit,inode_hardlimit)
    return Response(status=200)
예제 #18
0
파일: fs.py 프로젝트: OpenSight/StorLever
def add_quota_group(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    params = get_params_from_request(request, add_quoat_group_schema)
    group = params["group"]
    block_softlimit = params["block_softlimit"]
    block_hardlimit = params["block_hardlimit"]
    inode_softlimit = params["inode_softlimit"]
    inode_hardlimit = params["inode_hardlimit"]
    fs.quota_group_set(group,block_softlimit,block_hardlimit,inode_softlimit,inode_hardlimit)
    return Response(status=200)
예제 #19
0
def get_fs_list(request):
    fs_mrg = fsmgr.fs_mgr()
    files = fs_mrg.get_fs_list()
    fs_dict = []
    for fs in files:
        fs_info = {
            'name': fs.name,
            'conf': fs.fs_conf,
            'available': fs.is_available(),
        }
        fs_dict.append(fs_info)
    return fs_dict
예제 #20
0
    def test_quota_operation(self):
        mgr = fs_mgr()
        f = mgr.get_fs_by_name("test_quota")

        f.quota_check()
        ureport = f.quota_user_report()
        found = False
        for uquota in ureport:
            if uquota["name"] == "root":
                found = True
                self.assertEquals(uquota["block_softlimit"], 0)
                self.assertEquals(uquota["block_hardlimit"], 0)
                self.assertEquals(uquota["inode_softlimit"], 0)
                self.assertEquals(uquota["inode_hardlimit"], 0)
        self.assertTrue(found)

        greport = f.quota_group_report()
        found = False
        for gquota in greport:
            if gquota["name"] == "root":
                found = True
                self.assertEquals(gquota["block_softlimit"], 0)
                self.assertEquals(gquota["block_hardlimit"], 0)
                self.assertEquals(gquota["inode_softlimit"], 0)
                self.assertEquals(gquota["inode_hardlimit"], 0)
        self.assertTrue(found)

        f.quota_user_set("root", 1000, 1500, 2000, 2500)
        f.quota_group_set("root", 3000, 3500, 4000, 4500)

        f.quota_check()
        ureport = f.quota_user_report()
        found = False
        for uquota in ureport:
            if uquota["name"] == "root":
                found = True
                self.assertEquals(uquota["block_softlimit"], 1000)
                self.assertEquals(uquota["block_hardlimit"], 1500)
                self.assertEquals(uquota["inode_softlimit"], 2000)
                self.assertEquals(uquota["inode_hardlimit"], 2500)
        self.assertTrue(found)

        greport = f.quota_group_report()
        found = False
        for gquota in greport:
            if gquota["name"] == "root":
                found = True
                self.assertEquals(gquota["block_softlimit"], 3000)
                self.assertEquals(gquota["block_hardlimit"], 3500)
                self.assertEquals(gquota["inode_softlimit"], 4000)
                self.assertEquals(gquota["inode_hardlimit"], 4500)
        self.assertTrue(found)
예제 #21
0
def put_quota_user(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    params = get_params_from_request(request, put_quoat_group_schema)
    user = params["user"]
    block_softlimit = params["block_softlimit"]
    block_hardlimit = params["block_hardlimit"]
    inode_softlimit = params["inode_softlimit"]
    inode_hardlimit = params["inode_hardlimit"]
    fs.quota_user_set(user, block_softlimit, block_hardlimit, inode_softlimit,
                      inode_hardlimit)
    return Response(status=200)
예제 #22
0
def add_quota_group(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    params = get_params_from_request(request, add_quoat_group_schema)
    group = params["group"]
    block_softlimit = params["block_softlimit"]
    block_hardlimit = params["block_hardlimit"]
    inode_softlimit = params["inode_softlimit"]
    inode_hardlimit = params["inode_hardlimit"]
    fs.quota_group_set(group, block_softlimit, block_hardlimit,
                       inode_softlimit, inode_hardlimit)
    return Response(status=200)
예제 #23
0
 def test_add_fs(self):
     mgr = fs_mgr()
     dev_file = get_nfs_src()
     if dev_file == "":
         return
     mgr.mkfs_on_dev("nfs", dev_file)
     mgr.add_fs("test_nfs", "nfs", dev_file, comment="test")
     for fs in mgr.get_fs_list():
         if fs.name == "test_nfs":
             break;
     else:
         raise Exception("there is no file system name test_nfs")
     f = mgr.get_fs_by_name("test_nfs")
     self.assertEquals(f.fs_conf["dev_file"], dev_file)
     self.assertEquals(f.fs_conf["comment"], "test")
     self.assertTrue(f.is_available())
     self.assertTrue(f.usage_info()["total"] > 0)
     self.assertTrue(len(f.fs_meta_dump()) != 0)
     with open("/etc/fstab", "r") as fstab:
         self.assertTrue("/mnt/test_nfs" in fstab.read())
     mgr.del_fs("test_nfs")
예제 #24
0
 def test_add_fs(self):
     mgr = fs_mgr()
     dev_file = get_nfs_src()
     if dev_file == "":
         return
     mgr.mkfs_on_dev("nfs", dev_file)
     mgr.add_fs("test_nfs", "nfs", dev_file, comment="test")
     for fs in mgr.get_fs_list():
         if fs.name == "test_nfs":
             break
     else:
         raise Exception("there is no file system name test_nfs")
     f = mgr.get_fs_by_name("test_nfs")
     self.assertEquals(f.fs_conf["dev_file"], dev_file)
     self.assertEquals(f.fs_conf["comment"], "test")
     self.assertTrue(f.is_available())
     self.assertTrue(f.usage_info()["total"] > 0)
     self.assertTrue(len(f.fs_meta_dump()) != 0)
     with open("/etc/fstab", "r") as fstab:
         self.assertTrue("/mnt/test_nfs" in fstab.read())
     mgr.del_fs("test_nfs")
예제 #25
0
def file_opt_owner(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    params = get_params_from_request(request, get_fs_ls_schema)
    path = params["path"]
    if (params['opt']) == 'mod_owner':
        user = params["user"]
        group = params["group"]
        fs.mod_dir_owner(path, user, group, request.client_addr)
        return Response(status=200)
    elif params['opt'] == 'mod_mode':
        mode = params["mode"]
        fs.mod_dir_mode(path, mode, request.client_addr)
        return Response(status=200)
    elif params['opt'] == 'quota_check':
        mode = params["mode"]
        fs.quota_check()
        return Response(status=200)
    else:
        return Response(status=403)
예제 #26
0
파일: fs.py 프로젝트: OpenSight/StorLever
def file_opt_owner(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    params = get_params_from_request(request, get_fs_ls_schema)
    path = params["path"]
    if(params['opt']) == 'mod_owner' :
        user = params["user"]
        group = params["group"]
        fs.mod_dir_owner(path,user,group,request.client_addr)
        return Response(status=200)
    elif params['opt'] == 'mod_mode' :
        mode = params["mode"]
        fs.mod_dir_mode(path,mode,request.client_addr)
        return Response(status=200)
    elif params['opt'] == 'quota_check' :
        mode = params["mode"]
        fs.quota_check()
        return Response(status=200)
    else :
        return Response(status=403)
예제 #27
0
 def tearDown(self):
     mgr = fs_mgr()
     mgr.del_fs("test_quota")
예제 #28
0
def mk_fs(request):
    fs_mrg = fsmgr.fs_mgr()
    params = get_params_from_request(request, mk_fs_schema)
    fs_mrg.mkfs_on_dev(params["type"], params["dev"], params["options"])
    return Response(status=200)
예제 #29
0
 def test_mkfs_no_option(self):
     mgr = fs_mgr()
     dev_file = get_block_dev()
     if dev_file == "":
         return
     mgr.mkfs_on_dev("xfs", dev_file)
예제 #30
0
파일: fs.py 프로젝트: OpenSight/StorLever
def mk_fs(request):
    fs_mrg = fsmgr.fs_mgr()
    params = get_params_from_request(request, mk_fs_schema)
    fs_mrg.mkfs_on_dev(params["type"],params["dev"],params["options"])
    return Response(status=200)
예제 #31
0
 def tearDown(self):
     mgr = fs_mgr()
     mgr.del_fs("test_dir")
예제 #32
0
 def test_type_list(self):
     mgr = fs_mgr()
     self.assertTrue("xfs" in mgr.fs_type_list())
예제 #33
0
파일: fs.py 프로젝트: OpenSight/StorLever
def get_fs_meda(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    meta_info = fs.fs_meta_dump()
    return meta_info
예제 #34
0
def get_fs_meda(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    meta_info = fs.fs_meta_dump()
    return meta_info
예제 #35
0
파일: fs.py 프로젝트: OpenSight/StorLever
def get_quota_user_list(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    quota_user_info = fs.quota_user_report()
    return quota_user_info
예제 #36
0
파일: fs.py 프로젝트: OpenSight/StorLever
def get_fs_type_list(request):
    fs_mrg = fsmgr.fs_mgr()
    type_list = fs_mrg.fs_type_list()
    return type_list
예제 #37
0
def add_fs(request):
    fs_mrg = fsmgr.fs_mgr()
    params = get_params_from_request(request, add_fs_schema)
    fs_mrg.add_fs(params["fsname"],params["type"],params["dev"],\
                              params["mountoption"],params["checkonboot"],params["user"])
    return Response(status=200)
예제 #38
0
 def test_type_list(self):
     mgr = fs_mgr()
     self.assertTrue("nfs" in mgr.fs_type_list())
예제 #39
0
 def test_mkfs_no_option(self):
     mgr = fs_mgr()
     dev_file = get_block_dev()
     if dev_file == "":
         return
     mgr.mkfs_on_dev("xfs", dev_file)
예제 #40
0
 def tearDown(self):
     mgr = fs_mgr()
     mgr.del_fs("test_quota")
예제 #41
0
 def test_mkfs_no_option(self):
     mgr = fs_mgr()
     nfs_source = get_nfs_src()
     if nfs_source == "":
         return
     mgr.mkfs_on_dev("nfs", nfs_source)
예제 #42
0
 def tearDown(self):
     mgr = fs_mgr()
     mgr.del_fs("test_dir")
예제 #43
0
def get_fs_type_list(request):
    fs_mrg = fsmgr.fs_mgr()
    type_list = fs_mrg.fs_type_list()
    return type_list
예제 #44
0
def get_quota_user_list(request):
    fs_name = request.matchdict['fsname']
    fs_mrg = fsmgr.fs_mgr()
    fs = fs_mrg.get_fs_by_name(fs_name)
    quota_user_info = fs.quota_user_report()
    return quota_user_info
예제 #45
0
 def test_mkfs_no_option(self):
     mgr = fs_mgr()
     nfs_source = get_nfs_src()
     if nfs_source == "":
         return
     mgr.mkfs_on_dev("nfs", nfs_source)
예제 #46
0
파일: fs.py 프로젝트: OpenSight/StorLever
def add_fs(request):
    fs_mrg = fsmgr.fs_mgr()
    params = get_params_from_request(request, add_fs_schema)
    fs_mrg.add_fs(params["fsname"],params["type"],params["dev"],\
                              params["mountoption"],params["checkonboot"],params["user"])
    return Response(status=200)