Commit 4582de61 authored by Steven Murray's avatar Steven Murray
Browse files

This is the first attempt at adding the bare minimum of tapeserverd to the CTA project

Please note that you will have to install the following CASTOR rpms
in order to compile:

  castor
  castor-devel
  castor-lib
  castor-lib-server
  castor-lib-tape
parent 15587fb4
......@@ -16,20 +16,13 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#include "castor/tape/label/LabelCmd.hpp"
#include "castor/mediachanger/MmcProxy.hpp"
//------------------------------------------------------------------------------
// main
// destructor
//------------------------------------------------------------------------------
int main(int argc, char **argv) {
castor::tape::label::LabelCmd command;
return command.main(argc, argv);
castor::mediachanger::MmcProxy::~MmcProxy() throw() {
}
/******************************************************************************
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#pragma once
#include "castor/mediachanger/ManualLibrarySlot.hpp"
#include <string>
namespace castor {
namespace mediachanger {
/**
* Asbtract class defining the interface to manually operated media-changer.
*/
class MmcProxy {
public:
/**
* Destructor.
*/
virtual ~MmcProxy() throw() = 0;
/**
* Requests the media changer to mount of the specified tape for read-only
* access into the drive in the specified library slot.
*
* Please note that this method provides a best-effort service because not all
* media changers support read-only mounts.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot containing the tape drive.
*/
virtual void mountTapeReadOnly(const std::string &vid,
const mediachanger::ManualLibrarySlot &librarySlot) = 0;
/**
* Requests the media changer to mount of the specified tape for read/write
* access into the drive in the specified library slot.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot containing the tape drive.
*/
virtual void mountTapeReadWrite(const std::string &vid,
const mediachanger::ManualLibrarySlot &librarySlot) = 0;
/**
* Requests the media changer to dismount of the specified tape from the
* drive in the specifed library slot.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot containing the tape drive.
*/
virtual void dismountTape(const std::string &vid,
const mediachanger::ManualLibrarySlot &librarySlot) = 0;
/**
* Requests the media changer to forcefully dismount the specified tape from
* the drive in the specifed library slot. Forcefully means rewinding and
* ejecting the tape where necessary.
*
* Please note that this method provides a best-effort service because not all
* media changers support forceful dismounts.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot containing the tape drive.
*/
virtual void forceDismountTape(const std::string &vid,
const mediachanger::ManualLibrarySlot &librarySlot) = 0;
}; // class MmcProxy
} // namespace mediachanger
} // namespace castor
......@@ -16,36 +16,35 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#include "tape/TpConfigException.hpp"
#include "castor/mediachanger/MmcProxyDummy.hpp"
//------------------------------------------------------------------------------
// constructor
// mountTapeReadOnly
//------------------------------------------------------------------------------
tape::TpConfigException::TpConfigException(const std::string &what,
const int returnValue) throw(): m_what(what), m_exitValue(returnValue) {
void castor::mediachanger::MmcProxyDummy::mountTapeReadOnly(
const std::string &vid, const ManualLibrarySlot &librarySlot) {
}
//------------------------------------------------------------------------------
// destructor
// mountTapeReadWrite
//------------------------------------------------------------------------------
tape::TpConfigException::~TpConfigException() throw() {
void castor::mediachanger::MmcProxyDummy::mountTapeReadWrite(
const std::string &vid, const ManualLibrarySlot &librarySlot) {
}
//------------------------------------------------------------------------------
// what
// dismountTape
//------------------------------------------------------------------------------
const char *tape::TpConfigException::what() const throw() {
return m_what.c_str();
void castor::mediachanger::MmcProxyDummy::dismountTape(
const std::string &vid, const ManualLibrarySlot &librarySlot) {
}
//------------------------------------------------------------------------------
// exitValue
// forceDismountTape
//------------------------------------------------------------------------------
int tape::TpConfigException::exitValue() const throw() {
return m_exitValue;
void castor::mediachanger::MmcProxyDummy::forceDismountTape(
const std::string &vid, const ManualLibrarySlot &librarySlot) {
}
/******************************************************************************
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#pragma once
#include "castor/mediachanger/MmcProxy.hpp"
namespace castor {
namespace mediachanger {
/**
* Concrete class implementing a dummy MmcProxyDummy.
*/
class MmcProxyDummy: public MmcProxy {
public:
/**
* Requests the media changer to mount the specified tape for read-only
* access into the drive in the specified library slot.
*
* Please note that this method provides a best-effort service because not all
* media changers support read-only mounts.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot containing the tape drive.
*/
void mountTapeReadOnly(const std::string &vid,
const ManualLibrarySlot &librarySlot);
/**
* Requests the media changer to mount the specified tape for read/write
* access into the drive in the specified library slot.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot containing the tape drive.
*/
void mountTapeReadWrite(const std::string &vid,
const ManualLibrarySlot &librarySlot);
/**
* Requests the media changer to dismount the specified tape from the
* drive in the specifed library slot.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot containing the tape drive.
*/
void dismountTape(const std::string &vid,
const ManualLibrarySlot &librarySlot);
/**
* Request the CASTOR ACS daemon to forcefully dismount the specifed tape
* from the tape drive in the specified library slot. Forcefully means
* rewinding and ejecting the tape if necessary.
*
* Please note that this method provides a best-effort service because not all
* media changers support forceful dismounts.
*
* @param vid The volume identifier of the tape to be mounted.
* @param librarySlot The slot in the library that contains the tape drive.
*/
void forceDismountTape(const std::string &vid,
const ManualLibrarySlot &librarySlot);
}; // class MmcProxyDummy
} // namespace mediachanger
} // namespace castor
/******************************************************************************
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#include "castor/mediachanger/MmcProxyLog.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
castor::mediachanger::MmcProxyLog::MmcProxyLog(log::Logger &log) throw():
m_log(log) {
}
//------------------------------------------------------------------------------
// mountTapeReadOnly
//------------------------------------------------------------------------------
void castor::mediachanger::MmcProxyLog::mountTapeReadOnly(
const std::string &vid, const ManualLibrarySlot &librarySlot) {
log::Param params[] = {
log::Param("TPVID", vid),
log::Param("librarySlot", librarySlot.str())};
m_log(LOG_WARNING, "Tape should be manual mounted for read-only access",
params);
}
//------------------------------------------------------------------------------
// mountTapeReadWrite
//------------------------------------------------------------------------------
void castor::mediachanger::MmcProxyLog::mountTapeReadWrite(
const std::string &vid, const ManualLibrarySlot &librarySlot) {
log::Param params[] = {
log::Param("TPVID", vid),
log::Param("librarySlot", librarySlot.str())};
m_log(LOG_WARNING, "Tape should be manual mounted for read/write access",
params);
}
//------------------------------------------------------------------------------
// dismountTape
//------------------------------------------------------------------------------
void castor::mediachanger::MmcProxyLog::dismountTape(
const std::string &vid, const ManualLibrarySlot &librarySlot) {
log::Param params[] = {
log::Param("TPVID", vid),
log::Param("librarySlot", librarySlot.str())};
m_log(LOG_WARNING, "Tape should be manual dismounted", params);
}
//------------------------------------------------------------------------------
// forceDismountTape
//------------------------------------------------------------------------------
void castor::mediachanger::MmcProxyLog::forceDismountTape(
const std::string &vid, const ManualLibrarySlot &librarySlot) {
log::Param params[] = {
log::Param("TPVID", vid),
log::Param("librarySlot", librarySlot.str())};
m_log(LOG_WARNING, "Tape should be manual dismounted", params);
}
/******************************************************************************
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#pragma once
#include "castor/log/Logger.hpp"
#include "castor/mediachanger/MmcProxy.hpp"
namespace castor {
namespace mediachanger {
/**
* Concrete class implementing a MmcProxy that simply logs mount and dismount
* requests.
*/
class MmcProxyLog: public MmcProxy {
public:
/**
* Constructor.
*
* @param log Object representing the API to the CASTOR logging system.
*/
MmcProxyLog(log::Logger &log) throw();
/**
* Requests the media changer to mount the specified tape for read-only
* access into the drive in the specified library slot.
*
* Please note that this method provides a best-effort service because not all
* media changers support read-only mounts.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot containing the tape drive.
*/
void mountTapeReadOnly(const std::string &vid,
const ManualLibrarySlot &librarySlot);
/**
* Requests the media changer to mount the specified tape for read/write
* access into the drive in the specified library slot.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot containing the tape drive.
*/
void mountTapeReadWrite(const std::string &vid,
const ManualLibrarySlot &librarySlot);
/**
* Requests the media changer to dismount the specified tape from the
* drive in the specifed library slot.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot containing the tape drive.
*/
void dismountTape(const std::string &vid,
const ManualLibrarySlot &librarySlot);
/**
* Requests the media changer to forcefully dismount the specified tape from
* the drive in the specifed library slot. Forcefully means rewinding and
* ejecting the tape where necessary.
*
* Please note that this method provides a best-effort service because not all
* media changers support forceful dismounts.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot containing the tape drive.
*/
void forceDismountTape(const std::string &vid,
const ManualLibrarySlot &librarySlot);
private:
/**
* Object representing the API to the CASTOR logging system.
*/
log::Logger &m_log;
}; // class MmcProxyLog
} // namespace mediachanger
} // namespace castor
/******************************************************************************
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#include "castor/exception/Exception.hpp"
#include "castor/mediachanger/MmcProxyNotSupported.hpp"
//------------------------------------------------------------------------------
// mountTapeReadOnly
//------------------------------------------------------------------------------
void castor::mediachanger::MmcProxyNotSupported::mountTapeReadOnly(
const std::string &vid, const ManualLibrarySlot &librarySlot) {
castor::exception::Exception ex;
ex.getMessage() << "Manual mounting is not supported";
throw ex;
}
//------------------------------------------------------------------------------
// mountTapeReadWrite
//------------------------------------------------------------------------------
void castor::mediachanger::MmcProxyNotSupported::mountTapeReadWrite(
const std::string &vid, const ManualLibrarySlot &librarySlot) {
castor::exception::Exception ex;
ex.getMessage() << "Manual mounting is not supported";
throw ex;
}
//------------------------------------------------------------------------------
// dismountTape
//------------------------------------------------------------------------------
void castor::mediachanger::MmcProxyNotSupported::dismountTape(
const std::string &vid, const ManualLibrarySlot &librarySlot) {
castor::exception::Exception ex;
ex.getMessage() << "Manual dismounting is not supported";
throw ex;
}
//------------------------------------------------------------------------------
// forceDismountTape
//------------------------------------------------------------------------------
void castor::mediachanger::MmcProxyNotSupported::forceDismountTape(
const std::string &vid, const ManualLibrarySlot &librarySlot) {
castor::exception::Exception ex;
ex.getMessage() << "Manual dismounting is not supported";
throw ex;
}
/******************************************************************************
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#pragma once
#include "castor/mediachanger/MmcProxy.hpp"
namespace castor {
namespace mediachanger {
/**
* Concrete class implementing a manual media-changer that throws
* "not supported" exceptions.
*/
class MmcProxyNotSupported: public MmcProxy {
public:
/**
* Requests the media changer to mount the specified tape for read-only
* access into the drive in the specified library slot.
*
* Please note that this method provides a best-effort service because not all
* media changers support read-only mounts.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot containing the tape drive.
*/
void mountTapeReadOnly(const std::string &vid,
const ManualLibrarySlot &librarySlot);
/**
* Requests the media changer to mount the specified tape for read/write
* access into the drive in the specified library slot.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot containing the tape drive.
*/
void mountTapeReadWrite(const std::string &vid,
const ManualLibrarySlot &librarySlot);
/**
* Requests the media changer to dismount the specified tape from the
* drive in the specifed library slot.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot containing the tape drive.
*/
void dismountTape(const std::string &vid,
const ManualLibrarySlot &librarySlot);
/**
* Requests the media changer to forcefully dismount the specified tape from
* the drive in the specifed library slot. Forcefully means rewinding and
* ejecting the tape where necessary.
*
* Please note that this method provides a best-effort service because not all
* media changers support forceful dismounts.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot containing the tape drive.
*/
void forceDismountTape(const std::string &vid,
const ManualLibrarySlot &librarySlot);
}; // class MmcProxyNotSupported
} // namespace mediachanger
} // namespace castor
/******************************************************************************
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*