diff --git a/curvefs_python/curvefs_tool.py b/curvefs_python/curvefs_tool.py index caad082538..85583d839a 100644 --- a/curvefs_python/curvefs_tool.py +++ b/curvefs_python/curvefs_tool.py @@ -39,6 +39,8 @@ # 获取文件user信息 user = curvefs.UserInfo_t() user.owner = args.user + if args.password: + user.password = args.password if args.optype == "create": ret = cbd.Create(args.filename, user, args.length * kGB) diff --git a/curvefs_python/parser.py b/curvefs_python/parser.py index 04598837e0..05e5dde6d4 100644 --- a/curvefs_python/parser.py +++ b/curvefs_python/parser.py @@ -32,43 +32,51 @@ def get_parser(): subparser.add_argument("--filename", help='name of file', type=str, required=True) subparser.add_argument("--length", help='length of file(GB)', type=long, required=True) subparser.add_argument("--user", help='user of file', type=str, required=True) + subparser.add_argument("--password", help='password of user', type=str) # delete option subparser = subparsers.add_parser("delete", help="delete file") subparser.add_argument("--user", help='user of file', type=str, required=True) subparser.add_argument("--filename", help='name of file', type=str, required=True) + subparser.add_argument("--password", help='password of user', type=str) # extend option subparser = subparsers.add_parser("extend", help="extend file") subparser.add_argument("--user", help='user of file', type=str, required=True) subparser.add_argument("--filename", help='name of file', type=str, required=True) subparser.add_argument("--length", help='length of file(GB)', type=long, required=True) + subparser.add_argument("--password", help='password of user', type=str) # stat option subparser = subparsers.add_parser("stat", help="query file info") subparser.add_argument("--user", help='user of file', type=str, required=True) subparser.add_argument("--filename", help='name of file', type=str, required=True) + subparser.add_argument("--password", help='password of user', type=str) # rename option subparser = subparsers.add_parser("rename", help="rename file") subparser.add_argument("--user", help='user of file', type=str, required=True) subparser.add_argument("--filename", help='old name of file', type=str, required=True) subparser.add_argument("--newname", help='new name of file', type=str, required=True) + subparser.add_argument("--password", help='password of user', type=str) # mkdir option subparser = subparsers.add_parser("mkdir", help="create directory") subparser.add_argument("--user", help='user of dir', type=str, required=True) subparser.add_argument("--dirname", help='name of dir', type=str, required=True) + subparser.add_argument("--password", help='password of user', type=str) # rmdir option subparser = subparsers.add_parser("rmdir", help="delete directory") subparser.add_argument("--user", help='user of dir', type=str, required=True) subparser.add_argument("--dirname", help='name of dir', type=str, required=True) + subparser.add_argument("--password", help='password of user', type=str) # list option subparser = subparsers.add_parser("list", help="list file of dir") subparser.add_argument("--user", help='user of dir', type=str, required=True) subparser.add_argument("--dirname", help='name of dir', type=str, required=True) + subparser.add_argument("--password", help='password of user', type=str) return parser diff --git a/curvefs_python/test.py b/curvefs_python/test.py index 3a1c86c34c..0f0045fa62 100644 --- a/curvefs_python/test.py +++ b/curvefs_python/test.py @@ -37,6 +37,14 @@ def exec_cmd(cmd): exec_cmd(cmd) cmd = "curve list --user k8s --dirname /k8s" exec_cmd(cmd) +# 不是root,失败 +cmd = "curve list --user k8s --dirname /" +exec_cmd(cmd) +# root没有传入密码,失败 +cmd = "curve list --user root --dirname /" +exec_cmd(cmd) +cmd = "curve list --user root --dirname / --password root_password" +exec_cmd(cmd) cmd = "curve stat --user k8s --filename /k8s/volume2" exec_cmd(cmd) cmd = "curve delete --user k8s --filename /k8s/volume2" diff --git a/src/client/libcurve_file.cpp b/src/client/libcurve_file.cpp index 113a927686..54e85c4e42 100644 --- a/src/client/libcurve_file.cpp +++ b/src/client/libcurve_file.cpp @@ -74,6 +74,9 @@ void LoggerGuard::InitInternal(const std::string& confPath) { FLAGS_minloglevel = 0; FLAGS_log_dir = "/tmp"; + // disable error log output to console + FLAGS_stderrthreshold = 3; + LOG_IF(WARNING, !conf.GetIntValue("global.logLevel", &FLAGS_minloglevel)) << "config no loglevel info, using default value 0"; LOG_IF(WARNING, !conf.GetStringValue("global.logPath", &FLAGS_log_dir))