Commit 5955b06d authored by Daniele Kruse's avatar Daniele Kruse
Browse files

Changed the interface slightly and more work on the CLI

parent 362508d3
......@@ -26,6 +26,7 @@
#include "common/dataStructures/AdminHost.hpp"
#include "common/dataStructures/AdminUser.hpp"
#include "common/dataStructures/ArchiveFile.hpp"
#include "common/dataStructures/ArchiveFileSummary.hpp"
#include "common/dataStructures/ArchiveJob.hpp"
#include "common/dataStructures/ArchiveMount.hpp"
#include "common/dataStructures/ArchiveRequest.hpp"
......@@ -114,7 +115,9 @@ public:
virtual void createTape(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &vid, const std::string &logicalLibraryName, const std::string &tapePoolName, const uint64_t capacityInBytes,
const bool disabledValue, const bool fullValue, const std::string &comment) = 0;
virtual void deleteTape(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &vid) = 0;
virtual std::list<cta::common::dataStructures::Tape> getTapes(const cta::common::dataStructures::SecurityIdentity &requester, const std::map<std::string, std::string> &where) = 0; // "where" is a map resembling an "and-ed" where clause in a SQL query
virtual std::list<cta::common::dataStructures::Tape> getTapes(const cta::common::dataStructures::SecurityIdentity &requester,
const std::string &vid, const std::string &logicalLibraryName, const std::string &tapePoolName,
const std::string &capacityInBytes, const std::string &disabledValue, const std::string &fullValue, const std::string &busyValue) = 0;
virtual void labelTape(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &vid, const bool force, const bool lbp, const std::string &tag) = 0;
virtual void reclaimTape(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &vid) = 0;
virtual void modifyTapeLogicalLibraryName(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &vid, const std::string &logicalLibraryName) = 0;
......@@ -160,8 +163,11 @@ public:
virtual void modifyDedicationUntil(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &drivename, const uint64_t untilTimestamp) = 0;
virtual void modifyDedicationComment(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &drivename, const std::string &comment) = 0;
virtual std::list<cta::common::dataStructures::ArchiveFile> getArchiveFiles(const cta::common::dataStructures::SecurityIdentity &requester, const std::map<std::string, std::string> &where) = 0; // "where" is a map resembling an "and-ed" where clause in a SQL query
virtual std::list<cta::common::dataStructures::ArchiveFile> getArchiveFiles(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &id, const std::string &copynb, const std::string &tapepool,
const std::string &vid, const std::string &owner, const std::string &group, const std::string &storageclass, const std::string &path) = 0;
virtual cta::common::dataStructures::ArchiveFileSummary getArchiveFileSummary(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &id, const std::string &copynb, const std::string &tapepool,
const std::string &vid, const std::string &owner, const std::string &group, const std::string &storageclass, const std::string &path) = 0;
virtual void setDriveStatus(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &driveName, const bool up, const bool force) = 0;
/**
......
......@@ -198,7 +198,9 @@ void cta::catalogue::MockCatalogue::deleteTape(const cta::common::dataStructures
//------------------------------------------------------------------------------
// getTapes
//------------------------------------------------------------------------------
std::list<cta::common::dataStructures::Tape> cta::catalogue::MockCatalogue::getTapes(const cta::common::dataStructures::SecurityIdentity &requester, const std::map<std::string, std::string> &where) { return std::list<cta::common::dataStructures::Tape>();}
std::list<cta::common::dataStructures::Tape> cta::catalogue::MockCatalogue::getTapes(const cta::common::dataStructures::SecurityIdentity &requester,
const std::string &vid, const std::string &logicalLibraryName, const std::string &tapePoolName,
const std::string &capacityInBytes, const std::string &disabledValue, const std::string &fullValue, const std::string &busyValue) { return std::list<cta::common::dataStructures::Tape>();}
//------------------------------------------------------------------------------
// labelTape
......@@ -396,8 +398,19 @@ void cta::catalogue::MockCatalogue::modifyDedicationComment(const cta::common::d
//------------------------------------------------------------------------------
// getArchiveFiles
//------------------------------------------------------------------------------
std::list<cta::common::dataStructures::ArchiveFile> cta::catalogue::MockCatalogue::getArchiveFiles(const cta::common::dataStructures::SecurityIdentity &requester, const std::map<std::string, std::string> &where) { return std::list<cta::common::dataStructures::ArchiveFile>();}
std::list<cta::common::dataStructures::ArchiveFile> cta::catalogue::MockCatalogue::getArchiveFiles(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &id, const std::string &copynb, const std::string &tapepool,
const std::string &vid, const std::string &owner, const std::string &group, const std::string &storageclass, const std::string &path) {
return std::list<cta::common::dataStructures::ArchiveFile>();
}
//------------------------------------------------------------------------------
// getArchiveFileSummary
//------------------------------------------------------------------------------
cta::common::dataStructures::ArchiveFileSummary cta::catalogue::MockCatalogue::getArchiveFileSummary(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &id, const std::string &copynb, const std::string &tapepool,
const std::string &vid, const std::string &owner, const std::string &group, const std::string &storageclass, const std::string &path) {
return cta::common::dataStructures::ArchiveFileSummary();
}
//------------------------------------------------------------------------------
// setDriveStatus
//------------------------------------------------------------------------------
......
......@@ -87,7 +87,9 @@ public:
virtual void createTape(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &vid, const std::string &logicalLibraryName, const std::string &tapePoolName, const uint64_t capacityInBytes,
const bool disabledValue, const bool fullValue, const std::string &comment);
virtual void deleteTape(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &vid);
virtual std::list<cta::common::dataStructures::Tape> getTapes(const cta::common::dataStructures::SecurityIdentity &requester, const std::map<std::string, std::string> &where); // "where" is a map resembling an "and-ed" where clause in a SQL query
virtual std::list<cta::common::dataStructures::Tape> getTapes(const cta::common::dataStructures::SecurityIdentity &requester,
const std::string &vid, const std::string &logicalLibraryName, const std::string &tapePoolName,
const std::string &capacityInBytes, const std::string &disabledValue, const std::string &fullValue, const std::string &busyValue);
virtual void labelTape(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &vid, const bool force, const bool lbp, const std::string &tag);
virtual void reclaimTape(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &vid);
virtual void modifyTapeLogicalLibraryName(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &vid, const std::string &logicalLibraryName);
......@@ -133,8 +135,11 @@ public:
virtual void modifyDedicationUntil(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &drivename, const uint64_t untilTimestamp);
virtual void modifyDedicationComment(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &drivename, const std::string &comment);
virtual std::list<cta::common::dataStructures::ArchiveFile> getArchiveFiles(const cta::common::dataStructures::SecurityIdentity &requester, const std::map<std::string, std::string> &where); // "where" is a map resembling an "and-ed" where clause in a SQL query
virtual std::list<cta::common::dataStructures::ArchiveFile> getArchiveFiles(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &id, const std::string &copynb, const std::string &tapepool,
const std::string &vid, const std::string &owner, const std::string &group, const std::string &storageclass, const std::string &path);
virtual cta::common::dataStructures::ArchiveFileSummary getArchiveFileSummary(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &id, const std::string &copynb, const std::string &tapepool,
const std::string &vid, const std::string &owner, const std::string &group, const std::string &storageclass, const std::string &path);
virtual void setDriveStatus(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &driveName, const bool up, const bool force);
/**
* Returns the next identifier to be used for a new archive file.
......
......@@ -6,6 +6,7 @@ set (COMMON_LIB_SRC_FILES
dataStructures/AdminHost.cpp
dataStructures/AdminUser.cpp
dataStructures/ArchiveFile.cpp
dataStructures/ArchiveFileSummary.cpp
dataStructures/ArchiveJob.cpp
dataStructures/ArchiveMount.cpp
dataStructures/ArchiveRequest.cpp
......
/*
* 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/dataStructures/ArchiveFileSummary.hpp"
#include "common/exception/Exception.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::common::dataStructures::ArchiveFileSummary::ArchiveFileSummary() {
m_totalBytesSet = false;
m_totalFilesSet = false;
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
cta::common::dataStructures::ArchiveFileSummary::~ArchiveFileSummary() throw() {
}
//------------------------------------------------------------------------------
// allFieldsSet
//------------------------------------------------------------------------------
bool cta::common::dataStructures::ArchiveFileSummary::allFieldsSet() const {
return m_totalBytesSet
&& m_totalFilesSet;
}
//------------------------------------------------------------------------------
// setTotalBytes
//------------------------------------------------------------------------------
void cta::common::dataStructures::ArchiveFileSummary::setTotalBytes(const uint64_t totalBytes) {
m_totalBytes = totalBytes;
m_totalBytesSet = true;
}
//------------------------------------------------------------------------------
// getTotalBytes
//------------------------------------------------------------------------------
uint64_t cta::common::dataStructures::ArchiveFileSummary::getTotalBytes() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the ArchiveFileSummary have been set!");
}
return m_totalBytes;
}
//------------------------------------------------------------------------------
// setTotalFiles
//------------------------------------------------------------------------------
void cta::common::dataStructures::ArchiveFileSummary::setTotalFiles(const uint64_t totalFiles) {
m_totalFiles = totalFiles;
m_totalFilesSet = true;
}
//------------------------------------------------------------------------------
// getTotalFiles
//------------------------------------------------------------------------------
uint64_t cta::common::dataStructures::ArchiveFileSummary::getTotalFiles() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the ArchiveFileSummary have been set!");
}
return m_totalFiles;
}
/*
* 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 <list>
#include <map>
#include <stdint.h>
#include <string>
namespace cta {
namespace common {
namespace dataStructures {
class ArchiveFileSummary {
public:
/**
* Constructor
*/
ArchiveFileSummary();
/**
* Destructor
*/
~ArchiveFileSummary() throw();
void setTotalBytes(const uint64_t totalBytes);
uint64_t getTotalBytes() const;
void setTotalFiles(const uint64_t totalFiles);
uint64_t getTotalFiles() const;
private:
/**
* @return true if all fields have been set, false otherwise
*/
bool allFieldsSet() const;
uint64_t m_totalBytes;
bool m_totalBytesSet;
uint64_t m_totalFiles;
bool m_totalFilesSet;
}; // class ArchiveFileSummary
} // namespace dataStructures
} // namespace common
} // namespace cta
......@@ -80,7 +80,7 @@ cta ve/verify add/rm/ls/err:
ls [--vid/-v <vid>]
err --vid/-v <vid>
cta af/archivefile ls [--id/-I <archive_file_id>] [--copynb/-c <copy_no>] [--vid/-v <vid>] [--tapepool/-t <tapepool>] [--owner/-o <owner>] [--group/-g <owner>] [--storageclass/-s <class>] [--path/-p <fullpath>] [--summary/-S] [--all/-a] (default gives error)
cta af/archivefile ls [--id/-I <archive_file_id>] [--copynb/-c <copy_no>] [--vid/-v <vid>] [--tapepool/-t <tapepool>] [--owner/-o <owner>] [--group/-g <group>] [--storageclass/-s <class>] [--path/-p <fullpath>] [--summary/-S] [--all/-a] (default gives error)
cta te/test read/write (to be run on an empty self-dedicated drive; it is a synchronous command that returns performance stats and errors):
read --drive/-d <drive_name> --vid/-v <vid> --firstfseq/-f <first_fseq> --lastfseq/-l <last_fseq> --checkchecksum/-c --retries_per_file/-r <number_of_retries_per_file> [--outputdir/-o <output_dir>] [--null/-n] [--tag/-t <tag_name>]
......
......@@ -126,7 +126,8 @@ virtual void modifyLogicalLi
virtual void createTape (const SecurityIdentity &requester, const std::string &vid, const std::string &logicalLibraryName, const std::string &tapePoolName,
const uint64_t capacityInBytes, const bool disabledValue, const bool fullValue, const std::string &comment);
virtual void deleteTape (const SecurityIdentity &requester, const std::string &vid);
virtual std::list<Tape> getTapes (const SecurityIdentity &requester, const std::map<std::string, std::string> &where); // "where" is a map resembling an "and-ed" where clause in a SQL query
virtual std::list<Tape> getTapes (const SecurityIdentity &requester, const std::string &vid, const std::string &logicalLibraryName, const std::string &tapePoolName,
const std::string &capacityInBytes, const std::string &disabledValue, const std::string &fullValue, const std::string &busyValue);
virtual void labelTape (const SecurityIdentity &requester, const std::string &vid, const bool force, const bool lbp, const std::string &tag);
virtual void reclaimTape (const SecurityIdentity &requester, const std::string &vid);
virtual void modifyTapeLogicalLibraryName (const SecurityIdentity &requester, const std::string &vid, const std::string &logicalLibraryName);
......@@ -185,7 +186,10 @@ virtual void cancelVerify
virtual std::list<VerifyInfo> getVerifys (const SecurityIdentity &requester) const;
virtual VerifyInfo getVerify (const SecurityIdentity &requester, const std::string &vid) const;
virtual std::list<ArchiveFile> getArchiveFiles (const SecurityIdentity &requester, const std::map<std::string, std::string> &where); // "where" is a map resembling an "and-ed" where clause in a SQL query
virtual std::list<ArchiveFile> getArchiveFiles (const SecurityIdentity &requester, const std::string &id, const std::string &copynb, const std::string &tapepool,
const std::string &vid, const std::string &owner, const std::string &group, const std::string &storageclass, const std::string &path);
virtual ArchiveFileSummary getArchiveFileSummary (const SecurityIdentity &requester, const std::string &id, const std::string &copynb, const std::string &tapepool,
const std::string &vid, const std::string &owner, const std::string &group, const std::string &storageclass, const std::string &path);
virtual readTestResult readTest (const SecurityIdentity &requester, const std::string &driveName, const std::string &vid, const uint64_t firstFSeq, const uint64_t lastFSeq,
const bool checkChecksum, const uint32_t retriesPerFile, const std::string &outputDir, const bool redirectToDevNull, const std::string &tag) const;
......@@ -203,6 +207,13 @@ virtual std::list<RetrieveJob> getPendingRetri
virtual std::list<cta::DriveState> getDriveStates (const SecurityIdentity &requester) const;
struct ArchiveFileSummary {
uint64_t totalBytes;
uint64_t totalFiles;
}; // struct ArchiveFileSummary
struct ReadTestResult {
std::string driveName;
......
......@@ -37,7 +37,8 @@ virtual void modifyLogicalLi
virtual void createTape (const SecurityIdentity &requester, const std::string &vid, const std::string &logicalLibraryName, const std::string &tapePoolName,
const uint64_t capacityInBytes, const bool disabledValue, const bool fullValue, const std::string &comment);
virtual void deleteTape (const SecurityIdentity &requester, const std::string &vid);
virtual std::list<Tape> getTapes (const SecurityIdentity &requester, const std::map<std::string, std::string> &where); // "where" is a map resembling an "and-ed" where clause in a SQL query
virtual std::list<Tape> getTapes (const SecurityIdentity &requester, const std::string &vid, const std::string &logicalLibraryName, const std::string &tapePoolName,
const std::string &capacityInBytes, const std::string &disabledValue, const std::string &fullValue, const std::string &busyValue);
virtual void labelTape (const SecurityIdentity &requester, const std::string &vid, const bool force, const bool lbp, const std::string &tag);
virtual void reclaimTape (const SecurityIdentity &requester, const std::string &vid);
virtual void modifyTapeLogicalLibraryName (const SecurityIdentity &requester, const std::string &vid, const std::string &logicalLibraryName);
......@@ -84,6 +85,9 @@ virtual void modifyDedicatio
virtual void modifyDedicationUntil (const SecurityIdentity &requester, const std::string &drivename, const uint64_t untilTimestamp);
virtual void modifyDedicationComment (const SecurityIdentity &requester, const std::string &drivename, const std::string &comment);
virtual std::list<ArchiveFile> getArchiveFiles (const SecurityIdentity &requester, const std::map<std::string, std::string> &where); // "where" is a map resembling an "and-ed" where clause in a SQL query
virtual std::list<ArchiveFile> getArchiveFiles (const SecurityIdentity &requester, const std::string &id, const std::string &copynb, const std::string &tapepool,
const std::string &vid, const std::string &owner, const std::string &group, const std::string &storageclass, const std::string &path);
virtual ArchiveFileSummary getArchiveFileSummary (const SecurityIdentity &requester, const std::string &id, const std::string &copynb, const std::string &tapepool,
const std::string &vid, const std::string &owner, const std::string &group, const std::string &storageclass, const std::string &path);
virtual void setDriveStatus (const SecurityIdentity &requester, const std::string &driveName, const bool up, const bool force);
......@@ -306,7 +306,9 @@ void cta::Scheduler::deleteTape(const cta::common::dataStructures::SecurityIdent
//------------------------------------------------------------------------------
// getTapes
//------------------------------------------------------------------------------
std::list<cta::common::dataStructures::Tape> cta::Scheduler::getTapes(const cta::common::dataStructures::SecurityIdentity &requester, const std::map<std::string, std::string> &where) {
std::list<cta::common::dataStructures::Tape> cta::Scheduler::getTapes(const cta::common::dataStructures::SecurityIdentity &requester,
const std::string &vid, const std::string &logicalLibraryName, const std::string &tapePoolName,
const std::string &capacityInBytes, const std::string &disabledValue, const std::string &fullValue, const std::string &busyValue) {
return std::list<cta::common::dataStructures::Tape>();
}
......@@ -646,10 +648,19 @@ cta::common::dataStructures::VerifyInfo cta::Scheduler::getVerify(const cta::com
//------------------------------------------------------------------------------
// getArchiveFiles
//------------------------------------------------------------------------------
std::list<cta::common::dataStructures::ArchiveFile> cta::Scheduler::getArchiveFiles(const cta::common::dataStructures::SecurityIdentity &requester, const std::map<std::string, std::string> &where) {
std::list<cta::common::dataStructures::ArchiveFile> cta::Scheduler::getArchiveFiles(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &id, const std::string &copynb, const std::string &tapepool,
const std::string &vid, const std::string &owner, const std::string &group, const std::string &storageclass, const std::string &path) {
return std::list<cta::common::dataStructures::ArchiveFile>();
}
//------------------------------------------------------------------------------
// getArchiveFileSummary
//------------------------------------------------------------------------------
cta::common::dataStructures::ArchiveFileSummary cta::Scheduler::getArchiveFileSummary(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &id, const std::string &copynb, const std::string &tapepool,
const std::string &vid, const std::string &owner, const std::string &group, const std::string &storageclass, const std::string &path) {
return cta::common::dataStructures::ArchiveFileSummary();
}
//------------------------------------------------------------------------------
// readTest
//------------------------------------------------------------------------------
......
......@@ -23,6 +23,7 @@
#include "common/dataStructures/AdminHost.hpp"
#include "common/dataStructures/AdminUser.hpp"
#include "common/dataStructures/ArchiveFile.hpp"
#include "common/dataStructures/ArchiveFileSummary.hpp"
#include "common/dataStructures/ArchiveJob.hpp"
#include "common/dataStructures/ArchiveMount.hpp"
#include "common/dataStructures/ArchiveRequest.hpp"
......@@ -140,7 +141,9 @@ public:
virtual void createTape(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &vid, const std::string &logicalLibraryName, const std::string &tapePoolName,
const uint64_t capacityInBytes, const bool disabledValue, const bool fullValue, const std::string &comment);
virtual void deleteTape(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &vid);
virtual std::list<cta::common::dataStructures::Tape> getTapes(const cta::common::dataStructures::SecurityIdentity &requester, const std::map<std::string, std::string> &where); // "where" is a map resembling an "and-ed" where clause in a SQL query
virtual std::list<cta::common::dataStructures::Tape> getTapes(const cta::common::dataStructures::SecurityIdentity &requester,
const std::string &vid, const std::string &logicalLibraryName, const std::string &tapePoolName,
const std::string &capacityInBytes, const std::string &disabledValue, const std::string &fullValue, const std::string &busyValue);
virtual void labelTape(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &vid, const bool force, const bool lbp, const std::string &tag);
virtual void reclaimTape(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &vid);
virtual void modifyTapeLogicalLibraryName(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &vid, const std::string &logicalLibraryName);
......@@ -199,7 +202,10 @@ public:
virtual std::list<cta::common::dataStructures::VerifyInfo> getVerifys(const cta::common::dataStructures::SecurityIdentity &requester) const;
virtual cta::common::dataStructures::VerifyInfo getVerify(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &vid) const;
virtual std::list<cta::common::dataStructures::ArchiveFile> getArchiveFiles(const cta::common::dataStructures::SecurityIdentity &requester, const std::map<std::string, std::string> &where); // "where" is a map resembling an "and-ed" where clause in a SQL query
virtual std::list<cta::common::dataStructures::ArchiveFile> getArchiveFiles(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &id, const std::string &copynb, const std::string &tapepool,
const std::string &vid, const std::string &owner, const std::string &group, const std::string &storageclass, const std::string &path);
virtual cta::common::dataStructures::ArchiveFileSummary getArchiveFileSummary(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &id, const std::string &copynb, const std::string &tapepool,
const std::string &vid, const std::string &owner, const std::string &group, const std::string &storageclass, const std::string &path);
virtual cta::common::dataStructures::ReadTestResult readTest(const cta::common::dataStructures::SecurityIdentity &requester, const std::string &driveName, const std::string &vid, const uint64_t firstFSeq, const uint64_t lastFSeq,
const bool checkChecksum, const uint32_t retriesPerFile, const std::string &outputDir, const bool redirectToDevNull, const std::string &tag) const;
......
......@@ -17,19 +17,6 @@
*/
#include "cmdline/CTACmd.hpp"
#include "common/admin/AdminHost.hpp"
#include "common/admin/AdminUser.hpp"
#include "common/archiveNS/ArchiveDirIterator.hpp"
#include "common/archiveNS/StorageClass.hpp"
#include "common/archiveNS/Tape.hpp"
#include "common/archiveRoutes/ArchiveRoute.hpp"
#include "common/exception/Exception.hpp"
#include "common/SecurityIdentity.hpp"
#include "common/TapePool.hpp"
#include "common/UserIdentity.hpp"
#include "scheduler/ArchiveToTapeCopyRequest.hpp"
#include "scheduler/LogicalLibrary.hpp"
#include "scheduler/RetrieveRequestDump.hpp"
#include "scheduler/SchedulerDatabase.hpp"
#include "xroot_plugins/XrdCtaFile.hpp"
......@@ -760,6 +747,144 @@ void XrdProFile::xCom_tape(const std::vector<std::string> &tokens, const cta::co
<< "\treclaim --vid/-v <vid>" << std::endl
<< "\tls [--vid/-v <vid>] [--logicallibrary/-l <logical_library_name>] [--tapepool/-t <tapepool_name>] [--capacity/-c <capacity_in_bytes>] [--enabled/-e or --disabled/-d] [--free/-f or --full/-F] [--busy/-b or --notbusy/-n]" << std::endl
<< "\tlabel --vid/-v <vid> [--force/-f] [--lbp/-l] [--tag/-t <tag_name>]" << std::endl;
if("add" == tokens[2] || "ch" == tokens[2] || "rm" == tokens[2] || "reclaim" == tokens[2] || "label" == tokens[2]) {
std::string vid = getOptionValue(tokens, "-v", "--vid");
if(vid.empty()) {
m_data = help.str();
return;
}
if("add" == tokens[2]) { //add
std::string logicallibrary = getOptionValue(tokens, "-l", "--logicallibrary");
std::string tapepool = getOptionValue(tokens, "-t", "--tapepool");
std::string capacity_s = getOptionValue(tokens, "-c", "--capacity");
if(logicallibrary.empty()||tapepool.empty()||capacity_s.empty()) {
m_data = help.str();
return;
}
std::istringstream capacity_ss(capacity_s);
int capacity = 0;
capacity_ss >> capacity;
std::string comment = getOptionValue(tokens, "-m", "--comment");
bool disabled=false;
bool full=false;
if((hasOption(tokens, "-e", "--enabled") && hasOption(tokens, "-d", "--disabled")) || (hasOption(tokens, "-f", "--free") && hasOption(tokens, "-F", "--full"))) {
m_data = help.str();
return;
}
disabled=hasOption(tokens, "-d", "--disabled");
full=hasOption(tokens, "-F", "--full");
m_scheduler->createTape(requester, vid, logicallibrary, tapepool, capacity, disabled, full, comment);
}
else if("ch" == tokens[2]) { //ch
std::string logicallibrary = getOptionValue(tokens, "-l", "--logicallibrary");
std::string tapepool = getOptionValue(tokens, "-t", "--tapepool");
std::string capacity_s = getOptionValue(tokens, "-c", "--capacity");
std::string comment = getOptionValue(tokens, "-m", "--comment");
if(comment.empty() && logicallibrary.empty() && tapepool.empty() && capacity_s.empty() && !hasOption(tokens, "-e", "--enabled")
&& !hasOption(tokens, "-d", "--disabled") && !hasOption(tokens, "-f", "--free") && !hasOption(tokens, "-F", "--full")) {
m_data = help.str();
return;
}
if((hasOption(tokens, "-e", "--enabled") && hasOption(tokens, "-d", "--disabled")) || (hasOption(tokens, "-f", "--free") && hasOption(tokens, "-F", "--full"))) {
m_data = help.str();
return;
}
if(!logicallibrary.empty()) {
m_scheduler->modifyTapeLogicalLibraryName(requester, vid, logicallibrary);
}
if(!tapepool.empty()) {
m_scheduler->modifyTapeTapePoolName(requester, vid, tapepool);
}
if(!capacity_s.empty()) {
std::istringstream capacity_ss(capacity_s);
uint64_t capacity = 0;
capacity_ss >> capacity;
m_scheduler->modifyTapeCapacityInBytes(requester, vid, capacity);
}
if(!comment.empty()) {
m_scheduler->modifyTapeComment(requester, vid, comment);
}
if(hasOption(tokens, "-e", "--enabled")) {
m_scheduler->setTapeDisabled(requester, vid, false);
}
if(hasOption(tokens, "-d", "--disabled")) {
m_scheduler->setTapeDisabled(requester, vid, true);
}
if(hasOption(tokens, "-f", "--free")) {
m_scheduler->setTapeFull(requester, vid, false);
}
if(hasOption(tokens, "-F", "--full")) {
m_scheduler->setTapeFull(requester, vid, true);
}
}
else if("reclaim" == tokens[2]) { //reclaim
m_scheduler->reclaimTape(requester, vid);
}
else if("label" == tokens[2]) { //label
m_scheduler->labelTape(requester, vid, hasOption(tokens, "-f", "--force"), hasOption(tokens, "-l", "--lbp"), getOptionValue(tokens, "-t", "--tag"));
}
else { //rm
m_scheduler->deleteTape(requester, vid);
}
}
else if("ls" == tokens[2]) { //ls
std::string vid = getOptionValue(tokens, "-v", "--vid");
std::string logicallibrary = getOptionValue(tokens, "-l", "--logicallibrary");
std::string tapepool = getOptionValue(tokens, "-t", "--tapepool");
std::string capacity = getOptionValue(tokens, "-c", "--capacity");
if((hasOption(tokens, "-e", "--enabled") && hasOption(tokens, "-d", "--disabled"))
|| (hasOption(tokens, "-f", "--free") && hasOption(tokens, "-F", "--full"))
|| (hasOption(tokens, "-b", "--busy") && hasOption(tokens, "-n", "--notbusy"))) {
m_data = help.str();
return;
}
std::string disabled="";
std::string full="";
std::string busy="";
if(hasOption(tokens, "-e", "--enabled")) {
disabled = "false";
}
if(hasOption(tokens, "-d", "--disabled")) {
disabled = "true";
}
if(hasOption(tokens, "-f", "--free")) {
full = "false";
}
if(hasOption(tokens, "-F", "--full")) {
full = "true";
}
if(hasOption(tokens, "-b", "--busy")) {
busy = "false";
}
if(hasOption(tokens, "-n", "--notbusy")) {
busy = "true";
}
std::list<cta::common::dataStructures::Tape> list= m_scheduler->getTapes(requester, vid, logicallibrary, tapepool, capacity, disabled, full, busy);
if(list.size()>0) {
std::vector<std::vector<std::string>> responseTable;
std::vector<std::string> header = {"vid","logical library","tapepool","capacity","occupancy","last fseq","busy","full","disabled","c.uid","c.gid","c.host","c.time","m.uid","m.gid","m.host","m.time","comment"};
responseTable.push_back(header);
for(auto it = list.begin(); it != list.end(); it++) {
std::vector<std::string> currentRow;
currentRow.push_back(it->getVid());
currentRow.push_back(it->getLogicalLibraryName());
currentRow.push_back(it->getTapePoolName());
currentRow.push_back(std::to_string((unsigned long long)it->getCapacityInBytes()));
currentRow.push_back(std::to_string((unsigned long long)it->getDataOnTapeInBytes()));
currentRow.push_back(std::to_string((unsigned long long)it->getLastFSeq()));
if(it->getBusy()) currentRow.push_back("true"); else currentRow.push_back("false");
if(it->getFull()) currentRow.push_back("true"); else currentRow.push_back("false");
if(it->getDisabled()) currentRow.push_back("true"); else currentRow.push_back("false");
addLogInfoToResponseRow(currentRow, it->getCreationLog(), it->getLastModificationLog());
currentRow.push_back(it->getComment());
responseTable.push_back(currentRow);
}
m_data = formatResponse(responseTable);
}
}
else {
m_data = help.str();
}
}
//------------------------------------------------------------------------------
......@@ -851,7 +976,64 @@ void XrdProFile::xCom_verify(const std::vector<std::string> &tokens, const cta::
//------------------------------------------------------------------------------
void XrdProFile::xCom_archivefile(const std::vector<std::string> &tokens, const cta::common::dataStructures::SecurityIdentity &requester) {
std::stringstream help;
help << tokens[0] << " af/archivefile ls [--id/-I <archive_file_id>] [--copynb/-c <copy_no>] [--vid/-v <vid>] [--tapepool/-t <tapepool>] [--owner/-o <owner>] [--group/-g <owner>] [--storageclass/-s <class>] [--path/-p <fullpath>] [--summary/-S] [--all/-a] (default gives error)" << std::endl;
help << tokens[0] << " af/archivefile ls [--id/-I <archive_file_id>] [--copynb/-c <copy_no>] [--vid/-v <vid>] [--tapepool/-t <tapepool>] "
"[--owner/-o <owner>] [--group/-g <group>] [--storageclass/-s <class>] [--path/-p <fullpath>] [--summary/-S] [--all/-a] (default gives error)" << std::endl;
if("ls" == tokens[2]) { //ls
std::string id = getOptionValue(tokens, "-I", "--id");
std::string copynb = getOptionValue(tokens, "-c", "--copynb");
std::string tapepool = getOptionValue(tokens, "-t", "--tapepool");
std::string vid = getOptionValue(tokens, "-v", "--vid");
std::string owner = getOptionValue(tokens, "-o", "--owner");
std::string group = getOptionValue(tokens, "-g", "--group");
std::string storageclass = getOptionValue(tokens, "-s", "--storageclass");
std::string path = getOptionValue(tokens, "-p", "--path");
bool summary = hasOption(tokens, "-S", "--summary");
bool all = hasOption(tokens, "-a", "--all");
if(!all && (id.empty() && copynb.empty() && tapepool.empty() && vid.empty() && owner.empty() && group.empty() && storageclass.empty() && path.empty())) {
m_data = help.str();
return;