def test_two_shares_on_one_mount(self, quota_policies, expected_result): with TempFilesystem(self.quota_type, fs_type=self.fs_type) as tfs, udm_test.UCSTestUDM() as udm: self._activate_quota(tfs.loop_dev) print("Create Shares") share1_path = os.path.join(tfs.mount_point, self.share_name) share2_path = os.path.join(tfs.mount_point, self.share_name2) os.mkdir(share1_path) os.mkdir(share2_path) share1 = udm.create_object( 'shares/share', name=self.share_name, path=share1_path, host=self.my_fqdn, directorymode="0777" ) share2 = udm.create_object( 'shares/share', name=self.share_name2, path=share2_path, host=self.my_fqdn, directorymode="0777" ) utils.wait_for_replication_and_postrun() qc.cache_must_exists(share1) qc.cache_must_exists(share2) print("Create user") udm.create_user(username=self.username, check_for_drs_replication=False) print("Create quota policies") policies = [] for quota_policy in quota_policies: policies.append(self.create_quota_policy(udm, quota_policy)) print("Append quota policies") udm.modify_object("shares/share", dn=share1, policy_reference=policies[0]) udm.modify_object("shares/share", dn=share2, policy_reference=policies[1]) utils.wait_for_replication_and_postrun() self.touch_file(tfs.mount_point) self._check_quota_settings(tfs.loop_dev, expected_result)
def test_quota_pam(self): with TempFilesystem(self.quota_type, fs_type=self.fs_type) as tfs, udm_test.UCSTestUDM() as udm: quota_policy = { "inodeSoftLimit": '10', "inodeHardLimit": '15', "spaceSoftLimit": str(1024 ** 2), "spaceHardLimit": str(2048 ** 2), "reapplyQuota": 'TRUE', "name": uts.random_name(), } self._activate_quota(tfs.loop_dev) print("Create Share") share = udm.create_object( 'shares/share', name=self.share_name, path=tfs.mount_point, host=self.my_fqdn, directorymode="0777" ) utils.wait_for_replication_and_postrun() qc.cache_must_exists(share) print("Create user") udm.create_user(username=self.username, check_for_drs_replication=False, wait_for=False) print("Create quota policy") policy = self.create_quota_policy(udm, quota_policy) print("Append quota policy") udm.modify_object("shares/share", dn=share, policy_reference=policy) utils.wait_for_replication_and_postrun() qc.check_values( share, quota_policy["inodeSoftLimit"], quota_policy["inodeHardLimit"], quota_policy["spaceSoftLimit"], quota_policy["spaceHardLimit"], quota_policy["reapplyQuota"] ) self.touch_file(tfs.mount_point) self._check_quota_settings(tfs.loop_dev)
def test_quota_pam(self): with TempFilesystem( self.quota_type, fs_type=self.fs_type) as tfs, udm_test.UCSTestUDM() as udm: self._activate_quota(tfs.loop_dev) print("Create Share") share = udm.create_object('shares/share', name=self.share_name, path=tfs.mount_point, host=self.my_fqdn, directorymode="0777") utils.wait_for_replication_and_postrun() qc.cache_must_exists(share) print("Create user") udm.create_user(username=self.username, check_for_drs_replication=False) print("Create quota policy") policy = udm.create_object( 'policies/share_userquota', position=self.quota_policy["position"], name=self.quota_policy["name"], softLimitSpace=self.quota_policy["spaceSoftLimit"], hardLimitSpace=self.quota_policy["spaceHardLimit"], softLimitInodes=self.quota_policy["inodeSoftLimit"], hardLimitInodes=self.quota_policy["inodeHardLimit"], reapplyeverylogin=self.quota_policy["reapplyQuota"], ) print("Append quota policy") udm.modify_object("shares/share", dn=share, policy_reference=policy) utils.wait_for_replication_and_postrun() qc.check_values(share, self.quota_policy["inodeSoftLimit"], self.quota_policy["inodeHardLimit"], self.quota_policy["spaceSoftLimit"], self.quota_policy["spaceHardLimit"], self.quota_policy["reapplyQuota"]) print("Write file on filesystem as user: {}".format(self.username)) subprocess.check_call([ "sudo", "--user", self.username, "touch", os.path.join(tfs.mount_point, "foo"), ]) self._check_quota_settings(tfs.loop_dev)