Commit a96397d3 authored by Eric Cano's avatar Eric Cano
Browse files

Catching up with master branch.

parents 361b9012 27f0834b
......@@ -38,6 +38,7 @@ castor/tape/rechandler/rechandlerd
castor/tape/rmc/castor-tape-acs-dismount
castor/tape/rmc/castor-tape-acs-mount
castor/tape/rmc/castor-tape-acs-queryvolume
castor/tape/rmc/castor-tape-mount
castor/tape/tapebridge/tapebridged
castor/tape/tapegateway/tapegatewayd
castor/tape/tpcp/dumptp
......
......@@ -339,15 +339,15 @@ ELSE(DEFINED PackageOnly)
set_property (DIRECTORY PROPERTY COMPILE_DEFINITIONS _LARGEFILE64_SOURCE)
################################################################################
##############################################################################
# Rules to install the shared log and spool directories
################################################################################
##############################################################################
CastorInstallDir (/var/log/castor)
CastorInstallDir (/var/log/spool/castor)
################################################################################
##############################################################################
# Include the subdirectories of the project
################################################################################
##############################################################################
# Some directories have client components, and get included unconditionnaly
# inside them, we can filter further down what we need or not.
......
......@@ -118,12 +118,12 @@ protected:
*/
virtual void waitAllThreads() throw ();
private:
/**
* Prints out the online help
*/
void help(const std::string &programName) throw();
virtual void help(const std::string &programName) throw();
private:
/**
* Sets up the signal handling for this multi-threaded daemon.
......
......@@ -24,7 +24,7 @@ cmake_minimum_required (VERSION 2.6)
add_subdirectory (gatewayprotocol)
add_subdirectory (legacymsg)
#add_subdirectory (rmc)
add_subdirectory (rmc)
add_subdirectory (tapebridge)
add_subdirectory (tapegateway)
add_subdirectory (tapeserver)
......
......@@ -32,8 +32,7 @@
//------------------------------------------------------------------------------
castor::tape::rmc::AcsCmd::AcsCmd(std::istream &inStream,
std::ostream &outStream, std::ostream &errStream, Acs &acs) throw():
m_in(inStream), m_out(outStream), m_err(errStream), m_acs(acs),
m_debugBuf(outStream), m_dbg(&m_debugBuf) {
Cmd(inStream, outStream, errStream), m_acs(acs) {
}
//------------------------------------------------------------------------------
......@@ -45,25 +44,9 @@ castor::tape::rmc::AcsCmd::~AcsCmd() throw() {
//------------------------------------------------------------------------------
// bool2Str
//------------------------------------------------------------------------------
std::string castor::tape::rmc::AcsCmd::bool2Str(bool &value) const
std::string castor::tape::rmc::AcsCmd::bool2Str(const BOOLEAN value) const
throw() {
if(value) {
return "TRUE";
} else {
return "FALSE";
}
}
//------------------------------------------------------------------------------
// bool2Str
//------------------------------------------------------------------------------
std::string castor::tape::rmc::AcsCmd::bool2Str(BOOLEAN &value) const
throw() {
if(value) {
return "TRUE";
} else {
return "FALSE";
}
return value ? "TRUE" : "FALSE";
}
//------------------------------------------------------------------------------
......
......@@ -29,7 +29,7 @@
#include "castor/exception/Mismatch.hpp"
#include "castor/exception/RequestFailed.hpp"
#include "castor/tape/rmc/Acs.hpp"
#include "castor/tape/rmc/DebugBuf.hpp"
#include "castor/tape/rmc/Cmd.hpp"
#include <istream>
#include <ostream>
......@@ -48,7 +48,7 @@ namespace rmc {
* Abstract class implementing common code and data structures for command-line
* tools that interact with ACLS compatible tape libraries.
*/
class AcsCmd {
class AcsCmd: public Cmd {
public:
/**
* Constructor.
......@@ -68,49 +68,17 @@ public:
protected:
/**
* Standard input stream.
*/
std::istream &m_in;
/**
* Standard output stream.
*/
std::ostream &m_out;
/**
* Standard error stream.
*/
std::ostream &m_err;
/**
* Wrapper around the ACSLS C-API.
*/
Acs &m_acs;
/**
* Debug stream buffer that inserts a standard debug preamble before each
* message-line written to it.
*/
DebugBuf m_debugBuf;
/**
* Stream used to write debug messages.
*
* This stream will insert a standard debug preamble before each message-line
* written to it.
*/
std::ostream m_dbg;
/**
* Returns the string representation of the specfied boolean value.
*/
std::string bool2Str(bool &value) const throw();
/**
* Returns the string representation of the specfied boolean value.
*
* @param value The boolean value.
*/
std::string bool2Str(BOOLEAN &value) const throw();
std::string bool2Str(const BOOLEAN value) const throw();
/**
* Requests responses from ACSLS in a loop until the RT_FINAL response is
......
......@@ -102,11 +102,13 @@ void castor::tape::rmc::AcsDismountCmd::usage(std::ostream &os)
const throw() {
os <<
"Usage:\n"
"\n"
" castor-tape-acs-dismount [options] VID DRIVE\n"
"\n"
"Where:\n"
"\n"
" VID The VID of the volume to be dismounted.\n"
"\n"
" DRIVE The drive from which the volume is to be dismounted.\n"
" The format of DRIVE is:\n"
"\n"
......@@ -115,12 +117,16 @@ void castor::tape::rmc::AcsDismountCmd::usage(std::ostream &os)
"Options:\n"
"\n"
" -d|--debug Turn on the printing of debug information.\n"
"\n"
" -f|--force Force the dismount.\n"
"\n"
" -h|--help Print this help message and exit.\n"
"\n"
" -q|--query SECONDS Time to wait between queries to ACS for responses.\n"
" SECONDS must be an integer value greater than 0.\n"
" The default value of SECONDS is "
<< m_defaultQueryInterval << ".\n"
"\n"
" -t|--timeout SECONDS Time to wait for the dismount to conclude. SECONDS\n"
" must be an integer value greater than 0. The\n"
" default value of SECONDS is "
......
......@@ -43,7 +43,7 @@ struct AcsDismountCmdLine {
/**
* Constructor.
*
* Initialises all BOOLEAN member-variables to FALSE, all integer
* Initialises all boolean member-variables to false, all integer
* member-variables to 0 and the volume identifier to an empty string.
*/
AcsDismountCmdLine() throw();
......
......@@ -220,6 +220,7 @@ void castor::tape::rmc::AcsMountCmd::usage(std::ostream &os)
const throw() {
os <<
"Usage:\n"
"\n"
" castor-tape-acs-mount [options] VID DRIVE\n"
"\n"
"Where:\n"
......@@ -233,12 +234,16 @@ void castor::tape::rmc::AcsMountCmd::usage(std::ostream &os)
"Options:\n"
"\n"
" -d|--debug Turn on the printing of debug information.\n"
"\n"
" -h|--help Print this help message and exit.\n"
"\n"
" -q|--query SECONDS Time to wait between queries to ACS for responses.\n"
" SECONDS must be an integer value greater than 0.\n"
" The default value of SECONDS is "
<< m_defaultQueryInterval << ".\n"
"\n"
" -r|--readOnly Request the volume is mounted for read-only access\n"
"\n"
" -t|--timeout SECONDS Time to wait for the mount to conclude. SECONDS\n"
" must be an integer value greater than 0. The\n"
" default value of SECONDS is "
......
......@@ -22,62 +22,148 @@
#
cmake_minimum_required (VERSION 2.6)
################################################################################
# Rules to build and install castor-tape-acs-mount
################################################################################
set (ACS_MOUNT_SRC_FILES
if (${COMPILE_SERVER} STREQUAL "1")
##############################################################################
# Rules to build and install rmcd
##############################################################################
set (RMCD_SRC_FILES
RmcDaemon.cpp
RmcdCmdLine.cpp
RmcdMain.cpp)
add_executable (newrmcd ${RMCD_SRC_FILES})
target_link_libraries (newrmcd castorclient castorcommon)
#install (TARGETS newrmcd DESTINATION ${CASTOR_DEST_LIB_DIR})
#CastorInstallExeManPage(newrmcd)
##############################################################################
# Rules to build and install castor-tape-mount
##############################################################################
set (MOUNT_SRC_FILES
DebugBuf.cpp
Cmd.cpp
MountCmd.cpp
MountCmdLine.cpp
MountMain.cpp)
add_executable (castor-tape-mount ${MOUNT_SRC_FILES})
target_link_libraries (castor-tape-mount castorcommon castorrmc)
#install (TARGETS castor-tape-mount DESTINATION ${CASTOR_DEST_LIB_DIR})
#CastorInstallExeManPage(castor-tape-mount)
##############################################################################
# Try to find the four STK client libaries: libapi.so, libutl.so, libipc.so
# and libcl.so
##############################################################################
find_library (STK_API_LIB api
PATHS /usr/lib64/CDK /usr/lib/CDK NO_DEFAULT_PATH)
if (STK_API_LIB)
message(STATUS "Found the STK api library: ${STK_API_LIB}")
endif (STK_API_LIB)
find_library (STK_UTL_LIB utl
PATHS /usr/lib64/CDK /usr/lib/CDK NO_DEFAULT_PATH)
if (STK_UTL_LIB)
message(STATUS "Found the STK utl library: ${STK_UTL_LIB}")
endif (STK_UTL_LIB)
find_library (STK_IPC_LIB ipc
PATHS /usr/lib64/CDK /usr/lib/CDK NO_DEFAULT_PATH)
if (STK_IPC_LIB)
message(STATUS "Found the STK ipc library: ${STK_IPC_LIB}")
endif (STK_IPC_LIB)
find_library (STK_CL_LIB cl PATHS /usr/lib64/CDK /usr/lib/CDK NO_DEFAULT_PATH)
if (STK_CL_LIB)
message(STATUS "Found the STK cl library: ${STK_CL_LIB}")
endif (STK_CL_LIB)
##############################################################################
# Add the castor-tape-acs-dismount, castor-tape-acs-mount and
# castor-tape-queryvolume targets if all four STK client libaries
# (libapi.so, libutl.so, libipc.so and libcl.so) have been found
##############################################################################
if (STK_API_LIB AND STK_UTL_LIB AND STK_IPC_LIB AND STK_CL_LIB)
message(STATUS "Found all four STK libraries")
############################################################################
# Rules to build and install castor-tape-acs-dismount
############################################################################
message(STATUS "Adding castor-tape-acs-dismount target")
set (ACS_DISMOUNT_SRC_FILES
Acs.cpp
AcsCmd.cpp
AcsImpl.cpp
AcsMountCmd.cpp
AcsMountCmdLine.cpp
AcsMountMain.cpp
AcsDismountCmd.cpp
AcsDismountCmdLine.cpp
AcsDismountMain.cpp
Cmd.cpp
DebugBuf.cpp)
add_executable (castor-tape-acs-mount ${ACS_MOUNT_SRC_FILES})
set_target_properties (castor-tape-acs-mount PROPERTIES
add_executable (castor-tape-acs-dismount ${ACS_DISMOUNT_SRC_FILES})
set_target_properties (castor-tape-acs-dismount PROPERTIES
COMPILE_FLAGS -I/usr/include/CDK
COMPILE_DEFINITIONS LINUX)
target_link_libraries (castor-tape-acs-mount castorcommon castortapeutils
${STK_API_LIB} ${STK_UTL_LIB} ${STK_IPC_LIB} ${STK_CL_LIB})
install (TARGETS castor-tape-acs-mount DESTINATION ${CASTOR_DEST_LIB_DIR})
CastorInstallExeManPage(castor-tape-acs-mount)
target_link_libraries (castor-tape-acs-dismount
castorclient
castorcommon
castortapeutils
${STK_API_LIB}
${STK_UTL_LIB}
${STK_IPC_LIB}
${STK_CL_LIB})
#install (TARGETS castor-tape-acs-dismount
# DESTINATION ${CASTOR_DEST_LIB_DIR})
#CastorInstallExeManPage(castor-tape-acs-dismount)
################################################################################
# Rules to build and install castor-tape-acs-dismount
################################################################################
set (ACS_DISMOUNT_SRC_FILES
############################################################################
# Rules to build and install castor-tape-acs-mount
############################################################################
set (ACS_MOUNT_SRC_FILES
Acs.cpp
AcsCmd.cpp
AcsImpl.cpp
AcsDismountCmd.cpp
AcsDismountCmdLine.cpp
AcsDismountMain.cpp
AcsMountCmd.cpp
AcsMountCmdLine.cpp
AcsMountMain.cpp
Cmd.cpp
DebugBuf.cpp)
add_executable (castor-tape-acs-dismount ${ACS_DISMOUNT_SRC_FILES})
target_link_libraries (castor-tape-acs-dismount castorcommon castortapeutils
${STK_API_LIB} ${STK_UTL_LIB} ${STK_IPC_LIB} ${STK_CL_LIB})
set_target_properties (castor-tape-acs-dismount PROPERTIES
add_executable (castor-tape-acs-mount ${ACS_MOUNT_SRC_FILES})
set_target_properties (castor-tape-acs-mount PROPERTIES
COMPILE_FLAGS -I/usr/include/CDK
COMPILE_DEFINITIONS LINUX)
install (TARGETS castor-tape-acs-dismount DESTINATION ${CASTOR_DEST_LIB_DIR})
CastorInstallExeManPage(castor-tape-acs-dismount)
target_link_libraries (castor-tape-acs-mount
castorclient
castorcommon
castortapeutils
${STK_API_LIB}
${STK_UTL_LIB}
${STK_IPC_LIB}
${STK_CL_LIB})
#install (TARGETS castor-tape-acs-mount DESTINATION ${CASTOR_DEST_LIB_DIR})
#CastorInstallExeManPage(castor-tape-acs-mount)
################################################################################
# Rules to build and install castor-tape-acs-queryvolume
################################################################################
set (ACS_QUERYVOLUME_SRC_FILES
############################################################################
# Rules to build and install castor-tape-acs-queryvolume
############################################################################
message(STATUS "Adding castor-tape-acs-queryvolume target")
set (ACS_QUERYVOLUME_SRC_FILES
Acs.cpp
AcsCmd.cpp
AcsImpl.cpp
AcsQueryVolumeCmd.cpp
AcsQueryVolumeCmdLine.cpp
AcsQueryVolumeMain.cpp
Cmd.cpp
DebugBuf.cpp)
add_executable (castor-tape-acs-queryvolume ${ACS_QUERYVOLUME_SRC_FILES})
target_link_libraries (castor-tape-acs-queryvolume castorcommon castortapeutils
${STK_API_LIB} ${STK_UTL_LIB} ${STK_IPC_LIB} ${STK_CL_LIB})
set_target_properties (castor-tape-acs-queryvolume PROPERTIES
add_executable (castor-tape-acs-queryvolume ${ACS_QUERYVOLUME_SRC_FILES})
target_link_libraries (castor-tape-acs-queryvolume
castorclient
castorcommon
castortapeutils
${STK_API_LIB}
${STK_UTL_LIB}
${STK_IPC_LIB}
${STK_CL_LIB})
set_target_properties (castor-tape-acs-queryvolume PROPERTIES
COMPILE_FLAGS -I/usr/include/CDK
COMPILE_DEFINITIONS LINUX)
install (TARGETS castor-tape-acs-queryvolume DESTINATION ${CASTOR_DEST_LIB_DIR})
CastorInstallExeManPage(castor-tape-acs-queryvolume)
#install (TARGETS castor-tape-acs-queryvolume
# DESTINATION ${CASTOR_DEST_LIB_DIR})
#CastorInstallExeManPage(castor-tape-acs-queryvolume)
endif (STK_API_LIB AND STK_UTL_LIB AND STK_IPC_LIB AND STK_CL_LIB)
endif (${COMPILE_SERVER} STREQUAL "1")
/******************************************************************************
* castor/tape/rmc/Cmd.cpp
*
* 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 Steven.Murray@cern.ch
*****************************************************************************/
#include "castor/tape/rmc/Cmd.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
castor::tape::rmc::Cmd::Cmd(std::istream &inStream,
std::ostream &outStream, std::ostream &errStream) throw():
m_in(inStream), m_out(outStream), m_err(errStream), m_debugBuf(outStream),
m_dbg(&m_debugBuf) {
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
castor::tape::rmc::Cmd::~Cmd() throw() {
}
//------------------------------------------------------------------------------
// bool2Str
//------------------------------------------------------------------------------
std::string castor::tape::rmc::Cmd::bool2Str(const bool value) const throw() {
return value ? "TRUE" : "FALSE";
}
/******************************************************************************
* castor/tape/rmc/Cmd.hpp
*
* 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 Steven.Murray@cern.ch
*****************************************************************************/
#ifndef CASTOR_TAPE_RMC_CMD_HPP
#define CASTOR_TAPE_RMC_CMD_HPP 1
#include "castor/tape/rmc/DebugBuf.hpp"
#include <istream>
#include <ostream>
#include <string>
namespace castor {
namespace tape {
namespace rmc {
/**
* Abstract class implementing common code and data structures for a
* command-line tool.
*/
class Cmd {
public:
/**
* Constructor.
*
* @param inStream Standard input stream.
* @param outStream Standard output stream.
* @param errStream Standard error stream.
*/
Cmd(std::istream &inStream, std::ostream &outStream, std::ostream &errStream)
throw();
/**
* Pure-virtual destructor to guarantee this class is abstract.
*/
virtual ~Cmd() throw() = 0;
protected:
/**
* Standard input stream.
*/
std::istream &m_in;
/**
* Standard output stream.
*/
std::ostream &m_out;
/**
* Standard error stream.
*/
std::ostream &m_err;
/**
* Debug stream buffer that inserts a standard debug preamble before each
* message-line written to it.
*/
DebugBuf m_debugBuf;
/**
* Stream used to write debug messages.
*
* This stream will insert a standard debug preamble before each message-line
* written to it.
*/
std::ostream m_dbg;
/**
* Returns the string representation of the specfied boolean value.
*
* @param value The boolean value.
*/
std::string bool2Str(const bool value) const throw();
}; // class Cmd
} // namespace rmc
} // namespace tape
} // namespace castor
#endif // CASTOR_TAPE_RMC_CMD_HPP
/******************************************************************************
* castor/tape/rmc/MountCmd.cpp
*
* 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 Steven.Murray@cern.ch
*****************************************************************************/
#include "castor/tape/rmc/MountCmd.hpp"
#include "castor/tape/utils/utils.hpp"
#include "h/rmc_api.h"
#include "h/serrno.h"
#include <getopt.h>
#include <iostream>
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
castor::tape::rmc::MountCmd::MountCmd(std::istream &inStream,
std::ostream &outStream, std::ostream &errStream) throw():
Cmd(inStream, outStream, errStream), m_defaultTimeout(600) {
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
castor::tape::rmc::MountCmd::~MountCmd() throw() {
// Do nothing
}
//------------------------------------------------------------------------------
// main
//------------------------------------------------------------------------------
int castor::tape::rmc::MountCmd::main(const int argc,
char *const *const argv) throw() {
try {
m_cmdLine = parseCmdLine(argc, argv);
} catch(castor::exception::InvalidArgument &ia) {
m_err << "Aborting: Invalid command-line: " << ia.getMessage().str() <<