Skip to content

Commit

Permalink
add password for curvefs_tool && disable error log output to console
Browse files Browse the repository at this point in the history
Change-Id: Id094961cb2f835640a2a85df070f29e3c3b818ae
  • Loading branch information
wu-hanqing authored and bai-charisu committed Aug 12, 2020
1 parent 0d6d220 commit 57ac7d7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions curvefs_python/curvefs_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions curvefs_python/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions curvefs_python/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions src/client/libcurve_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 57ac7d7

Please sign in to comment.