Skip to content
Snippets Groups Projects
Commit cb32c3e8 authored by mvelosob's avatar mvelosob
Browse files

add --loadtimeout option to cta-tape-label and increase default value (#1231)

parent 8c4388ad
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@
- cta/CTA#1217 - Schema verification should just issue an warning if there are extra indexes in the db that are not in the catalogue
- cta/CTA#1220 - Improve queued retrieve logging message
- cta/CTA#1152 - Reduce eos free space query load
- cta/CTA#1231 - Add --loadtimeout option to cta-tape-label and increase default value
### Bug fixes
- cta/CTA#1120 - Fix negative disk space reservation content
......
......@@ -73,6 +73,7 @@ int TapeLabelCmd::exceptionThrowingMain(const int argc, char *const *const argv)
params.push_back(cta::log::Param("tapeVid", cmdLineArgs.m_vid));
params.push_back(cta::log::Param("tapeOldLabel",cmdLineArgs.m_oldLabel));
params.push_back(cta::log::Param("force", boolToStr(m_force)));
params.push_back(cta::log::Param("tapeLoadTimeout", cmdLineArgs.m_tapeLoadTimeout));
m_log(cta::log::INFO, "Label session started", params);
readAndSetConfiguration(getUsername(), cmdLineArgs.m_vid, cmdLineArgs.m_oldLabel);
......@@ -96,7 +97,7 @@ int TapeLabelCmd::exceptionThrowingMain(const int argc, char *const *const argv)
};
mountTape(m_vid);
waitUntilTapeLoaded(drive, TAPE_LABEL_UNITREADY_TIMEOUT);
waitUntilTapeLoaded(drive, cmdLineArgs.m_tapeLoadTimeout);
int returnCode = 0;
if(drive.isWriteProtected()) {
......
......@@ -39,6 +39,7 @@ TapeLabelCmdLineArgs::TapeLabelCmdLineArgs(const int argc, char *const *const ar
{"vid", required_argument, nullptr, 'v'},
{"oldlabel", required_argument, nullptr, 'o'},
{"debug", no_argument, nullptr, 'd'},
{"loadtimeout", required_argument, nullptr, 't'},
{"force", no_argument, nullptr, 'f'},
{"help", no_argument, nullptr, 'h'},
{nullptr, 0, nullptr, 0}
......@@ -50,7 +51,7 @@ TapeLabelCmdLineArgs::TapeLabelCmdLineArgs(const int argc, char *const *const ar
int opt = 0;
while((opt = getopt_long(argc, argv, ":v:o:hdf", longopts, nullptr)) != -1) {
while((opt = getopt_long(argc, argv, ":v:o:t:hdf", longopts, nullptr)) != -1) {
switch(opt) {
case 'v':
if (strlen(optarg) > CA_MAXVIDLEN) {
......@@ -69,7 +70,25 @@ TapeLabelCmdLineArgs::TapeLabelCmdLineArgs(const int argc, char *const *const ar
throw ex;
} else {
m_oldLabel = std::string(optarg);
utils::toUpper(m_oldLabel);
utils::toUpper(m_oldLabel);
}
break;
case 't':
try {
m_tapeLoadTimeout = std::stoul(optarg, nullptr, 0);
} catch (std::invalid_argument &) {
exception::CommandLineNotParsed ex;
ex.getMessage() << "Invalid value for the tape load timeout: " << optarg;
throw ex;
} catch (std::out_of_range &) {
exception::CommandLineNotParsed ex;
ex.getMessage() << "Too large value for the tape load timeout: " << optarg;
throw ex;
}
if (!m_tapeLoadTimeout) {
exception::CommandLineNotParsed ex;
ex.getMessage() << "The tape load timeout cannot be 0";
throw ex;
}
break;
case 'h':
......@@ -128,12 +147,13 @@ void TapeLabelCmdLineArgs::printUsage(std::ostream &os) {
"Usage:" << std::endl <<
" cta-tape-label [options] --vid/-v VID" << std::endl <<
"Where:" << std::endl <<
" -v, --vid The VID of the tape to be labeled" << std::endl <<
" -v, --vid The VID of the tape to be labeled" << std::endl <<
"Options:" <<std::endl <<
" -o, --oldlabel The vid of the current tape label on the tape if it is not the same as VID" << std::endl <<
" -h, --help Print this help message and exit" << std::endl <<
" -d, --debug Print more logs for label operations" << std::endl <<
" -f, --force Force labeling for not-blank tapes for testing purpose and without label checks. Must only be used manually." << std::endl;
" -o, --oldlabel The vid of the current tape label on the tape if it is not the same as VID" << std::endl <<
" -t, --loadtimeout The timeout to load the tape in the drive slot in seconds (default: 2 hours)" << std::endl <<
" -h, --help Print this help message and exit" << std::endl <<
" -d, --debug Print more logs for label operations" << std::endl <<
" -f, --force Force labeling for not-blank tapes for testing purpose and without label checks. Must only be used manually." << std::endl;
}
} // namespace tapelabel
......
......@@ -54,6 +54,11 @@ struct TapeLabelCmdLineArgs {
*/
bool m_force;
/**
* The timeout to load the tape in the drive slot in seconds
*/
uint64_t m_tapeLoadTimeout = 2 * 60 * 60; // 2 hours
/**
* Constructor that parses the specified command-line arguments.
*
......
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