}
+std::vector<Option> get_cephfs_shell_options() {
+ return std::vector<Option>({
+ Option("allow_ansi", Option::TYPE_STR, Option::LEVEL_BASIC)
+ .set_default("Terminal")
+ .set_description("Allow ANSI escape sequences in output. Values: "
+ "Terminal, Always, Never"),
+
+ Option("colors", Option::TYPE_STR, Option::LEVEL_BASIC)
+ .set_default("Terminal")
+ .set_description("Colouring CephFS shell input and output. Values: "
+ "Terminal, Always, Never"),
+
+ Option("continuation_prompt", Option::TYPE_STR, Option::LEVEL_BASIC)
+ .set_default(">")
+ .set_description("Prompt string when a command continue to second line"),
+
+ Option("debug_shell", Option::TYPE_BOOL, Option::LEVEL_BASIC)
+ .set_default(false)
+ .set_description("Allow tracebacks on error for CephFS Shell"),
+
+ Option("echo", Option::TYPE_BOOL, Option::LEVEL_BASIC)
+ .set_default(false)
+ .set_description("Allow tracebacks on error for CephFS Shell"),
+
+ Option("editor", Option::TYPE_STR, Option::LEVEL_BASIC)
+ .set_default("vim")
+ .set_description("Default text editor for shell"),
+
+ Option("feedback_to_output", Option::TYPE_BOOL, Option::LEVEL_BASIC)
+ .set_default(false)
+ .set_description("include '|' and '>' in result"),
+
+ Option("max_completion_items", Option::TYPE_INT, Option::LEVEL_BASIC)
+ .set_default(50)
+ .set_description("Maximum number of items to be displayed by tab "
+ "completion"),
+
+ Option("prompt", Option::TYPE_STR, Option::LEVEL_BASIC)
+ .set_default("\x1b[01;33mCephFS:~\x1b[96m/\x1b[0m\x1b[01;33m>>>\x1b[00m ")
+ .set_description("Whether non-essential feedback should be printed."),
+
+ Option("quiet", Option::TYPE_BOOL, Option::LEVEL_BASIC)
+ .set_default(false)
+ .set_description("Whether non-essential feedback should be printed."),
+
+ Option("timing", Option::TYPE_BOOL, Option::LEVEL_BASIC)
+ .set_default(false)
+ .set_description("Whether execution time should be reported"),
+ });
+}
+
static std::vector<Option> build_options()
{
std::vector<Option> result = get_global_options();
ingest(get_immutable_object_cache_options(), "immutable-objet-cache");
ingest(get_mds_options(), "mds");
ingest(get_mds_client_options(), "mds_client");
+ ingest(get_cephfs_shell_options(), "cephfs-shell");
return result;
}
except libcephfs.Error as e:
perror(e)
+def get_bool_vals_for_boolopts(val):
+ if val.lower() in ['true', 'yes']:
+ return True
+ elif val.lower() in ['false', 'no']:
+ return False
+ else:
+ return val
+
+def read_ceph_conf(shell, config_file):
+ try:
+ shell.debug = get_bool_vals_for_boolopts(cephfs.\
+ conf_get('debug_shell').strip('\n'))
+ shell.allow_ansi = get_bool_vals_for_boolopts(cephfs.\
+ conf_get('allow_ansi').strip('\n'))
+ shell.echo = get_bool_vals_for_boolopts(cephfs.\
+ conf_get('echo').strip('\n'))
+ shell.continuation_prompt = get_bool_vals_for_boolopts(cephfs.\
+ conf_get('continuation_prompt').strip('\n'))
+ shell.colors = get_bool_vals_for_boolopts(cephfs.\
+ conf_get('colors').strip('\n'))
+ shell.editor = get_bool_vals_for_boolopts(cephfs.\
+ conf_get('editor').strip('\n'))
+ shell.feedback_to_output = get_bool_vals_for_boolopts(cephfs.\
+ conf_get('feedback_to_output').strip('\n'))
+ shell.max_completion_items = get_bool_vals_for_boolopts(cephfs.\
+ conf_get('max_completion_items').strip('\n'))
+ shell.prompt = get_bool_vals_for_boolopts(cephfs.\
+ conf_get('prompt').strip('\n'))
+ shell.quiet = get_bool_vals_for_boolopts(cephfs.\
+ conf_get('quiet').strip('\n'))
+ shell.timing = get_bool_vals_for_boolopts(cephfs.\
+ conf_get('timing').strip('\n'))
+ except OSError as e:
+ perror(e)
+ except cephfs.Error as e:
+ perror(e)
if __name__ == '__main__':
config_file = ''
sys.argv.clear()
sys.argv.append(exe)
sys.argv.extend([i.strip() for i in ' '.join(args.commands).split(',')])
+
setup_cephfs(config_file)
shell = CephFSShell()
+ read_ceph_conf(shell, config_file)
sys.exit(shell.cmdloop())