Commit 258c329a authored by Steven Murray's avatar Steven Murray
Browse files

bug #104608: RFE: Remove the initial state column from TPCONFIG

Removed the initial state column from the TPCONFIG file for both the
taped and tapeserverd daemons.
parent 410b21ff
...@@ -107,7 +107,7 @@ void castor::tape::tapeserver::daemon::DriveCatalogue::enterTpconfigLine( ...@@ -107,7 +107,7 @@ void castor::tape::tapeserver::daemon::DriveCatalogue::enterTpconfigLine(
entry.dgn = line.dgn; entry.dgn = line.dgn;
entry.devFilename = line.devFilename; entry.devFilename = line.devFilename;
entry.densities.push_back(line.density); entry.densities.push_back(line.density);
entry.state = initial2DriveState(line.initialState); entry.state = DRIVE_STATE_DOWN;
entry.librarySlot = line.librarySlot; entry.librarySlot = line.librarySlot;
entry.devType = line.devType; entry.devType = line.devType;
m_drives[line.unitName] = entry; m_drives[line.unitName] = entry;
...@@ -123,32 +123,6 @@ void castor::tape::tapeserver::daemon::DriveCatalogue::enterTpconfigLine( ...@@ -123,32 +123,6 @@ void castor::tape::tapeserver::daemon::DriveCatalogue::enterTpconfigLine(
} }
} }
//-----------------------------------------------------------------------------
// initial2DriveState
//-----------------------------------------------------------------------------
castor::tape::tapeserver::daemon::DriveCatalogue::DriveState
castor::tape::tapeserver::daemon::DriveCatalogue::initial2DriveState(
const utils::TpconfigLine::InitialState initialState) const {
switch(initialState) {
case utils::TpconfigLine::TPCONFIG_DRIVE_NONE:
{
castor::exception::Exception ex;
ex.getMessage() << "Failed to convert initial drive state"
": TPCONFIG_DRIVE_NONE is invalid";
throw ex;
}
case utils::TpconfigLine::TPCONFIG_DRIVE_UP: return DRIVE_STATE_UP;
case utils::TpconfigLine::TPCONFIG_DRIVE_DOWN: return DRIVE_STATE_DOWN;
default:
{
castor::exception::Exception ex;
ex.getMessage() << "Failed to convert initial drive state"
": Unknown initial drive state: initialState=" << initialState;
throw ex;
}
}
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// checkTpconfigLine // checkTpconfigLine
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -158,7 +132,6 @@ void castor::tape::tapeserver::daemon::DriveCatalogue::checkTpconfigLine( ...@@ -158,7 +132,6 @@ void castor::tape::tapeserver::daemon::DriveCatalogue::checkTpconfigLine(
checkTpconfigLineDgn(catalogueEntry.dgn, line); checkTpconfigLineDgn(catalogueEntry.dgn, line);
checkTpconfigLineDevFilename(catalogueEntry.devFilename, line); checkTpconfigLineDevFilename(catalogueEntry.devFilename, line);
checkTpconfigLineDensity(catalogueEntry.densities, line); checkTpconfigLineDensity(catalogueEntry.densities, line);
checkTpconfigLineInitialState(catalogueEntry.state, line);
checkTpconfigLineLibrarySlot(catalogueEntry.librarySlot, line); checkTpconfigLineLibrarySlot(catalogueEntry.librarySlot, line);
checkTpconfigLineDevType(catalogueEntry.devType, line); checkTpconfigLineDevType(catalogueEntry.devType, line);
} }
...@@ -212,22 +185,6 @@ void castor::tape::tapeserver::daemon::DriveCatalogue::checkTpconfigLineDensity( ...@@ -212,22 +185,6 @@ void castor::tape::tapeserver::daemon::DriveCatalogue::checkTpconfigLineDensity(
} }
} }
//-----------------------------------------------------------------------------
// checkTpconfigLineInitialState
//-----------------------------------------------------------------------------
void castor::tape::tapeserver::daemon::DriveCatalogue::
checkTpconfigLineInitialState(const DriveState catalogueInitialState,
const utils::TpconfigLine &line) {
if(catalogueInitialState != initial2DriveState(line.initialState)) {
castor::exception::Exception ex;
ex.getMessage() << "Invalid TPCONFIG line"
": A tape drive can only have one initial state"
": catalogueInitialState=" << catalogueInitialState <<
" lineInitialState=" << line.initialState;
throw ex;
}
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// checkTpconfigLineLibrarySlot // checkTpconfigLineLibrarySlot
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
......
...@@ -626,18 +626,6 @@ private: ...@@ -626,18 +626,6 @@ private:
*/ */
void enterTpconfigLine(const utils::TpconfigLine &line) ; void enterTpconfigLine(const utils::TpconfigLine &line) ;
/**
* Converts the specified TPCONFIG initial drive-state to a drive-catalogue
* drive-state.
*
* This method throws an exception if the conversion fails.
*
* @param initialState The TPCONFIG initial drive-state.
* @return The drive-catalogue drive-state.
*/
DriveState initial2DriveState(
const utils::TpconfigLine::InitialState initialState) const;
/** /**
* Checks the semantics of the specified TPCONFIG line against the specified * Checks the semantics of the specified TPCONFIG line against the specified
* current catalogue entry. * current catalogue entry.
......
...@@ -61,13 +61,13 @@ TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest, goodDayPopulate) { ...@@ -61,13 +61,13 @@ TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest, goodDayPopulate) {
castor::tape::utils::TpconfigLines lines; castor::tape::utils::TpconfigLines lines;
lines.push_back(castor::tape::utils::TpconfigLine( lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT1", "DGN1", "DEV1", "DEN11", "down", "SLOT1", "DEVTYPE1")); "UNIT1", "DGN1", "DEV1", "DEN11", "SLOT1", "DEVTYPE1"));
lines.push_back(castor::tape::utils::TpconfigLine( lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT1", "DGN1", "DEV1", "DEN12", "down", "SLOT1", "DEVTYPE1")); "UNIT1", "DGN1", "DEV1", "DEN12", "SLOT1", "DEVTYPE1"));
lines.push_back(castor::tape::utils::TpconfigLine( lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT2", "DGN2", "DEV2", "DEN21", "up", "SLOT2", "DEVTYPE2")); "UNIT2", "DGN2", "DEV2", "DEN21", "SLOT2", "DEVTYPE2"));
lines.push_back(castor::tape::utils::TpconfigLine( lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT2", "DGN2", "DEV2", "DEN22", "up", "SLOT2", "DEVTYPE2")); "UNIT2", "DGN2", "DEV2", "DEN22", "SLOT2", "DEVTYPE2"));
DriveCatalogue catalogue; DriveCatalogue catalogue;
ASSERT_NO_THROW(catalogue.populateCatalogue(lines)); ASSERT_NO_THROW(catalogue.populateCatalogue(lines));
...@@ -154,7 +154,7 @@ TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest, goodDayPopulate) { ...@@ -154,7 +154,7 @@ TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest, goodDayPopulate) {
{ {
DriveCatalogue::DriveState fromCatalogue = DriveCatalogue::DRIVE_STATE_INIT; DriveCatalogue::DriveState fromCatalogue = DriveCatalogue::DRIVE_STATE_INIT;
ASSERT_NO_THROW(fromCatalogue = catalogue.getState("UNIT2")); ASSERT_NO_THROW(fromCatalogue = catalogue.getState("UNIT2"));
ASSERT_EQ(DriveCatalogue::DRIVE_STATE_UP, fromCatalogue); ASSERT_EQ(DriveCatalogue::DRIVE_STATE_DOWN, fromCatalogue);
} }
{ {
...@@ -176,24 +176,9 @@ TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest, ...@@ -176,24 +176,9 @@ TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest,
castor::tape::utils::TpconfigLines lines; castor::tape::utils::TpconfigLines lines;
lines.push_back(castor::tape::utils::TpconfigLine( lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT1", "DGN1", "DEV", "DEN1", "down", "SLOT", "DEVTYPE")); "UNIT1", "DGN1", "DEV", "DEN1", "SLOT", "DEVTYPE"));
lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT1", "DGN2", "DEV", "DEN2", "down", "SLOT", "DEVTYPE"));
DriveCatalogue catalogue;
ASSERT_THROW(catalogue.populateCatalogue(lines),
castor::exception::Exception);
}
TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest,
initialStateMismatchPopulate) {
using namespace castor::tape::tapeserver::daemon;
castor::tape::utils::TpconfigLines lines;
lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT1", "DGN", "DEV", "DEN1", "down", "SLOT", "DEVTYPE"));
lines.push_back(castor::tape::utils::TpconfigLine( lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT1", "DGN", "DEV", "DEN2", "up", "SLOT", "DEVTYPE")); "UNIT1", "DGN2", "DEV", "DEN2", "SLOT", "DEVTYPE"));
DriveCatalogue catalogue; DriveCatalogue catalogue;
ASSERT_THROW(catalogue.populateCatalogue(lines), ASSERT_THROW(catalogue.populateCatalogue(lines),
...@@ -206,9 +191,9 @@ TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest, ...@@ -206,9 +191,9 @@ TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest,
castor::tape::utils::TpconfigLines lines; castor::tape::utils::TpconfigLines lines;
lines.push_back(castor::tape::utils::TpconfigLine( lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT1", "DGN", "DEV1", "DEN1", "down", "SLOT", "DEVTYPE")); "UNIT1", "DGN", "DEV1", "DEN1", "SLOT", "DEVTYPE"));
lines.push_back(castor::tape::utils::TpconfigLine( lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT1", "DGN", "DEV2", "DEN2", "down", "SLOT", "DEVTYPE")); "UNIT1", "DGN", "DEV2", "DEN2", "SLOT", "DEVTYPE"));
DriveCatalogue catalogue; DriveCatalogue catalogue;
ASSERT_THROW(catalogue.populateCatalogue(lines), ASSERT_THROW(catalogue.populateCatalogue(lines),
...@@ -221,9 +206,9 @@ TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest, ...@@ -221,9 +206,9 @@ TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest,
castor::tape::utils::TpconfigLines lines; castor::tape::utils::TpconfigLines lines;
lines.push_back(castor::tape::utils::TpconfigLine( lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT1", "DGN", "DEV", "DEN1", "down", "SLOT1", "DEVTYPE")); "UNIT1", "DGN", "DEV", "DEN1", "SLOT1", "DEVTYPE"));
lines.push_back(castor::tape::utils::TpconfigLine( lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT1", "DGN", "DEV", "DEN2", "down", "SLOT2", "DEVTYPE")); "UNIT1", "DGN", "DEV", "DEN2", "SLOT2", "DEVTYPE"));
DriveCatalogue catalogue; DriveCatalogue catalogue;
ASSERT_THROW(catalogue.populateCatalogue(lines), ASSERT_THROW(catalogue.populateCatalogue(lines),
...@@ -236,9 +221,9 @@ TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest, ...@@ -236,9 +221,9 @@ TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest,
castor::tape::utils::TpconfigLines lines; castor::tape::utils::TpconfigLines lines;
lines.push_back(castor::tape::utils::TpconfigLine( lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT1", "DGN", "DEV", "DEN1", "down", "SLOT", "DEVTYPE1")); "UNIT1", "DGN", "DEV", "DEN1", "SLOT", "DEVTYPE1"));
lines.push_back(castor::tape::utils::TpconfigLine( lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT1", "DGN", "DEV", "DEN2", "down", "SLOT", "DEVTYPE2")); "UNIT1", "DGN", "DEV", "DEN2", "SLOT", "DEVTYPE2"));
DriveCatalogue catalogue; DriveCatalogue catalogue;
ASSERT_THROW(catalogue.populateCatalogue(lines), ASSERT_THROW(catalogue.populateCatalogue(lines),
...@@ -261,7 +246,7 @@ TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest, completeFSTN) { ...@@ -261,7 +246,7 @@ TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest, completeFSTN) {
// Start with the tape drive in status DOWN // Start with the tape drive in status DOWN
castor::tape::utils::TpconfigLines lines; castor::tape::utils::TpconfigLines lines;
lines.push_back(castor::tape::utils::TpconfigLine( lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT", "DGN", "DEV", "DEN", "down", "SLOT", "DEVTYPE")); "UNIT", "DGN", "DEV", "DEN", "SLOT", "DEVTYPE"));
DriveCatalogue catalogue; DriveCatalogue catalogue;
ASSERT_NO_THROW(catalogue.populateCatalogue(lines)); ASSERT_NO_THROW(catalogue.populateCatalogue(lines));
ASSERT_EQ(DriveCatalogue::DRIVE_STATE_DOWN, catalogue.getState("UNIT")); ASSERT_EQ(DriveCatalogue::DRIVE_STATE_DOWN, catalogue.getState("UNIT"));
...@@ -342,7 +327,7 @@ TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest, dgnMismatchStart) { ...@@ -342,7 +327,7 @@ TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest, dgnMismatchStart) {
using namespace castor::tape::tapeserver::daemon; using namespace castor::tape::tapeserver::daemon;
castor::tape::utils::TpconfigLines lines; castor::tape::utils::TpconfigLines lines;
lines.push_back(castor::tape::utils::TpconfigLine( lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT", "DGN1", "DEV", "DEN", "down", "SLOT", "DEVTYPE")); "UNIT", "DGN1", "DEV", "DEN", "SLOT", "DEVTYPE"));
DriveCatalogue catalogue; DriveCatalogue catalogue;
ASSERT_NO_THROW(catalogue.populateCatalogue(lines)); ASSERT_NO_THROW(catalogue.populateCatalogue(lines));
...@@ -365,9 +350,9 @@ TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest, getUnitNames) { ...@@ -365,9 +350,9 @@ TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest, getUnitNames) {
using namespace castor::tape::tapeserver::daemon; using namespace castor::tape::tapeserver::daemon;
castor::tape::utils::TpconfigLines lines; castor::tape::utils::TpconfigLines lines;
lines.push_back(castor::tape::utils::TpconfigLine( lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT1", "DGN1", "DEV1", "DEN1", "down", "SLOT1", "DEVTYPE1")); "UNIT1", "DGN1", "DEV1", "DEN1", "SLOT1", "DEVTYPE1"));
lines.push_back(castor::tape::utils::TpconfigLine( lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT2", "DGN2", "DEV2", "DEN2", "up", "SLOT2", "DEVTYPE2")); "UNIT2", "DGN2", "DEV2", "DEN2", "SLOT2", "DEVTYPE2"));
DriveCatalogue catalogue; DriveCatalogue catalogue;
ASSERT_NO_THROW(catalogue.populateCatalogue(lines)); ASSERT_NO_THROW(catalogue.populateCatalogue(lines));
...@@ -386,16 +371,15 @@ TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest, getUnitNames) { ...@@ -386,16 +371,15 @@ TEST_F(castor_tape_tapeserver_daemon_DriveCatalogueTest, getUnitNames) {
{ {
std::list<std::string> downUnitNames; std::list<std::string> downUnitNames;
ASSERT_NO_THROW(downUnitNames = catalogue.getUnitNames(DriveCatalogue::DRIVE_STATE_DOWN)); ASSERT_NO_THROW(downUnitNames =
ASSERT_EQ((std::list<std::string>::size_type)1, downUnitNames.size()); catalogue.getUnitNames(DriveCatalogue::DRIVE_STATE_DOWN));
ASSERT_EQ(std::string("UNIT1"), downUnitNames.front()); ASSERT_EQ((std::list<std::string>::size_type)2, downUnitNames.size());
} }
{ {
std::list<std::string> upUnitNames; std::list<std::string> upUnitNames;
ASSERT_NO_THROW(upUnitNames = catalogue.getUnitNames(DriveCatalogue::DRIVE_STATE_UP)); ASSERT_NO_THROW(upUnitNames = catalogue.getUnitNames(DriveCatalogue::DRIVE_STATE_UP));
ASSERT_EQ((std::list<std::string>::size_type)1, upUnitNames.size()); ASSERT_EQ((std::list<std::string>::size_type)0, upUnitNames.size());
ASSERT_EQ(std::string("UNIT2"), upUnitNames.front());
} }
} }
......
...@@ -151,9 +151,9 @@ TEST(tapeServer, MountSessionGooddayRecall) { ...@@ -151,9 +151,9 @@ TEST(tapeServer, MountSessionGooddayRecall) {
utils::TpconfigLines tpConfig; utils::TpconfigLines tpConfig;
// Actual TPCONFIG lifted from prod // Actual TPCONFIG lifted from prod
tpConfig.push_back(utils::TpconfigLine("T10D6116", "T10KD6", tpConfig.push_back(utils::TpconfigLine("T10D6116", "T10KD6",
"/dev/tape_T10D6116", "8000GC", "down", "acs0,1,1,6", "T10000")); "/dev/tape_T10D6116", "8000GC", "acs0,1,1,6", "T10000"));
tpConfig.push_back(utils::TpconfigLine("T10D6116", "T10KD6", tpConfig.push_back(utils::TpconfigLine("T10D6116", "T10KD6",
"/dev/tape_T10D6116", "5000GC", "down", "acs0,1,1,6", "T10000")); "/dev/tape_T10D6116", "5000GC", "acs0,1,1,6", "T10000"));
MountSession::CastorConf castorConf; MountSession::CastorConf castorConf;
castorConf.rtcopydBufsz = 1024*1024; // 1 MB memory buffers castorConf.rtcopydBufsz = 1024*1024; // 1 MB memory buffers
castorConf.rtcopydNbBufs = 10; castorConf.rtcopydNbBufs = 10;
...@@ -217,9 +217,9 @@ TEST(tapeServer, MountSessionNoSuchDrive) { ...@@ -217,9 +217,9 @@ TEST(tapeServer, MountSessionNoSuchDrive) {
utils::TpconfigLines tpConfig; utils::TpconfigLines tpConfig;
// Actual TPCONFIG lifted from prod // Actual TPCONFIG lifted from prod
tpConfig.push_back(utils::TpconfigLine("T10D6116", "T10KD6", tpConfig.push_back(utils::TpconfigLine("T10D6116", "T10KD6",
"/dev/noSuchTape", "8000GC", "down", "acs0,1,1,6", "T10000")); "/dev/noSuchTape", "8000GC", "acs0,1,1,6", "T10000"));
tpConfig.push_back(utils::TpconfigLine("T10D6116", "T10KD6", tpConfig.push_back(utils::TpconfigLine("T10D6116", "T10KD6",
"/dev/noSuchTape", "5000GC", "down", "acs0,1,1,6", "T10000")); "/dev/noSuchTape", "5000GC", "acs0,1,1,6", "T10000"));
MountSession::CastorConf castorConf; MountSession::CastorConf castorConf;
castorConf.rtcopydBufsz = 1024; castorConf.rtcopydBufsz = 1024;
castorConf.rtcopydNbBufs = 10; castorConf.rtcopydNbBufs = 10;
...@@ -367,9 +367,9 @@ TEST(tapeServer, MountSessionGooddayMigration) { ...@@ -367,9 +367,9 @@ TEST(tapeServer, MountSessionGooddayMigration) {
utils::TpconfigLines tpConfig; utils::TpconfigLines tpConfig;
// Actual TPCONFIG lifted from prod // Actual TPCONFIG lifted from prod
tpConfig.push_back(utils::TpconfigLine("T10D6116", "T10KD6", tpConfig.push_back(utils::TpconfigLine("T10D6116", "T10KD6",
"/dev/tape_T10D6116", "8000GC", "down", "acs0,1,1,6", "T10000")); "/dev/tape_T10D6116", "8000GC", "acs0,1,1,6", "T10000"));
tpConfig.push_back(utils::TpconfigLine("T10D6116", "T10KD6", tpConfig.push_back(utils::TpconfigLine("T10D6116", "T10KD6",
"/dev/tape_T10D6116", "5000GC", "down", "acs0,1,1,6", "T10000")); "/dev/tape_T10D6116", "5000GC", "acs0,1,1,6", "T10000"));
MountSession::CastorConf castorConf; MountSession::CastorConf castorConf;
castorConf.rtcopydBufsz = 1024*1024; // 1 MB memory buffers castorConf.rtcopydBufsz = 1024*1024; // 1 MB memory buffers
castorConf.rtcopydNbBufs = 10; castorConf.rtcopydNbBufs = 10;
......
...@@ -77,7 +77,7 @@ TEST(castor_tape_tapeserver_daemon, RecallTaskInjectorNominal) { ...@@ -77,7 +77,7 @@ TEST(castor_tape_tapeserver_daemon, RecallTaskInjectorNominal) {
volume.vid="V12345"; volume.vid="V12345";
volume.volumeMode=castor::tape::tapegateway::READ; volume.volumeMode=castor::tape::tapegateway::READ;
castor::tape::tapeserver::daemon::GlobalStatusReporter gsr(initialProcess, castor::tape::tapeserver::daemon::GlobalStatusReporter gsr(initialProcess,
utils::TpconfigLine("","","","","UP","",""),"0.0.0.0",volume,lc); utils::TpconfigLine("","","","","",""),"0.0.0.0",volume,lc);
castor::tape::tapeserver::daemon::CapabilityUtilsDummy cap; castor::tape::tapeserver::daemon::CapabilityUtilsDummy cap;
FakeSingleTapeReadThread tapeRead(drive, rmc, gsr, volume, cap,lc); FakeSingleTapeReadThread tapeRead(drive, rmc, gsr, volume, cap,lc);
...@@ -135,7 +135,7 @@ TEST(castor_tape_tapeserver_daemon, RecallTaskInjectorNoFiles) { ...@@ -135,7 +135,7 @@ TEST(castor_tape_tapeserver_daemon, RecallTaskInjectorNoFiles) {
volume.volumeMode=castor::tape::tapegateway::READ; volume.volumeMode=castor::tape::tapegateway::READ;
castor::tape::tapeserver::daemon::CapabilityUtilsDummy cap; castor::tape::tapeserver::daemon::CapabilityUtilsDummy cap;
castor::tape::tapeserver::daemon::GlobalStatusReporter gsr(initialProcess, castor::tape::tapeserver::daemon::GlobalStatusReporter gsr(initialProcess,
utils::TpconfigLine("","","","","UP","",""),"0.0.0.0",volume,lc); utils::TpconfigLine("","","","","",""),"0.0.0.0",volume,lc);
FakeSingleTapeReadThread tapeRead(drive, rmc, gsr, volume,cap, lc); FakeSingleTapeReadThread tapeRead(drive, rmc, gsr, volume,cap, lc);
tapeserver::daemon::RecallReportPacker rrp(client,2,lc); tapeserver::daemon::RecallReportPacker rrp(client,2,lc);
......
...@@ -250,7 +250,6 @@ void castor::tape::tapeserver::daemon::TapeDaemon::logTpconfigLine( ...@@ -250,7 +250,6 @@ void castor::tape::tapeserver::daemon::TapeDaemon::logTpconfigLine(
log::Param("dgn", line.dgn), log::Param("dgn", line.dgn),
log::Param("devFilename", line.devFilename), log::Param("devFilename", line.devFilename),
log::Param("density", line.density), log::Param("density", line.density),
log::Param("initialState", line.initialState),
log::Param("librarySlot", line.librarySlot), log::Param("librarySlot", line.librarySlot),
log::Param("devType", line.devType)}; log::Param("devType", line.devType)};
m_log(LOG_INFO, "TPCONFIG line", params); m_log(LOG_INFO, "TPCONFIG line", params);
......
...@@ -34,46 +34,12 @@ castor::tape::utils::TpconfigLine::TpconfigLine( ...@@ -34,46 +34,12 @@ castor::tape::utils::TpconfigLine::TpconfigLine(
const std::string &dgn, const std::string &dgn,
const std::string &devFilename, const std::string &devFilename,
const std::string &density, const std::string &density,
const std::string &initialState,
const std::string &librarySlot, const std::string &librarySlot,
const std::string &devType) throw(): const std::string &devType) throw():
unitName(unitName), unitName(unitName),
dgn(dgn), dgn(dgn),
devFilename(devFilename), devFilename(devFilename),
density(density), density(density),
initialState(str2InitialState(initialState)),
librarySlot(librarySlot), librarySlot(librarySlot),
devType(devType) { devType(devType) {
} }
//------------------------------------------------------------------------------
// initialState2Str
//------------------------------------------------------------------------------
const char *castor::tape::utils::TpconfigLine::initialState2Str(
const InitialState value) throw() {
switch(value) {
case TPCONFIG_DRIVE_NONE: return "none";
case TPCONFIG_DRIVE_UP: return "up";
case TPCONFIG_DRIVE_DOWN: return "down";
default: return "unknown";
}
}
//------------------------------------------------------------------------------
// str2InitialState
//------------------------------------------------------------------------------
castor::tape::utils::TpconfigLine::InitialState
castor::tape::utils::TpconfigLine::str2InitialState(std::string str) {
castor::utils::toUpper(str);
if(str == "UP") {
return TPCONFIG_DRIVE_UP;
} else if(str == "DOWN") {
return TPCONFIG_DRIVE_DOWN;
} else {
castor::exception::Exception ex;
ex.getMessage() <<
"Failed to interpret string representation of initial tape-drive state"
": str=" << str;
throw ex;
}
}
...@@ -36,46 +36,10 @@ namespace utils { ...@@ -36,46 +36,10 @@ namespace utils {
* TPCONFIG file (/etc/castor/TPCONFIG). * TPCONFIG file (/etc/castor/TPCONFIG).
*/ */
struct TpconfigLine { struct TpconfigLine {
/**
* Enumeration of the possible initial states of a tape drive.
*/
enum InitialState {
TPCONFIG_DRIVE_NONE,
TPCONFIG_DRIVE_UP,
TPCONFIG_DRIVE_DOWN};
/**
* Returns the string representation of the specified initial state of a
* tape drive.
*
* This method is thread safe.
*
* This method does not throw an exception. If the specified state is
* unknown then an appropriately worded string is returned.
*
* @param state The initial state of a tape drive.
* @return The string representation.
*/
static const char *initialState2Str(const InitialState value) throw();
/**
* Returns the initial tape-drive state represented by the specified string.
*
* This method throws an exception if the specified string representation is
* unknown.
*
* This method will not interpret a string a representing TPCONFIG_DRIVE_NONE.
*
* @param str The string representation of the initial tape-drive state.
* @return The initial state of the tape drive.
*/
static InitialState str2InitialState(std::string str);
std::string unitName; std::string unitName;
std::string dgn; std::string dgn;
std::string devFilename; std::string devFilename;
std::string density; std::string density;
InitialState initialState;
std::string librarySlot; std::string librarySlot;
std::string devType; std::string devType;
...@@ -87,7 +51,6 @@ struct TpconfigLine { ...@@ -87,7 +51,6 @@ struct TpconfigLine {
const std::string &dgn, const std::string &dgn,
const std::string &devFilename, const std::string &devFilename,
const std::string &density, const std::string &density,
const std::string &initialState,
const std::string &librarySlot, const std::string &librarySlot,
const std::string &devType) throw(); const std::string &devType) throw();
}; // struct TpconfigLine }; // struct TpconfigLine
......
...@@ -40,65 +40,4 @@ protected: ...@@ -40,65 +40,4 @@ protected:
} }
}; };
TEST_F( castor_tape_utils_TpconfigLineTest, convertDownLowerCase) {
using namespace castor::tape::utils;
TpconfigLine::InitialState state = TpconfigLine::TPCONFIG_DRIVE_NONE;
ASSERT_NO_THROW(state = TpconfigLine::str2InitialState("down"));
ASSERT_EQ(TpconfigLine::TPCONFIG_DRIVE_DOWN, state);
}
TEST_F( castor_tape_utils_TpconfigLineTest, convertDownUpperCase) {
using namespace castor::tape::utils;
TpconfigLine::InitialState state = TpconfigLine::TPCONFIG_DRIVE_NONE;
ASSERT_NO_THROW(state = TpconfigLine::str2InitialState("DOWN"));
ASSERT_EQ(TpconfigLine::TPCONFIG_DRIVE_DOWN, state);
}
TEST_F( castor_tape_utils_TpconfigLineTest, convertDownMixedCase) {
using namespace castor::tape::utils;
TpconfigLine::InitialState state = TpconfigLine::TPCONFIG_DRIVE_NONE;
ASSERT_NO_THROW(state = TpconfigLine::str2InitialState("Down"));
ASSERT_EQ(TpconfigLine::TPCONFIG_DRIVE_DOWN, state);
}
TEST_F( castor_tape_utils_TpconfigLineTest, convertUpLowerCase) {
using namespace castor::tape::utils;
TpconfigLine::InitialState state = TpconfigLine::TPCONFIG_DRIVE_NONE;
ASSERT_NO_THROW(state = TpconfigLine::str2InitialState("up"));
ASSERT_EQ(TpconfigLine::TPCONFIG_DRIVE_UP, state);
}
TEST_F( castor_tape_utils_TpconfigLineTest, convertUpUpperCase) {
using namespace castor::tape::utils;
TpconfigLine::InitialState state = TpconfigLine::TPCONFIG_DRIVE_NONE;
ASSERT_NO_THROW(state = TpconfigLine::str2InitialState("UP"));
ASSERT_EQ(TpconfigLine::TPCONFIG_DRIVE_UP, state);
}