Commit 0911d981 authored by Steven Murray's avatar Steven Murray
Browse files

Removed support for Oracle tape libraries

parent 1ca1bb95
......@@ -72,14 +72,6 @@ endif (NOT DEFINED SKIP_UNIT_TESTS)
#Load version information in all cases.
include(cmake/CTAVersions.cmake)
if (DEFINED NoACS)
message (STATUS "Running CMake without support for ACS")
set (use_manually_specified_variable ${NoACS})
else (DEFINED NoACS)
message (STATUS "Running CMake with support for ACS")
message (STATUS "Override with -DNoACS:Bool=true")
endif (DEFINED NoACS)
IF(DEFINED PackageOnly)
message (STATUS "Running CMake in package-only mode")
set(COMPILE_PACKAGING "1")
......
# The CERN Tape Archive(CTA) project
# Copyright(C) 2015 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 3 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, see <http://www.gnu.org/licenses/>.
# This module will set the following variables:
# STK_FOUND
# STK_LIBRARIES
# STK_INCLUDE_DIR
find_library (STK_LIBRARIES
stk-ssi
PATHS /usr/lib64/CDK /usr/lib/CDK
NO_DEFAULT_PATH)
find_path (STK_INCLUDE_DIRS
acssys.h
PATHS /usr/include/CDK
NO_DEFAULT_PATH)
message (STATUS "STK_LIBRARIES=${STK_LIBRARIES}")
message (STATUS "STK_INCLUDE_DIRS=${STK_INCLUDE_DIRS}")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(stk DEFAULT_MSG
STK_LIBRARIES
STK_INCLUDE_DIRS)
......@@ -289,7 +289,6 @@ Unit tests and system tests with virtual tape drives
%{_libdir}/libctatapeserverscsiunittests.so*
%{_libdir}/libctadaemonunittests.so*
%{_libdir}/libctamediachangerunittests.so*
%{_libdir}/libctamediachangeracsdaemonunittests.so*
%{_bindir}/cta-systemTests
%{_libdir}/libctadaemonunittests-multiprocess.so*
%attr(0644,root,root) %{_datadir}/%{name}-%{ctaVersion}/unittest/*.suppr
......@@ -344,34 +343,6 @@ Utilities to faciliate working with the mediachangers
%attr(0644,root,root) %doc /usr/share/man/man1/cta-mediachanger-dismount.1cta.gz
%attr(0644,root,root) %doc /usr/share/man/man1/cta-mediachanger-mount.1cta.gz
%package -n cta-acsd
Summary: Tools to faciliate working with acsd in cta
Group: Application/CTA
Requires: logrotate
Requires: cta-common = %{version}-%{release}
Requires: cta-lib = %{version}-%{release}
%description -n cta-acsd
CERN Tape Archive:
Tools to faciliate working with acsd in cta
%files -n cta-acsd
%defattr(-,root,root)
%attr(0644,root,root) %config(noreplace) /etc/logrotate.d/cta-acsd
#%attr(0644,root,root) %doc /usr/share/man/man1/cta-acsd.1cta.gz
%attr(0755,root,root) %{_bindir}/cta-acsd
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/cta/cta-acsd.conf
%attr(0644,root,root) /etc/systemd/system/cta-acsd.service
%post -n cta-acsd
%systemd_post cta-acsd.service
%systemdDaemonReload
%preun -n cta-acsd
%systemd_preun cta-acsd.service
%postun -n cta-acsd
%systemd_postun cta-acsd.service
%systemdDaemonReload
%package -n cta-rmcd
Summary: Tools to faciliate working with rmcd and smc in cta
Group: Application/CTA
......@@ -403,25 +374,6 @@ Tools to faciliate working with rmcd and smc in cta
%systemd_postun cta-rmcd.service
%systemdDaemonReload
%package -n cta-tape-developer-acs-tools
Summary: Cern Advanced mass STORage
Group: Application/Castor
Requires: stk-ssi-lib
BuildRequires: stk-ssi-devel
%description -n cta-tape-developer-acs-tools
castor (Cern Advanced STORage system)
ASC tools for CASTOR tape developers
%files -n cta-tape-developer-acs-tools
%defattr(-,root,root)
%attr(0755,root,root) /usr/bin/cta-acs-queryvolume
%attr(0755,root,root) /usr/bin/cta-acs-dismount
%attr(0755,root,root) /usr/bin/cta-acs-mount
%attr(0755,root,root) /usr/bin/cta-acs-querydrive
%attr(0644,root,root) %doc /usr/share/man/man1/cta-acs-queryvolume.1cta.gz
%attr(0644,root,root) %doc /usr/share/man/man1/cta-acs-mount.1cta.gz
%attr(0644,root,root) %doc /usr/share/man/man1/cta-acs-dismount.1cta.gz
%attr(0644,root,root) %doc /usr/share/man/man1/cta-acs-querydrive.1cta.gz
%package -n cta-common
Summary: CERN Tape Archive common items
Group: Application/CTA
......
......@@ -15,10 +15,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required (VERSION 2.6)
if (NOT DEFINED NoACS)
add_subdirectory(acs)
endif (NOT DEFINED NoACS)
add_subdirectory(reactor)
add_subdirectory(castorrmc)
find_package(openssl REQUIRED)
......
/*
* The CERN Tape Archive(CTA) project
* Copyright(C) 2015 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "Acs.hpp"
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>
#include <vector>
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
cta::mediachanger::acs::Acs::~Acs() {
}
//------------------------------------------------------------------------------
// alpd2DriveId
//------------------------------------------------------------------------------
DRIVEID cta::mediachanger::acs::Acs::alpd2DriveId(const uint32_t acs,
const uint32_t lsm, const uint32_t panel, const uint32_t drive) {
DRIVEID driveId;
driveId.panel_id.lsm_id.acs = (ACS)acs;
driveId.panel_id.lsm_id.lsm = (LSM)lsm;
driveId.panel_id.panel = (PANEL)panel;
driveId.drive = (DRIVE)drive;
return driveId;
}
//------------------------------------------------------------------------------
// str2Volid
//------------------------------------------------------------------------------
VOLID cta::mediachanger::acs::Acs::str2Volid(const std::string &str) {
if(EXTERNAL_LABEL_SIZE < str.length()) {
InvalidVolid ex;
ex.getMessage() << "Failed to convert string to volume identifier"
": String is longer than the " << EXTERNAL_LABEL_SIZE <<
" character maximum";
throw ex;
}
VOLID v;
strncpy(v.external_label, str.c_str(), sizeof(v.external_label));
v.external_label[sizeof(v.external_label) - 1] = '\0';
return v;
}
//------------------------------------------------------------------------------
// driveId2Str
//------------------------------------------------------------------------------
std::string cta::mediachanger::acs::Acs::driveId2Str(const DRIVEID &driveId) {
std::ostringstream oss;
oss << std::setfill('0') <<
std::setw(3) << (int32_t)driveId.panel_id.lsm_id.acs << ":" <<
std::setw(3) << (int32_t)driveId.panel_id.lsm_id.lsm << ":" <<
std::setw(3) << (int32_t)driveId.panel_id.panel << ":" <<
std::setw(3) << (int32_t)driveId.drive;
return oss.str();
}
/*
* The CERN Tape Archive(CTA) project
* Copyright(C) 2015 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "common/exception/Exception.hpp"
extern "C" {
#include "acssys.h"
#include "acsapi.h"
}
#include <string>
#include <stdint.h>
namespace cta {
namespace mediachanger {
namespace acs {
/**
* Abstract class that defines the interface to an object that wraps the ACLS
* C-API.
*/
class Acs {
public:
/**
* Pure-virtual destructor to ensure this class is abstract.
*/
virtual ~Acs() = 0;
/**
* Converts acs, lsm, panel, drive numbers to the corresponding
* drive ID object.
*
* @param acs The integer for acs.
* @param lsm The integer for lsm.
* @param panel The integer for panel.
* @param drive The integer for drive.
* @return The drive ID object.
*/
static DRIVEID alpd2DriveId(const uint32_t acs, const uint32_t lsm,
const uint32_t panel, const uint32_t drive);
/**
* Invalid volume identifier.
*/
struct InvalidVolid: public exception::Exception {
InvalidVolid(const std::string &context = "", const bool embedBacktrace = true):
cta::exception::Exception(context, embedBacktrace) {}
};
/**
* Returns the VOLID equibvalent of the specified string.
*
* @param str The string representation of the volume identifier.
* @return The VOLID representation of the volume identifier.
* @throw InvalidVolid if the string is longer than EXTERNAL_LABEL_SIZE.
*/
static VOLID str2Volid(const std::string &str);
/**
* Returns the string reprsentation of the specified drive identifier.
*
* The string format is ACS:LSM:panel:drive
*
* @param driveId The drive identifier.
* @return The string representation.
*/
static std::string driveId2Str(const DRIVEID &driveId);
/**
* C++ wrapper around the acs_mount() function of the ACSLS C-API.
*
* @param seqNumber Client supplied sequence number.
* @param lockId Lock identifier or 0 meaning no lock.
* @param volId The indentifier of volume to be mounted.
* @param driveId The ID of the drive into which the volume is to be mounted.
* @param readOnly Set to true to request the volume be mounted for read-only
* access.
* @param bypass Set to true to override the ACSLS verification of
* compatibility between the drive and the media type of the volume.
* @return status value returned by acs_mount().
*/
virtual STATUS mount(
const SEQ_NO seqNumber,
const LOCKID lockId,
const VOLID &volId,
const DRIVEID &driveId,
const BOOLEAN readOnly,
const BOOLEAN bypass)
= 0;
/**
* C++ wrapper around the acs_dismount() function of the ACSLS C-API.
*
* @param seqNumber Client supplied sequence number.
* @param lockId Lock identifier or 0 meaning no lock.
* @param volId The identifier of the volume to be mounted.
* @param driveId The ID of the drive into which the volume is to be mounted.
* @param force Set to true if the dismount should be forced. Forcing a
* dismount means dismounting the volume from the specified drive without
* checking the identifier of the volume.
* @return status value returned by acs_dismount().
*/
virtual STATUS dismount(
const SEQ_NO seqNumber,
const LOCKID lockId,
const VOLID &volId,
const DRIVEID &driveId,
const BOOLEAN force)
= 0;
/**
* C++ wrapper around the acs_response() function of the ACSLS C-API.
*
* @param timeout Time in seconds to wait for a response. A value of -1
* means block indefinitely and an a value of 0 means poll for the existence
* of a response.
* @param seqNumber Output parameter. If a response exists then seqNumber
* is set.
* @param reqId Output parameter. For an acknowledge response reqId is set
* to the request identifier of the original request. For an intermediate or
* final response reqId will be set to 0.
* @param rType Output parameter. Set to the type of the response.
* @param rBuf Output parameter. Set to the response information.
* @return status value returned by acs_response().
*/
virtual STATUS response(
const int timeout,
SEQ_NO &seqNumber,
REQ_ID &reqId,
ACS_RESPONSE_TYPE &rType,
ALIGNED_BYTES rBuf) = 0;
/**
* C++ wrapper around the acs_query_volume() function of the ACSLS C-API.
*
* @param seqNumber Client supplied sequence number.
* @param volIds Array of the volume identifiers to be queried.
* @param count The number of volume identifiers contained iwthin the volId
* parameter.
* @return status value returned by acs_response().
*/
virtual STATUS queryVolume(
const SEQ_NO seqNumber,
VOLID (&volIds)[MAX_ID],
const unsigned short count) = 0;
}; // class Acs
} // namespace acs
} // namespace mediachanger
} // namespace cta
/*
* The CERN Tape Archive(CTA) project
* Copyright(C) 2015 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "AcsCmd.hpp"
#include "common/exception/Exception.hpp"
#include <stdlib.h>
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::mediachanger::acs::AcsCmd::AcsCmd(std::istream &inStream,
std::ostream &outStream, std::ostream &errStream, Acs &acs):
CmdLineTool(inStream, outStream, errStream), m_acs(acs) {
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
cta::mediachanger::acs::AcsCmd::~AcsCmd() {
}
//------------------------------------------------------------------------------
// bool2Str
//------------------------------------------------------------------------------
std::string cta::mediachanger::acs::AcsCmd::bool2Str(const BOOLEAN value) const
{
return value ? "TRUE" : "FALSE";
}
//------------------------------------------------------------------------------
// requestResponsesUntilFinal
//------------------------------------------------------------------------------
void cta::mediachanger::acs::AcsCmd::requestResponsesUntilFinal(
const SEQ_NO requestSeqNumber,
ALIGNED_BYTES (&buf)[MAX_MESSAGE_SIZE / sizeof(ALIGNED_BYTES)],
const int queryInterval, const int timeout) {
ACS_RESPONSE_TYPE responseType = RT_NONE;
int elapsedTime = 0;
do {
const int remainingTime = timeout - elapsedTime;
const int responseTimeout = remainingTime > queryInterval ?
queryInterval : remainingTime;
const time_t startTime = time(NULL);
responseType = requestResponse(responseTimeout, requestSeqNumber, buf);
elapsedTime += time(NULL) - startTime;
if(RT_ACKNOWLEDGE == responseType) {
m_dbg << "Received RT_ACKNOWLEDGE" << std::endl;
}
if(elapsedTime >= timeout) {
cta::exception::RequestFailed ex;
ex.getMessage() << "Timed out after " << timeout << " seconds";
throw ex;
}
} while(RT_FINAL != responseType);
m_dbg << "Received RT_FINAL" << std::endl;
}
//------------------------------------------------------------------------------
// requestResponse
//------------------------------------------------------------------------------
ACS_RESPONSE_TYPE cta::mediachanger::acs::AcsCmd::requestResponse(
const int timeout, const SEQ_NO requestSeqNumber,
ALIGNED_BYTES (&buf)[MAX_MESSAGE_SIZE / sizeof(ALIGNED_BYTES)]) {
SEQ_NO responseSeqNumber = 0;
REQ_ID reqId = (REQ_ID)0;
ACS_RESPONSE_TYPE responseType = RT_NONE;
m_dbg << "Calling Acs::response()" << std::endl;
const STATUS s = m_acs.response(timeout, responseSeqNumber, reqId,
responseType, buf);
m_dbg << "Acs::response() returned " << acs_status(s) << std::endl;
switch(s) {
case STATUS_SUCCESS:
checkResponseSeqNumber(requestSeqNumber, responseSeqNumber);
return responseType;
case STATUS_PENDING:
return RT_NONE;
default:
cta::exception::RequestFailed ex;
ex.getMessage() << "Failed to request response: " << acs_status(s);
throw ex;
}
}
//------------------------------------------------------------------------------
// checkSeqNumber
//------------------------------------------------------------------------------
void cta::mediachanger::acs::AcsCmd::checkResponseSeqNumber( const SEQ_NO requestSeqNumber, const SEQ_NO responseSeqNumber) {
if(requestSeqNumber != responseSeqNumber) {
cta::exception::Mismatch ex;
ex.getMessage() << ": Sequence number mismatch: requestSeqNumber="
<< requestSeqNumber << " responseSeqNumber=" << responseSeqNumber;
throw ex;
}
}
/*
* The CERN Tape Archive(CTA) project
* Copyright(C) 2015 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "common/exception/Mismatch.hpp"
//#include "common/exception/RequestFailed.hpp"
#include "common/exception/RequestFailed.hpp"
#include "Acs.hpp"
#include "AcsCmd.hpp"
#include "CmdLineTool.hpp"
#include <istream>
#include <ostream>
#include <string>
extern "C" {
#include "acssys.h"
#include "acsapi.h"
}
namespace cta {
namespace mediachanger {
namespace acs {
/**
* Abstract class implementing common code and data structures for command-line
* tools that interact with ACLS compatible tape libraries.
*/
class AcsCmd: public CmdLineTool {
public:
/**
* Constructor.
*
* @param inStream Standard input stream.
* @param outStream Standard output stream.
* @param errStream Standard error stream.
* @param acs Wrapper around the ACSLS C-API.
*/
AcsCmd(std::istream &inStream, std::ostream &outStream,
std::ostream &errStream, Acs &acs);
/**
* Pure-virtual destructor to guarantee this class is abstract.
*/
virtual ~AcsCmd() = 0;
protected:
/**
* Wrapper around the ACSLS C-API.
*/
Acs &m_acs;
/**
* Returns the string representation of the specfied boolean value.
*
* @param value The boolean value.
*/
std::string bool2Str(const BOOLEAN value) const;
/**
* Requests responses from ACSLS in a loop until the RT_FINAL response is
* received.
*
* @param requestSeqNumber The sequemce number that was sent in the initial
* request to the ACSLS.
* @param buf Output parameter. Message buffer into which the RT_FINAL
* response shall be written.
* @param queryInterval Time in seconds to wait between queries to ACS for
* responses.
* @param timeout The time in seconds to spend trying to get the RT_FINAL
* response.
*/
void requestResponsesUntilFinal(const SEQ_NO requestSeqNumber,
ALIGNED_BYTES (&buf)[MAX_MESSAGE_SIZE / sizeof(ALIGNED_BYTES)],
const int queryInterval, const int timeout);
/**
* Sends a request for a response to the ACSLS.
*
* @param timeout The timeout.
* @param requestSeqNumber The sequemce number that was sent in the initial
* request to the ACSLS.
* @param buf Output parameter. The response message if there is one.
* @return The type of the response message if there is one or RT_NONE if
* there isn't one.
*/
ACS_RESPONSE_TYPE requestResponse(const int timeout,
const SEQ_NO requestSeqNumber,
ALIGNED_BYTES (&buf)[MAX_MESSAGE_SIZE / sizeof(ALIGNED_BYTES)]);
/**
* Throws cta::exception::Mismatch if the specified request and
* response sequence-numbers do not match.
*
* @param requestSeqNumber Request sequence-number.
* @param responseSeqNumber Response sequence-number.
*/
void checkResponseSeqNumber(const SEQ_NO requestSeqNumber,
const SEQ_NO responseSeqNumber);
}; // class AcsCmd
} // namespace acs
} // namespace mediachanger
} // namespace cta
/*
* The CERN Tape Archive(CTA) project
* Copyright(C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify