From 2310e8c5f5b51d8a778ae4dd305d991da8ed8e37 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 4 Sep 2006 21:18:25 +0000 Subject: [PATCH] Implement Enabled on update slots git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3410 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 14 +++++++------- bacula/src/dird/protos.h | 1 + bacula/src/dird/ua_input.c | 25 +++++++++++++++++++++++++ bacula/src/dird/ua_label.c | 15 +++++++++++++++ bacula/src/dird/ua_update.c | 13 ++----------- bacula/src/version.h | 4 ++-- bacula/technotes-1.39 | 2 ++ 7 files changed, 54 insertions(+), 20 deletions(-) diff --git a/bacula/kernstodo b/bacula/kernstodo index 4b5e303f54..ca5f74a2d7 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -62,13 +62,6 @@ For 1.39: - Print warning message if LANG environment variable does not specify UTF-8. - New dot commands from Arno. - .update volume [enabled|disabled|*see below] - > However, I could easily imagine an option to "update slots" that says - > "enable=yes|no" that would automatically enable or disable all the Volumes - > found in the autochanger. This will permit the user to optionally mark all - > the Volumes in the magazine disabled prior to taking them offsite, and mark - > them all enabled when bringing them back on site. Coupled with the options - > to the slots keyword, you can apply the enable/disable to any or all volumes. .show device=xxx lists information from one storage device, including devices (I'm not even sure that information exists in the DIR...) .move eject device=xxx mostly the same as 'unmount xxx' but perhaps with @@ -1658,4 +1651,11 @@ Block Position: 0 daemon it was trying to connect to. - Freespace on DVD requested over and over even with no intervening writes. +- .update volume [enabled|disabled|*see below] + > However, I could easily imagine an option to "update slots" that says + > "enable=yes|no" that would automatically enable or disable all the Volumes + > found in the autochanger. This will permit the user to optionally mark all + > the Volumes in the magazine disabled prior to taking them offsite, and mark + > them all enabled when bringing them back on site. Coupled with the options + > to the slots keyword, you can apply the enable/disable to any or all volumes. diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index d7c040fbb2..f25fac5c78 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -170,6 +170,7 @@ int get_cmd(UAContext *ua, const char *prompt); bool get_pint(UAContext *ua, const char *prompt); bool get_yesno(UAContext *ua, const char *prompt); bool is_yesno(char *val, int *ret); +int get_enabled(UAContext *ua, const char *val); void parse_ua_args(UAContext *ua); /* ua_label.c */ diff --git a/bacula/src/dird/ua_input.c b/bacula/src/dird/ua_input.c index 9472af9271..183e502870 100644 --- a/bacula/src/dird/ua_input.c +++ b/bacula/src/dird/ua_input.c @@ -149,6 +149,31 @@ bool get_yesno(UAContext *ua, const char *prompt) } } +/* + * Gets an Enabled value => 0, 1, 2, yes, no, archived + * Returns: 0, 1, 2 if OK + * -1 on error + */ +int get_enabled(UAContext *ua, const char *val) +{ + int Enabled = -1; + + if (strcasecmp(val, "yes") == 0 || strcasecmp(val, "true") == 0) { + Enabled = 1; + } else if (strcasecmp(val, "no") == 0 || strcasecmp(val, "false") == 0) { + Enabled = 0; + } else if (strcasecmp(val, "archived") == 0) { + Enabled = 2; + } else { + Enabled = atoi(val); + } + if (Enabled < 0 || Enabled > 2) { + bsendmsg(ua, _("Invalid Enabled value, it must be yes, no, archived, 0, 1, or 2\n")); + return -1; + } + return Enabled; +} + void parse_ua_args(UAContext *ua) { parse_args(ua->cmd, &ua->args, &ua->argc, ua->argk, ua->argv, MAX_CMD_ARGS); diff --git a/bacula/src/dird/ua_label.c b/bacula/src/dird/ua_label.c index b60ba3df93..89a1c30c51 100644 --- a/bacula/src/dird/ua_label.c +++ b/bacula/src/dird/ua_label.c @@ -156,6 +156,9 @@ void update_slots(UAContext *ua) bool scan; int max_slots; int drive; + int Enabled = 1; + bool have_enabled; + int i; if (!open_db(ua)) { @@ -169,6 +172,15 @@ void update_slots(UAContext *ua) drive = get_storage_drive(ua, store); scan = find_arg(ua, NT_("scan")) >= 0; + if ((i=find_arg_with_value(ua, NT_("Enabled"))) >= 0) { + Enabled = get_enabled(ua, ua->argv[i]); + if (Enabled < 0) { + return; + } + have_enabled = true; + } else { + have_enabled = false; + } max_slots = get_num_slots_from_SD(ua); Dmsg1(100, "max_slots=%d\n", max_slots); @@ -235,6 +247,9 @@ void update_slots(UAContext *ua) mr.Slot = vl->Slot; mr.InChanger = 1; mr.StorageId = store->StorageId; + if (have_enabled) { + mr.Enabled = Enabled; + } if (!db_update_media_record(ua->jcr, ua->db, &mr)) { bsendmsg(ua, "%s", db_strerror(ua->db)); } else { diff --git a/bacula/src/dird/ua_update.c b/bacula/src/dird/ua_update.c index aa5d80b598..2eaf0617e7 100644 --- a/bacula/src/dird/ua_update.c +++ b/bacula/src/dird/ua_update.c @@ -364,17 +364,8 @@ static void update_all_vols_from_pool(UAContext *ua) static void update_volenabled(UAContext *ua, char *val, MEDIA_DBR *mr) { - if (strcasecmp(val, "yes") == 0 || strcasecmp(val, "true") == 0) { - mr->Enabled = 1; - } else if (strcasecmp(val, "no") == 0 || strcasecmp(val, "false") == 0) { - mr->Enabled = 0; - } else if (strcasecmp(val, "archived") == 0) { - mr->Enabled = 2; - } else { - mr->Enabled = atoi(val); - } - if (mr->Enabled < 0 || mr->Enabled > 2) { - bsendmsg(ua, _("Invalid Enabled, it must be 0, 1, or 2\n")); + mr->Enabled = get_enabled(ua, val); + if (mr->Enabled < 0) { return; } if (!db_update_media_record(ua->jcr, ua->db, mr)) { diff --git a/bacula/src/version.h b/bacula/src/version.h index b15923ae6d..ef3500c71c 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "1.39.21" -#define BDATE "02 Septermber 2006" -#define LSMDATE "02Sep06" +#define BDATE "04 Septermber 2006" +#define LSMDATE "04Sep06" #define BYEAR "2006" /* year for copyright messages in progs */ /* Debug flags */ diff --git a/bacula/technotes-1.39 b/bacula/technotes-1.39 index c35abe0968..d021daad5c 100644 --- a/bacula/technotes-1.39 +++ b/bacula/technotes-1.39 @@ -1,6 +1,8 @@ Technical notes on version 1.39 General: +04Sep06 +kes Implement Enabled on update slots. 02Sep06 kes When doing a label, pass the VolBytes back to the Director, which puts it in the catalog. -- 2.39.5