Commit 41ef5629 authored by Steven Murray's avatar Steven Murray
Browse files

CASTOR-4772 The code to parse the name of a slot in a tape library should be...

CASTOR-4772 The code to parse the name of a slot in a tape library should be implemented in one place

Added TapeLibraryType and TapeLibrarySlot.
parent 52f2f705
......@@ -22,6 +22,7 @@
#pragma once
#include "castor/exception/Exception.hpp"
#include "castor/tape/utils/TapeLibrarySlot.hpp"
#include <string>
......@@ -61,27 +62,24 @@ public:
* drive in the specified library slot.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot in one of the following three forms:
* "acs@rmc_host,ACS_NUMBER,LSM_NUMBER,PANEL_NUMBER,TRANSPORT_NUMBER",
* "manual" or "smc@rmc_host,drive_ordinal".
* @param librarySlot The tape library slot containing the tape drive.
* @param mode The access mode in which the specified tape should be mounted.
* Please note that the value of this parameter is honored in a best effort
* fashion. If the library and drive combination do not support specifying
* the access mode, then this parameter will be ignored.
*/
virtual void mountTape(const std::string &vid, const std::string &librarySlot,
const MountMode mode) = 0;
virtual void mountTape(const std::string &vid,
const tape::utils::TapeLibrarySlot &librarySlot, const MountMode mode) = 0;
/**
* Asks the remote media-changer daemon to unmount the specified tape from the
* drive in the specified library slot.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot in one of the following three forms:
* "acs@rmc_host,ACS_NUMBER,LSM_NUMBER,PANEL_NUMBER,TRANSPORT_NUMBER",
* "manual" or "smc@rmc_host,drive_ordinal".
* @param librarySlot The tape library slot containing the tape drive.
*/
virtual void unmountTape(const std::string &vid, const std::string &librarySlot) = 0;
virtual void unmountTape(const std::string &vid,
const tape::utils::TapeLibrarySlot &librarySlot) = 0;
}; // class RmcProxy
......
......@@ -31,11 +31,12 @@ castor::legacymsg::RmcProxyDummy::~RmcProxyDummy() throw() {
// mountTape
//------------------------------------------------------------------------------
void castor::legacymsg::RmcProxyDummy::mountTape(const std::string &vid,
const std::string &librarySlot, const MountMode mode) {
const tape::utils::TapeLibrarySlot &librarySlot, const MountMode mode) {
}
//------------------------------------------------------------------------------
// unmountTape
//------------------------------------------------------------------------------
void castor::legacymsg::RmcProxyDummy::unmountTape(const std::string &vid, const std::string &librarySlot) {
void castor::legacymsg::RmcProxyDummy::unmountTape(const std::string &vid,
const tape::utils::TapeLibrarySlot &librarySlot) {
}
......@@ -44,27 +44,24 @@ public:
* drive in the specified library slot.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot in one of the following three forms:
* "acs@rmc_host,ACS_NUMBER,LSM_NUMBER,PANEL_NUMBER,TRANSPORT_NUMBER",
* "manual" or "smc@rmc_host,drive_ordinal".
* @param librarySlot The tape library slot containing the tape drive.
* @param mode The access mode in which the specified tape should be mounted.
* Please note that the value of this parameter is honored in a best effort
* fashion. If the library and drive combination do not support specifying
* the access mode, then this parameter will be ignored.
*/
void mountTape(const std::string &vid, const std::string &librarySlot,
const MountMode mode);
void mountTape(const std::string &vid,
const tape::utils::TapeLibrarySlot &librarySlot, const MountMode mode);
/**
* Asks the remote media-changer daemon to unmount the specified tape from the
* drive in the specified library slot.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot in one of the following three forms:
* "acs@rmc_host,ACS_NUMBER,LSM_NUMBER,PANEL_NUMBER,TRANSPORT_NUMBER",
* "manual" or "smc@rmc_host,drive_ordinal".
* @param librarySlot The tape library slot containing the tape drive.
*/
void unmountTape(const std::string &vid, const std::string &librarySlot) ;
void unmountTape(const std::string &vid,
const tape::utils::TapeLibrarySlot &librarySlot);
}; // class RmcProxyDummy
......
......@@ -49,7 +49,7 @@ castor::legacymsg::RmcProxyTcpIp::~RmcProxyTcpIp() throw() {
// mountTape
//------------------------------------------------------------------------------
void castor::legacymsg::RmcProxyTcpIp::mountTape(const std::string &vid,
const std::string &librarySlot, const MountMode mode) {
const tape::utils::TapeLibrarySlot &librarySlot, const MountMode mode) {
// Verify parameters
if(vid.empty()) {
castor::exception::Exception ex;
......@@ -63,51 +63,28 @@ void castor::legacymsg::RmcProxyTcpIp::mountTape(const std::string &vid,
vid.length();
throw ex;
}
if(librarySlot.empty()) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to mount tape: librarySlot is an empty string"
": vid=" << vid;
throw ex;
}
// Dispatch the appropriate helper method depending on library slot type
switch(getLibrarySlotType(librarySlot)) {
case RMC_LIBRARY_SLOT_TYPE_ACS:
mountTapeAcs(vid, librarySlot);
switch(librarySlot.getLibraryType()) {
case tape::utils::TAPE_LIBRARY_TYPE_ACS:
mountTapeAcs(vid, librarySlot.str());
break;
case RMC_LIBRARY_SLOT_TYPE_MANUAL:
case tape::utils::TAPE_LIBRARY_TYPE_MANUAL:
mountTapeManual(vid);
break;
case RMC_LIBRARY_SLOT_TYPE_SCSI:
mountTapeScsi(vid, librarySlot);
case tape::utils::TAPE_LIBRARY_TYPE_SCSI:
mountTapeScsi(vid, librarySlot.str());
break;
default:
{
castor::exception::Exception ex;
ex.getMessage() << "Failed to mount tape: Unknown library slot type"
": vid=" << vid << " librarySlot=" << librarySlot;
ex.getMessage() << "Failed to mount tape: Unexpected library slot type"
": vid=" << vid << " librarySlot=" << librarySlot.str();
throw ex;
}
}
}
//------------------------------------------------------------------------------
// getLibrarySlotType
//------------------------------------------------------------------------------
castor::legacymsg::RmcProxyTcpIp::RmcLibrarySlotType
castor::legacymsg::RmcProxyTcpIp::getLibrarySlotType(
const std::string &librarySlot) throw() {
if(0 == librarySlot.find("acs@")) {
return RMC_LIBRARY_SLOT_TYPE_ACS;
} else if(0 == librarySlot.find("manual")) {
return RMC_LIBRARY_SLOT_TYPE_MANUAL;
} else if(0 == librarySlot.find("smc@")) {
return RMC_LIBRARY_SLOT_TYPE_SCSI;
} else {
return RMC_LIBRARY_SLOT_TYPE_UNKNOWN;
}
}
//------------------------------------------------------------------------------
// mountTapeAcs
//------------------------------------------------------------------------------
......@@ -186,7 +163,7 @@ void castor::legacymsg::RmcProxyTcpIp::mountTapeScsi(const std::string &vid,
// unmountTape
//------------------------------------------------------------------------------
void castor::legacymsg::RmcProxyTcpIp::unmountTape(const std::string &vid,
const std::string &librarySlot) {
const tape::utils::TapeLibrarySlot &librarySlot) {
// Verify parameters
if(vid.empty()) {
castor::exception::Exception ex;
......@@ -199,29 +176,23 @@ void castor::legacymsg::RmcProxyTcpIp::unmountTape(const std::string &vid,
": vid=" << vid << " maxLen=" << CA_MAXVIDLEN << " actualLen=" << vid.length();
throw ex;
}
if(librarySlot.empty()) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to unmount tape: librarySlot is an empty string"
": vid=" << vid;
throw ex;
}
// Dispatch the appropriate helper method depending on library slot type
switch(getLibrarySlotType(librarySlot)) {
case RMC_LIBRARY_SLOT_TYPE_ACS:
unmountTapeAcs(vid, librarySlot);
switch(librarySlot.getLibraryType()) {
case tape::utils::TAPE_LIBRARY_TYPE_ACS:
unmountTapeAcs(vid, librarySlot.str());
break;
case RMC_LIBRARY_SLOT_TYPE_MANUAL:
case tape::utils::TAPE_LIBRARY_TYPE_MANUAL:
unmountTapeManual(vid);
break;
case RMC_LIBRARY_SLOT_TYPE_SCSI:
unmountTapeScsi(vid, librarySlot);
case tape::utils::TAPE_LIBRARY_TYPE_SCSI:
unmountTapeScsi(vid, librarySlot.str());
break;
default:
{
castor::exception::Exception ex;
ex.getMessage() << "Failed to unmount tape: Unknown library slot type"
": vid=" << vid << " librarySlot=" << librarySlot;
ex.getMessage() << "Failed to unmount tape: Unexpected library slot type"
": vid=" << vid << " librarySlot=" << librarySlot.str();
throw ex;
}
}
......
......@@ -60,46 +60,24 @@ public:
* drive in the specified library slot.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot in one of the following three forms:
* "acs@rmc_host,ACS_NUMBER,LSM_NUMBER,PANEL_NUMBER,TRANSPORT_NUMBER",
* "manual" or "smc@rmc_host,drive_ordinal".
* @param librarySlot The tape library slot containing the tape drive.
* @param mode The access mode in which the specified tape should be mounted.
* Please note that the value of this parameter is honored in a best effort
* fashion. If the library and drive combination do not support specifying
* the access mode, then this parameter will be ignored.
*/
void mountTape(const std::string &vid, const std::string &librarySlot,
const MountMode mode);
void mountTape(const std::string &vid,
const tape::utils::TapeLibrarySlot &librarySlot, const MountMode mode);
/**
* Asks the remote media-changer daemon to unmount the specified tape from the
* drive in the specified library slot.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot in one of the following three forms:
* "acs@rmc_host,ACS_NUMBER,LSM_NUMBER,PANEL_NUMBER,TRANSPORT_NUMBER",
* "manual" or "smc@rmc_host,drive_ordinal".
* @param librarySlot The tape library slot containing the tape drive.
*/
void unmountTape(const std::string &vid, const std::string &librarySlot) ;
/**
* Enumeration of the different types of library slot.
*/
enum RmcLibrarySlotType {
RMC_LIBRARY_SLOT_TYPE_ACS,
RMC_LIBRARY_SLOT_TYPE_MANUAL,
RMC_LIBRARY_SLOT_TYPE_SCSI,
RMC_LIBRARY_SLOT_TYPE_UNKNOWN};
/**
* Returns the type of the specified string representation of a library slot.
*
* @param librarySlot The library slot in one of the following three forms:
* "acs@rmc_host,ACS_NUMBER,LSM_NUMBER,PANEL_NUMBER,TRANSPORT_NUMBER",
* "manual" or "smc@rmc_host,drive_ordinal".
* @return The library slot type.
*/
RmcLibrarySlotType getLibrarySlotType(const std::string &librarySlot) throw();
void unmountTape(const std::string &vid,
const tape::utils::TapeLibrarySlot &librarySlot);
protected:
......
......@@ -24,6 +24,7 @@ cmake_minimum_required (VERSION 2.6)
add_subdirectory (gatewayprotocol)
add_subdirectory (label)
add_subdirectory (mediachanger)
add_subdirectory (reactor)
add_subdirectory (rmc)
add_subdirectory (tapebridge)
......
......@@ -27,7 +27,9 @@ cmake_minimum_required (VERSION 2.6)
################################################################################
set (LABEL_SRC_FILES
LabelCmd.cpp
LabelMain.cpp)
LabelMain.cpp
../utils/TapeLibrarySlot.cpp
../utils/TapeLibraryType.cpp)
add_executable (castor-tape-label ${LABEL_SRC_FILES})
target_link_libraries (castor-tape-label castorclient castorlegacymsg)
install (TARGETS castor-tape-label DESTINATION ${CASTOR_DEST_BIN_DIR})
......
#
# castor/tape/reactor/CMakeLists.txt
#
# This file is part of the Castor project.
# See http://castor.web.cern.ch/castor
#
......@@ -18,7 +15,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
# Steven.Murray@cern.ch
# @author Castor Dev team, castor-dev@cern.ch
#
cmake_minimum_required (VERSION 2.6)
......
......@@ -30,7 +30,9 @@ if (${COMPILE_SERVER} STREQUAL "1")
AcceptHandler.cpp
ConnectionHandler.cpp
RmcDaemon.cpp
RmcDaemonMain.cpp)
RmcDaemonMain.cpp
../utils/TapeLibrarySlot.cpp
../utils/TapeLibraryType.cpp)
add_executable (newrmcd ${RMCD_SRC_FILES})
target_link_libraries (newrmcd castorclient castorcommon castorlegacymsg
castorserver castortapereactor zmq)
......
......@@ -48,13 +48,13 @@ TEST_F(castor_tape_tapeserver_daemon_CatalogueTest, goodDayPopulate) {
castor::tape::utils::TpconfigLines lines;
lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT1", "DGN1", "DEV1", "DEN11", "SLOT1", "DEVTYPE1"));
"UNIT1", "DGN1", "DEV1", "DEN11", "manual@SLOT1", "DEVTYPE1"));
lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT1", "DGN1", "DEV1", "DEN12", "SLOT1", "DEVTYPE1"));
"UNIT1", "DGN1", "DEV1", "DEN12", "manual@SLOT1", "DEVTYPE1"));
lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT2", "DGN2", "DEV2", "DEN21", "SLOT2", "DEVTYPE2"));
"UNIT2", "DGN2", "DEV2", "DEN21", "manual@SLOT2", "DEVTYPE2"));
lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT2", "DGN2", "DEV2", "DEN22", "SLOT2", "DEVTYPE2"));
"UNIT2", "DGN2", "DEV2", "DEN22", "manual@SLOT2", "DEVTYPE2"));
castor::tape::utils::DriveConfigMap driveConfigs;
driveConfigs.enterTpconfigLines(lines);
......@@ -102,7 +102,9 @@ TEST_F(castor_tape_tapeserver_daemon_CatalogueTest, goodDayPopulate) {
}
ASSERT_EQ(CatalogueDrive::DRIVE_STATE_DOWN, unit1.getState());
ASSERT_EQ(std::string("SLOT1"), unit1Config.librarySlot);
ASSERT_EQ(castor::tape::utils::TAPE_LIBRARY_TYPE_MANUAL,
unit1Config.librarySlot.getLibraryType());
ASSERT_EQ(std::string("manual@SLOT1"), unit1Config.librarySlot.str());
ASSERT_EQ(std::string("DEVTYPE1"), unit1Config.devType);
///////////////////
......@@ -126,7 +128,9 @@ TEST_F(castor_tape_tapeserver_daemon_CatalogueTest, goodDayPopulate) {
}
ASSERT_EQ(CatalogueDrive::DRIVE_STATE_DOWN, unit2.getState());
ASSERT_EQ(std::string("SLOT2"), unit2Config.librarySlot);
ASSERT_EQ(castor::tape::utils::TAPE_LIBRARY_TYPE_MANUAL,
unit2Config.librarySlot.getLibraryType());
ASSERT_EQ(std::string("manual@SLOT2"), unit2Config.librarySlot.str());
ASSERT_EQ(std::string("DEVTYPE2"), unit2Config.devType);
}
......@@ -153,7 +157,7 @@ TEST_F(castor_tape_tapeserver_daemon_CatalogueTest, dgnMismatchStart) {
using namespace castor::tape::tapeserver::daemon;
castor::tape::utils::TpconfigLines lines;
lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT", "DGN1", "DEV", "DEN", "SLOT", "DEVTYPE"));
"UNIT", "DGN1", "DEV", "DEN", "manual@SLOT", "DEVTYPE"));
castor::tape::utils::DriveConfigMap driveConfigs;
driveConfigs.enterTpconfigLines(lines);
......@@ -189,9 +193,9 @@ TEST_F(castor_tape_tapeserver_daemon_CatalogueTest, getUnitNames) {
using namespace castor::tape::tapeserver::daemon;
castor::tape::utils::TpconfigLines lines;
lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT1", "DGN1", "DEV1", "DEN1", "SLOT1", "DEVTYPE1"));
"UNIT1", "DGN1", "DEV1", "DEN1", "manual@SLOT1", "DEVTYPE1"));
lines.push_back(castor::tape::utils::TpconfigLine(
"UNIT2", "DGN2", "DEV2", "DEN2", "SLOT2", "DEVTYPE2"));
"UNIT2", "DGN2", "DEV2", "DEN2", "manual@SLOT2", "DEVTYPE2"));
castor::tape::utils::DriveConfigMap driveConfigs;
driveConfigs.enterTpconfigLines(lines);
......
......@@ -95,7 +95,7 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
try {
// We implement the same policy as with the tape sessions:
// if the librarySlot parameter is "manual", do nothing.
if (m_driveConfig.librarySlot != "manual") {
if (tape::utils::TAPE_LIBRARY_TYPE_MANUAL != m_driveConfig.librarySlot.getLibraryType()) {
drive->unloadTape();
m_log(LOG_INFO, "Cleaner session: Tape unloaded");
} else {
......@@ -106,8 +106,8 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
m_log(LOG_INFO, "Cleaner session could not unload the tape. Will still try to unmount it in case it is already unloaded.", params);
}
try {
m_rmc.unmountTape(vol1.getVSN(), m_driveConfig.librarySlot);
m_log(LOG_INFO, m_driveConfig.librarySlot != "manual"?
m_rmc.unmountTape(vol1.getVSN(), m_driveConfig.librarySlot.str());
m_log(LOG_INFO, tape::utils::TAPE_LIBRARY_TYPE_MANUAL != m_driveConfig.librarySlot.getLibraryType() ?
"Cleaner session: unmounted tape":
"Cleaner session: tape NOT unmounted (manual mode)");
} catch(castor::exception::Exception &ne) {
......
......@@ -155,7 +155,7 @@ TEST(tapeServer, DataTransferSessionGooddayRecall) {
driveConfig.devFilename = "/dev/tape_T10D6116";
driveConfig.densities.push_back("8000GC");
driveConfig.densities.push_back("5000GC");
driveConfig.librarySlot = "manual";
driveConfig.librarySlot = castor::tape::utils::TapeLibrarySlot("manual@opaque_drive_id");
driveConfig.devType = "T10000";
DataTransferSession::CastorConf castorConf;
castorConf.rtcopydBufsz = 1024*1024; // 1 MB memory buffers
......@@ -260,7 +260,7 @@ TEST(tapeServer, DataTransferSessionWrongRecall) {
driveConfig.devFilename = "/dev/tape_T10D6116";
driveConfig.densities.push_back("8000GC");
driveConfig.densities.push_back("5000GC");
driveConfig.librarySlot = "manual";
driveConfig.librarySlot = castor::tape::utils::TapeLibrarySlot("manual@opaque_drive_id");
driveConfig.devType = "T10000";
DataTransferSession::CastorConf castorConf;
castorConf.rtcopydBufsz = 1024*1024; // 1 MB memory buffers
......@@ -318,7 +318,7 @@ TEST(tapeServer, DataTransferSessionNoSuchDrive) {
driveConfig.devFilename = "/dev/noSuchTape";
driveConfig.densities.push_back("8000GC");
driveConfig.densities.push_back("5000GC");
driveConfig.librarySlot = "manual";
driveConfig.librarySlot = castor::tape::utils::TapeLibrarySlot("manual@opaque_drive_id");
driveConfig.devType = "T10000";
DataTransferSession::CastorConf castorConf;
castorConf.rtcopydBufsz = 1024;
......@@ -462,7 +462,7 @@ TEST(tapeServer, DataTransferSessionGooddayMigration) {
driveConfig.devFilename = "/dev/tape_T10D6116";
driveConfig.densities.push_back("8000GC");
driveConfig.densities.push_back("5000GC");
driveConfig.librarySlot = "manual";
driveConfig.librarySlot = castor::tape::utils::TapeLibrarySlot("manual@opaque_drive_id");
driveConfig.devType = "T10000";
DataTransferSession::CastorConf castorConf;
castorConf.rtcopydBufsz = 1024*1024; // 1 MB memory buffers
......@@ -552,7 +552,7 @@ TEST(tapeServer, DataTransferSessionMissingFilesMigration) {
driveConfig.devFilename = "/dev/tape_T10D6116";
driveConfig.densities.push_back("8000GC");
driveConfig.densities.push_back("5000GC");
driveConfig.librarySlot = "manual";
driveConfig.librarySlot = castor::tape::utils::TapeLibrarySlot("manual@opaque_drive_id");
driveConfig.devType = "T10000";
DataTransferSession::CastorConf castorConf;
castorConf.rtcopydBufsz = 1024*1024; // 1 MB memory buffers
......@@ -654,7 +654,7 @@ TEST(tapeServer, DataTransferSessionTapeFullMigration) {
driveConfig.devFilename = "/dev/tape_T10D6116";
driveConfig.densities.push_back("8000GC");
driveConfig.densities.push_back("5000GC");
driveConfig.librarySlot = "manual";
driveConfig.librarySlot = castor::tape::utils::TapeLibrarySlot("manual@opaque_drive_id");
driveConfig.devType = "T10000";
DataTransferSession::CastorConf castorConf;
castorConf.rtcopydBufsz = 1024*1024; // 1 MB memory buffers
......@@ -761,7 +761,7 @@ TEST(tapeServer, DataTransferSessionTapeFullOnFlushMigration) {
driveConfig.devFilename = "/dev/tape_T10D6116";
driveConfig.densities.push_back("8000GC");
driveConfig.densities.push_back("5000GC");
driveConfig.librarySlot = "manual";
driveConfig.librarySlot = castor::tape::utils::TapeLibrarySlot("manual@opaque_drive_id");
driveConfig.devType = "T10000";
DataTransferSession::CastorConf castorConf;
castorConf.rtcopydBufsz = 1024*1024; // 1 MB memory buffers
......
......@@ -82,7 +82,7 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
drive->unloadTape();
m_log(LOG_INFO, "The tape has been successfully unloaded after labeling",
params);
m_rmc.unmountTape(m_request.vid, m_driveConfig.librarySlot);
m_rmc.unmountTape(m_request.vid, m_driveConfig.librarySlot.str());
m_log(LOG_INFO, "The tape has been successfully unmounted after labeling",
params);
......@@ -131,12 +131,12 @@ std::auto_ptr<castor::tape::tapeserver::drive::DriveInterface>
//------------------------------------------------------------------------------
void castor::tape::tapeserver::daemon::LabelSession::mountTape() {
try {
m_rmc.mountTape(m_request.vid, m_driveConfig.librarySlot,
m_rmc.mountTape(m_request.vid, m_driveConfig.librarySlot.str(),
castor::legacymsg::RmcProxy::MOUNT_MODE_READWRITE);
const log::Param params[] = {
log::Param("vid", m_request.vid),
log::Param("unitName", m_request.drive),
log::Param("librarySlot", m_driveConfig.librarySlot)};
log::Param("librarySlot", m_driveConfig.librarySlot.str())};
m_log(LOG_INFO, "Tape successfully mounted for labeling", params);
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
......@@ -156,7 +156,7 @@ void castor::tape::tapeserver::daemon::LabelSession::waitUntilTapeLoaded(
const log::Param params[] = {
log::Param("vid", m_request.vid),
log::Param("unitName", m_request.drive),
log::Param("librarySlot", m_driveConfig.librarySlot)};
log::Param("librarySlot", m_driveConfig.librarySlot.str())};
m_log(LOG_INFO, "Tape to be labelled has been mounted", params);
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
......@@ -179,7 +179,7 @@ void castor::tape::tapeserver::daemon::LabelSession::checkTapeIsWritable(
const log::Param params[] = {
log::Param("vid", m_request.vid),
log::Param("unitName", m_request.drive),
log::Param("librarySlot", m_driveConfig.librarySlot)};
log::Param("librarySlot", m_driveConfig.librarySlot.str())};
m_log(LOG_INFO, "Tape to be labelled is writable", params);
}
......
......@@ -171,7 +171,7 @@ private:
itor != densities.end(); itor++) {
msg.add_density(*itor);
}
msg.set_libraryslot(driveConfig.librarySlot);
msg.set_libraryslot(driveConfig.librarySlot.str());
msg.set_devtype(driveConfig.devType);
}
......
......@@ -53,7 +53,7 @@ castor::tape::tapeserver::daemon::TapeReadSingleThread::TapeCleaning::~TapeClean
try {
// Do the final cleanup
// in the special case of a "manual" mode tape, we should skip the unload too.
if (m_this.m_drive.librarySlot != "manual") {
if (utils::TAPE_LIBRARY_TYPE_MANUAL != m_this.m_drive.librarySlot.getLibraryType()) {
m_this.m_drive.unloadTape();
m_this.m_logContext.log(LOG_INFO, "TapeReadSingleThread: Tape unloaded");
} else {
......@@ -63,9 +63,9 @@ castor::tape::tapeserver::daemon::TapeReadSingleThread::TapeCleaning::~TapeClean
// And return the tape to the library
// In case of manual mode, this will be filtered by the rmc daemon
// (which will do nothing)
m_this.m_rmc.unmountTape(m_this.m_volInfo.vid, m_this.m_drive.librarySlot);
m_this.m_rmc.unmountTape(m_this.m_volInfo.vid, m_this.m_drive.librarySlot.str());
m_this.m_stats.unmountTime += m_timer.secs(utils::Timer::resetCounter);
m_this.m_logContext.log(LOG_INFO, m_this.m_drive.librarySlot != "manual"?
m_this.m_logContext.log(LOG_INFO, utils::TAPE_LIBRARY_TYPE_MANUAL != m_this.m_drive.librarySlot.getLibraryType() ?
"TapeReadSingleThread : tape unmounted":"TapeReadSingleThread : tape NOT unmounted (manual mode)");
m_this.m_initialProcess.tapeUnmounted();
m_this.m_stats.waitReportingTime += m_timer.secs(utils::Timer::resetCounter);
......
......@@ -113,10 +113,10 @@ protected:
void mountTape(castor::legacymsg::RmcProxy::MountMode mode){
castor::log::ScopedParamContainer scoped(m_logContext);
scoped.add("vid",m_volInfo.vid)
.add("drive_Slot",m_drive.librarySlot);
.add("drive_Slot",m_drive.librarySlot.str());
try {
tape::utils::Timer timer;
m_rmc.mountTape(m_volInfo.vid, m_drive.librarySlot,
m_rmc.mountTape(m_volInfo.vid, m_drive.librarySlot.str(),
mode);
const std::string modeAsString = std::string("R")+ ((mode==legacymsg::RmcProxy::MOUNT_MODE_READWRITE) ? "W" : "");
scoped.addTiming("RMCMountTime",timer.secs()).add("mode",modeAsString);
......
......@@ -82,7 +82,7 @@ private:
try{
// Do the final cleanup
// in the special case of a "manual" mode tape, we should skip the unload too.
if (m_this.m_drive.librarySlot != "manual") {
if (utils::TAPE_LIBRARY_TYPE_MANUAL != m_this.m_drive.librarySlot.getLibraryType()) {
m_this.m_drive.unloadTape();
m_this.m_logContext.log(LOG_INFO, "TapeWriteSingleThread: Tape unloaded");
} else {
......@@ -92,9 +92,9 @@ private:
// And return the tape to the library
// In case of manual mode, this will be filtered by the rmc daemon
// (which will do nothing)
m_this.m_rmc.unmountTape(m_this.m_volInfo.vid, m_this.m_drive.librarySlot);
m_this.m_rmc.unmountTape(m_this.m_volInfo.vid, m_this.m_drive.librarySlot.str());
m_this.m_stats.unmountTime += m_timer.secs(utils::Timer::resetCounter);
m_this.m_logContext.log(LOG_INFO, m_this.m_drive.librarySlot != "manual"?
m_this.m_logContext.log(LOG_INFO, utils::TAPE_LIBRARY_TYPE_MANUAL != m_this.m_drive.librarySlot.getLibraryType() ?
"TapeWriteSingleThread : tape unmounted":"TapeWriteSingleThread : tape NOT unmounted (manual mode)");
m_this.m_initialProcess.tapeUnmounted();
m_this.m_stats.waitReportingTime += m_timer.secs(utils::Timer::resetCounter);
......
......@@ -2,5 +2,17 @@ add_library(TapeDrive DriveGeneric.cpp FakeDrive.cpp)
set_property(SOURCE DriveGeneric.cpp PROPERTY COMPILE_FLAGS -fno-strict-aliasing)
target_link_libraries(TapeDrive SCSI)
add_executable(TapeDriveReadWriteTest TapeDriveReadWriteTest.cpp)
target_link_libraries(TapeDriveReadWriteTest TapeDrive SCSI System Utils castorcommon castorclient ${GTEST_LIBRARY} gmock pthread)
add_executable(TapeDriveReadWriteTest
TapeDriveReadWriteTest.cpp
../../utils/TapeLibrarySlot.cpp
../../utils/TapeLibraryType.cpp)
target_link_libraries(TapeDriveReadWriteTest
TapeDrive
SCSI
System
Utils
castorcommon
castorclient
${GTEST_LIBRARY}
gmock
pthread)
......@@ -24,12 +24,13 @@
#pragma once
#include "castor/exception/Errnum.hpp"