Skip to content

Commit 3daee19

Browse files
committed
Merge PR ceph#62136 into main
* refs/pull/62136/head: qa: add test case for remove xattr cephfs-shell: Add the option to remove xattr Reviewed-by: Patrick Donnelly <[email protected]>
2 parents 2d40f1a + 814f113 commit 3daee19

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

qa/tasks/cephfs/test_cephfs_shell.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,13 @@ def test_non_existing_dir(self):
980980
cmd=['getxattr', self.dir_name, input_val[0]])
981981
self.negtest_cephfs_shell_cmd(cmd=['listxattr', self.dir_name])
982982

983+
def test_remove_xattr(self):
984+
self.test_set()
985+
self.get_cephfs_shell_cmd_output(
986+
['removexattr', self.dir_name, 'user.key'])
987+
self.negtest_cephfs_shell_cmd(
988+
cmd=['getxattr', self.dir_name, 'user.key'])
989+
983990

984991
class TestLS(TestCephFSShell):
985992
dir_name = 'test_dir'

src/tools/cephfs/shell/cephfs-shell

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,6 +1664,22 @@ class CephFSShell(Cmd):
16641664
except libcephfs.Error as e:
16651665
set_exit_code_msg(msg=e)
16661666

1667+
removexattr_parser = argparse.ArgumentParser(
1668+
description='Remove extended attribute set for a file')
1669+
removexattr_parser.add_argument('path', type=str, action=path_to_bytes,
1670+
help='Name of the file')
1671+
removexattr_parser.add_argument('name', type=str, help='Extended attribute name')
1672+
1673+
@with_argparser(removexattr_parser)
1674+
def do_removexattr(self, args):
1675+
"""
1676+
Remove extended attribute for a file
1677+
"""
1678+
try:
1679+
poutput('{}'.format(cephfs.removexattr(args.path, to_bytes(args.name))))
1680+
except libcephfs.Error as e:
1681+
set_exit_code_msg(msg=e)
1682+
16671683

16681684
#######################################################
16691685
#

0 commit comments

Comments
 (0)