From: Eric Bollengier Date: Tue, 27 Oct 2009 14:34:59 +0000 (+0100) Subject: Add .media command X-Git-Tag: Release-7.0.0~2598^2~33 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=11b8419be43797594851adbefdce4f50efdd53bb;p=bacula%2Fbacula Add .media command Add .help [all|item=command] Tweak help ouput --- diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 92c6298b12..b24b2adacb 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -123,11 +123,13 @@ static struct cmdstruct commands[] = { /* C { NT_("disable"), disable_cmd, _("disable -- disable a job"), true}, { NT_("enable"), enable_cmd, _("enable -- enable a job"), true}, { NT_("estimate"), estimate_cmd, _("performs FileSet estimate, listing gives full listing" - "\n you can make it more accurate with accurate=yes/no"), true}, + "\n you can make it more accurate with accurate=yes/no" + "\n estimate fileset= client= accurate= job= listing"), true}, { NT_("exit"), quit_cmd, _("exit = quit"), false}, { NT_("gui"), gui_cmd, _("gui [on|off] -- non-interactive gui mode"), false}, { NT_("help"), help_cmd, _("print this command"), false}, - { NT_("label"), label_cmd, _("label a tape"), false}, + { NT_("label"), label_cmd, _("label a tape -- " + "\n label storage= volume= pool="), false}, { NT_("list"), list_cmd, _("list [pools | jobs | jobtotals | media | " "\n files | copies ]; from catalog"), true}, { NT_("llist"), llist_cmd, _("full or long list like list command"), true}, @@ -137,11 +139,13 @@ static struct cmdstruct commands[] = { /* C "\n or mount [ jobid= | job= ]"), false}, { NT_("prune"), prunecmd, _("prune files|jobs|volume client= volume= " "\n prune expired records from catalog"), true}, - { NT_("purge"), purgecmd, _("purge records from catalog"), true}, + { NT_("purge"), purgecmd, _("purge records from catalog - purge [volume=]"), true}, { NT_("python"), python_cmd, _("python control commands"), false}, { NT_("quit"), quit_cmd, _("quit"), false}, { NT_("query"), querycmd, _("query catalog"), false}, - { NT_("restore"), restore_cmd, _("restore files"), false}, + { NT_("restore"), restore_cmd, _("restore files - " + "\n restore [where=/path client= storage= bootstrap=" + "\n jobid= done select all]"), false}, { NT_("relabel"), relabel_cmd, _("relabel storage= oldvolume= " "\n volume= -- relabel a tape"), false}, { NT_("release"), release_cmd, _("release "), false}, @@ -154,15 +158,18 @@ static struct cmdstruct commands[] = { /* C { NT_("setdebug"), setdebug_cmd, _("setdebug level=nn [trace=0/1 client= |" "\n dir | director | storage= | all] -- sets debug level"), true}, { NT_("setip"), setip_cmd, _("sets new client address -- if authorized"), false}, - { NT_("show"), show_cmd, _("show (resource records) [jobs | pools | ... | all]"), true}, + { NT_("show"), show_cmd, _("show (resource records) [job=xxx | pool=yyy | fileset=aaa " + "\n schedule=sss | client=zzz | fileset... | all]"), true}, { NT_("sqlquery"), sqlquerycmd, _("use SQL to query catalog"), false}, { NT_("time"), time_cmd, _("print current time"), true}, { NT_("trace"), trace_cmd, _("turn on/off trace to file"), true}, { NT_("unmount"), unmount_cmd, _("unmount storage= [ drive= ] " "\n or unmount [ jobid= | job= ]"), false}, { NT_("umount"), unmount_cmd, _("umount - for old-time Unix guys, see unmount"),false}, - { NT_("update"), update_cmd, _("update Volume, Pool or slots"), true}, - { NT_("use"), use_cmd, _("use -- catalog xxx"), false}, + { NT_("update"), update_cmd, _("update [pool= | slots | stats | " + "\n volume= volstatus= volretention=" + "\n pool= recycle= slot= inchanger=]"),true}, + { NT_("use"), use_cmd, _("use -- catalog xxx"), false}, { NT_("var"), var_cmd, _("does variable expansion"), false}, { NT_("version"), version_cmd, _("print Director version"), true}, { NT_("wait"), wait_cmd, _("wait [ | | ] -- " @@ -1860,8 +1867,27 @@ static int help_cmd(UAContext *ua, const char *cmd) int qhelp_cmd(UAContext *ua, const char *cmd) { - int i; - + int i,j; + /* Want to display only commands */ + j = find_arg(ua, NT_("all")); + if (j >= 0) { + for (i=0; isend_msg("%s\n", commands[i].key); + } + return 1; + } + /* Want to display a specific help section */ + j = find_arg_with_value(ua, NT_("item")); + if (j >= 0 && ua->argk[j]) { + for (i=0; iargv[j])) { + ua->send_msg("%s\n", _(commands[i].help)); + break; + } + } + return 1; + } + /* Want to display everything */ for (i=0; isend_msg("%s %s\n", commands[i].key, _(commands[i].help)); } diff --git a/bacula/src/dird/ua_dotcmds.c b/bacula/src/dird/ua_dotcmds.c index c277c64b42..677447c967 100644 --- a/bacula/src/dird/ua_dotcmds.c +++ b/bacula/src/dird/ua_dotcmds.c @@ -68,6 +68,7 @@ static bool getmsgscmd(UAContext *ua, const char *cmd); static bool volstatuscmd(UAContext *ua, const char *cmd); static bool mediatypescmd(UAContext *ua, const char *cmd); static bool locationscmd(UAContext *ua, const char *cmd); +static bool mediacmd(UAContext *ua, const char *cmd); static bool dot_bvfs_lsdirs(UAContext *ua, const char *cmd); static bool dot_bvfs_lsfiles(UAContext *ua, const char *cmd); @@ -77,6 +78,7 @@ static bool api_cmd(UAContext *ua, const char *cmd); static bool sql_cmd(UAContext *ua, const char *cmd); static bool dot_quit_cmd(UAContext *ua, const char *cmd); static bool dot_help_cmd(UAContext *ua, const char *cmd); +static bool helpscmd(UAContext *ua, const char *cmd); struct cmdstruct { const char *key; bool (*func)(UAContext *ua, const char *cmd); const char *help;const bool use_in_rs;}; static struct cmdstruct commands[] = { /* help */ /* can be used in runscript */ @@ -98,6 +100,7 @@ static struct cmdstruct commands[] = { /* help */ /* can be used in runscript * { NT_(".status"), dot_status_cmd, NULL, false}, { NT_(".storage"), storagecmd, NULL, true}, { NT_(".volstatus"), volstatuscmd, NULL, true}, + { NT_(".media"), mediacmd, NULL, true}, { NT_(".mediatypes"), mediatypescmd, NULL, true}, { NT_(".locations"), locationscmd, NULL, true}, { NT_(".bvfs_lsdirs"), dot_bvfs_lsdirs, NULL, true}, @@ -714,6 +717,20 @@ static bool mediatypescmd(UAContext *ua, const char *cmd) return true; } +static bool mediacmd(UAContext *ua, const char *cmd) +{ + if (!open_client_db(ua)) { + return true; + } + if (!db_sql_query(ua->db, + "SELECT DISTINCT Media.VolumeName FROM Media ORDER BY VolumeName", + one_handler, (void *)ua)) + { + ua->error_msg(_("List Media failed: ERR=%s\n"), db_strerror(ua->db)); + } + return true; +} + static bool locationscmd(UAContext *ua, const char *cmd) { if (!open_client_db(ua)) {