Commit 0e229281 authored by Steven Murray's avatar Steven Murray
Browse files

Moved vid from Cleaner::execute() to Cleaner constructor

parent b432f9c6
......@@ -30,18 +30,19 @@ castor::tape::tapeserver::daemon::CleanerSession::CleanerSession(
legacymsg::RmcProxy &rmc,
castor::log::Logger &log,
const utils::DriveConfig &driveConfig,
System::virtualWrapper &sysWrapper):
System::virtualWrapper &sysWrapper,
const std::string &vid):
m_rmc(rmc),
m_log(log),
m_driveConfig(driveConfig),
m_sysWrapper(sysWrapper) {
m_sysWrapper(sysWrapper),
m_vid(vid) {
}
//------------------------------------------------------------------------------
// execute
//------------------------------------------------------------------------------
int castor::tape::tapeserver::daemon::CleanerSession::execute(const std::string &vid) {
int castor::tape::tapeserver::daemon::CleanerSession::execute() {
castor::tape::SCSI::DeviceVector dv(m_sysWrapper);
castor::tape::SCSI::DeviceInfo driveInfo = dv.findBySymlink(m_driveConfig.devFilename);
......@@ -72,16 +73,16 @@ int castor::tape::tapeserver::daemon::CleanerSession::execute(const std::string
drive->rewind();
drive->readExactBlock((void * )&vol1, sizeof(vol1), "[CleanerSession::clean()] - Reading header VOL1");
vol1.verify();
if(vid.empty()) { // vid given is empty
log::Param params[] = {log::Param("vid", vid)};
if(m_vid.empty()) { // vid given is empty
log::Param params[] = {log::Param("vid", m_vid)};
m_log(LOG_INFO, "Cleaner session received an empty vid.", params);
}
else if(!(vid.compare(vol1.getVSN()))) { // vid provided and vid read on VOL1 correspond
log::Param params[] = {log::Param("vid", vid)};
else if(!(m_vid.compare(vol1.getVSN()))) { // vid provided and vid read on VOL1 correspond
log::Param params[] = {log::Param("vid", m_vid)};
m_log(LOG_INFO, "Cleaner session received the same vid read on tape.", params);
}
else { // vid provided and vid read on VOL1 don NOT correspond!
log::Param params[] = {log::Param("vid provided", vid), log::Param("vid read on label", vol1.getVSN())};
log::Param params[] = {log::Param("vid provided", m_vid), log::Param("vid read on label", vol1.getVSN())};
m_log(LOG_WARNING, "Cleaner session received a different vid from the one read on tape.", params);
}
} catch(castor::exception::Exception &ne) {
......
......@@ -50,24 +50,27 @@ namespace daemon {
* @param log Object representing the API to the CASTOR logging system.
* @param driveConfig Configuration of the tape drive to be cleaned.
* @param sysWrapper Object representing the operating system.
* @param vid The volume identifier of the mounted tape if known,
* else the empty string.
*/
CleanerSession(
legacymsg::RmcProxy &rmc,
castor::log::Logger &log,
const utils::DriveConfig &driveConfig,
System::virtualWrapper &sysWrapper);
System::virtualWrapper &sysWrapper,
const std::string &vid);
/**
* Cleans the drive by unloading any tape present and unmounting it
* Executes the cleaner session which unloads and unmounts any tape that is
* present in the drive.
*
* @param vid The identifier of the mounted volume (one can pass the empty string
* in case it is unknown, as it not used except for logging purposes).
*
* @return 0 in case of success (drive can stay UP) or 1 in case of failure (drive needs to be put down by the caller)
* @return 0 in case of success (drive can stay UP) or 1 in case of failure
* (drive needs to be put down by the caller)
*/
int execute(const std::string &vid);
int execute();
private:
/**
* The object representing the rmcd daemon.
*/
......@@ -87,6 +90,12 @@ namespace daemon {
* The system wrapper used to find the device and instantiate the drive object
*/
System::virtualWrapper & m_sysWrapper;
/**
* The volume identifier of the mounted tape if known, else the empty
* string.
*/
const std::string m_vid;
}; // class CleanerSession
......
......@@ -473,9 +473,10 @@ int castor::tape::tapeserver::daemon::ProcessForker::runCleanerSession(
rmc,
m_log,
driveConfig,
sWrapper);
sWrapper,
rqst.vid());
// execute() returns 0 if drive should be put up or 1 if it should be put down
return cleanerSession.execute(rqst.vid());
return cleanerSession.execute();
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to run cleaner session: " << ne.getMessage().str();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment