*/
/*
- Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
+ Copyright (C) 2000-2003 Kern Sibbald and John Walker
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
#include "bacula.h"
#include "dird.h"
-#include "ua.h"
/* Imported subroutines */
-extern void run_job(JCR *jcr);
/* Imported variables */
extern int r_first;
/* Imported functions */
/* Forward referenced functions */
+static int do_listcmd(UAContext *ua, char *cmd, e_list_type llist);
/*
static struct showstruct reses[] = {
{N_("directors"), R_DIRECTOR},
{N_("clients"), R_CLIENT},
+ {N_("counters"), R_COUNTER},
{N_("jobs"), R_JOB},
{N_("storages"), R_STORAGE},
{N_("catalogs"), R_CATALOG},
* show <resource-keyword-name>=<name> e.g. show director=HeadMan
*
*/
-int showcmd(UAContext *ua, char *cmd)
+int show_cmd(UAContext *ua, char *cmd)
{
int i, j, type, len;
int recurse;
* list files job=name
* list pools - list pool records
* list jobtotals - list totals for all jobs
- * list media - list media for given pool
+ * list media - list media for given pool (deprecated)
+ * list volumes - list Volumes
* list clients - list clients
*
*/
-int listcmd(UAContext *ua, char *cmd)
+
+/* Do long or full listing */
+int llistcmd(UAContext *ua, char *cmd)
+{
+ return do_listcmd(ua, cmd, VERT_LIST);
+}
+
+/* Do short or summary listing */
+int listcmd(UAContext *ua, char *cmd)
+{
+ return do_listcmd(ua, cmd, HORZ_LIST);
+}
+
+static int do_listcmd(UAContext *ua, char *cmd, e_list_type llist)
{
POOLMEM *VolumeName;
int jobid, n;
for (i=1; i<ua->argc; i++) {
/* List JOBS */
if (strcasecmp(ua->argk[i], _("jobs")) == 0) {
- db_list_job_records(ua->db, &jr, prtit, ua);
+ db_list_job_records(ua->jcr, ua->db, &jr, prtit, ua, llist);
/* List JOBTOTALS */
} else if (strcasecmp(ua->argk[i], _("jobtotals")) == 0) {
- db_list_job_totals(ua->db, &jr, prtit, ua);
+ db_list_job_totals(ua->jcr, ua->db, &jr, prtit, ua);
/* List JOBID */
} else if (strcasecmp(ua->argk[i], _("jobid")) == 0) {
jobid = atoi(ua->argv[i]);
if (jobid > 0) {
jr.JobId = jobid;
- db_list_job_records(ua->db, &jr, prtit, ua);
+ db_list_job_records(ua->jcr, ua->db, &jr, prtit, ua, llist);
}
}
} else if (strcasecmp(ua->argk[i], _("job")) == 0 && ua->argv[i]) {
bstrncpy(jr.Job, ua->argv[i], MAX_NAME_LENGTH);
jr.JobId = 0;
- db_list_job_records(ua->db, &jr, prtit, ua);
+ db_list_job_records(ua->jcr, ua->db, &jr, prtit, ua, llist);
/* List FILES */
} else if (strcasecmp(ua->argk[i], _("files")) == 0) {
if (strcasecmp(ua->argk[j], _("job")) == 0 && ua->argv[j]) {
bstrncpy(jr.Job, ua->argv[j], MAX_NAME_LENGTH);
jr.JobId = 0;
- db_get_job_record(ua->db, &jr);
+ db_get_job_record(ua->jcr, ua->db, &jr);
jobid = jr.JobId;
} else if (strcasecmp(ua->argk[j], _("jobid")) == 0 && ua->argv[j]) {
jobid = atoi(ua->argv[j]);
continue;
}
if (jobid > 0) {
- db_list_files_for_job(ua->db, jobid, prtit, ua);
+ db_list_files_for_job(ua->jcr, ua->db, jobid, prtit, ua);
}
}
if (strcasecmp(ua->argk[j], _("job")) == 0 && ua->argv[j]) {
bstrncpy(jr.Job, ua->argv[j], MAX_NAME_LENGTH);
jr.JobId = 0;
- db_get_job_record(ua->db, &jr);
+ db_get_job_record(ua->jcr, ua->db, &jr);
jobid = jr.JobId;
} else if (strcasecmp(ua->argk[j], _("jobid")) == 0 && ua->argv[j]) {
jobid = atoi(ua->argv[j]);
} else {
continue;
}
- db_list_jobmedia_records(ua->db, jobid, prtit, ua);
+ db_list_jobmedia_records(ua->jcr, ua->db, jobid, prtit, ua, llist);
done = TRUE;
}
if (!done) {
/* List for all jobs (jobid=0) */
- db_list_jobmedia_records(ua->db, 0, prtit, ua);
+ db_list_jobmedia_records(ua->jcr, ua->db, 0, prtit, ua, llist);
}
/* List POOLS */
} else if (strcasecmp(ua->argk[i], _("pools")) == 0) {
- db_list_pool_records(ua->db, prtit, ua);
+ db_list_pool_records(ua->jcr, ua->db, prtit, ua, llist);
} else if (strcasecmp(ua->argk[i], _("clients")) == 0) {
- db_list_client_records(ua->db, prtit, ua);
+ db_list_client_records(ua->jcr, ua->db, prtit, ua, llist);
/* List MEDIA or VOLUMES */
if (strcasecmp(ua->argk[j], _("job")) == 0 && ua->argv[j]) {
bstrncpy(jr.Job, ua->argv[j], MAX_NAME_LENGTH);
jr.JobId = 0;
- db_get_job_record(ua->db, &jr);
+ db_get_job_record(ua->jcr, ua->db, &jr);
jobid = jr.JobId;
} else if (strcasecmp(ua->argk[j], _("jobid")) == 0 && ua->argv[j]) {
jobid = atoi(ua->argv[j]);
continue;
}
VolumeName = get_pool_memory(PM_FNAME);
- n = db_get_job_volume_names(ua->db, jobid, &VolumeName);
+ n = db_get_job_volume_names(ua->jcr, ua->db, jobid, &VolumeName);
bsendmsg(ua, _("Jobid %d used %d Volume(s): %s\n"), jobid, n, VolumeName);
free_pool_memory(VolumeName);
done = TRUE;
}
/* if no job or jobid keyword found, then we list all media */
if (!done) {
- if (!get_pool_dbr(ua, &pr)) {
+ int num_pools;
+ uint32_t *ids;
+ /* Is a specific pool wanted? */
+ for (i=1; i<ua->argc; i++) {
+ if (strcasecmp(ua->argk[i], _("pool")) == 0) {
+ if (!get_pool_dbr(ua, &pr)) {
+ bsendmsg(ua, _("No Pool specified.\n"));
+ return 1;
+ }
+ mr.PoolId = pr.PoolId;
+ db_list_media_records(ua->jcr, ua->db, &mr, prtit, ua, llist);
+ return 1;
+ }
+ }
+ /* List Volumes in all pools */
+ if (!db_get_pool_ids(ua->jcr, ua->db, &num_pools, &ids)) {
+ bsendmsg(ua, _("Error obtaining pool ids. ERR=%s\n"),
+ db_strerror(ua->db));
+ return 1;
+ }
+ if (num_pools <= 0) {
return 1;
}
- mr.PoolId = pr.PoolId;
- db_list_media_records(ua->db, &mr, prtit, ua);
+ for (i=0; i < num_pools; i++) {
+ pr.PoolId = ids[i];
+ if (db_get_pool_record(ua->jcr, ua->db, &pr)) {
+ bsendmsg(ua, _("Pool: %s\n"), pr.Name);
+ }
+ mr.PoolId = ids[i];
+ db_list_media_records(ua->jcr, ua->db, &mr, prtit, ua, llist);
+ }
+ free(ids);
+ return 1;
+ }
+ /* List a specific volume */
+ } else if (strcasecmp(ua->argk[i], _("volume")) == 0) {
+ if (!ua->argv[i]) {
+ bsendmsg(ua, _("No Volume Name specified.\n"));
+ return 1;
}
+ bstrncpy(mr.VolumeName, ua->argv[i], sizeof(mr.VolumeName));
+ db_list_media_records(ua->jcr, ua->db, &mr, prtit, ua, llist);
+ return 1;
} else {
bsendmsg(ua, _("Unknown list keyword: %s\n"), NPRT(ua->argk[i]));
}
bs->msglen = len;
bnet_send(bs);
} else { /* No UA, send to Job */
- Jmsg(ua->jcr, M_INFO, 0, msg);
+ Jmsg(ua->jcr, M_INFO, 0, "%s", msg);
free_pool_memory(msg);
}