*
* Version $Id$
*/
-
/*
- Copyright (C) 2000-2005 Kern Sibbald
+ Copyright (C) 2000-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License
+ version 2 as amended with additional clauses defined in the
+ file LICENSE in the main source directory.
This program 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
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ the file LICENSE for additional details.
*/
extern int r_last;
extern struct s_res resources[];
extern char my_name[];
-extern jobq_t job_queue; /* job queue */
+extern jobq_t job_queue; /* job queue */
/* Imported functions */
{ N_("add"), add_cmd, _("add media to a pool")},
{ N_("autodisplay"), autodisplay_cmd, _("autodisplay [on|off] -- console messages")},
{ N_("automount"), automount_cmd, _("automount [on|off] -- after label")},
- { N_("cancel"), cancel_cmd, _("cancel <job=nnn> -- cancel a job")},
+ { N_("cancel"), cancel_cmd, _("cancel [<jobid=nnn> | <job=name>] -- cancel a job")},
{ N_("create"), create_cmd, _("create DB Pool from resource")},
{ N_("delete"), delete_cmd, _("delete [pool=<pool-name> | media volume=<volume-name>]")},
{ N_("estimate"), estimate_cmd, _("performs FileSet estimate, listing gives full listing")},
{ N_("trace"), trace_cmd, _("turn on/off trace to file")},
{ N_("unmount"), unmount_cmd, _("unmount <storage-name>")},
{ N_("umount"), unmount_cmd, _("umount <storage-name> for old-time Unix guys")},
- { N_("update"), update_cmd, _("update Volume or Pool")},
+ { N_("update"), update_cmd, _("update Volume, Pool or slots")},
{ N_("use"), use_cmd, _("use catalog xxx")},
{ N_("var"), var_cmd, _("does variable expansion")},
{ N_("version"), version_cmd, _("print Director version")},
{ N_("wait"), wait_cmd, _("wait until no jobs are running")},
- };
+ };
#define comsize (sizeof(commands)/sizeof(struct cmdstruct))
/*
return 1;
}
+ while (ua->jcr->storage->size()) {
+ ua->jcr->storage->remove(0);
+ }
+
len = strlen(ua->argk[0]);
- for (i=0; i<comsize; i++) { /* search for command */
+ for (i=0; i<comsize; i++) { /* search for command */
if (strncasecmp(ua->argk[0], _(commands[i].key), len) == 0) {
- if (!acl_access_ok(ua, Command_ACL, ua->argk[0], len)) {
- break;
- }
- stat = (*commands[i].func)(ua, cmd); /* go execute command */
- found = true;
- break;
+ /* Check if command permitted, but "quit" is always OK */
+ if (strcmp(ua->argk[0], "quit") != 0 &&
+ !acl_access_ok(ua, Command_ACL, ua->argk[0], len)) {
+ break;
+ }
+ stat = (*commands[i].func)(ua, cmd); /* go execute command */
+ found = true;
+ break;
}
}
if (!found) {
bsendmsg(ua, _("Pool already has maximum volumes = %d\n"), pr.MaxVols);
for (;;) {
if (!get_pint(ua, _("Enter new maximum (zero for unlimited): "))) {
- return 1;
- }
- pr.MaxVols = ua->pint32_val;
+ return 1;
+ }
+ pr.MaxVols = ua->pint32_val;
}
}
/* Get media type */
- if ((store = get_storage_resource(ua, 0)) != NULL) {
+ if ((store = get_storage_resource(ua, false/*no default*/)) != NULL) {
bstrncpy(mr.MediaType, store->media_type, sizeof(mr.MediaType));
} else if (!get_media_type(ua, mr.MediaType, sizeof(mr.MediaType))) {
return 1;
char buf[100];
bsnprintf(buf, sizeof(buf), _("Enter number of Volumes to create. 0=>fixed name. Max=%d: "), max);
if (!get_pint(ua, buf)) {
- return 1;
+ return 1;
}
num = ua->pint32_val;
if (num < 0 || num > max) {
bsendmsg(ua, _("The number must be between 0 and %d\n"), max);
- continue;
+ continue;
}
break;
}
getVolName:
if (num == 0) {
if (!get_cmd(ua, _("Enter Volume name: "))) {
- return 1;
+ return 1;
}
} else {
if (!get_cmd(ua, _("Enter base volume name: "))) {
- return 1;
+ return 1;
}
}
/* Don't allow | in Volume name because it is the volume separator character */
for (;;) {
if (!get_pint(ua, _("Enter the starting number: "))) {
- return 1;
- }
- startnum = ua->pint32_val;
- if (startnum < 1) {
+ return 1;
+ }
+ startnum = ua->pint32_val;
+ if (startnum < 1) {
bsendmsg(ua, _("Start number must be greater than zero.\n"));
- continue;
- }
- break;
+ continue;
+ }
+ break;
}
} else {
startnum = 1;
if (store && store->autochanger) {
if (!get_pint(ua, _("Enter slot (0 for none): "))) {
- return 1;
+ return 1;
}
Slot = ua->pint32_val;
if (!get_yesno(ua, _("InChanger? yes/no: "))) {
- return 1;
+ return 1;
}
InChanger = ua->pint32_val;
}
Dmsg1(200, "Create Volume %s\n", mr.VolumeName);
if (!db_create_media_record(ua->jcr, ua->db, &mr)) {
bsendmsg(ua, "%s", db_strerror(ua->db));
- return 1;
+ return 1;
}
if (i == startnum) {
- first_id = mr.PoolId;
+ first_id = mr.PoolId;
}
}
pr.NumVols += num;
if (ua->argc != 2) {
if (!get_cmd(ua, _("Turn on or off? "))) {
- return 1;
+ return 1;
}
onoff = ua->cmd;
} else {
for (i=1; i<ua->argc; i++) {
if (strcasecmp(ua->argk[i], _("jobid")) == 0) {
- uint32_t JobId;
- if (!ua->argv[i]) {
- break;
- }
- JobId = str_to_int64(ua->argv[i]);
- if (!(jcr=get_jcr_by_id(JobId))) {
- bsendmsg(ua, _("JobId %d is not running.\n"), JobId);
- return 1;
- }
- break;
+ uint32_t JobId;
+ if (!ua->argv[i]) {
+ break;
+ }
+ JobId = str_to_int64(ua->argv[i]);
+ if (!(jcr=get_jcr_by_id(JobId))) {
+ bsendmsg(ua, _("JobId %s is not running. Use Job name to cancel inactive jobs.\n"), ua->argv[i]);
+ return 1;
+ }
+ break;
} else if (strcasecmp(ua->argk[i], _("job")) == 0) {
- if (!ua->argv[i]) {
- break;
- }
- if (!(jcr=get_jcr_by_partial_name(ua->argv[i]))) {
- bsendmsg(ua, _("Job %s is not running.\n"), ua->argv[i]);
- return 1;
- }
- break;
+ if (!ua->argv[i]) {
+ break;
+ }
+ if (!(jcr=get_jcr_by_partial_name(ua->argv[i]))) {
+ bsendmsg(ua, _("Warning Job %s is not running. Continuing anyway ...\n"), ua->argv[i]);
+ jcr = new_jcr(sizeof(JCR), dird_free_jcr);
+ bstrncpy(jcr->Job, ua->argv[i], sizeof(jcr->Job));
+ }
+ break;
}
}
/* If we still do not have a jcr,
- * throw up a list and ask the user to select one.
+ * throw up a list and ask the user to select one.
*/
if (!jcr) {
char buf[1000];
/* Count Jobs running */
- lock_jcr_chain();
foreach_jcr(jcr) {
- if (jcr->JobId == 0) { /* this is us */
- free_locked_jcr(jcr);
- continue;
- }
- free_locked_jcr(jcr);
- njobs++;
+ if (jcr->JobId == 0) { /* this is us */
+ continue;
+ }
+ njobs++;
}
- unlock_jcr_chain();
+ endeach_jcr(jcr);
if (njobs == 0) {
bsendmsg(ua, _("No Jobs running.\n"));
- return 1;
+ return 1;
}
start_prompt(ua, _("Select Job:\n"));
- lock_jcr_chain();
foreach_jcr(jcr) {
- if (jcr->JobId == 0) { /* this is us */
- free_locked_jcr(jcr);
- continue;
- }
- bsnprintf(buf, sizeof(buf), "JobId=%d Job=%s", jcr->JobId, jcr->Job);
- add_prompt(ua, buf);
- free_locked_jcr(jcr);
+ char ed1[50];
+ if (jcr->JobId == 0) { /* this is us */
+ continue;
+ }
+ bsnprintf(buf, sizeof(buf), _("JobId=%s Job=%s"), edit_int64(jcr->JobId, ed1), jcr->Job);
+ add_prompt(ua, buf);
}
- unlock_jcr_chain();
+ endeach_jcr(jcr);
if (do_prompt(ua, _("Job"), _("Choose Job to cancel"), buf, sizeof(buf)) < 0) {
- return 1;
+ return 1;
}
if (njobs == 1) {
if (!get_yesno(ua, _("Confirm cancel (yes/no): ")) || ua->pint32_val == 0) {
- return 1;
- }
+ return 1;
+ }
}
/* NOTE! This increments the ref_count */
sscanf(buf, "JobId=%d Job=%127s", &njobs, JobName);
jcr = get_jcr_by_full_name(JobName);
if (!jcr) {
bsendmsg(ua, _("Job %s not found.\n"), JobName);
- return 1;
+ return 1;
}
}
ret = cancel_job(ua, jcr);
free_jcr(jcr);
-
return ret;
}
if (op == POOL_OP_CREATE) {
pr->MaxVols = pool->max_volumes;
pr->NumVols = 0;
- } else { /* update pool */
+ } else { /* update pool */
if (pr->MaxVols != pool->max_volumes) {
- pr->MaxVols = pool->max_volumes;
+ pr->MaxVols = pool->max_volumes;
}
if (pr->MaxVols != 0 && pr->MaxVols < pr->NumVols) {
- pr->MaxVols = pr->NumVols;
+ pr->MaxVols = pr->NumVols;
}
}
pr->LabelType = pool->LabelType;
/*
* Create a pool record from a given Pool resource
* Also called from backup.c
- * Returns: -1 on error
- * 0 record already exists
- * 1 record created
+ * Returns: -1 on error
+ * 0 record already exists
+ * 1 record created
*/
int create_pool(JCR *jcr, B_DB *db, POOL *pool, e_pool_op op)
if (db_get_pool_record(jcr, db, &pr)) {
/* Pool Exists */
if (op == POOL_OP_UPDATE) { /* update request */
- set_pooldbr_from_poolres(&pr, pool, op);
- db_update_pool_record(jcr, db, &pr);
+ set_pooldbr_from_poolres(&pr, pool, op);
+ db_update_pool_record(jcr, db, &pr);
}
- return 0; /* exists */
+ return 0; /* exists */
}
set_pooldbr_from_poolres(&pr, pool, op);
if (!db_create_pool_record(jcr, db, &pr)) {
- return -1; /* error */
+ return -1; /* error */
}
return 1;
}
*/
static int python_cmd(UAContext *ua, const char *cmd)
{
- if (strcasecmp(ua->argk[1], _("restart")) == 0) {
+ if (ua->argc >= 1 && strcasecmp(ua->argk[1], _("restart")) == 0) {
term_python_interpreter();
- init_python_interpreter(director->hdr.name, director->scripts_directory ?
- director->scripts_directory : ".");
+ init_python_interpreter(director->hdr.name,
+ director->scripts_directory, "DirStartUp");
bsendmsg(ua, _("Python interpreter restarted.\n"));
} else {
bsendmsg(ua, _("Nothing done.\n"));
sockaddr_to_ascii(&(ua->UA_sock->client_addr), buf, sizeof(buf));
client->address = bstrdup(buf);
bsendmsg(ua, _("Client \"%s\" address set to %s\n"),
- client->hdr.name, client->address);
+ client->hdr.name, client->address);
get_out:
UnlockRes();
return 1;
while ((store = (STORE *)GetNextRes(R_STORAGE, (RES *)store))) {
found = 0;
for (j=0; j<i; j++) {
- if (strcmp(unique_store[j]->address, store->address) == 0 &&
- unique_store[j]->SDport == store->SDport) {
- found = 1;
- break;
- }
+ if (strcmp(unique_store[j]->address, store->address) == 0 &&
+ unique_store[j]->SDport == store->SDport) {
+ found = 1;
+ break;
+ }
}
if (!found) {
- unique_store[i++] = store;
+ unique_store[i++] = store;
Dmsg2(140, "Stuffing: %s:%d\n", store->address, store->SDport);
}
}
while ((client = (CLIENT *)GetNextRes(R_CLIENT, (RES *)client))) {
found = 0;
for (j=0; j<i; j++) {
- if (strcmp(unique_client[j]->address, client->address) == 0 &&
- unique_client[j]->FDport == client->FDport) {
- found = 1;
- break;
- }
+ if (strcmp(unique_client[j]->address, client->address) == 0 &&
+ unique_client[j]->FDport == client->FDport) {
+ found = 1;
+ break;
+ }
}
if (!found) {
- unique_client[i++] = client;
+ unique_client[i++] = client;
Dmsg2(140, "Stuffing: %s:%d\n", client->address, client->FDport);
}
}
Dmsg1(120, "setdebug:%s:\n", cmd);
level = -1;
- i = find_arg_with_value(ua, _("level"));
+ i = find_arg_with_value(ua, "level");
if (i >= 0) {
level = atoi(ua->argv[i]);
}
if (level < 0) {
if (!get_pint(ua, _("Enter new debug level: "))) {
- return 1;
+ return 1;
}
level = ua->pint32_val;
}
/* Look for trace flag. -1 => not change */
- i = find_arg_with_value(ua, _("trace"));
+ i = find_arg_with_value(ua, "trace");
if (i >= 0) {
trace_flag = atoi(ua->argv[i]);
if (trace_flag > 0) {
- trace_flag = 1;
+ trace_flag = 1;
}
}
/* General debug? */
for (i=1; i<ua->argc; i++) {
- if (strcasecmp(ua->argk[i], _("all")) == 0) {
- do_all_setdebug(ua, level, trace_flag);
- return 1;
+ if (strcasecmp(ua->argk[i], "all") == 0) {
+ do_all_setdebug(ua, level, trace_flag);
+ return 1;
}
- if (strcasecmp(ua->argk[i], _("dir")) == 0 ||
- strcasecmp(ua->argk[i], _("director")) == 0) {
- debug_level = level;
- set_trace(trace_flag);
- return 1;
+ if (strcasecmp(ua->argk[i], "dir") == 0 ||
+ strcasecmp(ua->argk[i], "director") == 0) {
+ debug_level = level;
+ set_trace(trace_flag);
+ return 1;
}
- if (strcasecmp(ua->argk[i], _("client")) == 0 ||
- strcasecmp(ua->argk[i], _("fd")) == 0) {
- client = NULL;
- if (ua->argv[i]) {
- client = (CLIENT *)GetResWithName(R_CLIENT, ua->argv[i]);
- if (client) {
- do_client_setdebug(ua, client, level, trace_flag);
- return 1;
- }
- }
- client = select_client_resource(ua);
- if (client) {
- do_client_setdebug(ua, client, level, trace_flag);
- return 1;
- }
+ if (strcasecmp(ua->argk[i], "client") == 0 ||
+ strcasecmp(ua->argk[i], "fd") == 0) {
+ client = NULL;
+ if (ua->argv[i]) {
+ client = (CLIENT *)GetResWithName(R_CLIENT, ua->argv[i]);
+ if (client) {
+ do_client_setdebug(ua, client, level, trace_flag);
+ return 1;
+ }
+ }
+ client = select_client_resource(ua);
+ if (client) {
+ do_client_setdebug(ua, client, level, trace_flag);
+ return 1;
+ }
}
- if (strcasecmp(ua->argk[i], _("store")) == 0 ||
- strcasecmp(ua->argk[i], _("storage")) == 0 ||
- strcasecmp(ua->argk[i], _("sd")) == 0) {
- store = NULL;
- if (ua->argv[i]) {
- store = (STORE *)GetResWithName(R_STORAGE, ua->argv[i]);
- if (store) {
- do_storage_setdebug(ua, store, level, trace_flag);
- return 1;
- }
- }
- store = get_storage_resource(ua, 0);
- if (store) {
- do_storage_setdebug(ua, store, level, trace_flag);
- return 1;
- }
+ if (strcasecmp(ua->argk[i], "store") == 0 ||
+ strcasecmp(ua->argk[i], "storage") == 0 ||
+ strcasecmp(ua->argk[i], "sd") == 0) {
+ store = NULL;
+ if (ua->argv[i]) {
+ store = (STORE *)GetResWithName(R_STORAGE, ua->argv[i]);
+ if (store) {
+ do_storage_setdebug(ua, store, level, trace_flag);
+ return 1;
+ }
+ }
+ store = get_storage_resource(ua, false/*no default*/);
+ if (store) {
+ do_storage_setdebug(ua, store, level, trace_flag);
+ return 1;
+ }
}
}
/*
* prompt the user.
*/
start_prompt(ua, _("Available daemons are: \n"));
- add_prompt(ua, _("Director"));
- add_prompt(ua, _("Storage"));
- add_prompt(ua, _("Client"));
- add_prompt(ua, _("All"));
+ add_prompt(ua, "Director");
+ add_prompt(ua, "Storage");
+ add_prompt(ua, "Client");
+ add_prompt(ua, "All");
switch(do_prompt(ua, "", _("Select daemon type to set debug level"), NULL, 0)) {
- case 0: /* Director */
+ case 0: /* Director */
debug_level = level;
set_trace(trace_flag);
break;
case 1:
- store = get_storage_resource(ua, 0);
+ store = get_storage_resource(ua, false/*no default*/);
if (store) {
- do_storage_setdebug(ua, store, level, trace_flag);
+ do_storage_setdebug(ua, store, level, trace_flag);
}
break;
case 2:
client = select_client_resource(ua);
if (client) {
- do_client_setdebug(ua, client, level, trace_flag);
+ do_client_setdebug(ua, client, level, trace_flag);
}
break;
case 3:
if (ua->argc != 2) {
if (!get_cmd(ua, _("Turn on or off? "))) {
- return 1;
+ return 1;
}
onoff = ua->cmd;
} else {
JOB *job = NULL;
CLIENT *client = NULL;
FILESET *fileset = NULL;
- FILESET_DBR fsr;
int listing = 0;
char since[MAXSTRING];
JCR *jcr = ua->jcr;
jcr->JobLevel = L_FULL;
for (int i=1; i<ua->argc; i++) {
- if (strcasecmp(ua->argk[i], _("client")) == 0 ||
- strcasecmp(ua->argk[i], _("fd")) == 0) {
- if (ua->argv[i]) {
- client = (CLIENT *)GetResWithName(R_CLIENT, ua->argv[i]);
- continue;
- }
+ if (strcasecmp(ua->argk[i], "client") == 0 ||
+ strcasecmp(ua->argk[i], "fd") == 0) {
+ if (ua->argv[i]) {
+ client = (CLIENT *)GetResWithName(R_CLIENT, ua->argv[i]);
+ continue;
+ }
}
- if (strcasecmp(ua->argk[i], _("job")) == 0) {
- if (ua->argv[i]) {
- job = (JOB *)GetResWithName(R_JOB, ua->argv[i]);
- continue;
- }
+ if (strcasecmp(ua->argk[i], "job") == 0) {
+ if (ua->argv[i]) {
+ job = (JOB *)GetResWithName(R_JOB, ua->argv[i]);
+ continue;
+ }
}
- if (strcasecmp(ua->argk[i], _("fileset")) == 0) {
- if (ua->argv[i]) {
- fileset = (FILESET *)GetResWithName(R_FILESET, ua->argv[i]);
- continue;
- }
+ if (strcasecmp(ua->argk[i], "fileset") == 0) {
+ if (ua->argv[i]) {
+ fileset = (FILESET *)GetResWithName(R_FILESET, ua->argv[i]);
+ continue;
+ }
}
- if (strcasecmp(ua->argk[i], _("listing")) == 0) {
- listing = 1;
- continue;
+ if (strcasecmp(ua->argk[i], "listing") == 0) {
+ listing = 1;
+ continue;
}
- if (strcasecmp(ua->argk[i], _("level")) == 0) {
- if (!get_level_from_name(ua->jcr, ua->argv[i])) {
+ if (strcasecmp(ua->argk[i], "level") == 0) {
+ if (!get_level_from_name(ua->jcr, ua->argv[i])) {
bsendmsg(ua, _("Level %s not valid.\n"), ua->argv[i]);
- }
- continue;
+ }
+ continue;
}
}
if (!job && !(client && fileset)) {
if (!(job = select_job_resource(ua))) {
- return 1;
+ return 1;
}
}
if (!job) {
job = (JOB *)GetResWithName(R_JOB, ua->argk[1]);
if (!job) {
bsendmsg(ua, _("No job specified.\n"));
- return 1;
+ return 1;
}
}
if (!client) {
if (!get_or_create_client_record(jcr)) {
return 1;
}
- if (!get_or_create_fileset_record(jcr, &fsr)) {
+ if (!get_or_create_fileset_record(jcr)) {
return 1;
}
*
* delete pool=<pool-name>
* delete volume pool=<pool-name> volume=<name>
- * delete job jobid=xxx
+ * delete jobid=xxx
*/
static int delete_cmd(UAContext *ua, const char *cmd)
{
static const char *keywords[] = {
N_("volume"),
N_("pool"),
- N_("job"),
N_("jobid"),
NULL};
delete_pool(ua);
return 1;
case 2:
- case 3:
int i;
- while ((i=find_arg(ua, _("jobid"))) > 0) {
- delete_job(ua);
- *ua->argk[i] = 0; /* zap keyword already visited */
+ while ((i=find_arg(ua, "jobid")) > 0) {
+ delete_job(ua);
+ *ua->argk[i] = 0; /* zap keyword already visited */
}
return 1;
default:
/*
* delete_job has been modified to parse JobID lists like the
* following:
- * delete job JobID=3,4,6,7-11,14
+ * delete JobID=3,4,6,7-11,14
*
* Thanks to Phil Stracchino for the above addition.
*/
JobId_t JobId;
char *s,*sep,*tok;
- int i = find_arg_with_value(ua, _("jobid"));
+ int i = find_arg_with_value(ua, N_("jobid"));
if (i >= 0) {
if (strchr(ua->argv[i], ',') != NULL || strchr(ua->argv[i], '-') != NULL) {
- s = bstrdup(ua->argv[i]);
- tok = s;
- /*
+ s = bstrdup(ua->argv[i]);
+ tok = s;
+ /*
* We could use strtok() here. But we're not going to, because:
- * (a) strtok() is deprecated, having been replaced by strsep();
- * (b) strtok() is broken in significant ways.
+ * (a) strtok() is deprecated, having been replaced by strsep();
+ * (b) strtok() is broken in significant ways.
* we could use strsep() instead, but it's not universally available.
- * so we grow our own using strchr().
- */
+ * so we grow our own using strchr().
+ */
sep = strchr(tok, ',');
- while (sep != NULL) {
+ while (sep != NULL) {
*sep = '\0';
if (strchr(tok, '-')) {
- delete_job_id_range(ua, tok);
- } else {
- JobId = str_to_int64(tok);
- do_job_delete(ua, JobId);
- }
- tok = ++sep;
+ delete_job_id_range(ua, tok);
+ } else {
+ JobId = str_to_int64(tok);
+ do_job_delete(ua, JobId);
+ }
+ tok = ++sep;
sep = strchr(tok, ',');
- }
- /* pick up the last token */
+ }
+ /* pick up the last token */
if (strchr(tok, '-')) {
- delete_job_id_range(ua, tok);
- } else {
- JobId = str_to_int64(tok);
- do_job_delete(ua, JobId);
- }
+ delete_job_id_range(ua, tok);
+ } else {
+ JobId = str_to_int64(tok);
+ do_job_delete(ua, JobId);
+ }
- free(s);
+ free(s);
} else {
- JobId = str_to_int64(ua->argv[i]);
- do_job_delete(ua, JobId);
+ JobId = str_to_int64(ua->argv[i]);
+ do_job_delete(ua, JobId);
}
} else if (!get_pint(ua, _("Enter JobId to delete: "))) {
return;
BSOCK *sd;
JCR *jcr = ua->jcr;
char dev_name[MAX_NAME_LENGTH];
+ int drive;
if (!open_db(ua)) {
return;
}
Dmsg2(120, "%s: %s\n", command, ua->UA_sock->msg);
- store = get_storage_resource(ua, 1);
+ store = get_storage_resource(ua, true/*arg is storage*/);
if (!store) {
return;
}
+ set_storage(jcr, store);
+ drive = get_storage_drive(ua, store);
- Dmsg2(120, "Found storage, MediaType=%s DevName=%s\n",
- store->media_type, store->dev_name());
+ Dmsg3(120, "Found storage, MediaType=%s DevName=%s drive=%d\n",
+ store->media_type, store->dev_name(), drive);
- set_storage(jcr, store);
if (!connect_to_storage_daemon(jcr, 10, SDConnectTimeout, 1)) {
bsendmsg(ua, _("Failed to connect to Storage daemon.\n"));
return;
sd = jcr->store_bsock;
bstrncpy(dev_name, store->dev_name(), sizeof(dev_name));
bash_spaces(dev_name);
- bnet_fsend(sd, "%s %s", command, dev_name);
+ bnet_fsend(sd, "%s %s drive=%d", command, dev_name, drive);
while (bnet_recv(sd) >= 0) {
bsendmsg(ua, "%s", sd->msg);
}
}
/*
- * mount [storage | device] <name>
+ * mount [storage=<name>] [drive=nn]
*/
static int mount_cmd(UAContext *ua, const char *cmd)
{
/*
- * unmount [storage | device] <name>
+ * unmount [storage=<name>] [drive=nn]
*/
static int unmount_cmd(UAContext *ua, const char *cmd)
{
/*
- * release [storage | device] <name>
+ * release [storage=<name>] [drive=nn]
*/
static int release_cmd(UAContext *ua, const char *cmd)
{
CAT *oldcatalog, *catalog;
- close_db(ua); /* close any previously open db */
+ close_db(ua); /* close any previously open db */
oldcatalog = ua->catalog;
if (!(catalog = get_catalog_resource(ua))) {
}
if (open_db(ua)) {
bsendmsg(ua, _("Using Catalog name=%s DB=%s\n"),
- ua->catalog->hdr.name, ua->catalog->db_name);
+ ua->catalog->hdr.name, ua->catalog->db_name);
}
return 1;
}
int wait_cmd(UAContext *ua, const char *cmd)
{
JCR *jcr;
- bmicrosleep(0, 200000); /* let job actually start */
+ bmicrosleep(0, 200000); /* let job actually start */
for (bool running=true; running; ) {
running = false;
- lock_jcr_chain();
foreach_jcr(jcr) {
- if (jcr->JobId != 0) {
- running = true;
- free_locked_jcr(jcr);
- break;
- }
- free_locked_jcr(jcr);
+ if (jcr->JobId != 0) {
+ running = true;
+ break;
+ }
}
- unlock_jcr_chain();
+ endeach_jcr(jcr);
+
if (running) {
- bmicrosleep(1, 0);
+ bmicrosleep(1, 0);
}
}
return 1;
unsigned int i;
for (i=0; i<comsize; i++) {
- bsendmsg(ua, _("%s %s\n"), _(commands[i].key), _(commands[i].help));
+ bsendmsg(ua, "%s %s\n", _(commands[i].key), _(commands[i].help));
}
return 1;
}
static int version_cmd(UAContext *ua, const char *cmd)
{
- bsendmsg(ua, "%s Version: " VERSION " (" BDATE ")\n", my_name);
+ bsendmsg(ua, _("%s Version: %s (%s)\n"), my_name, VERSION, BDATE);
return 1;
}
UnlockRes();
if (!ua->catalog) {
bsendmsg(ua, _("Could not find a Catalog resource\n"));
- return 0;
+ return 0;
} else {
bsendmsg(ua, _("Using default Catalog name=%s DB=%s\n"),
- ua->catalog->hdr.name, ua->catalog->db_name);
+ ua->catalog->hdr.name, ua->catalog->db_name);
}
}
Dmsg0(150, "Open database\n");
ua->db = db_init_database(ua->jcr, ua->catalog->db_name, ua->catalog->db_user,
- ua->catalog->db_password, ua->catalog->db_address,
- ua->catalog->db_port, ua->catalog->db_socket,
- ua->catalog->mult_db_connections);
+ ua->catalog->db_password, ua->catalog->db_address,
+ ua->catalog->db_port, ua->catalog->db_socket,
+ ua->catalog->mult_db_connections);
if (!ua->db || !db_open_database(ua->jcr, ua->db)) {
bsendmsg(ua, _("Could not open database \"%s\".\n"),
- ua->catalog->db_name);
+ ua->catalog->db_name);
if (ua->db) {
bsendmsg(ua, "%s", db_strerror(ua->db));
}
db_close_database(ua->jcr, ua->db);
ua->db = NULL;
if (ua->jcr) {
- ua->jcr->db = NULL;
+ ua->jcr->db = NULL;
}
}
}