Commit 11835403 authored by Steven Murray's avatar Steven Murray
Browse files

Removed lingering unused ACS and ZeroMQ code

parent 047a7a3b
# 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:
# ZEROMQ_FOUND
# ZEROMQ_INCLUDE_DIRS
find_path (ZEROMQ_INCLUDE_DIRS
zmq.h
PATHS /usr/include
NO_DEFAULT_PATH)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(zeromq DEFAULT_MSG
ZEROMQ_INCLUDE_DIRS)
......@@ -51,7 +51,6 @@ BuildRequires: gmock-devel >= 1.5.0 gtest-devel >= 1.5.0
BuildRequires: sqlite-devel >= 3.6
BuildRequires: libcap-devel >= 2.16
BuildRequires: binutils-devel >= 2.20
BuildRequires: zeromq-devel >= 4.0
BuildRequires: openssl-devel >= 1.0.1e
BuildRequires: cryptopp-devel >= 5.6.2
BuildRequires: libuuid-devel >= 2.17
......@@ -207,7 +206,6 @@ Requires: mariadb-libs
Requires: postgresql-libs
# Explicity require protobuf3 to avoid clash with eos-protobuf3
Requires: protobuf3
Requires: zeromq
Requires: cta-lib-common = %{version}-%{release}
%description -n cta-lib
CERN Tape Archive:
......
// 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/>.
//
syntax = "proto2";
package cta.mediachanger;
message AcsDismountTape {
required string vid = 1;
required uint32 acs = 2;
required uint32 lsm = 3;
required uint32 panel = 4;
required uint32 drive = 5;
}
// 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/>.
//
syntax = "proto2";
package cta.mediachanger;
message AcsForceDismountTape {
required string vid = 1;
required uint32 acs = 2;
required uint32 lsm = 3;
required uint32 panel = 4;
required uint32 drive = 5;
}
/*
* 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 "mediachanger/AcsLibrarySlot.hpp"
#include <sstream>
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::mediachanger::AcsLibrarySlot::AcsLibrarySlot():
LibrarySlot(TAPE_LIBRARY_TYPE_ACS),
m_acs(0),
m_lsm(0),
m_panel(0),
m_drive(0) {
m_str = librarySlotToString(0, 0, 0, 0);
}
//------------------------------------------------------------------------------
// librarySlotToString
//------------------------------------------------------------------------------
std::string cta::mediachanger::AcsLibrarySlot::librarySlotToString(
const uint32_t acs, const uint32_t lsm, const uint32_t panel,
const uint32_t drive) const {
std::ostringstream oss;
oss << "acs" << acs << "," << lsm << "," << panel << "," << drive;
return oss.str();
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::mediachanger::AcsLibrarySlot::AcsLibrarySlot(const uint32_t acs,
const uint32_t lsm, const uint32_t panel, const uint32_t drive):
LibrarySlot(TAPE_LIBRARY_TYPE_ACS),
m_acs(acs),
m_lsm(lsm),
m_panel(panel),
m_drive(drive) {
m_str = librarySlotToString(acs, lsm, panel, drive);
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
cta::mediachanger::AcsLibrarySlot::~AcsLibrarySlot() {
}
//------------------------------------------------------------------------------
// clone
//------------------------------------------------------------------------------
cta::mediachanger::LibrarySlot *cta::mediachanger::AcsLibrarySlot::
clone() {
return new AcsLibrarySlot(*this);
}
//------------------------------------------------------------------------------
// getAcs
//------------------------------------------------------------------------------
uint32_t cta::mediachanger::AcsLibrarySlot::getAcs() const {
return m_acs;
}
//------------------------------------------------------------------------------
// getLsm
//------------------------------------------------------------------------------
uint32_t cta::mediachanger::AcsLibrarySlot::getLsm() const {
return m_lsm;
}
//------------------------------------------------------------------------------
// getPanel
//------------------------------------------------------------------------------
uint32_t cta::mediachanger::AcsLibrarySlot::getPanel() const {
return m_panel;
}
//------------------------------------------------------------------------------
// getDrive
//------------------------------------------------------------------------------
uint32_t cta::mediachanger::AcsLibrarySlot::getDrive() const {
return m_drive;
}
/*
* 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/InvalidArgument.hpp"
#include "mediachanger/LibrarySlot.hpp"
#include <stdint.h>
namespace cta {
namespace mediachanger {
/**
* Class reprsenting a slot in an ACS tape-library.
*/
class AcsLibrarySlot: public LibrarySlot {
public:
/**
* Default constructor that sets all integer members to 0.
*/
AcsLibrarySlot();
/**
* Constructor.
*
* @param acs The acs component of the library slot.
* @param lsm The lsm component of the library slot.
* @param panel The panel component of the library slot.
* @param drive The drive component of the library slot.
*/
AcsLibrarySlot(const uint32_t acs, const uint32_t lsm,
const uint32_t panel, const uint32_t drive);
/**
* Destructor.
*/
~AcsLibrarySlot();
/**
* Creates a clone of this object.
*
* @return The clone.
*/
LibrarySlot *clone();
/**
* Gets the acs component of the library slot.
*
* @return the acs component of the library slot.
*/
uint32_t getAcs() const;
/**
* Gets the lsm component of the library slot.
*
* @return the lsm component of the library slot.
*/
uint32_t getLsm() const;
/**
* Gets the panel component of the library slot.
*
* @return the panel component of the library slot.
*/
uint32_t getPanel() const;
/**
* Gets the drive component of the library slot.
*
* @return the drive component of the library slot.
*/
uint32_t getDrive() const;
private:
/**
* The acs component of the library slot.
*/
uint32_t m_acs;
/**
* The lsm component of the library slot.
*/
uint32_t m_lsm;
/**
* The panel component of the library slot.
*/
uint32_t m_panel;
/**
* The drive component of the library slot.
*/
uint32_t m_drive;
/**
* Returns the string representation of the specified ACS library slot.
*
* @param acs The acs component of the library slot.
* @param lsm The lsm component of the library slot.
* @param panel The panel component of the library slot.
* @param drive The drive component of the library slot.
* @return The string representation.
*/
std::string librarySlotToString(const uint32_t acs, const uint32_t lsm,
const uint32_t panel, const uint32_t drive) const;
}; // class AcsProxy
} // 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/>.
//
syntax = "proto2";
package cta.mediachanger;
message AcsMountTapeReadOnly {
required string vid = 1;
required uint32 acs = 2;
required uint32 lsm = 3;
required uint32 panel = 4;
required uint32 drive = 5;
}
// 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/>.
//
syntax = "proto2";
package cta.mediachanger;
message AcsMountTapeReadWrite {
required string vid = 1;
required uint32 acs = 2;
required uint32 lsm = 3;
required uint32 panel = 4;
required uint32 drive = 5;
}
/*
* 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 "common/threading/MutexLocker.hpp"
#include "mediachanger/AcsDismountTape.pb.h"
#include "mediachanger/AcsForceDismountTape.pb.h"
#include "mediachanger/AcsLibrarySlot.hpp"
#include "mediachanger/AcsMountTapeReadOnly.pb.h"
#include "mediachanger/AcsMountTapeReadWrite.pb.h"
#include "mediachanger/AcsProxy.hpp"
#include "mediachanger/Constants.hpp"
#include "mediachanger/MediaChangerReturnValue.pb.h"
#include "mediachanger/messages.hpp"
#include "mediachanger/ZmqContextSingleton.hpp"
#include "mediachanger/ZmqSocketST.hpp"
namespace cta {
namespace mediachanger {
namespace {
/**
* Creates a frame containing an AcsMountTapeReadOnly message.
*
* @param vid The tape to be mounted.
* @param librarySlot The slot in the library that contains the tape drive.
* @return The frame.
*/
Frame createAcsMountTapeReadOnlyFrame(const std::string &vid, const AcsLibrarySlot &librarySlot) {
try {
Frame frame;
frame.header = protoTapePreFillHeader();
frame.header.set_msgtype(MSG_TYPE_ACSMOUNTTAPEREADONLY);
frame.header.set_bodysignature("PIPO");
AcsMountTapeReadOnly body;
body.set_vid(vid);
body.set_acs(librarySlot.getAcs());
body.set_lsm(librarySlot.getLsm());
body.set_panel(librarySlot.getPanel());
body.set_drive(librarySlot.getDrive());
frame.serializeProtocolBufferIntoBody(body);
return frame;
} catch(cta::exception::Exception &ne) {
cta::exception::Exception ex;
ex.getMessage() << "Failed to create AcsMountTapeReadOnly frame: " <<
ne.getMessage().str();
throw ex;
}
}
/**
* Creates a frame containing a AcsMountTapeReadWrite message.
*
* @param vid The tape to be mounted.
* @param librarySlot The slot in the library that contains the tape drive.
* @return The frame.
*/
Frame createAcsMountTapeReadWriteFrame(const std::string &vid, const AcsLibrarySlot &librarySlot) {
try {
Frame frame;
frame.header = protoTapePreFillHeader();
frame.header.set_msgtype(MSG_TYPE_ACSMOUNTTAPEREADWRITE);
frame.header.set_bodysignature("PIPO");
AcsMountTapeReadWrite body;
body.set_vid(vid);
body.set_acs(librarySlot.getAcs());
body.set_lsm(librarySlot.getLsm());
body.set_panel(librarySlot.getPanel());
body.set_drive(librarySlot.getDrive());
frame.serializeProtocolBufferIntoBody(body);
return frame;
} catch(cta::exception::Exception &ne) {
cta::exception::Exception ex;
ex.getMessage() << "Failed to create AcsMountTapeReadWrite frame: " <<
ne.getMessage().str();
throw ex;
}
}
/**
* Creates a frame containing an AcsDismountTape message.
*
* @param vid The tape to be dismounted.
* @param librarySlot The slot in the library that contains the tape drive.
* @return The frame.
*/
Frame createAcsDismountTapeFrame(const std::string &vid, const AcsLibrarySlot &librarySlot) {
try {
Frame frame;
frame.header = protoTapePreFillHeader();
frame.header.set_msgtype(MSG_TYPE_ACSDISMOUNTTAPE);
frame.header.set_bodysignature("PIPO");
AcsDismountTape body;
body.set_vid(vid);
body.set_acs(librarySlot.getAcs());
body.set_lsm(librarySlot.getLsm());
body.set_panel(librarySlot.getPanel());
body.set_drive(librarySlot.getDrive());
frame.serializeProtocolBufferIntoBody(body);
return frame;
} catch(cta::exception::Exception &ne) {
cta::exception::Exception ex;
ex.getMessage() << "Failed to create AcsDismountTape frame: " <<
ne.getMessage().str();
throw ex;
}
}
/**
* Creates a frame containing an AcsForceDismountTape message.
*
* @param vid The tape to be dismounted.
* @param librarySlot The slot in the library that contains the tape drive.
* @return The frame.
*/
Frame createAcsForceDismountTapeFrame(const std::string &vid, const AcsLibrarySlot &librarySlot) {
try {
Frame frame;
frame.header = protoTapePreFillHeader();
frame.header.set_msgtype(MSG_TYPE_ACSFORCEDISMOUNTTAPE);
frame.header.set_bodysignature("PIPO");
AcsForceDismountTape body;
body.set_vid(vid);
body.set_acs(librarySlot.getAcs());
body.set_lsm(librarySlot.getLsm());
body.set_panel(librarySlot.getPanel());
body.set_drive(librarySlot.getDrive());
frame.serializeProtocolBufferIntoBody(body);
return frame;
} catch(cta::exception::Exception &ne) {
cta::exception::Exception ex;
ex.getMessage() << "Failed to create AcsForceDismountTape frame: " <<
ne.getMessage().str();
throw ex;
}
}
} // anonyous namespace
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
AcsProxy::AcsProxy(const unsigned short serverPort):
m_serverPort(serverPort) {
}
//------------------------------------------------------------------------------
// mountTapeReadOnly
//------------------------------------------------------------------------------
void AcsProxy::mountTapeReadOnly(const std::string &vid, const LibrarySlot &librarySlot) {
threading::MutexLocker locker(m_mutex);
try {
const Frame rqst = createAcsMountTapeReadOnlyFrame(vid, dynamic_cast<const AcsLibrarySlot&>(librarySlot));
sendFrame(serverSocketInstance(), rqst);
MediaChangerReturnValue reply;
recvTapeReplyOrEx(serverSocketInstance(), reply);
if(0 != reply.value()) {
// Should never get here
cta::exception::Exception ex;
ex.getMessage() << "Received an unexpected return value"
": expected=0 actual=" << reply.value();
throw ex;
}
} catch(cta::exception::Exception &ne) {
cta::exception::Exception ex;
ex.getMessage() <<
"Failed to request CTA ACS daemon to mount tape for read only access: "
<< librarySlot.str() << ": " << ne.getMessage().str();
throw ex;
}
}
//------------------------------------------------------------------------------
// mountTapeReadWrite
//------------------------------------------------------------------------------
void AcsProxy::mountTapeReadWrite(const std::string &vid, const LibrarySlot &librarySlot) {
threading::MutexLocker locker(m_mutex);
try {
const Frame rqst = createAcsMountTapeReadWriteFrame(vid, dynamic_cast<const AcsLibrarySlot&>(librarySlot));
sendFrame(serverSocketInstance(), rqst);
MediaChangerReturnValue reply;
recvTapeReplyOrEx(serverSocketInstance(), reply);
if(0 != reply.value()) {
// Should never get here
cta::exception::Exception ex;
ex.getMessage() << "Received an unexpected return value"
": expected=0 actual=" << reply.value();
throw ex;
}
} catch(cta::exception::Exception &ne) {
cta::exception::Exception ex;
ex.getMessage() <<
"Failed to request CTA ACS daemon to mount tape for read/write "
"access: " << librarySlot.str() << ": " << ne.getMessage().str();
throw ex;
}
}
//------------------------------------------------------------------------------
// dismountTape
//------------------------------------------------------------------------------
void AcsProxy