diff options
Diffstat (limited to 'cli/src/cli.h')
| -rw-r--r-- | cli/src/cli.h | 289 |
1 files changed, 230 insertions, 59 deletions
diff --git a/cli/src/cli.h b/cli/src/cli.h index 33a6fa187..8daa4b741 100644 --- a/cli/src/cli.h +++ b/cli/src/cli.h @@ -1,22 +1,12 @@ /* - Copyright (c) 2006-2010 Gluster, Inc. <http://www.gluster.com> + Copyright (c) 2006-2012 Red Hat, Inc. <http://www.redhat.com> This file is part of GlusterFS. - GlusterFS is free software; you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - GlusterFS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see - <http://www.gnu.org/licenses/>. + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. */ - #ifndef __CLI_H__ #define __CLI_H__ @@ -28,11 +18,24 @@ #include "rpc-clnt.h" #include "glusterfs.h" #include "protocol-common.h" +#include "logging.h" + +#include "cli1-xdr.h" + +#if (HAVE_LIB_XML) +#include <libxml/encoding.h> +#include <libxml/xmlwriter.h> +#endif #define DEFAULT_EVENT_POOL_SIZE 16384 #define CLI_GLUSTERD_PORT 24007 #define CLI_DEFAULT_CONN_TIMEOUT 120 #define CLI_DEFAULT_CMD_TIMEOUT 120 +#define CLI_TEN_MINUTES_TIMEOUT 600 //Longer timeout for volume top +#define DEFAULT_CLI_LOG_FILE_DIRECTORY DATADIR "/log/glusterfs" +#define CLI_VOL_STATUS_BRICK_LEN 55 +#define CLI_TAB_LENGTH 8 +#define CLI_BRICK_STATUS_LINE_LEN 78 enum argp_option_keys { ARGP_DEBUG_KEY = 133, @@ -41,15 +44,22 @@ enum argp_option_keys { #define GLUSTER_MODE_SCRIPT (1 << 0) #define GLUSTER_MODE_ERR_FATAL (1 << 1) - +#define GLUSTER_MODE_XML (1 << 2) struct cli_state; struct cli_cmd_word; struct cli_cmd_tree; +struct cli_cmd; + +extern char *cli_vol_type_str[]; +extern char *cli_vol_status_str[]; +extern char *cli_vol_task_status_str[]; typedef int (cli_cmd_cbk_t)(struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount); +typedef void (cli_cmd_reg_cbk_t)( struct cli_cmd *this); + typedef int (cli_cmd_match_t)(struct cli_cmd_word *word); typedef int (cli_cmd_filler_t)(struct cli_cmd_word *word); @@ -101,53 +111,81 @@ struct cli_state { char *remote_host; int remote_port; int mode; + int await_connected; + + char *log_file; + gf_loglevel_t log_level; + + char *glusterd_sock; }; struct cli_local { - union { - struct { - dict_t *dict; - } create_vol; - - struct { - char *volname; - int flags; - } start_vol; - - struct { - char *volname; - int flags; - } stop_vol; - - struct { - char *volname; - } delete_vol; - - struct { - char *volname; - int cmd; - } defrag_vol; - - struct { - char *volname; - dict_t *dict; - } replace_brick; - - struct { - char *volname; - int flags; - } get_vol; - } u; + struct { + char *volname; + int flags; + } get_vol; + + dict_t *dict; + const char **words; + /* Marker for volume status all */ + gf_boolean_t all; +#if (HAVE_LIB_XML) + xmlTextWriterPtr writer; + xmlDocPtr doc; + int vol_count; +#endif }; +struct gf_cli_gsync_detailed_status_ { + char *node; + char *master; + char *slave; + char *health; + char *uptime; + char *files_syncd; + char *files_pending; + char *bytes_pending; + char *deletes_pending; +}; + +struct cli_volume_status { + int port; + int online; + uint64_t block_size; + uint64_t total_inodes; + uint64_t free_inodes; + char *brick; + char *pid_str; + char *free; + char *total; +#ifdef GF_LINUX_HOST_OS + char *fs_name; + char *mount_options; + char *device; + char *inode_size; +#endif +}; + +struct snap_config_opt_vals_ { + char *op_name; + char *question; +}; + +typedef struct gf_cli_gsync_detailed_status_ gf_cli_gsync_status_t; + +typedef struct cli_volume_status cli_volume_status_t; + typedef struct cli_local cli_local_t; typedef ssize_t (*cli_serialize_t) (struct iovec outmsg, void *args); extern struct cli_state *global_state; /* use only in readline callback */ -int cli_cmd_register (struct cli_cmd_tree *tree, const char *template, - cli_cmd_cbk_t cbk, const char *desc); +typedef const char *(*cli_selector_t) (void *wcon); + +void *cli_getunamb (const char *tok, void **choices, cli_selector_t sel); + +int cli_cmd_register (struct cli_cmd_tree *tree, struct cli_cmd *cmd); int cli_cmds_register (struct cli_state *state); int cli_input_init (struct cli_state *state); @@ -157,16 +195,32 @@ int cli_cmd_process_line (struct cli_state *state, const char *line); int cli_rl_enable (struct cli_state *state); int cli_rl_out (struct cli_state *state, const char *fmt, va_list ap); +int cli_rl_err (struct cli_state *state, const char *fmt, va_list ap); int cli_usage_out (const char *usage); -int cli_out (const char *fmt, ...); + +int _cli_out (const char *fmt, ...); +int _cli_err (const char *fmt, ...); + +#define cli_out(fmt...) do { \ + FMT_WARN (fmt); \ + \ + _cli_out(fmt); \ + \ + } while (0) + +#define cli_err(fmt...) do { \ + FMT_WARN (fmt); \ + \ + _cli_err(fmt); \ + \ + } while (0) int cli_submit_request (void *req, call_frame_t *frame, rpc_clnt_prog_t *prog, int procnum, struct iobref *iobref, - cli_serialize_t sfunc, xlator_t *this, - fop_cbk_fn_t cbkfn); + xlator_t *this, fop_cbk_fn_t cbkfn, xdrproc_t xdrproc); int32_t cli_cmd_volume_create_parse (const char **words, int wordcount, @@ -183,7 +237,7 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **opt); int32_t cli_cmd_volume_set_parse (const char **words, int wordcount, - dict_t **options); + dict_t **options, char **op_errstr); int32_t cli_cmd_volume_add_brick_parse (const char **words, int wordcount, @@ -191,7 +245,7 @@ cli_cmd_volume_add_brick_parse (const char **words, int wordcount, int32_t cli_cmd_volume_remove_brick_parse (const char **words, int wordcount, - dict_t **options); + dict_t **options, int *question); int32_t cli_cmd_volume_replace_brick_parse (const char **words, int wordcount, @@ -204,6 +258,13 @@ cli_cmd_log_locate_parse (const char **words, int wordcount, dict_t **options); int32_t cli_cmd_log_filename_parse (const char **words, int wordcount, dict_t **options); +int32_t +cli_cmd_volume_statedump_options_parse (const char **words, int wordcount, + dict_t **options); +int32_t +cli_cmd_volume_clrlks_opts_parse (const char **words, int wordcount, + dict_t **options); + cli_local_t * cli_local_get (); void @@ -218,12 +279,122 @@ cli_cmd_broadcast_connected (); int cli_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, void *data); -void -cli_path_strip_trailing_slashes (char *path); + int32_t cli_cmd_volume_profile_parse (const char **words, int wordcount, dict_t **options); int32_t cli_cmd_volume_top_parse (const char **words, int wordcount, dict_t **options); + +int32_t +cli_cmd_log_level_parse (const char **words, int wordcount, + dict_t **options); + +int32_t +cli_cmd_volume_status_parse (const char **words, int wordcount, + dict_t **options); + +int +cli_cmd_volume_heal_options_parse (const char **words, int wordcount, + dict_t **options); + +int +cli_cmd_volume_defrag_parse (const char **words, int wordcount, + dict_t **options); + +int +cli_print_brick_status (cli_volume_status_t *status); + +void +cli_print_detailed_status (cli_volume_status_t *status); + +int +cli_get_detail_status (dict_t *dict, int i, cli_volume_status_t *status); + +void +cli_print_line (int len); + +int +cli_xml_output_str (char *op, char *str, int op_ret, int op_errno, + char *op_errstr); + +int +cli_xml_output_dict (char *op, dict_t *dict, int op_ret, int op_errno, + char *op_errstr); + +int +cli_xml_output_vol_top (dict_t *dict, int op_ret, int op_errno, + char *op_errstr); + +int +cli_xml_output_vol_profile (dict_t *dict, int op_ret, int op_errno, + char *op_errstr); + +int +cli_xml_output_vol_status_begin (cli_local_t *local, int op_ret, int op_errno, + char *op_errstr); + +int +cli_xml_output_vol_status_end (cli_local_t *local); + +int +cli_xml_output_vol_status (cli_local_t *local, dict_t *dict); + +int +cli_xml_output_vol_list (dict_t *dict, int op_ret, int op_errno, + char *op_errstr); + +int +cli_xml_output_vol_info_begin (cli_local_t *local, int op_ret, int op_errno, + char *op_errstr); + +int +cli_xml_output_vol_info_end (cli_local_t *local); + +int +cli_xml_output_vol_info (cli_local_t *local, dict_t *dict); + +int +cli_xml_output_vol_quota_limit_list (char *volname, char *limit_list, + int op_ret, int op_errno, + char *op_errstr); + +int +cli_xml_output_peer_status (dict_t *dict, int op_ret, int op_errno, + char *op_errstr); + +int +cli_xml_output_vol_rebalance (gf_cli_defrag_type op, dict_t *dict, int op_ret, + int op_errno, char *op_errstr); + +int +cli_xml_output_vol_remove_brick (gf_boolean_t status_op, dict_t *dict, + int op_ret, int op_errno, char *op_errstr); + +int +cli_xml_output_vol_replace_brick (gf1_cli_replace_op op, dict_t *dict, + int op_ret, int op_errno, char *op_errstr); + +int +cli_xml_output_vol_create (dict_t *dict, int op_ret, int op_errno, + char *op_errstr); + +int +cli_xml_output_generic_volume (char *op, dict_t *dict, int op_ret, int op_errno, + char *op_errstr); + +int +cli_xml_output_vol_gsync (dict_t *dict, int op_ret, int op_errno, + char *op_errstr); +int +cli_xml_output_vol_status_tasks_detail (cli_local_t *local, dict_t *dict); + +char * +is_server_debug_xlator (void *myframe); + +int32_t +cli_cmd_snapshot_parse (const char **words, int wordcount, dict_t **options, + struct cli_state *state); + #endif /* __CLI_H__ */ |
