Skip to content
Snippets Groups Projects
Commit 017d0d64 authored by Lasse Tjernaes Wardenaer's avatar Lasse Tjernaes Wardenaer
Browse files

Resolve "Improve error message if vid does not exist when running cta-verify-file"

parent 7d687061
No related branches found
No related tags found
No related merge requests found
Pipeline #44368 failed
......@@ -2,6 +2,7 @@
## Summary
### Features
- cta/CTA#224 - Improve error message for cta-verify-file whn VID does not exist
### Bug Fixes
- cta/CTA#234 - Replace stoi with toUint64 in standalone cli tool
......
......@@ -31,6 +31,9 @@ using namespace cta::cliTool;
const std::string g_config_file = "/etc/cta/cta-cli.conf";
// Global variable from CtaCatalogueFetch
extern std::list<std::string> g_listedVids;
/*
* Fill a Notification message from the command-line parameters and stdin
*
......@@ -140,6 +143,17 @@ void sendVerifyRequest(const CmdLineArgs &cmdLineArgs, const std::string &archiv
google::protobuf::ShutdownProtobufLibrary();
}
/*
* Checks if the provided vid exists
*/
void vidExists(const std::string &vid, const XrdSsiPb::Config &config) {
auto serviceProviderPtr = std::make_unique<XrdSsiPbServiceType>(config);
bool vidExists = CatalogueFetch::vidExists(vid, serviceProviderPtr);
if(!vidExists) {
throw std::runtime_error("The provided --vid does not exist in the Catalogue.");
}
}
/*
* Sends a Notification to the CTA XRootD SSI server
......@@ -181,6 +195,8 @@ int exceptionThrowingMain(int argc, char *const *const argv)
const XrdSsiPb::Config config = getConfig();
vidExists(cmdLineArgs.m_vid.value(), config);
for(const auto &archiveFileId : archiveFileIds) {
sendVerifyRequest(cmdLineArgs, archiveFileId, config);
}
......
......@@ -138,7 +138,7 @@ std::tuple<std::string,std::string> CatalogueFetch::getInstanceAndFid(const std:
return listedTapeFile;
}
std::list<std::string> CatalogueFetch::getVids(std::unique_ptr<XrdSsiPbServiceType> &serviceProviderPtr, cta::log::StdoutLogger &log) {
bool CatalogueFetch::vidExists(const std::string &vid, std::unique_ptr<XrdSsiPbServiceType> &serviceProviderPtr) {
cta::xrd::Request request;
auto admincmd = request.mutable_admincmd();
......@@ -147,13 +147,16 @@ std::list<std::string> CatalogueFetch::getVids(std::unique_ptr<XrdSsiPbServiceTy
admincmd->set_cmd(cta::admin::AdminCmd::CMD_TAPE);
admincmd->set_subcmd(cta::admin::AdminCmd::SUBCMD_LS);
auto new_opt = admincmd->add_option_bool();
new_opt->set_key(cta::admin::OptionBoolean::ALL);
new_opt->set_value(true);
auto new_opt = admincmd->add_option_str();
new_opt->set_key(cta::admin::OptionString::VID);
new_opt->set_value(vid);
handleResponse(request, serviceProviderPtr);
return g_listedVids;
if(g_listedVids.empty()) {
return false;
}
return true;
}
void CatalogueFetch::handleResponse(const cta::xrd::Request &request, std::unique_ptr<XrdSsiPbServiceType> &serviceProviderPtr) {
......
......@@ -50,9 +50,9 @@ public:
* Fetches the vids form the CTA catalogue
*
* @param serviceProviderPtr Service provider for communication with the catalogue.
* @return A list of vids.
* @return True if vid exists, false if it does not exist
*/
static std::list<std::string> getVids(std::unique_ptr<XrdSsiPbServiceType> &serviceProviderPtr, cta::log::StdoutLogger &log);
static bool vidExists(const std::string &vid, std::unique_ptr<XrdSsiPbServiceType> &serviceProviderPtr);
private:
static void handleResponse(const cta::xrd::Request &request, std::unique_ptr<XrdSsiPbServiceType> &serviceProviderPtr);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment