/* * @project The CERN Tape Archive (CTA) * @copyright Copyright © 2021-2022 CERN * @license This program is free software, distributed under the terms of the GNU General Public * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". You can * redistribute it and/or modify it under the terms of the GPL Version 3, 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. * * In applying this licence, CERN does not waive the privileges and immunities * granted to it by virtue of its status as an Intergovernmental Organization or * submit itself to any jurisdiction. */ #pragma once #include #include #include #include "common/dataStructures/DriveStatus.hpp" #include "common/dataStructures/EntryLog.hpp" #include "common/dataStructures/MountType.hpp" namespace cta::common::dataStructures { /** * This struct holds status of a Tape Drive */ struct TapeDrive { static const std::map STATE_TO_STRING_MAP; static const std::map STRING_TO_STATE_MAP; static std::string getAllPossibleStates(); TapeDrive(); bool operator==(const TapeDrive &rhs) const; bool operator!=(const TapeDrive &rhs) const; void setState(const std::string & state); std::string getStateStr() const; /** * Return the string representation of the tape drive State passed in parameter * @param state the state to return the string representation * @return the string representation of the state passed in parameter * @throws cta::exception::Exception if the state passed in parameter does not exist */ static std::string stateToString(const DriveStatus &state); /** * Return the state value according to the state passed in parameter (not case sensitive) * @param state the string that identifies the state enum value to return * @return the state corresponding to the State enum value * @throws cta::exception::Exception if the state passed in parameter does not match any existing State enum value */ static DriveStatus stringToState(const std::string & state); std::string driveName; std::string host; std::string logicalLibrary; bool logicalLibraryDisabled; std::optional sessionId; std::optional bytesTransferedInSession; std::optional filesTransferedInSession; std::optional sessionStartTime; std::optional sessionElapsedTime; std::optional mountStartTime; std::optional transferStartTime; std::optional unloadStartTime; std::optional unmountStartTime; std::optional drainingStartTime; std::optional downOrUpStartTime; std::optional probeStartTime; std::optional cleanupStartTime; std::optional startStartTime; std::optional shutdownTime; MountType mountType; DriveStatus driveStatus; bool desiredUp; bool desiredForceDown; std::optional reasonUpDown; std::optional currentVid; std::optional ctaVersion; std::optional currentPriority; std::optional currentActivity; std::optional currentTapePool; MountType nextMountType; // defaults to NO_MOUNT. This can't be optional, as we have a NOT nullptr constraint in the DB. std::optional nextVid; std::optional nextTapePool; std::optional nextPriority; std::optional nextActivity; std::optional devFileName; std::optional rawLibrarySlot; std::optional currentVo; std::optional nextVo; std::optional diskSystemName; std::optional reservedBytes; std::optional reservationSessionId; std::optional physicalLibraryName; std::optional userComment; std::optional creationLog; std::optional lastModificationLog; }; // struct TapeDrive std::ostream &operator<<(std::ostream &os, const TapeDrive &obj); } // namespace cta::common::dataStructures