Skip to content

Commit

Permalink
cats: added function to get all volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
alaaeddineelamri authored and pstorz committed Dec 14, 2021
1 parent 6751255 commit 2e9c5ab
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/src/cats/cats.h
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ class BareosDb : public BareosDbQueryEnum {
FileDbRecord* fdbr);
int GetFilesetRecord(JobControlRecord* jcr, FileSetDbRecord* fsr);
bool GetMediaRecord(JobControlRecord* jcr, MediaDbRecord* mr);
bool GetAllVolumeNames(db_list_ctx* volumenames);
int GetNumMediaRecords(JobControlRecord* jcr);
int GetNumPoolRecords(JobControlRecord* jcr);
int GetPoolIds(JobControlRecord* jcr, int* num_ids, DBId_t** ids);
Expand Down
21 changes: 21 additions & 0 deletions core/src/cats/sql_get.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,27 @@ bool BareosDb::GetQueryDbids(JobControlRecord* jcr,
}


/**
* Get all volumes names
*
* Returns: false: on failure
* true: on success
*/
bool BareosDb::GetAllVolumeNames(db_list_ctx* volumenames)
{
PoolMem query(PM_MESSAGE);
volumenames->clear();
Mmsg(query,
"SELECT DISTINCT Media.VolumeName FROM Media ORDER BY VolumeName");

if (!SqlQueryWithHandler(query.c_str(), DbListHandler, volumenames)) {
Emsg1(M_ERROR, 0, "Could not retrieve volume names: ERR=%s\n",
sql_strerror());
return false;
}
return true;
}

/**
* Get Media Record
*
Expand Down

0 comments on commit 2e9c5ab

Please sign in to comment.