Skip to content

Commit

Permalink
Deviceinfo in rss and with strings
Browse files Browse the repository at this point in the history
  • Loading branch information
pstorz committed Feb 9, 2018
1 parent 5d0e37a commit 27af3c9
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 30 deletions.
8 changes: 8 additions & 0 deletions src/dird/dird.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "ua.h"
#include "jobq.h"


/* Globals that dird.c exports */
extern DIRRES *me; /**< Our Global resource */
extern CONFIG *my_config; /**< Our Global config */
Expand Down Expand Up @@ -168,6 +169,12 @@ struct smc_elem_aa {

};

#if HAVE_NDMP
struct ndmp_deviceinfo_t {
std::string device;
std::string model;
};
#endif

struct runtime_storage_status_t {
int32_t NumConcurrentJobs; /**< Number of concurrent jobs running */
Expand All @@ -178,6 +185,7 @@ struct runtime_storage_status_t {
unsigned char smc_ident[32]; /**< smc ident info = changer name */
smc_elem_aa storage_mapping; /**< smc element assignment */
changer_vol_list_t *vol_list; /**< Cached content of autochanger */
std::list<ndmp_deviceinfo_t> *ndmp_deviceinfo; /**< NDMP device info for devices in this Storage */
};

struct runtime_client_status_t {
Expand Down
1 change: 0 additions & 1 deletion src/dird/dird_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ class STORERES : public BRSRES {
runtime_storage_status_t *rss; /**< Runtime Storage Status */
STORERES *paired_storage; /**< Paired storage configuration item for protocols like NDMP */
tls_t tls; /**< TLS structure */
alist *ndmp_deviceinfo; /**< NDMP device info for devices in this Storage */

/* Methods */
char *dev_name() const;
Expand Down
4 changes: 0 additions & 4 deletions src/dird/ndmp_dma_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ struct ndmp_backup_format_option {
bool needs_namelist;
};

struct ndmp_deviceinfo {
char *device;
char *model;
};

/**
* Internal structure to keep track of private data.
Expand Down
42 changes: 17 additions & 25 deletions src/dird/ndmp_dma_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,21 @@ int get_tape_info(struct ndm_session *sess, ndmp9_device_info *info, unsigned n_
NIS *nis = (NIS *)sess->param->log.ctx;
JCR *jcr = nis->ua->jcr;

if (jcr->res.wstore->ndmp_deviceinfo) {
char* info = NULL;
foreach_alist(info, jcr->res.wstore->ndmp_deviceinfo) {
delete(info);
info = NULL;
}
jcr->res.wstore->ndmp_deviceinfo->destroy();
jcr->res.wstore->ndmp_deviceinfo = NULL;
if (jcr->res.wstore->rss->ndmp_deviceinfo) {
delete(jcr->res.wstore->rss->ndmp_deviceinfo);
jcr->res.wstore->rss->ndmp_deviceinfo = NULL;
}
jcr->res.wstore->ndmp_deviceinfo = New(alist(10, not_owned_by_alist));
jcr->res.wstore->rss->ndmp_deviceinfo = new(std::list<ndmp_deviceinfo_t>);

for (i = 0; i < n_info; i++) {
Dmsg2(100, " %s %s\n", what, info[i].model);

ndmp_deviceinfo *devinfo = new(ndmp_deviceinfo);
ndmp_deviceinfo_t *devinfo = new(ndmp_deviceinfo_t);
ndmp9_device_capability *info_dc;
info_dc = info[i].caplist.caplist_val;
devinfo->model = bstrdup(info[i].model);
devinfo->device = bstrdup(info_dc->device);
jcr->res.wstore->ndmp_deviceinfo->append(devinfo);
jcr->res.wstore->rss->ndmp_deviceinfo->push_back(*devinfo);

for (j = 0; j < info[i].caplist.caplist_len; j++) {
ndmp9_device_capability *dc;
Expand Down Expand Up @@ -140,7 +135,7 @@ void do_ndmp_native_storage_status(UAContext *ua, STORERES *store, char *cmd)
NDM_JOB_OP_QUERY_AGENTS,
&ndmp_job)) {

ua->info_msg("ld_storage_job failed\n");
ua->info_msg("build_storage_job failed\n");
return;
}

Expand All @@ -150,18 +145,16 @@ void do_ndmp_native_storage_status(UAContext *ua, STORERES *store, char *cmd)

ndmp_do_query(ua, &ndmp_job, me->ndmp_loglevel, query_cbs);

ndmp_deviceinfo *deviceinfo = NULL;
ndmp_deviceinfo_t *deviceinfo = NULL;

ua->info_msg("Devices for storage %s:(%s)\n", store->name(), store->rss->smc_ident);

/* debug output */
int i=0;
if (store->ndmp_deviceinfo) {
foreach_alist(deviceinfo, store->ndmp_deviceinfo){
ua->info_msg("Device %d: %s Model: %s\n", i++, deviceinfo->device, deviceinfo->model );
}
} else {
ua->info_msg("deviceinfo for storage %s empty!\n", store->name());
for (auto devinfo = store->rss->ndmp_deviceinfo->begin();
devinfo != store->rss->ndmp_deviceinfo->end();
devinfo++) {
ua->info_msg("Device %d: %s Model: %s\n", i++, &devinfo->device, &devinfo->model );
}
}

Expand Down Expand Up @@ -737,16 +730,15 @@ char *lookup_ndmp_drivename_by_number(STORERES *store, drive_number_t drivenumbe
int lookup_ndmp_driveindex_by_name(STORERES *store, char *drivename)
{
int cnt = 0;
ndmp_deviceinfo *devinfo = NULL;

if (store->ndmp_deviceinfo) {
foreach_alist(devinfo, store->ndmp_deviceinfo) {
if (bstrcmp(drivename, devinfo->device)) {
for (auto devinfo = store->rss->ndmp_deviceinfo->begin();
devinfo != store->rss->ndmp_deviceinfo->end();
devinfo++) {
//if (bstrcmp(drivename, devinfo->device.c_str())) {
if ((drivename == devinfo->device)) {
return cnt;
}
cnt++;
}
}
return -1;
}

Expand Down
1 change: 1 addition & 0 deletions src/include/bareos.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ extern "C" {
* Local Bareos includes. Be sure to put all the system includes before these.
*/
#define _GLIBCXX_GTHREAD_USE_WEAK 0
#include <string>
#include <list>


Expand Down

0 comments on commit 27af3c9

Please sign in to comment.