Skip to content
Snippets Groups Projects
Commit 9de8548e authored by Michael Davis's avatar Michael Davis
Browse files

[cta-admin] Displays new uid/gid and checksum formats

parent 72ee2e3a
No related branches found
No related tags found
No related merge requests found
......@@ -32,13 +32,8 @@ include_directories(${CMAKE_BINARY_DIR}/eos_cta ${PROTOBUF3_INCLUDE_DIRS})
#
# cta-admin <admin_command> is the SSI version of "cta <admin_command>"
#
add_executable(cta-admin
CtaAdminCmd.cpp
CtaAdminCmdParse.cpp
CtaAdminTextFormatter.cpp
../common/dataStructures/DriveStatus.cpp
../common/dataStructures/MountType.cpp)
target_link_libraries(cta-admin XrdSsiPbEosCta XrdSsi-4 XrdSsiLib XrdUtils)
add_executable(cta-admin CtaAdminCmd.cpp CtaAdminCmdParse.cpp CtaAdminTextFormatter.cpp)
target_link_libraries(cta-admin XrdSsiPbEosCta XrdSsi-4 XrdSsiLib XrdUtils ctacommon)
set_property (TARGET cta-admin APPEND PROPERTY INSTALL_RPATH ${PROTOBUF3_RPATH})
#
......
......@@ -20,6 +20,7 @@
#include <iostream>
#include <iomanip>
#include <cmdline/CtaAdminTextFormatter.hpp>
#include <common/checksum/ChecksumBlobSerDeser.hpp>
#include <common/dataStructures/DriveStatusSerDeser.hpp>
#include <common/dataStructures/MountTypeSerDeser.hpp>
......@@ -162,6 +163,22 @@ void TextFormatter::printArchiveFileLsHeader() {
}
void TextFormatter::print(const ArchiveFileLsItem &afls_item) {
using namespace cta::checksum;
std::string checksumType("NONE");
std::string checksumValue;
ChecksumBlob csb;
ProtobufToChecksumBlob(afls_item.af().csb(), csb);
// Files can have multiple checksums of different types. Display only the first checksum here. All
// checksums will be listed in JSON.
if(!csb.empty()) {
auto cs_it = csb.getMap().begin();
checksumType = ChecksumTypeName.at(cs_it->first);
checksumValue = "0x" + ChecksumBlob::ByteArrayToHex(cs_it->second);
}
push_back(
afls_item.af().archive_id(),
afls_item.copy_nb(),
......@@ -171,11 +188,11 @@ void TextFormatter::print(const ArchiveFileLsItem &afls_item) {
afls_item.af().disk_instance(),
afls_item.af().disk_id(),
dataSizeToStr(afls_item.af().size()),
afls_item.af().cs().type(),
afls_item.af().cs().value(),
checksumType,
checksumValue,
afls_item.af().storage_class(),
afls_item.af().df().owner(),
afls_item.af().df().group(),
afls_item.af().df().owner_id().uid(),
afls_item.af().df().owner_id().gid(),
timeToStr(afls_item.af().creation_time()),
afls_item.tf().superseded_by_vid(),
afls_item.tf().superseded_by_f_seq(),
......@@ -421,6 +438,22 @@ void TextFormatter::printListPendingArchivesHeader() {
}
void TextFormatter::print(const ListPendingArchivesItem &lpa_item) {
using namespace cta::checksum;
std::string checksumType("NONE");
std::string checksumValue;
ChecksumBlob csb;
ProtobufToChecksumBlob(lpa_item.af().csb(), csb);
// Files can have multiple checksums of different types. Display only the first checksum here. All
// checksums will be listed in JSON.
if(!csb.empty()) {
auto cs_it = csb.getMap().begin();
checksumType = ChecksumTypeName.at(cs_it->first);
checksumValue = "0x" + ChecksumBlob::ByteArrayToHex(cs_it->second);
}
push_back(
lpa_item.tapepool(),
lpa_item.af().archive_id(),
......@@ -428,11 +461,11 @@ void TextFormatter::print(const ListPendingArchivesItem &lpa_item) {
lpa_item.copy_nb(),
lpa_item.af().disk_id(),
lpa_item.af().disk_instance(),
lpa_item.af().cs().type(),
lpa_item.af().cs().value(),
checksumType,
checksumValue,
dataSizeToStr(lpa_item.af().size()),
lpa_item.af().df().owner(),
lpa_item.af().df().group(),
lpa_item.af().df().owner_id().uid(),
lpa_item.af().df().owner_id().gid(),
lpa_item.af().df().path()
);
}
......@@ -477,8 +510,8 @@ void TextFormatter::print(const ListPendingRetrievesItem &lpr_item) {
lpr_item.tf().f_seq(),
lpr_item.tf().block_id(),
dataSizeToStr(lpr_item.af().size()),
lpr_item.af().df().owner(),
lpr_item.af().df().group(),
lpr_item.af().df().owner_id().uid(),
lpr_item.af().df().owner_id().gid(),
lpr_item.af().df().path()
);
}
......
......@@ -24,7 +24,8 @@
#include <XrdSsiPbLog.hpp>
#include "common/dataStructures/FrontendReturnCode.hpp"
#include <common/dataStructures/FrontendReturnCode.hpp>
#include <common/checksum/ChecksumBlobSerDeser.hpp>
#include "CtaFrontendApi.hpp"
......@@ -109,10 +110,15 @@ void base64Decode(cta::eos::Notification &notification, const std::string &argva
notification.mutable_file()->mutable_mtime()->set_nsec(stoi(val.substr(pt_pos+1)));
}
else if(key == "size") notification.mutable_file()->set_size(stoi(val));
#ifdef CTA_CHECKSUMS_DONE
else if(key == "xstype") notification.mutable_file()->mutable_cks()->set_type(val);
else if(key == "xs") notification.mutable_file()->mutable_cks()->set_value(val);
#endif
else if(key == "xs")
{
// In principle it's possible to set the full checksum blob with multiple checksums of different
// types, but this is not currently supported in eos_wfe_stub. It's only possible to set one
// checksum, which is assumed to be of type ADLER32.
auto cs = notification.mutable_file()->mutable_csb()->add_cs();
cs->set_type(cta::common::ChecksumBlob::Checksum::ADLER32);
cs->set_value(cta::checksum::ChecksumBlob::HexToByteArray(val));
}
else if(key == "mode") notification.mutable_file()->set_mode(stoi(val));
else if(key == "file") notification.mutable_file()->set_lpath(val);
else {
......@@ -222,10 +228,15 @@ void fillNotification(cta::eos::Notification &notification, int argc, const char
else if(argstr == "--diskfileowner") notification.mutable_file()->mutable_owner()->set_uid(std::stoi(argval));
else if(argstr == "--diskfilegroup") notification.mutable_file()->mutable_owner()->set_gid(std::stoi(argval));
else if(argstr == "--size") notification.mutable_file()->set_size(std::stoi(argval));
#ifdef CTA_CHECKSUMS_DONE
else if(argstr == "--checksumtype") notification.mutable_file()->mutable_cks()->set_type(argval);
else if(argstr == "--checksumvalue") notification.mutable_file()->mutable_cks()->set_value(argval);
#endif
else if(argstr == "--checksumvalue")
{
// In principle it's possible to set the full checksum blob with multiple checksums of different
// types, but this is not currently supported in eos_wfe_stub. It's only possible to set one
// checksum, which is assumed to be of type ADLER32.
auto cs = notification.mutable_file()->mutable_csb()->add_cs();
cs->set_type(cta::common::ChecksumBlob::Checksum::ADLER32);
cs->set_value(cta::checksum::ChecksumBlob::HexToByteArray(argval));
}
else if(argstr == "--diskfilepath") notification.mutable_file()->set_lpath(argval);
else if(argstr == "--storageclass") {
google::protobuf::MapPair<std::string,std::string> sc("CTA_StorageClass", argval);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment