From 38bdb0e449e5c262514365e5266aeb3233aece92 Mon Sep 17 00:00:00 2001
From: guenther <jaroslav.guenther@cern.ch>
Date: Tue, 1 Apr 2025 16:43:47 +0200
Subject: [PATCH 1/6] expending cta-admin command output by instanceName and
 schedulerBackendName

---
 cmdline/CtaAdminTextFormatter.cpp             | 174 +++++++++++-------
 frontend/common/FrontendService.cpp           |   3 +-
 frontend/common/FrontendService.hpp           |   6 +
 xroot_plugins/AdminCmdStream.cpp              |   5 +-
 xroot_plugins/AdminCmdStream.hpp              |   6 +
 xroot_plugins/XrdCtaActivityMountRuleLs.hpp   |   7 +-
 xroot_plugins/XrdCtaAdminLs.hpp               |   6 +-
 xroot_plugins/XrdCtaArchiveRouteLs.hpp        |   5 +-
 xroot_plugins/XrdCtaDiskInstanceLs.hpp        |   5 +-
 xroot_plugins/XrdCtaDiskInstanceSpaceLs.hpp   |   5 +-
 xroot_plugins/XrdCtaDiskSystemLs.hpp          |   5 +-
 xroot_plugins/XrdCtaDriveLs.hpp               |   5 +-
 xroot_plugins/XrdCtaFailedRequestLs.hpp       |  23 ++-
 xroot_plugins/XrdCtaGroupMountRuleLs.hpp      |   5 +-
 xroot_plugins/XrdCtaLogicalLibraryLs.hpp      |   5 +-
 xroot_plugins/XrdCtaMediaTypeLs.hpp           |   5 +-
 xroot_plugins/XrdCtaMountPolicyLs.hpp         |   5 +-
 xroot_plugins/XrdCtaPhysicalLibraryLs.hpp     |   5 +-
 xroot_plugins/XrdCtaRecycleTapeFileLs.hpp     |   4 +-
 xroot_plugins/XrdCtaRepackLs.hpp              |   6 +-
 xroot_plugins/XrdCtaRequesterMountRuleLs.hpp  |   5 +-
 xroot_plugins/XrdCtaShowQueues.hpp            |  15 +-
 xroot_plugins/XrdCtaStorageClassLs.hpp        |   5 +-
 xroot_plugins/XrdCtaTapeFileLs.hpp            |   7 +-
 xroot_plugins/XrdCtaTapeLs.hpp                |   5 +-
 xroot_plugins/XrdCtaTapePoolLs.hpp            |   5 +-
 xroot_plugins/XrdCtaVersion.hpp               |   3 +
 xroot_plugins/XrdCtaVirtualOrganizationLs.hpp |   5 +-
 28 files changed, 244 insertions(+), 96 deletions(-)

diff --git a/cmdline/CtaAdminTextFormatter.cpp b/cmdline/CtaAdminTextFormatter.cpp
index ccf9173f64..1c2d2109e0 100644
--- a/cmdline/CtaAdminTextFormatter.cpp
+++ b/cmdline/CtaAdminTextFormatter.cpp
@@ -176,6 +176,7 @@ void TextFormatter::flush() {
 void TextFormatter::printActivityMountRuleLsHeader() {
   push_back("HEADER");
   push_back("instance",
+            "disk buffer",
             "username",
             "policy",
             "activity",
@@ -189,7 +190,8 @@ void TextFormatter::printActivityMountRuleLsHeader() {
 }
 
 void TextFormatter::print(const ActivityMountRuleLsItem& amrls_item) {
-  push_back(amrls_item.disk_instance(),
+  push_back(amrls_item.instance_name(),
+            amrls_item.disk_instance(),
             amrls_item.activity_mount_rule(),
             amrls_item.mount_policy(),
             amrls_item.activity_regex(),
@@ -204,7 +206,7 @@ void TextFormatter::print(const ActivityMountRuleLsItem& amrls_item) {
 
 void TextFormatter::printAdminLsHeader() {
   push_back("HEADER");
-  push_back("user", "c.user", "c.host", "c.time", "m.user", "m.host", "m.time", "comment");
+  push_back("user", "c.user", "c.host", "c.time", "m.user", "m.host", "m.time", "comment", "instance");
 }
 
 void TextFormatter::print(const AdminLsItem& adls_item) {
@@ -215,12 +217,14 @@ void TextFormatter::print(const AdminLsItem& adls_item) {
             adls_item.last_modification_log().username(),
             adls_item.last_modification_log().host(),
             timeToStr(adls_item.last_modification_log().time()),
-            adls_item.comment());
+            adls_item.comment(),
+            adls_item.instance_name());
 }
 
 void TextFormatter::printArchiveRouteLsHeader() {
   push_back("HEADER");
-  push_back("storage class",
+  push_back("instance",
+            "storage class",
             "copy number",
             "type",
             "tapepool",
@@ -234,7 +238,8 @@ void TextFormatter::printArchiveRouteLsHeader() {
 }
 
 void TextFormatter::print(const ArchiveRouteLsItem& arls_item) {
-  push_back(arls_item.storage_class(),
+  push_back(arls_item.instance_name(),
+            arls_item.storage_class(),
             arls_item.copy_number(),
             cta::common::dataStructures::toString(ProtobufToArchiveRouteTypeFormat(arls_item.archive_route_type())),
             arls_item.tapepool(),
@@ -266,6 +271,7 @@ void TextFormatter::printDriveLsHeader() {
             "priority",
             "activity",
             "scheduler",
+            "instance",
             "age",
             "reason");
 }
@@ -275,6 +281,7 @@ void TextFormatter::print(const DriveLsItem& drls_item) {
 
   std::string driveStatusSince;
   std::string driveSchedulerBackendName = drls_item.scheduler_backend_name();
+  std::string instanceName = drls_item.instance_name();
   std::string filesTransferredInSession;
   std::string bytesTransferredInSession;
   std::string averageBandwidth;
@@ -327,13 +334,14 @@ void TextFormatter::print(const DriveLsItem& drls_item) {
             drls_item.current_priority(),
             drls_item.current_activity(),
             driveSchedulerBackendName,
+            instanceName,
             timeSinceLastUpdate,
             reason);
 }
 
 void TextFormatter::printFailedRequestLsHeader() {
   push_back("HEADER");
-  push_back("object id", "request type", "copy no", "tapepool/vid", "requester", "group", "path");
+  push_back("object id", "request type", "copy no", "tapepool/vid", "requester", "group", "path", "scheduler", "instance");
 }
 
 void TextFormatter::print(const FailedRequestLsItem& frls_item) {
@@ -359,7 +367,9 @@ void TextFormatter::print(const FailedRequestLsItem& frls_item) {
             tapepool_vid,
             frls_item.requester().username(),
             frls_item.requester().groupname(),
-            frls_item.af().df().path());
+            frls_item.af().df().path(),
+            frls_item.scheduler_backend_name(),
+            frls_item.instance_name());
 
   // Note: failure log messages are available in frls_item.failurelogs(). These are not currently
   //       displayed in the text output, only in JSON.
@@ -367,7 +377,7 @@ void TextFormatter::print(const FailedRequestLsItem& frls_item) {
 
 void TextFormatter::printFailedRequestLsSummaryHeader() {
   push_back("HEADER");
-  push_back("request type", "total files", "total size");
+  push_back("request type", "total files", "total size", "scheduler", "instance");
 }
 
 void TextFormatter::print(const FailedRequestLsSummary& frls_summary) {
@@ -375,16 +385,17 @@ void TextFormatter::print(const FailedRequestLsSummary& frls_summary) {
                              frls_summary.request_type() == RequestType::RETRIEVE_REQUEST ? "retrieve" :
                                                                                             "total";
 
-  push_back(request_type, frls_summary.total_files(), dataSizeToStr(frls_summary.total_size()));
+  push_back(request_type, frls_summary.total_files(), dataSizeToStr(frls_summary.total_size()), frls_summary.scheduler_backend_name(), frls_summary.instance_name());
 }
 
 void TextFormatter::printGroupMountRuleLsHeader() {
   push_back("HEADER");
-  push_back("instance", "group", "policy", "c.user", "c.host", "c.time", "m.user", "m.host", "m.time", "comment");
+  push_back("instance", "disk buffer", "group", "policy", "c.user", "c.host", "c.time", "m.user", "m.host", "m.time", "comment");
 }
 
 void TextFormatter::print(const GroupMountRuleLsItem& gmrls_item) {
-  push_back(gmrls_item.disk_instance(),
+  push_back(gmrls_item.instance_name(),
+            gmrls_item.disk_instance(),
             gmrls_item.group_mount_rule(),
             gmrls_item.mount_policy(),
             gmrls_item.creation_log().username(),
@@ -490,7 +501,8 @@ void TextFormatter::printLogicalLibraryLsHeader() {
             "m.user",
             "m.host",
             "m.time",
-            "comment");
+            "comment",
+            "instance");
 }
 
 void TextFormatter::print(const LogicalLibraryLsItem& llls_item) {
@@ -504,7 +516,8 @@ void TextFormatter::print(const LogicalLibraryLsItem& llls_item) {
             llls_item.last_modification_log().username(),
             llls_item.last_modification_log().host(),
             timeToStr(llls_item.last_modification_log().time()),
-            llls_item.comment());
+            llls_item.comment(),
+            llls_item.instance_name());
 }
 
 void TextFormatter::printMediaTypeLsHeader() {
@@ -523,7 +536,8 @@ void TextFormatter::printMediaTypeLsHeader() {
             "m.user",
             "m.host",
             "m.time",
-            "comment");
+            "comment",
+            "instance");
 }
 
 void TextFormatter::print(const MediaTypeLsItem& mtls_item) {
@@ -541,7 +555,8 @@ void TextFormatter::print(const MediaTypeLsItem& mtls_item) {
             mtls_item.last_modification_log().username(),
             mtls_item.last_modification_log().host(),
             timeToStr(mtls_item.last_modification_log().time()),
-            mtls_item.comment());
+            mtls_item.comment(),
+            mtls_item.instance_name());
 }
 
 void TextFormatter::printMountPolicyLsHeader() {
@@ -557,7 +572,8 @@ void TextFormatter::printMountPolicyLsHeader() {
             "m.user",
             "m.host",
             "m.time",
-            "comment");
+            "comment",
+            "instance");
 }
 
 void TextFormatter::print(const MountPolicyLsItem& mpls_item) {
@@ -572,7 +588,8 @@ void TextFormatter::print(const MountPolicyLsItem& mpls_item) {
             mpls_item.last_modification_log().username(),
             mpls_item.last_modification_log().host(),
             timeToStr(mpls_item.last_modification_log().time()),
-            mpls_item.comment());
+            mpls_item.comment(),
+            mpls_item.instance_name());
 }
 
 void TextFormatter::printRepackLsHeader() {
@@ -589,7 +606,8 @@ void TextFormatter::printRepackLsHeader() {
             "filesToRetrieve",
             "filesToArchive",
             "failed",
-            "status");
+            "status",
+            "instance");
 }
 
 void TextFormatter::print(const RepackLsItem& rels_item) {
@@ -610,16 +628,18 @@ void TextFormatter::print(const RepackLsItem& rels_item) {
     rels_item.files_left_to_retrieve(),                       //https://gitlab.cern.ch/cta/CTA/-/issues/680#note_3845829
     rels_item.files_left_to_archive(),                        //https://gitlab.cern.ch/cta/CTA/-/issues/680#note_3845829
     rels_item.total_failed_files(),                           //https://gitlab.cern.ch/cta/CTA/-/issues/680#note_3849927
-    rels_item.status());
+    rels_item.status(),
+    rels_item.instance_name());
 }
 
 void TextFormatter::printRequesterMountRuleLsHeader() {
   push_back("HEADER");
-  push_back("instance", "username", "policy", "c.user", "c.host", "c.time", "m.user", "m.host", "m.time", "comment");
+  push_back("instance", "disk buffer", "username", "policy", "c.user", "c.host", "c.time", "m.user", "m.host", "m.time", "comment");
 }
 
 void TextFormatter::print(const RequesterMountRuleLsItem& rmrls_item) {
-  push_back(rmrls_item.disk_instance(),
+  push_back(rmrls_item.instance_name(),
+            rmrls_item.disk_instance(),
             rmrls_item.requester_mount_rule(),
             rmrls_item.mount_policy(),
             rmrls_item.creation_log().username(),
@@ -634,6 +654,8 @@ void TextFormatter::print(const RequesterMountRuleLsItem& rmrls_item) {
 void TextFormatter::printShowQueuesHeader() {
   push_back("HEADER");
   push_back("type",
+            "instance",
+            "scheduler",
             "tapepool",
             "vo",
             "library",
@@ -671,6 +693,8 @@ void TextFormatter::print(const ShowQueuesItem& sq_item) {
   }
 
   push_back(toCamelCaseString(ProtobufToMountType(sq_item.mount_type())),
+            sq_item.instance_name(),
+            sq_item.scheduler_backend_name(),
             sq_item.tapepool(),
             sq_item.vo(),
             sq_item.logical_library(),
@@ -704,7 +728,8 @@ void TextFormatter::printStorageClassLsHeader() {
             "m.user",
             "m.host",
             "m.time",
-            "comment");
+            "comment",
+            "instance");
 }
 
 void TextFormatter::print(const StorageClassLsItem& scls_item) {
@@ -717,7 +742,8 @@ void TextFormatter::print(const StorageClassLsItem& scls_item) {
             scls_item.last_modification_log().username(),
             scls_item.last_modification_log().host(),
             timeToStr(scls_item.last_modification_log().time()),
-            scls_item.comment());
+            scls_item.comment(),
+            scls_item.instance_name());
 }
 
 void TextFormatter::printTapeLsHeader() {
@@ -751,7 +777,8 @@ void TextFormatter::printTapeLsHeader() {
             "m.user",
             "m.host",
             "m.time",
-            "comment");
+            "comment",
+            "instance");
 }
 
 void TextFormatter::print(const TapeLsItem& tals_item) {
@@ -785,7 +812,8 @@ void TextFormatter::print(const TapeLsItem& tals_item) {
             tals_item.last_modification_log().username(),
             tals_item.last_modification_log().host(),
             timeToStr(tals_item.last_modification_log().time()),
-            tals_item.comment());
+            tals_item.comment(),
+            tals_item.instance_name());
 }
 
 void TextFormatter::printTapeFileLsHeader() {
@@ -803,7 +831,8 @@ void TextFormatter::printTapeFileLsHeader() {
             "storage class",
             "owner",
             "group",
-            "creation time");
+            "creation time",
+            "instance");
 }
 
 void TextFormatter::print(const TapeFileLsItem& tfls_item) {
@@ -831,7 +860,8 @@ void TextFormatter::print(const TapeFileLsItem& tfls_item) {
             tfls_item.af().storage_class(),
             tfls_item.df().owner_id().uid(),
             tfls_item.df().owner_id().gid(),
-            timeToStr(tfls_item.af().creation_time()));
+            timeToStr(tfls_item.af().creation_time()),
+            tfls_item.instance_name());
 }
 
 void TextFormatter::printTapePoolLsHeader() {
@@ -853,7 +883,8 @@ void TextFormatter::printTapePoolLsHeader() {
             "m.user",
             "m.host",
             "m.time",
-            "comment");
+            "comment",
+            "instance");
 }
 
 void TextFormatter::print(const TapePoolLsItem& tpls_item) {
@@ -893,35 +924,14 @@ void TextFormatter::print(const TapePoolLsItem& tpls_item) {
             tpls_item.modified().username(),
             tpls_item.modified().host(),
             timeToStr(tpls_item.modified().time()),
-            tpls_item.comment());
-}
-
-void TextFormatter::printDiskSystemLsHeader() {
-  push_back("HEADER");
-  push_back("name",
-            "instance",
-            "diskspace",
-            "regexp",
-            "space",
-            "sleep",
-            "c.user",
-            "c.host",
-            "c.time",
-            "m.user",
-            "m.host",
-            "m.time",
-            "comment");
-}
-
-void TextFormatter::printDiskInstanceLsHeader() {
-  push_back("HEADER");
-  push_back("name", "c.user", "c.host", "c.time", "m.user", "m.host", "m.time", "comment");
+            tpls_item.comment(),
+            tpls_item.instance_name());
 }
 
 void TextFormatter::printDiskInstanceSpaceLsHeader() {
   push_back("HEADER");
   push_back("name",
-            "instance",
+            "disk buffer",
             "url",
             "interval",
             "last refresh",
@@ -932,13 +942,13 @@ void TextFormatter::printDiskInstanceSpaceLsHeader() {
             "m.user",
             "m.host",
             "m.time",
-            "comment");
+            "comment",
+            "instance");
 }
 
 void TextFormatter::print(const DiskInstanceSpaceLsItem& disls_item) {
   push_back(disls_item.name(),
             disls_item.disk_instance(),
-            disls_item.free_space_query_url(),
             disls_item.refresh_interval(),
             disls_item.last_refresh_time(),
             disls_item.free_space(),
@@ -948,7 +958,13 @@ void TextFormatter::print(const DiskInstanceSpaceLsItem& disls_item) {
             disls_item.last_modification_log().username(),
             disls_item.last_modification_log().host(),
             timeToStr(disls_item.last_modification_log().time()),
-            disls_item.comment());
+            disls_item.comment(),
+            disls_item.instance_name());
+}
+
+void TextFormatter::printDiskInstanceLsHeader() {
+  push_back("HEADER");
+  push_back("name", "c.user", "c.host", "c.time", "m.user", "m.host", "m.time", "comment", "instance");
 }
 
 void TextFormatter::print(const DiskInstanceLsItem& dils_item) {
@@ -959,7 +975,26 @@ void TextFormatter::print(const DiskInstanceLsItem& dils_item) {
             dils_item.last_modification_log().username(),
             dils_item.last_modification_log().host(),
             timeToStr(dils_item.last_modification_log().time()),
-            dils_item.comment());
+            dils_item.comment(),
+            dils_item.instance_name());
+}
+
+void TextFormatter::printDiskSystemLsHeader() {
+  push_back("HEADER");
+  push_back("name",
+            "instance",
+            "diskspace",
+            "regexp",
+            "space",
+            "sleep",
+            "c.user",
+            "c.host",
+            "c.time",
+            "m.user",
+            "m.host",
+            "m.time",
+            "comment",
+            "instance");
 }
 
 void TextFormatter::print(const DiskSystemLsItem& dsls_item) {
@@ -975,7 +1010,8 @@ void TextFormatter::print(const DiskSystemLsItem& dsls_item) {
             dsls_item.last_modification_log().username(),
             dsls_item.last_modification_log().host(),
             timeToStr(dsls_item.last_modification_log().time()),
-            dsls_item.comment());
+            dsls_item.comment(),
+            dsls_item.instance_name());
 }
 
 void TextFormatter::printVirtualOrganizationLsHeader() {
@@ -992,7 +1028,8 @@ void TextFormatter::printVirtualOrganizationLsHeader() {
             "m.user",
             "m.host",
             "m.time",
-            "comment");
+            "comment",
+            "instance");
 }
 
 void TextFormatter::print(const VirtualOrganizationLsItem& vols_item) {
@@ -1008,7 +1045,8 @@ void TextFormatter::print(const VirtualOrganizationLsItem& vols_item) {
             vols_item.last_modification_log().username(),
             vols_item.last_modification_log().host(),
             timeToStr(vols_item.last_modification_log().time()),
-            vols_item.comment());
+            vols_item.comment(),
+            vols_item.instance_name());
 }
 
 void TextFormatter::printVersionHeader() {
@@ -1017,8 +1055,9 @@ void TextFormatter::printVersionHeader() {
             "Client xrd-ssi-protobuf",
             "CTA Frontend",
             "Server xrd-ssi-protobuf",
-            "Catalogue schema",
-            "DB connection string",
+            "Catalogue Schema",
+            "DB Connection String",
+            "Instance Name",
             "Status",
             "Scheduler Backend Name");
 }
@@ -1030,6 +1069,7 @@ void TextFormatter::print(const VersionItem& version_item) {
             version_item.server_version().xrootd_ssi_protobuf_interface_version(),
             version_item.catalogue_version(),
             version_item.catalogue_connection_string(),
+            version_item.instance_name(),
             version_item.is_upgrading() ? "UPGRADING" : "PRODUCTION",
             version_item.scheduler_backend_name());
 }
@@ -1051,7 +1091,8 @@ void TextFormatter::printRecycleTapeFileLsHeader() {
             "group",
             "deletion time",
             "path when deleted",
-            "reason");
+            "reason",
+            "instance");
 }
 
 void TextFormatter::print(const RecycleTapeFileLsItem& rtfls_item) {
@@ -1081,7 +1122,8 @@ void TextFormatter::print(const RecycleTapeFileLsItem& rtfls_item) {
             rtfls_item.disk_file_gid(),
             timeToStr(rtfls_item.recycle_log_time()),
             rtfls_item.disk_file_path(),
-            rtfls_item.reason_log());
+            rtfls_item.reason_log(),
+            rtfls_item.instance_name());
 }
 
 void TextFormatter::printPhysicalLibraryLsHeader() {
@@ -1103,7 +1145,8 @@ void TextFormatter::printPhysicalLibraryLsHeader() {
             "m.user",
             "m.host",
             "m.time",
-            "comment");
+            "comment",
+            "instance");
 }
 
 void TextFormatter::print(const PhysicalLibraryLsItem& plls_item) {
@@ -1124,7 +1167,8 @@ void TextFormatter::print(const PhysicalLibraryLsItem& plls_item) {
             plls_item.last_modification_log().username(),
             plls_item.last_modification_log().host(),
             timeToStr(plls_item.last_modification_log().time()),
-            plls_item.comment());
+            plls_item.comment(),
+            plls_item.instance_name());
 }
 
 }  // namespace cta::admin
diff --git a/frontend/common/FrontendService.cpp b/frontend/common/FrontendService.cpp
index 8b3043d03c..1d20cbb785 100644
--- a/frontend/common/FrontendService.cpp
+++ b/frontend/common/FrontendService.cpp
@@ -92,6 +92,7 @@ FrontendService::FrontendService(const std::string& configFilename) : m_archiveF
     if (!instanceName.has_value()) {
       throw exception::UserError("cta.instance_name is not set in configuration file " + configFilename);
     }
+    m_instanceName = instanceName.value();
     if (!backendName.has_value()) {
       throw exception::UserError("cta.schedulerdb.scheduler_backend_name is not set in configuration file " +
                                  configFilename);
@@ -99,7 +100,7 @@ FrontendService::FrontendService(const std::string& configFilename) : m_archiveF
       m_schedulerBackendName = backendName.value();
     }
 
-    staticParamMap["instance"] = instanceName.value();
+    staticParamMap["instance"] = m_instanceName;
     staticParamMap["sched_backend"] = m_schedulerBackendName;
     log.setStaticParams(staticParamMap);
   }
diff --git a/frontend/common/FrontendService.hpp b/frontend/common/FrontendService.hpp
index 79de900c6c..9db932d943 100644
--- a/frontend/common/FrontendService.hpp
+++ b/frontend/common/FrontendService.hpp
@@ -151,6 +151,11 @@ public:
    */
   const std::optional<int> getThreads() const { return m_threads; }
 
+  /*
+   * Get the instanceName from config file
+   */
+  const std::string getInstanceName() const { return m_instanceName; }
+
 private:
   /*!
    * Set the verification mount policy
@@ -192,6 +197,7 @@ private:
   std::optional<std::string>                    m_tlsCert;                      //!< The TLS service certificate file
   std::optional<std::string>                    m_tlsChain;                     //!< The TLS CA chain file
   uint64_t                                      m_missingFileCopiesMinAgeSecs;  //!< Missing tape file copies minimum age.
+  std::string                                   m_instanceName;               //!< value of cta.instance_name in the CTA frontend configuration file
   // clang-format on
 };
 
diff --git a/xroot_plugins/AdminCmdStream.cpp b/xroot_plugins/AdminCmdStream.cpp
index 70ce06692a..e28ef243d2 100644
--- a/xroot_plugins/AdminCmdStream.cpp
+++ b/xroot_plugins/AdminCmdStream.cpp
@@ -57,7 +57,8 @@ AdminCmdStream::AdminCmdStream(const frontend::FrontendService& frontendService,
     : AdminCmd(frontendService, clientIdentity, adminCmd),
       m_stream(stream),
       m_schedDb(frontendService.getSchedDb()),
-      m_catalogueConnString(frontendService.getCatalogueConnString()) {}
+      m_catalogueConnString(frontendService.getCatalogueConnString()),
+      m_instanceName(frontendService.getInstanceName()) {}
 
 xrd::Response AdminCmdStream::process() {
   xrd::Response response;
@@ -244,7 +245,7 @@ void AdminCmdStream::processMountPolicy_Ls(xrd::Response& response) {
 void AdminCmdStream::processRepack_Ls(xrd::Response& response) {
   auto vid = getOptional(admin::OptionString::VID);
 
-  m_stream = new xrd::RepackLsStream(m_scheduler, m_catalogue, vid);
+  m_stream = new xrd::RepackLsStream(*this, m_scheduler, m_catalogue, vid);
 
   response.set_show_header(admin::HeaderType::REPACK_LS);
   response.set_type(xrd::Response::RSP_SUCCESS);
diff --git a/xroot_plugins/AdminCmdStream.hpp b/xroot_plugins/AdminCmdStream.hpp
index d3aa344e6c..5e0da38d53 100644
--- a/xroot_plugins/AdminCmdStream.hpp
+++ b/xroot_plugins/AdminCmdStream.hpp
@@ -53,6 +53,11 @@ public:
    */
   static bool isStreamCmd(const admin::AdminCmd& adminCmd);
 
+  /*!
+   * Get CTA instance Name (set in the CTA Frontend config file)
+   */
+  const std::string getInstanceName() const { return m_instanceName; }
+
 private:
   /*!
    * Process admin commands which return a stream response
@@ -86,6 +91,7 @@ private:
   XrdSsiStream*&         m_stream;                 //!< XRootD SSI stream for responses
   cta::SchedulerDB_t&    m_schedDb;                //!< Reference to CTA SchedulerDB
   const std::string      m_catalogueConnString;    //!< CTA Catalogue DB connection string
+  const std::string      m_instanceName;    //!< name of the CTA instance as specified in the server configuration file
   // clang-format on
 };
 
diff --git a/xroot_plugins/XrdCtaActivityMountRuleLs.hpp b/xroot_plugins/XrdCtaActivityMountRuleLs.hpp
index dc91ab0e3a..45b143221a 100644
--- a/xroot_plugins/XrdCtaActivityMountRuleLs.hpp
+++ b/xroot_plugins/XrdCtaActivityMountRuleLs.hpp
@@ -50,6 +50,7 @@ private:
   virtual int fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf);
 
   std::list<cta::common::dataStructures::RequesterActivityMountRule> m_activityMountRuleList;    //!< List of group mount rules from the catalogue
+  const std::string m_instanceName;
 
   static constexpr const char* const LOG_SUFFIX  = "ActivityMountRuleLsStream";               //!< Identifier for log messages
 };
@@ -57,7 +58,8 @@ private:
 
 ActivityMountRuleLsStream::ActivityMountRuleLsStream(const frontend::AdminCmdStream& requestMsg, cta::catalogue::Catalogue &catalogue, cta::Scheduler &scheduler) :
   XrdCtaStream(catalogue, scheduler),
-  m_activityMountRuleList(catalogue.RequesterActivityMountRule()->getRequesterActivityMountRules())
+  m_activityMountRuleList(catalogue.RequesterActivityMountRule()->getRequesterActivityMountRules()),
+  m_instanceName(requestMsg.getInstanceName())
 {
   using namespace cta::admin;
 
@@ -81,7 +83,8 @@ int ActivityMountRuleLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streamb
     amr_item->mutable_last_modification_log()->set_username(amr.lastModificationLog.username);
     amr_item->mutable_last_modification_log()->set_host(amr.lastModificationLog.host);
     amr_item->mutable_last_modification_log()->set_time(amr.lastModificationLog.time);
-    amr_item->set_comment(amr.comment);
+    amr_item->set_comment(amr.comment),
+    amr_item->set_instance_name(m_instanceName);
 
     is_buffer_full = streambuf->Push(record);
   }
diff --git a/xroot_plugins/XrdCtaAdminLs.hpp b/xroot_plugins/XrdCtaAdminLs.hpp
index c5e14c9238..748e608803 100644
--- a/xroot_plugins/XrdCtaAdminLs.hpp
+++ b/xroot_plugins/XrdCtaAdminLs.hpp
@@ -52,6 +52,7 @@ private:
   virtual int fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf);
 
   std::list<cta::common::dataStructures::AdminUser> m_adminList;       //!< List of admin users from the catalogue
+  const std::string m_instanceName;
 
   static constexpr const char* const LOG_SUFFIX  = "AdminLsStream";    //!< Identifier for log messages
 };
@@ -59,7 +60,8 @@ private:
 
 AdminLsStream::AdminLsStream(const frontend::AdminCmdStream& requestMsg, cta::catalogue::Catalogue &catalogue, cta::Scheduler &scheduler) :
   XrdCtaStream(catalogue, scheduler),
-  m_adminList(catalogue.AdminUser()->getAdminUsers())
+  m_adminList(catalogue.AdminUser()->getAdminUsers()),
+  m_instanceName(requestMsg.getInstanceName())
 {
   using namespace cta::admin;
 
@@ -81,7 +83,7 @@ int AdminLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf) {
     ad_item->mutable_last_modification_log()->set_host(ad.lastModificationLog.host);
     ad_item->mutable_last_modification_log()->set_time(ad.lastModificationLog.time);
     ad_item->set_comment(ad.comment);
-
+    ad_item->set_instance_name(m_instanceName);
     is_buffer_full = streambuf->Push(record);
   }
   return streambuf->Size();
diff --git a/xroot_plugins/XrdCtaArchiveRouteLs.hpp b/xroot_plugins/XrdCtaArchiveRouteLs.hpp
index a7c12baac0..cba2743cec 100644
--- a/xroot_plugins/XrdCtaArchiveRouteLs.hpp
+++ b/xroot_plugins/XrdCtaArchiveRouteLs.hpp
@@ -50,6 +50,7 @@ private:
   virtual int fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf);
 
   std::list<cta::common::dataStructures::ArchiveRoute> m_archiveRouteList;    //!< List of archive routes from the catalogue
+  const std::string m_instanceName;
 
   static constexpr const char* const LOG_SUFFIX  = "ArchiveRouteLsStream";    //!< Identifier for log messages
 };
@@ -57,7 +58,8 @@ private:
 
 ArchiveRouteLsStream::ArchiveRouteLsStream(const frontend::AdminCmdStream& requestMsg, cta::catalogue::Catalogue &catalogue, cta::Scheduler &scheduler) :
   XrdCtaStream(catalogue, scheduler),
-  m_archiveRouteList(catalogue.ArchiveRoute()->getArchiveRoutes())
+  m_archiveRouteList(catalogue.ArchiveRoute()->getArchiveRoutes()),
+  m_instanceName(requestMsg.getInstanceName())
 {
   using namespace cta::admin;
 
@@ -82,6 +84,7 @@ int ArchiveRouteLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf) {
     ar_item->mutable_last_modification_log()->set_host(ar.lastModificationLog.host);
     ar_item->mutable_last_modification_log()->set_time(ar.lastModificationLog.time);
     ar_item->set_comment(ar.comment);
+    ar_item->set_instance_name(m_instanceName);
 
     is_buffer_full = streambuf->Push(record);
   }
diff --git a/xroot_plugins/XrdCtaDiskInstanceLs.hpp b/xroot_plugins/XrdCtaDiskInstanceLs.hpp
index 72fe604113..3f3f95ac39 100644
--- a/xroot_plugins/XrdCtaDiskInstanceLs.hpp
+++ b/xroot_plugins/XrdCtaDiskInstanceLs.hpp
@@ -50,6 +50,7 @@ private:
   virtual int fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf);
 
   std::list<common::dataStructures::DiskInstance> m_diskInstanceList;             //!< List of disk instances from the catalogue
+  const std::string m_instanceName;
 
   static constexpr const char* const LOG_SUFFIX  = "DiskInstanceLsStream";    //!< Identifier for log messages
 };
@@ -57,7 +58,8 @@ private:
 
 DiskInstanceLsStream::DiskInstanceLsStream(const frontend::AdminCmdStream& requestMsg, cta::catalogue::Catalogue &catalogue, cta::Scheduler &scheduler) :
   XrdCtaStream(catalogue, scheduler),
-  m_diskInstanceList(catalogue.DiskInstance()->getAllDiskInstances())
+  m_diskInstanceList(catalogue.DiskInstance()->getAllDiskInstances()),
+  m_instanceName(requestMsg.getInstanceName())
 {
   using namespace cta::admin;
 
@@ -72,6 +74,7 @@ int DiskInstanceLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf) {
     auto  di_item = record.mutable_dils_item();
 
     di_item->set_name(di.name);
+    di_item->set_instance_name(m_instanceName);
     di_item->mutable_creation_log()->set_username(di.creationLog.username);
     di_item->mutable_creation_log()->set_host(di.creationLog.host);
     di_item->mutable_creation_log()->set_time(di.creationLog.time);
diff --git a/xroot_plugins/XrdCtaDiskInstanceSpaceLs.hpp b/xroot_plugins/XrdCtaDiskInstanceSpaceLs.hpp
index e6eeeab745..fb3919045e 100644
--- a/xroot_plugins/XrdCtaDiskInstanceSpaceLs.hpp
+++ b/xroot_plugins/XrdCtaDiskInstanceSpaceLs.hpp
@@ -50,6 +50,7 @@ private:
   virtual int fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf);
 
   std::list<common::dataStructures::DiskInstanceSpace> m_diskInstanceSpaceList;             //!< List of disk instance spaces from the catalogue
+  const std::string m_instanceName;
 
   static constexpr const char* const LOG_SUFFIX  = "DiskInstanceSpaceLsStream";    //!< Identifier for log messages
 };
@@ -57,7 +58,8 @@ private:
 
 DiskInstanceSpaceLsStream::DiskInstanceSpaceLsStream(const frontend::AdminCmdStream& requestMsg, cta::catalogue::Catalogue &catalogue, cta::Scheduler &scheduler) :
   XrdCtaStream(catalogue, scheduler),
-  m_diskInstanceSpaceList(catalogue.DiskInstanceSpace()->getAllDiskInstanceSpaces())
+  m_diskInstanceSpaceList(catalogue.DiskInstanceSpace()->getAllDiskInstanceSpaces()),
+  m_instanceName(requestMsg.getInstanceName())
 {
   using namespace cta::admin;
 
@@ -72,6 +74,7 @@ int DiskInstanceSpaceLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streamb
     auto  dis_item = record.mutable_disls_item();
 
     dis_item->set_name(dis.name);
+    dis_item->set_instance_name(dis.name);
     dis_item->set_disk_instance(dis.diskInstance);
     dis_item->set_refresh_interval(dis.refreshInterval);
     dis_item->set_free_space_query_url(dis.freeSpaceQueryURL);
diff --git a/xroot_plugins/XrdCtaDiskSystemLs.hpp b/xroot_plugins/XrdCtaDiskSystemLs.hpp
index 861c21558b..e902e502b3 100644
--- a/xroot_plugins/XrdCtaDiskSystemLs.hpp
+++ b/xroot_plugins/XrdCtaDiskSystemLs.hpp
@@ -50,6 +50,7 @@ private:
   virtual int fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf);
 
   cta::disk::DiskSystemList m_diskSystemList;             //!< List of disk systems from the catalogue
+  const std::string m_instanceName;
 
   static constexpr const char* const LOG_SUFFIX  = "DiskSystemLsStream";    //!< Identifier for log messages
 };
@@ -57,7 +58,8 @@ private:
 
 DiskSystemLsStream::DiskSystemLsStream(const frontend::AdminCmdStream& requestMsg, cta::catalogue::Catalogue &catalogue, cta::Scheduler &scheduler) :
   XrdCtaStream(catalogue, scheduler),
-  m_diskSystemList(catalogue.DiskSystem()->getAllDiskSystems())
+  m_diskSystemList(catalogue.DiskSystem()->getAllDiskSystems()),
+  m_instanceName(requestMsg.getInstanceName())
 {
   using namespace cta::admin;
 
@@ -82,6 +84,7 @@ int DiskSystemLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf) {
     auto  ds_item = record.mutable_dsls_item();
 
     ds_item->set_name(ds.name);
+    ds_item->set_instance_name(m_instanceName);
     ds_item->set_file_regexp(ds.fileRegexp);
     ds_item->set_disk_instance(ds.diskInstanceSpace.diskInstance);
     ds_item->set_disk_instance_space(ds.diskInstanceSpace.name);
diff --git a/xroot_plugins/XrdCtaDriveLs.hpp b/xroot_plugins/XrdCtaDriveLs.hpp
index 2ee013eff8..be0ba03e4e 100644
--- a/xroot_plugins/XrdCtaDriveLs.hpp
+++ b/xroot_plugins/XrdCtaDriveLs.hpp
@@ -72,6 +72,8 @@ private:
   int fillBuffer(XrdSsiPb::OStreamBuffer<Data>* streambuf) override;
   bool listAllDrives = false;
   std::optional<std::string> m_schedulerBackendName;
+  const std::string m_instanceName;
+
   cta::log::LogContext m_lc;
 
   static constexpr const char* const LOG_SUFFIX = "DriveLsStream";  //!< Identifier for log messages
@@ -86,6 +88,7 @@ DriveLsStream::DriveLsStream(const frontend::AdminCmdStream& requestMsg,
                              cta::Scheduler& scheduler,
                              log::LogContext& lc)
     : XrdCtaStream(catalogue, scheduler),
+      m_instanceName(requestMsg.getInstanceName()),
       m_lc(lc),
       m_tapeDrives(m_catalogue.DriveState()->getTapeDrives()),
       m_tapeDriveNameConfigMap(convertToMap(m_catalogue.DriveConfig()->getTapeDriveConfigs())) {
@@ -156,7 +159,7 @@ int DriveLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data>* streambuf) {
       continue;
     }
     auto dr_item = record.mutable_drls_item();
-
+    dr_item->set_instance_name(m_instanceName);
     dr_item->set_cta_version(dr.ctaVersion ? dr.ctaVersion.value() : "");
     dr_item->set_logical_library(dr.logicalLibrary);
     dr_item->set_drive_name(dr.driveName);
diff --git a/xroot_plugins/XrdCtaFailedRequestLs.hpp b/xroot_plugins/XrdCtaFailedRequestLs.hpp
index 07c20a9661..6f01459a65 100644
--- a/xroot_plugins/XrdCtaFailedRequestLs.hpp
+++ b/xroot_plugins/XrdCtaFailedRequestLs.hpp
@@ -89,6 +89,8 @@ class FailedRequestLsStream : public XrdCtaStream {
   bool m_isSummaryDone;                                                     //!< Summary has been sent
   bool m_isLogEntries;                                                      //!< Show failure log messages (verbose)
   log::LogContext &m_lc;                                                    //!< Reference to CTA Log Context
+  std::optional<std::string> m_schedulerBackendName;
+  const std::string m_instanceName;
 
   static constexpr const char* const LOG_SUFFIX  = "FailedRequestLsStream";  //!< Identifier for SSI log messages
 };
@@ -101,13 +103,20 @@ FailedRequestLsStream::FailedRequestLsStream(const frontend::AdminCmdStream& req
     m_isSummary(requestMsg.has_flag(admin::OptionBoolean::SUMMARY)),
     m_isSummaryDone(false),
     m_isLogEntries(requestMsg.has_flag(admin::OptionBoolean::SHOW_LOG_ENTRIES)),
-    m_lc(lc) {
+    m_lc(lc),
+    m_instanceName(requestMsg.getInstanceName()) {
   XrdSsiPb::Log::Msg(XrdSsiPb::Log::DEBUG, LOG_SUFFIX, "FailedRequestLsStream() constructor");
 
   if (m_isLogEntries && m_isSummary) {
     throw cta::exception::UserError("--log and --summary are mutually exclusive");
   }
-
+  m_schedulerBackendName = scheduler.getSchedulerBackendName();
+  if (!m_schedulerBackendName) {
+    XrdSsiPb::Log::Msg(
+      XrdSsiPb::Log::ERROR,
+      LOG_SUFFIX,
+      "FailedRequestLsStream constructor, the cta.scheduler_backend_name is not set in the frontend configuration.");
+  }
   auto tapepool     = requestMsg.getOptional(cta::admin::OptionString::TAPE_POOL);
   auto vid          = requestMsg.getOptional(cta::admin::OptionString::VID);
   bool justarchive  = requestMsg.has_flag(cta::admin::OptionBoolean::JUSTARCHIVE)  || tapepool;
@@ -152,6 +161,8 @@ pushRecord(XrdSsiPb::OStreamBuffer<Data> *streambuf, const common::dataStructure
     *record.mutable_frls_item()->mutable_failurelogs() = { item.failurelogs.begin(), item.failurelogs.end() };
     *record.mutable_frls_item()->mutable_reportfailurelogs() = { item.reportfailurelogs.begin(), item.reportfailurelogs.end() };
   }
+  record.mutable_frls_item()->set_scheduler_backend_name(m_schedulerBackendName.value_or(""));
+  record.mutable_frls_item()->set_instance_name(m_instanceName);
   return streambuf->Push(record);
 }
 
@@ -193,6 +204,8 @@ pushRecord(XrdSsiPb::OStreamBuffer<Data> *streambuf, const common::dataStructure
     *record.mutable_frls_item()->mutable_failurelogs() = { item.failurelogs.begin(), item.failurelogs.end() };
     *record.mutable_frls_item()->mutable_reportfailurelogs() = {item.reportfailurelogs.begin(), item.reportfailurelogs.end()};
   }
+  record.mutable_frls_item()->set_scheduler_backend_name(m_schedulerBackendName.value_or(""));
+  record.mutable_frls_item()->set_instance_name(m_instanceName);
   return streambuf->Push(record);
 }
 
@@ -230,6 +243,8 @@ void FailedRequestLsStream::GetBuffSummary(XrdSsiPb::OStreamBuffer<Data> *stream
     record.mutable_frls_summary()->set_request_type(admin::RequestType::ARCHIVE_REQUEST);
     record.mutable_frls_summary()->set_total_files(archive_summary.totalFiles);
     record.mutable_frls_summary()->set_total_size(archive_summary.totalBytes);
+    record.mutable_frls_summary()->set_scheduler_backend_name(m_schedulerBackendName.value_or(""));
+    record.mutable_frls_summary()->set_instance_name(m_instanceName);
     streambuf->Push(record);
   }
   if (isRetrieveJobs()) {
@@ -238,6 +253,8 @@ void FailedRequestLsStream::GetBuffSummary(XrdSsiPb::OStreamBuffer<Data> *stream
     record.mutable_frls_summary()->set_request_type(admin::RequestType::RETRIEVE_REQUEST);
     record.mutable_frls_summary()->set_total_files(retrieve_summary.totalFiles);
     record.mutable_frls_summary()->set_total_size(retrieve_summary.totalBytes);
+    record.mutable_frls_summary()->set_scheduler_backend_name(m_schedulerBackendName.value_or(""));
+    record.mutable_frls_summary()->set_instance_name(m_instanceName);
     streambuf->Push(record);
   }
   if (isArchiveJobs() && isRetrieveJobs()) {
@@ -245,6 +262,8 @@ void FailedRequestLsStream::GetBuffSummary(XrdSsiPb::OStreamBuffer<Data> *stream
     record.mutable_frls_summary()->set_request_type(admin::RequestType::TOTAL);
     record.mutable_frls_summary()->set_total_files(archive_summary.totalFiles + retrieve_summary.totalFiles);
     record.mutable_frls_summary()->set_total_size(archive_summary.totalBytes + retrieve_summary.totalBytes);
+    record.mutable_frls_summary()->set_scheduler_backend_name(m_schedulerBackendName.value_or(""));
+    record.mutable_frls_summary()->set_instance_name(m_instanceName);
     streambuf->Push(record);
   }
 
diff --git a/xroot_plugins/XrdCtaGroupMountRuleLs.hpp b/xroot_plugins/XrdCtaGroupMountRuleLs.hpp
index a3c1b1cba2..e303d1f330 100644
--- a/xroot_plugins/XrdCtaGroupMountRuleLs.hpp
+++ b/xroot_plugins/XrdCtaGroupMountRuleLs.hpp
@@ -50,6 +50,7 @@ private:
   virtual int fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf);
 
   std::list<cta::common::dataStructures::RequesterGroupMountRule> m_groupMountRuleList;    //!< List of group mount rules from the catalogue
+  const std::string m_instanceName;
 
   static constexpr const char* const LOG_SUFFIX  = "GroupMountRuleLsStream";               //!< Identifier for log messages
 };
@@ -57,7 +58,8 @@ private:
 
 GroupMountRuleLsStream::GroupMountRuleLsStream(const frontend::AdminCmdStream& requestMsg, cta::catalogue::Catalogue &catalogue, cta::Scheduler &scheduler) :
   XrdCtaStream(catalogue, scheduler),
-  m_groupMountRuleList(catalogue.RequesterGroupMountRule()->getRequesterGroupMountRules())
+  m_groupMountRuleList(catalogue.RequesterGroupMountRule()->getRequesterGroupMountRules()),
+  m_instanceName(requestMsg.getInstanceName())
 {
   using namespace cta::admin;
 
@@ -71,6 +73,7 @@ int GroupMountRuleLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf)
     auto &gmr      = m_groupMountRuleList.front();
     auto  gmr_item = record.mutable_gmrls_item();
 
+    gmr_item->set_instance_name(m_instanceName);
     gmr_item->set_disk_instance(gmr.diskInstance);
     gmr_item->set_group_mount_rule(gmr.name);
     gmr_item->set_mount_policy(gmr.mountPolicy);
diff --git a/xroot_plugins/XrdCtaLogicalLibraryLs.hpp b/xroot_plugins/XrdCtaLogicalLibraryLs.hpp
index f94497898f..ef325fb3af 100644
--- a/xroot_plugins/XrdCtaLogicalLibraryLs.hpp
+++ b/xroot_plugins/XrdCtaLogicalLibraryLs.hpp
@@ -55,6 +55,7 @@ private:
   // List of logical libraries from the catalogue
   std::list<cta::common::dataStructures::LogicalLibrary> m_logicalLibraryList;
   const std::optional<bool> m_disabled;
+  const std::string m_instanceName;
 
   static constexpr const char* const LOG_SUFFIX  = "LogicalLibraryLsStream";      //!< Identifier for log messages
 };
@@ -64,7 +65,8 @@ LogicalLibraryLsStream::LogicalLibraryLsStream(const frontend::AdminCmdStream& r
   cta::Scheduler &scheduler, const std::optional<bool>& disabled) :
   XrdCtaStream(catalogue, scheduler),
   m_logicalLibraryList(catalogue.LogicalLibrary()->getLogicalLibraries()),
-  m_disabled(disabled) {
+  m_disabled(disabled),
+  m_instanceName(requestMsg.getInstanceName()) {
   using namespace cta::admin;
 
   XrdSsiPb::Log::Msg(XrdSsiPb::Log::DEBUG, LOG_SUFFIX, "LogicalLibraryLsStream() constructor");
@@ -97,6 +99,7 @@ int LogicalLibraryLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf)
     ll_item->mutable_last_modification_log()->set_host(ll.lastModificationLog.host);
     ll_item->mutable_last_modification_log()->set_time(ll.lastModificationLog.time);
     ll_item->set_comment(ll.comment);
+    ll_item->set_instance_name(m_instanceName);
 
     is_buffer_full = streambuf->Push(record);
   }
diff --git a/xroot_plugins/XrdCtaMediaTypeLs.hpp b/xroot_plugins/XrdCtaMediaTypeLs.hpp
index 38ac839961..f8a8a21803 100644
--- a/xroot_plugins/XrdCtaMediaTypeLs.hpp
+++ b/xroot_plugins/XrdCtaMediaTypeLs.hpp
@@ -50,6 +50,7 @@ private:
   virtual int fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf);
 
   std::list<cta::catalogue::MediaTypeWithLogs> m_mediaTypeList;    //!< List of tape media types from the catalogue
+  const std::string m_instanceName;
 
   static constexpr const char* const LOG_SUFFIX  = "MediaTypeLsStream";    //!< Identifier for log messages
 };
@@ -57,7 +58,8 @@ private:
 
 MediaTypeLsStream::MediaTypeLsStream(const frontend::AdminCmdStream& requestMsg, cta::catalogue::Catalogue &catalogue, cta::Scheduler &scheduler) :
   XrdCtaStream(catalogue, scheduler),
-  m_mediaTypeList(catalogue.MediaType()->getMediaTypes())
+  m_mediaTypeList(catalogue.MediaType()->getMediaTypes()),
+  m_instanceName(requestMsg.getInstanceName())
 {
   using namespace cta::admin;
 
@@ -72,6 +74,7 @@ int MediaTypeLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf) {
     auto  mt_item = record.mutable_mtls_item();
 
     mt_item->set_name(mt.name);
+    mt_item->set_instance_name(m_instanceName);
     mt_item->set_cartridge(mt.cartridge);
     mt_item->set_capacity(mt.capacityInBytes);
     if (mt.primaryDensityCode) mt_item->set_primary_density_code(mt.primaryDensityCode.value());
diff --git a/xroot_plugins/XrdCtaMountPolicyLs.hpp b/xroot_plugins/XrdCtaMountPolicyLs.hpp
index 94697764df..c0abbf45cb 100644
--- a/xroot_plugins/XrdCtaMountPolicyLs.hpp
+++ b/xroot_plugins/XrdCtaMountPolicyLs.hpp
@@ -49,6 +49,7 @@ private:
   virtual int fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf);
 
   std::list<cta::common::dataStructures::MountPolicy> m_mountPolicyList;     //!< List of mount policies from the catalogue
+  const std::string m_instanceName;
 
   static constexpr const char* const LOG_SUFFIX  = "MountPolicyLsStream";    //!< Identifier for log messages
 };
@@ -56,7 +57,8 @@ private:
 
 MountPolicyLsStream::MountPolicyLsStream(const frontend::AdminCmdStream& requestMsg, cta::catalogue::Catalogue &catalogue, cta::Scheduler &scheduler) :
   XrdCtaStream(catalogue, scheduler),
-  m_mountPolicyList(catalogue.MountPolicy()->getMountPolicies())
+  m_mountPolicyList(catalogue.MountPolicy()->getMountPolicies()),
+  m_instanceName(requestMsg.getInstanceName())
 {
   using namespace cta::admin;
 
@@ -71,6 +73,7 @@ int MountPolicyLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf) {
     auto  mp_item = record.mutable_mpls_item();
 
     mp_item->set_name(mp.name);
+    mp_item->set_instance_name(m_instanceName);
     mp_item->set_archive_priority(mp.archivePriority);
     mp_item->set_archive_min_request_age(mp.archiveMinRequestAge);
     mp_item->set_retrieve_priority(mp.retrievePriority);
diff --git a/xroot_plugins/XrdCtaPhysicalLibraryLs.hpp b/xroot_plugins/XrdCtaPhysicalLibraryLs.hpp
index 14b0274695..746d5851ef 100644
--- a/xroot_plugins/XrdCtaPhysicalLibraryLs.hpp
+++ b/xroot_plugins/XrdCtaPhysicalLibraryLs.hpp
@@ -55,6 +55,7 @@ private:
   // List of physical libraries from the catalogue
   std::list<cta::common::dataStructures::PhysicalLibrary> m_physicalLibraryList;
   const std::optional<bool> m_disabled;
+  const std::string m_instanceName;
 
   static constexpr const char* const LOG_SUFFIX  = "PhysicalLibraryLsStream";      //!< Identifier for log messages
 };
@@ -62,7 +63,8 @@ private:
 
 PhysicalLibraryLsStream::PhysicalLibraryLsStream(const frontend::AdminCmdStream& requestMsg, cta::catalogue::Catalogue &catalogue, cta::Scheduler &scheduler) :
   XrdCtaStream(catalogue, scheduler),
-  m_physicalLibraryList(catalogue.PhysicalLibrary()->getPhysicalLibraries()) {
+  m_physicalLibraryList(catalogue.PhysicalLibrary()->getPhysicalLibraries()),
+  m_instanceName(requestMsg.getInstanceName()) {
   using namespace cta::admin;
 
   XrdSsiPb::Log::Msg(XrdSsiPb::Log::DEBUG, LOG_SUFFIX, "PhysicalLibraryLsStream() constructor");
@@ -77,6 +79,7 @@ int PhysicalLibraryLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf
     auto pl_item = record.mutable_plls_item();
 
     pl_item->set_name(pl.name);
+    pl_item->set_instance_name(m_instanceName);
     pl_item->set_manufacturer(pl.manufacturer);
     pl_item->set_model(pl.model);
 
diff --git a/xroot_plugins/XrdCtaRecycleTapeFileLs.hpp b/xroot_plugins/XrdCtaRecycleTapeFileLs.hpp
index 3d9c560d73..2f4a127950 100644
--- a/xroot_plugins/XrdCtaRecycleTapeFileLs.hpp
+++ b/xroot_plugins/XrdCtaRecycleTapeFileLs.hpp
@@ -52,13 +52,14 @@ private:
   virtual int fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf);
 
   cta::catalogue::FileRecycleLogItor m_fileRecycleLogItor;     //!< List of recycle tape files from the catalogue
+  const std::string m_instanceName;
 
   static constexpr const char* const LOG_SUFFIX  = "RecycleTapeFileLsStream";    //!< Identifier for log messages
 };
 
 
 RecycleTapeFileLsStream::RecycleTapeFileLsStream(const frontend::AdminCmdStream& requestMsg, cta::catalogue::Catalogue &catalogue, cta::Scheduler &scheduler) :
-  XrdCtaStream(catalogue, scheduler)
+  XrdCtaStream(catalogue, scheduler), m_instanceName(requestMsg.getInstanceName())
 {
   using namespace cta::admin;
 
@@ -101,6 +102,7 @@ int RecycleTapeFileLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf
     Data record;
     
     auto recycleLogToReturn = record.mutable_rtfls_item();
+    recycleLogToReturn->set_instance_name(m_instanceName);
     recycleLogToReturn->set_vid(fileRecycleLog.vid);
     recycleLogToReturn->set_fseq(fileRecycleLog.fSeq);
     recycleLogToReturn->set_block_id(fileRecycleLog.blockId);
diff --git a/xroot_plugins/XrdCtaRepackLs.hpp b/xroot_plugins/XrdCtaRepackLs.hpp
index f9c866de43..ff0fc23d24 100644
--- a/xroot_plugins/XrdCtaRepackLs.hpp
+++ b/xroot_plugins/XrdCtaRepackLs.hpp
@@ -31,8 +31,8 @@ namespace cta::xrd {
   class RepackLsStream: public XrdCtaStream {
   public:
     
-    RepackLsStream(cta::Scheduler& scheduler, cta::catalogue::Catalogue& catalogue, const std::optional<std::string> vid):
-    XrdCtaStream(catalogue, scheduler), m_vid(vid) {
+    RepackLsStream(const frontend::AdminCmdStream& requestMsg, cta::Scheduler& scheduler, cta::catalogue::Catalogue& catalogue, const std::optional<std::string> vid):
+    XrdCtaStream(catalogue, scheduler), m_vid(vid), m_instanceName(requestMsg.getInstanceName()) {
       XrdSsiPb::Log::Msg(XrdSsiPb::Log::DEBUG, LOG_SUFFIX, "RepackLsStream() constructor");
       if(!vid){
         m_repackList = m_scheduler.getRepacks();
@@ -73,6 +73,7 @@ namespace cta::xrd {
         uint64_t totalFilesToArchive = repackRequest.totalFilesToArchive;
         
         auto repackRequestItem = record.mutable_rels_item();
+        repackRequestItem->set_instance_name(m_instanceName);
         repackRequestItem->set_vid(repackRequest.vid);
         repackRequestItem->set_tapepool(tapeVidMap[repackRequest.vid].tapePoolName);
         repackRequestItem->set_repack_buffer_url(repackRequest.repackBufferBaseURL);
@@ -122,6 +123,7 @@ namespace cta::xrd {
   
   private:
     const std::optional<std::string> m_vid;
+    const std::string m_instanceName;
     std::list<common::dataStructures::RepackInfo> m_repackList;
     static constexpr const char * const LOG_SUFFIX = "RepackLsStream";
   };
diff --git a/xroot_plugins/XrdCtaRequesterMountRuleLs.hpp b/xroot_plugins/XrdCtaRequesterMountRuleLs.hpp
index 2ca0842e17..c75cda2ab6 100644
--- a/xroot_plugins/XrdCtaRequesterMountRuleLs.hpp
+++ b/xroot_plugins/XrdCtaRequesterMountRuleLs.hpp
@@ -50,6 +50,7 @@ private:
   virtual int fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf);
 
   std::list<cta::common::dataStructures::RequesterMountRule> m_requesterMountRuleList;    //!< List of requester mount rules from the catalogue
+  const std::string m_instanceName;
 
   static constexpr const char* const LOG_SUFFIX  = "RequesterMountRuleLsStream";          //!< Identifier for log messages
 };
@@ -57,7 +58,8 @@ private:
 
 RequesterMountRuleLsStream::RequesterMountRuleLsStream(const frontend::AdminCmdStream& requestMsg, cta::catalogue::Catalogue &catalogue, cta::Scheduler &scheduler) :
   XrdCtaStream(catalogue, scheduler),
-  m_requesterMountRuleList(catalogue.RequesterMountRule()->getRequesterMountRules())
+  m_requesterMountRuleList(catalogue.RequesterMountRule()->getRequesterMountRules()),
+  m_instanceName(requestMsg.getInstanceName())
 {
   using namespace cta::admin;
 
@@ -71,6 +73,7 @@ int RequesterMountRuleLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *stream
     auto &rmr      = m_requesterMountRuleList.front();
     auto  rmr_item = record.mutable_rmrls_item();
 
+    rmr_item->set_instance_name(m_instanceName);
     rmr_item->set_disk_instance(rmr.diskInstance);
     rmr_item->set_requester_mount_rule(rmr.name);
     rmr_item->set_mount_policy(rmr.mountPolicy);
diff --git a/xroot_plugins/XrdCtaShowQueues.hpp b/xroot_plugins/XrdCtaShowQueues.hpp
index 5a1778bff6..0aac986d2b 100644
--- a/xroot_plugins/XrdCtaShowQueues.hpp
+++ b/xroot_plugins/XrdCtaShowQueues.hpp
@@ -50,6 +50,8 @@ private:
   virtual int fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf);
 
   std::list<cta::common::dataStructures::QueueAndMountSummary> m_queuesAndMountsList;    //!< List of queues and mounts from the scheduler
+  std::optional<std::string> m_schedulerBackendName;
+  const std::string m_instanceName;
 
   static constexpr const char* const LOG_SUFFIX  = "ShowQueuesStream";                   //!< Identifier for log messages
 };
@@ -57,10 +59,17 @@ private:
 ShowQueuesStream::ShowQueuesStream(const frontend::AdminCmdStream& requestMsg, cta::catalogue::Catalogue& catalogue,
   cta::Scheduler& scheduler, log::LogContext& lc) :
   XrdCtaStream(catalogue, scheduler),
-  m_queuesAndMountsList(scheduler.getQueuesAndMountSummaries(lc))
+  m_queuesAndMountsList(scheduler.getQueuesAndMountSummaries(lc)),
+  m_instanceName(requestMsg.getInstanceName())
 {
   using namespace cta::admin;
-
+  m_schedulerBackendName = scheduler.getSchedulerBackendName();
+  if (!m_schedulerBackendName) {
+    XrdSsiPb::Log::Msg(
+      XrdSsiPb::Log::ERROR,
+      LOG_SUFFIX,
+      "ShowQueuesStream constructor, the cta.scheduler_backend_name is not set in the frontend configuration.");
+  }
   XrdSsiPb::Log::Msg(XrdSsiPb::Log::DEBUG, LOG_SUFFIX, "ShowQueuesStream() constructor");
 }
 
@@ -88,6 +97,8 @@ int ShowQueuesStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf) {
     }
 
     sq_item->set_mount_type(MountTypeToProtobuf(sq.mountType));
+    sq_item->set_instance_name(m_instanceName);
+    sq_item->set_scheduler_backend_name(m_schedulerBackendName.value_or(""));
     sq_item->set_tapepool(sq.tapePool);
     sq_item->set_logical_library(sq.logicalLibrary);
     sq_item->set_vid(sq.vid);
diff --git a/xroot_plugins/XrdCtaStorageClassLs.hpp b/xroot_plugins/XrdCtaStorageClassLs.hpp
index e9aa235a94..e8c9980d3b 100644
--- a/xroot_plugins/XrdCtaStorageClassLs.hpp
+++ b/xroot_plugins/XrdCtaStorageClassLs.hpp
@@ -52,6 +52,7 @@ private:
   std::list<cta::common::dataStructures::StorageClass> m_storageClassList;    //!< List of storage classes from the catalogue
 
   std::optional<std::string> m_storageClassName;
+  const std::string m_instanceName;
 
   static constexpr const char* const LOG_SUFFIX  = "StorageClassLsStream";    //!< Identifier for log messages
 };
@@ -59,7 +60,8 @@ private:
 
 StorageClassLsStream::StorageClassLsStream(const frontend::AdminCmdStream& requestMsg, cta::catalogue::Catalogue &catalogue, cta::Scheduler &scheduler, const std::optional<std::string> storageClassName) :
   XrdCtaStream(catalogue, scheduler),
-  m_storageClassName(storageClassName)
+  m_storageClassName(storageClassName),
+  m_instanceName(requestMsg.getInstanceName())
 {
   using namespace cta::admin;
 
@@ -91,6 +93,7 @@ int StorageClassLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf) {
     sc_item->mutable_last_modification_log()->set_host(sc.lastModificationLog.host);
     sc_item->mutable_last_modification_log()->set_time(sc.lastModificationLog.time);
     sc_item->set_comment(sc.comment);
+    sc_item->set_instance_name(m_instanceName);
 
     is_buffer_full = streambuf->Push(record);
   }
diff --git a/xroot_plugins/XrdCtaTapeFileLs.hpp b/xroot_plugins/XrdCtaTapeFileLs.hpp
index d19810387d..c3329f477e 100644
--- a/xroot_plugins/XrdCtaTapeFileLs.hpp
+++ b/xroot_plugins/XrdCtaTapeFileLs.hpp
@@ -45,6 +45,7 @@ private:
   virtual int fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf);
 
   catalogue::ArchiveFileItor m_tapeFileItor;       //!< Iterator across files which have been archived
+  const std::string m_instanceName;
 
   static constexpr const char* const LOG_SUFFIX  = "TapeFileLsStream";    //!< Identifier for log messages
 };
@@ -52,7 +53,8 @@ private:
 
 TapeFileLsStream::TapeFileLsStream(const frontend::AdminCmdStream& requestMsg,
   cta::catalogue::Catalogue &catalogue, cta::Scheduler &scheduler) :
-    XrdCtaStream(catalogue, scheduler)
+    XrdCtaStream(catalogue, scheduler),
+    m_instanceName(requestMsg.getInstanceName())
 {
   using namespace cta::admin;
 
@@ -91,7 +93,8 @@ int TapeFileLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf) {
 
     for(auto jt = archiveFile.tapeFiles.cbegin(); jt != archiveFile.tapeFiles.cend(); jt++) {
       Data record;
-
+      // Set the instance_name field
+      record.mutable_tfls_item()->set_instance_name(m_instanceName);
       // Archive file
       auto af = record.mutable_tfls_item()->mutable_af();
       af->set_archive_id(archiveFile.archiveFileID);
diff --git a/xroot_plugins/XrdCtaTapeLs.hpp b/xroot_plugins/XrdCtaTapeLs.hpp
index 4a5cedafef..c59e2ddfeb 100644
--- a/xroot_plugins/XrdCtaTapeLs.hpp
+++ b/xroot_plugins/XrdCtaTapeLs.hpp
@@ -50,13 +50,15 @@ private:
   virtual int fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf);
   
   std::list<common::dataStructures::Tape> m_tapeList;
+  const std::string m_instanceName;
 
   static constexpr const char * const LOG_SUFFIX = "TapeLsStream";
 };
 
 
 TapeLsStream::TapeLsStream(const frontend::AdminCmdStream& requestMsg, cta::catalogue::Catalogue &catalogue, cta::Scheduler &scheduler) :
-  XrdCtaStream(catalogue, scheduler)
+  XrdCtaStream(catalogue, scheduler),
+  m_instanceName(requestMsg.getInstanceName())
 {
   using namespace cta::admin;
 
@@ -105,6 +107,7 @@ int TapeLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf) {
     auto &tape = m_tapeList.front();
     auto tape_item = record.mutable_tals_item();
     
+    tape_item->set_instance_name(m_instanceName);
     tape_item->set_vid(tape.vid);
     tape_item->set_media_type(tape.mediaType);
     tape_item->set_vendor(tape.vendor);
diff --git a/xroot_plugins/XrdCtaTapePoolLs.hpp b/xroot_plugins/XrdCtaTapePoolLs.hpp
index bde13c1068..8eb143bd1c 100644
--- a/xroot_plugins/XrdCtaTapePoolLs.hpp
+++ b/xroot_plugins/XrdCtaTapePoolLs.hpp
@@ -52,6 +52,7 @@ private:
   virtual int fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf);
 
   std::list<cta::catalogue::TapePool> m_tapePoolList;                     //!< List of tape pools from the catalogue
+  const std::string m_instanceName;
 
   static constexpr const char* const LOG_SUFFIX  = "TapePoolLsStream";    //!< Identifier for log messages
 };
@@ -59,7 +60,8 @@ private:
 
 TapePoolLsStream::TapePoolLsStream(const frontend::AdminCmdStream& requestMsg, cta::catalogue::Catalogue &catalogue, cta::Scheduler &scheduler) :
   XrdCtaStream(catalogue, scheduler),
-  m_tapePoolList(catalogue.TapePool()->getTapePools())
+  m_tapePoolList(catalogue.TapePool()->getTapePools()),
+  m_instanceName(requestMsg.getInstanceName())
 {
   using namespace cta::admin;
 
@@ -86,6 +88,7 @@ int TapePoolLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf) {
     auto  tp_item = record.mutable_tpls_item();
 
     tp_item->set_name(tp.name);
+    tp_item->set_instance_name(m_instanceName);
     tp_item->set_vo(tp.vo.name);
     tp_item->set_num_tapes(tp.nbTapes);
     tp_item->set_num_partial_tapes(tp.nbPartialTapes);
diff --git a/xroot_plugins/XrdCtaVersion.hpp b/xroot_plugins/XrdCtaVersion.hpp
index 7ad8c0b677..9047ac7791 100644
--- a/xroot_plugins/XrdCtaVersion.hpp
+++ b/xroot_plugins/XrdCtaVersion.hpp
@@ -49,6 +49,7 @@ private:
   std::string m_catalogue_conn_string;
   std::string m_catalogue_version;
   std::optional<std::string> m_schedulerBackendName;
+  const std::string m_instanceName;
   bool m_is_upgrading;
 
   bool m_is_done = false;
@@ -73,6 +74,7 @@ VersionStream::VersionStream(const frontend::AdminCmdStream& requestMsg,
       m_catalogue_conn_string(catalogueConnString),
       m_catalogue_version(m_catalogue.Schema()->getSchemaVersion().getSchemaVersion<std::string>()),
       m_schedulerBackendName(scheduler.getSchedulerBackendName()),
+      m_instanceName(requestMsg.getInstanceName()),
       m_is_upgrading(m_catalogue.Schema()->getSchemaVersion().getStatus<catalogue::SchemaVersion::Status>() ==
                      catalogue::SchemaVersion::Status::UPGRADING) {
   XrdSsiPb::Log::Msg(XrdSsiPb::Log::DEBUG, LOG_SUFFIX, "VersionStream() constructor");
@@ -100,6 +102,7 @@ int VersionStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data>* streambuf) {
   version->set_catalogue_version(m_catalogue_version);
   version->set_is_upgrading(m_is_upgrading);
   version->set_scheduler_backend_name(m_schedulerBackendName.value());
+  version->set_instance_name(m_instanceName);
   streambuf->Push(record);
 
   return streambuf->Size();
diff --git a/xroot_plugins/XrdCtaVirtualOrganizationLs.hpp b/xroot_plugins/XrdCtaVirtualOrganizationLs.hpp
index e31ce83d6e..faa59b4134 100644
--- a/xroot_plugins/XrdCtaVirtualOrganizationLs.hpp
+++ b/xroot_plugins/XrdCtaVirtualOrganizationLs.hpp
@@ -51,6 +51,7 @@ private:
   virtual int fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf);
 
   std::list<cta::common::dataStructures::VirtualOrganization> m_virtualOrganizationList;             //!< List of virtual organizations from the catalogue
+  const std::string m_instanceName;
 
   static constexpr const char* const LOG_SUFFIX  = "VirtualOrganizationLsStream";    //!< Identifier for log messages
 };
@@ -58,7 +59,8 @@ private:
 
 VirtualOrganizationLsStream::VirtualOrganizationLsStream(const frontend::AdminCmdStream& requestMsg, cta::catalogue::Catalogue &catalogue, cta::Scheduler &scheduler) :
   XrdCtaStream(catalogue, scheduler),
-  m_virtualOrganizationList(catalogue.VO()->getVirtualOrganizations())
+  m_virtualOrganizationList(catalogue.VO()->getVirtualOrganizations()),
+  m_instanceName(requestMsg.getInstanceName())
 {
   using namespace cta::admin;
 
@@ -73,6 +75,7 @@ int VirtualOrganizationLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *strea
     auto  vo_item = record.mutable_vols_item();
 
     vo_item->set_name(vo.name);
+    vo_item->set_instance_name(m_instanceName);
     vo_item->set_read_max_drives(vo.readMaxDrives);
     vo_item->set_write_max_drives(vo.writeMaxDrives);
     vo_item->set_max_file_size(vo.maxFileSize);
-- 
GitLab


From db2ffa8b73f64dd4aeb3343759f22838aaf27462 Mon Sep 17 00:00:00 2001
From: guenther <jaroslav.guenther@cern.ch>
Date: Wed, 2 Apr 2025 09:02:03 +0200
Subject: [PATCH 2/6] change position of instance field to be before the
 comment or reason in tabular form

---
 cmdline/CtaAdminTextFormatter.cpp | 139 +++++++++++++++---------------
 1 file changed, 69 insertions(+), 70 deletions(-)

diff --git a/cmdline/CtaAdminTextFormatter.cpp b/cmdline/CtaAdminTextFormatter.cpp
index 1c2d2109e0..7485f4fcd9 100644
--- a/cmdline/CtaAdminTextFormatter.cpp
+++ b/cmdline/CtaAdminTextFormatter.cpp
@@ -175,8 +175,7 @@ void TextFormatter::flush() {
 
 void TextFormatter::printActivityMountRuleLsHeader() {
   push_back("HEADER");
-  push_back("instance",
-            "disk buffer",
+  push_back("disk buffer",
             "username",
             "policy",
             "activity",
@@ -186,12 +185,12 @@ void TextFormatter::printActivityMountRuleLsHeader() {
             "m.user",
             "m.host",
             "m.time",
+            "instance",
             "comment");
 }
 
 void TextFormatter::print(const ActivityMountRuleLsItem& amrls_item) {
-  push_back(amrls_item.instance_name(),
-            amrls_item.disk_instance(),
+  push_back(amrls_item.disk_instance(),
             amrls_item.activity_mount_rule(),
             amrls_item.mount_policy(),
             amrls_item.activity_regex(),
@@ -201,12 +200,13 @@ void TextFormatter::print(const ActivityMountRuleLsItem& amrls_item) {
             amrls_item.last_modification_log().username(),
             amrls_item.last_modification_log().host(),
             timeToStr(amrls_item.last_modification_log().time()),
+            amrls_item.instance_name(),
             amrls_item.comment());
 }
 
 void TextFormatter::printAdminLsHeader() {
   push_back("HEADER");
-  push_back("user", "c.user", "c.host", "c.time", "m.user", "m.host", "m.time", "comment", "instance");
+  push_back("user", "c.user", "c.host", "c.time", "m.user", "m.host", "m.time", "instance", "comment");
 }
 
 void TextFormatter::print(const AdminLsItem& adls_item) {
@@ -217,14 +217,13 @@ void TextFormatter::print(const AdminLsItem& adls_item) {
             adls_item.last_modification_log().username(),
             adls_item.last_modification_log().host(),
             timeToStr(adls_item.last_modification_log().time()),
-            adls_item.comment(),
-            adls_item.instance_name());
+            adls_item.instance_name(),
+            adls_item.comment());
 }
 
 void TextFormatter::printArchiveRouteLsHeader() {
   push_back("HEADER");
-  push_back("instance",
-            "storage class",
+  push_back("storage class",
             "copy number",
             "type",
             "tapepool",
@@ -234,12 +233,12 @@ void TextFormatter::printArchiveRouteLsHeader() {
             "m.user",
             "m.host",
             "m.time",
+            "instance",
             "comment");
 }
 
 void TextFormatter::print(const ArchiveRouteLsItem& arls_item) {
-  push_back(arls_item.instance_name(),
-            arls_item.storage_class(),
+  push_back(arls_item.storage_class(),
             arls_item.copy_number(),
             cta::common::dataStructures::toString(ProtobufToArchiveRouteTypeFormat(arls_item.archive_route_type())),
             arls_item.tapepool(),
@@ -249,6 +248,7 @@ void TextFormatter::print(const ArchiveRouteLsItem& arls_item) {
             arls_item.last_modification_log().username(),
             arls_item.last_modification_log().host(),
             timeToStr(arls_item.last_modification_log().time()),
+            arls_item.instance_name(),
             arls_item.comment());
 }
 
@@ -390,12 +390,11 @@ void TextFormatter::print(const FailedRequestLsSummary& frls_summary) {
 
 void TextFormatter::printGroupMountRuleLsHeader() {
   push_back("HEADER");
-  push_back("instance", "disk buffer", "group", "policy", "c.user", "c.host", "c.time", "m.user", "m.host", "m.time", "comment");
+  push_back("disk buffer", "group", "policy", "c.user", "c.host", "c.time", "m.user", "m.host", "m.time", "instance",  "comment");
 }
 
 void TextFormatter::print(const GroupMountRuleLsItem& gmrls_item) {
-  push_back(gmrls_item.instance_name(),
-            gmrls_item.disk_instance(),
+  push_back(gmrls_item.disk_instance(),
             gmrls_item.group_mount_rule(),
             gmrls_item.mount_policy(),
             gmrls_item.creation_log().username(),
@@ -404,6 +403,7 @@ void TextFormatter::print(const GroupMountRuleLsItem& gmrls_item) {
             gmrls_item.last_modification_log().username(),
             gmrls_item.last_modification_log().host(),
             timeToStr(gmrls_item.last_modification_log().time()),
+            gmrls_item.instance_name(),
             gmrls_item.comment());
 }
 
@@ -414,7 +414,6 @@ void TextFormatter::printListPendingArchivesHeader() {
             "storage class",
             "copy no",
             "disk id",
-            "instance",
             "checksum type",
             "checksum value",
             "size",
@@ -501,8 +500,8 @@ void TextFormatter::printLogicalLibraryLsHeader() {
             "m.user",
             "m.host",
             "m.time",
-            "comment",
-            "instance");
+            "instance",
+            "comment");
 }
 
 void TextFormatter::print(const LogicalLibraryLsItem& llls_item) {
@@ -516,8 +515,8 @@ void TextFormatter::print(const LogicalLibraryLsItem& llls_item) {
             llls_item.last_modification_log().username(),
             llls_item.last_modification_log().host(),
             timeToStr(llls_item.last_modification_log().time()),
-            llls_item.comment(),
-            llls_item.instance_name());
+            llls_item.instance_name(),
+            llls_item.comment());
 }
 
 void TextFormatter::printMediaTypeLsHeader() {
@@ -536,8 +535,8 @@ void TextFormatter::printMediaTypeLsHeader() {
             "m.user",
             "m.host",
             "m.time",
-            "comment",
-            "instance");
+            "instance",
+            "comment");
 }
 
 void TextFormatter::print(const MediaTypeLsItem& mtls_item) {
@@ -555,8 +554,8 @@ void TextFormatter::print(const MediaTypeLsItem& mtls_item) {
             mtls_item.last_modification_log().username(),
             mtls_item.last_modification_log().host(),
             timeToStr(mtls_item.last_modification_log().time()),
-            mtls_item.comment(),
-            mtls_item.instance_name());
+            mtls_item.instance_name(),
+            mtls_item.comment());
 }
 
 void TextFormatter::printMountPolicyLsHeader() {
@@ -572,8 +571,8 @@ void TextFormatter::printMountPolicyLsHeader() {
             "m.user",
             "m.host",
             "m.time",
-            "comment",
-            "instance");
+            "instance",
+            "comment");
 }
 
 void TextFormatter::print(const MountPolicyLsItem& mpls_item) {
@@ -588,8 +587,8 @@ void TextFormatter::print(const MountPolicyLsItem& mpls_item) {
             mpls_item.last_modification_log().username(),
             mpls_item.last_modification_log().host(),
             timeToStr(mpls_item.last_modification_log().time()),
-            mpls_item.comment(),
-            mpls_item.instance_name());
+            mpls_item.instance_name(),
+            mpls_item.comment());
 }
 
 void TextFormatter::printRepackLsHeader() {
@@ -634,12 +633,11 @@ void TextFormatter::print(const RepackLsItem& rels_item) {
 
 void TextFormatter::printRequesterMountRuleLsHeader() {
   push_back("HEADER");
-  push_back("instance", "disk buffer", "username", "policy", "c.user", "c.host", "c.time", "m.user", "m.host", "m.time", "comment");
+  push_back("disk buffer", "username", "policy", "c.user", "c.host", "c.time", "m.user", "m.host", "m.time", "instance", "comment");
 }
 
 void TextFormatter::print(const RequesterMountRuleLsItem& rmrls_item) {
-  push_back(rmrls_item.instance_name(),
-            rmrls_item.disk_instance(),
+  push_back(rmrls_item.disk_instance(),
             rmrls_item.requester_mount_rule(),
             rmrls_item.mount_policy(),
             rmrls_item.creation_log().username(),
@@ -648,6 +646,7 @@ void TextFormatter::print(const RequesterMountRuleLsItem& rmrls_item) {
             rmrls_item.last_modification_log().username(),
             rmrls_item.last_modification_log().host(),
             timeToStr(rmrls_item.last_modification_log().time()),
+            rmrls_item.instance_name(),
             rmrls_item.comment());
 }
 
@@ -728,8 +727,8 @@ void TextFormatter::printStorageClassLsHeader() {
             "m.user",
             "m.host",
             "m.time",
-            "comment",
-            "instance");
+            "instance",
+            "comment");
 }
 
 void TextFormatter::print(const StorageClassLsItem& scls_item) {
@@ -742,8 +741,8 @@ void TextFormatter::print(const StorageClassLsItem& scls_item) {
             scls_item.last_modification_log().username(),
             scls_item.last_modification_log().host(),
             timeToStr(scls_item.last_modification_log().time()),
-            scls_item.comment(),
-            scls_item.instance_name());
+            scls_item.instance_name(),
+            scls_item.comment());
 }
 
 void TextFormatter::printTapeLsHeader() {
@@ -777,8 +776,8 @@ void TextFormatter::printTapeLsHeader() {
             "m.user",
             "m.host",
             "m.time",
-            "comment",
-            "instance");
+            "instance",
+            "comment");
 }
 
 void TextFormatter::print(const TapeLsItem& tals_item) {
@@ -812,8 +811,8 @@ void TextFormatter::print(const TapeLsItem& tals_item) {
             tals_item.last_modification_log().username(),
             tals_item.last_modification_log().host(),
             timeToStr(tals_item.last_modification_log().time()),
-            tals_item.comment(),
-            tals_item.instance_name());
+            tals_item.instance_name(),
+            tals_item.comment());
 }
 
 void TextFormatter::printTapeFileLsHeader() {
@@ -823,7 +822,7 @@ void TextFormatter::printTapeFileLsHeader() {
             "vid",
             "fseq",
             "block id",
-            "instance",
+            "disk buffer",
             "disk fxid",
             "size",
             "checksum type",
@@ -883,8 +882,8 @@ void TextFormatter::printTapePoolLsHeader() {
             "m.user",
             "m.host",
             "m.time",
-            "comment",
-            "instance");
+            "instance",
+            "comment");
 }
 
 void TextFormatter::print(const TapePoolLsItem& tpls_item) {
@@ -924,8 +923,8 @@ void TextFormatter::print(const TapePoolLsItem& tpls_item) {
             tpls_item.modified().username(),
             tpls_item.modified().host(),
             timeToStr(tpls_item.modified().time()),
-            tpls_item.comment(),
-            tpls_item.instance_name());
+            tpls_item.instance_name(),
+            tpls_item.comment());
 }
 
 void TextFormatter::printDiskInstanceSpaceLsHeader() {
@@ -942,8 +941,8 @@ void TextFormatter::printDiskInstanceSpaceLsHeader() {
             "m.user",
             "m.host",
             "m.time",
-            "comment",
-            "instance");
+            "instance",
+            "comment");
 }
 
 void TextFormatter::print(const DiskInstanceSpaceLsItem& disls_item) {
@@ -958,13 +957,13 @@ void TextFormatter::print(const DiskInstanceSpaceLsItem& disls_item) {
             disls_item.last_modification_log().username(),
             disls_item.last_modification_log().host(),
             timeToStr(disls_item.last_modification_log().time()),
-            disls_item.comment(),
-            disls_item.instance_name());
+            disls_item.instance_name(),
+            disls_item.comment());
 }
 
 void TextFormatter::printDiskInstanceLsHeader() {
   push_back("HEADER");
-  push_back("name", "c.user", "c.host", "c.time", "m.user", "m.host", "m.time", "comment", "instance");
+  push_back("name", "c.user", "c.host", "c.time", "m.user", "m.host", "m.time", "instance", "comment");
 }
 
 void TextFormatter::print(const DiskInstanceLsItem& dils_item) {
@@ -975,15 +974,15 @@ void TextFormatter::print(const DiskInstanceLsItem& dils_item) {
             dils_item.last_modification_log().username(),
             dils_item.last_modification_log().host(),
             timeToStr(dils_item.last_modification_log().time()),
-            dils_item.comment(),
-            dils_item.instance_name());
+            dils_item.instance_name(),
+            dils_item.comment());
 }
 
 void TextFormatter::printDiskSystemLsHeader() {
   push_back("HEADER");
   push_back("name",
-            "instance",
-            "diskspace",
+            "disk buffer",
+            "disk space",
             "regexp",
             "space",
             "sleep",
@@ -993,8 +992,8 @@ void TextFormatter::printDiskSystemLsHeader() {
             "m.user",
             "m.host",
             "m.time",
-            "comment",
-            "instance");
+            "instance",
+            "comment");
 }
 
 void TextFormatter::print(const DiskSystemLsItem& dsls_item) {
@@ -1010,8 +1009,8 @@ void TextFormatter::print(const DiskSystemLsItem& dsls_item) {
             dsls_item.last_modification_log().username(),
             dsls_item.last_modification_log().host(),
             timeToStr(dsls_item.last_modification_log().time()),
-            dsls_item.comment(),
-            dsls_item.instance_name());
+            dsls_item.instance_name(),
+            dsls_item.comment());
 }
 
 void TextFormatter::printVirtualOrganizationLsHeader() {
@@ -1020,7 +1019,7 @@ void TextFormatter::printVirtualOrganizationLsHeader() {
             "read max drives",
             "write max drives",
             "max file size",
-            "disk instance",
+            "disk buffer",
             "is repack vo",
             "c.user",
             "c.host",
@@ -1028,8 +1027,8 @@ void TextFormatter::printVirtualOrganizationLsHeader() {
             "m.user",
             "m.host",
             "m.time",
-            "comment",
-            "instance");
+            "instance",
+            "comment");
 }
 
 void TextFormatter::print(const VirtualOrganizationLsItem& vols_item) {
@@ -1045,8 +1044,8 @@ void TextFormatter::print(const VirtualOrganizationLsItem& vols_item) {
             vols_item.last_modification_log().username(),
             vols_item.last_modification_log().host(),
             timeToStr(vols_item.last_modification_log().time()),
-            vols_item.comment(),
-            vols_item.instance_name());
+            vols_item.instance_name(),
+            vols_item.comment());
 }
 
 void TextFormatter::printVersionHeader() {
@@ -1081,7 +1080,7 @@ void TextFormatter::printRecycleTapeFileLsHeader() {
             "vid",
             "fseq",
             "block id",
-            "instance",
+            "disk buffer",
             "disk fxid",
             "size",
             "checksum type",
@@ -1091,8 +1090,8 @@ void TextFormatter::printRecycleTapeFileLsHeader() {
             "group",
             "deletion time",
             "path when deleted",
-            "reason",
-            "instance");
+            "instance",
+            "reason");
 }
 
 void TextFormatter::print(const RecycleTapeFileLsItem& rtfls_item) {
@@ -1122,8 +1121,8 @@ void TextFormatter::print(const RecycleTapeFileLsItem& rtfls_item) {
             rtfls_item.disk_file_gid(),
             timeToStr(rtfls_item.recycle_log_time()),
             rtfls_item.disk_file_path(),
-            rtfls_item.reason_log(),
-            rtfls_item.instance_name());
+            rtfls_item.instance_name(),
+            rtfls_item.reason_log());
 }
 
 void TextFormatter::printPhysicalLibraryLsHeader() {
@@ -1145,8 +1144,8 @@ void TextFormatter::printPhysicalLibraryLsHeader() {
             "m.user",
             "m.host",
             "m.time",
-            "comment",
-            "instance");
+            "instance",
+            "comment");
 }
 
 void TextFormatter::print(const PhysicalLibraryLsItem& plls_item) {
@@ -1167,8 +1166,8 @@ void TextFormatter::print(const PhysicalLibraryLsItem& plls_item) {
             plls_item.last_modification_log().username(),
             plls_item.last_modification_log().host(),
             timeToStr(plls_item.last_modification_log().time()),
-            plls_item.comment(),
-            plls_item.instance_name());
+            plls_item.instance_name(),
+            plls_item.comment());
 }
 
 }  // namespace cta::admin
-- 
GitLab


From 45ff90511153c71f508da690884572f6f08b1bef Mon Sep 17 00:00:00 2001
From: guenther <jaroslav.guenther@cern.ch>
Date: Wed, 2 Apr 2025 12:06:40 +0200
Subject: [PATCH 3/6] changing xrootd-ssi-protobuf-interface reference commit

---
 xrootd-ssi-protobuf-interface | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xrootd-ssi-protobuf-interface b/xrootd-ssi-protobuf-interface
index ad2bd6c391..8e79bed81d 160000
--- a/xrootd-ssi-protobuf-interface
+++ b/xrootd-ssi-protobuf-interface
@@ -1 +1 @@
-Subproject commit ad2bd6c3914bee772ec15b664e0863715d101d70
+Subproject commit 8e79bed81de41c240be3f9f2922e1ba32474949c
-- 
GitLab


From 9ffb13a2e27861f7a12fa2fee555427c44e87f8e Mon Sep 17 00:00:00 2001
From: guenther <jaroslav.guenther@cern.ch>
Date: Wed, 2 Apr 2025 12:21:35 +0200
Subject: [PATCH 4/6] attept to fix CI cpp check

---
 frontend/common/FrontendService.hpp | 2 +-
 xroot_plugins/XrdCtaShowQueues.hpp  | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/frontend/common/FrontendService.hpp b/frontend/common/FrontendService.hpp
index 9db932d943..ecf4c061ea 100644
--- a/frontend/common/FrontendService.hpp
+++ b/frontend/common/FrontendService.hpp
@@ -154,7 +154,7 @@ public:
   /*
    * Get the instanceName from config file
    */
-  const std::string getInstanceName() const { return m_instanceName; }
+  const std::string& getInstanceName() const { return m_instanceName; }
 
 private:
   /*!
diff --git a/xroot_plugins/XrdCtaShowQueues.hpp b/xroot_plugins/XrdCtaShowQueues.hpp
index 0aac986d2b..46e97ba513 100644
--- a/xroot_plugins/XrdCtaShowQueues.hpp
+++ b/xroot_plugins/XrdCtaShowQueues.hpp
@@ -60,6 +60,7 @@ ShowQueuesStream::ShowQueuesStream(const frontend::AdminCmdStream& requestMsg, c
   cta::Scheduler& scheduler, log::LogContext& lc) :
   XrdCtaStream(catalogue, scheduler),
   m_queuesAndMountsList(scheduler.getQueuesAndMountSummaries(lc)),
+  m_schedulerBackendName(std::nullopt),
   m_instanceName(requestMsg.getInstanceName())
 {
   using namespace cta::admin;
-- 
GitLab


From 149532be12c161f1716271aeace3807c217bd434 Mon Sep 17 00:00:00 2001
From: guenther <jaroslav.guenther@cern.ch>
Date: Wed, 2 Apr 2025 12:24:41 +0200
Subject: [PATCH 5/6] attept to fix CI cpp check

---
 xroot_plugins/AdminCmdStream.hpp   | 2 +-
 xroot_plugins/XrdCtaShowQueues.hpp | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/xroot_plugins/AdminCmdStream.hpp b/xroot_plugins/AdminCmdStream.hpp
index 5e0da38d53..09d17e86fc 100644
--- a/xroot_plugins/AdminCmdStream.hpp
+++ b/xroot_plugins/AdminCmdStream.hpp
@@ -56,7 +56,7 @@ public:
   /*!
    * Get CTA instance Name (set in the CTA Frontend config file)
    */
-  const std::string getInstanceName() const { return m_instanceName; }
+  const std::string& getInstanceName() const { return m_instanceName; }
 
 private:
   /*!
diff --git a/xroot_plugins/XrdCtaShowQueues.hpp b/xroot_plugins/XrdCtaShowQueues.hpp
index 46e97ba513..162cab549a 100644
--- a/xroot_plugins/XrdCtaShowQueues.hpp
+++ b/xroot_plugins/XrdCtaShowQueues.hpp
@@ -60,11 +60,10 @@ ShowQueuesStream::ShowQueuesStream(const frontend::AdminCmdStream& requestMsg, c
   cta::Scheduler& scheduler, log::LogContext& lc) :
   XrdCtaStream(catalogue, scheduler),
   m_queuesAndMountsList(scheduler.getQueuesAndMountSummaries(lc)),
-  m_schedulerBackendName(std::nullopt),
+  m_schedulerBackendName(scheduler.getSchedulerBackendName()),
   m_instanceName(requestMsg.getInstanceName())
 {
   using namespace cta::admin;
-  m_schedulerBackendName = scheduler.getSchedulerBackendName();
   if (!m_schedulerBackendName) {
     XrdSsiPb::Log::Msg(
       XrdSsiPb::Log::ERROR,
-- 
GitLab


From 8d7de2c4b0a7ba228131afa01995cf1ac47f0bd6 Mon Sep 17 00:00:00 2001
From: guenther <jaroslav.guenther@cern.ch>
Date: Thu, 3 Apr 2025 14:34:18 +0200
Subject: [PATCH 6/6] review comment - renaming field in unused
 printListPendingArchivesHeader - to be reviewed later in issue #1128

---
 cmdline/CtaAdminTextFormatter.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/cmdline/CtaAdminTextFormatter.cpp b/cmdline/CtaAdminTextFormatter.cpp
index 7485f4fcd9..ad63518d92 100644
--- a/cmdline/CtaAdminTextFormatter.cpp
+++ b/cmdline/CtaAdminTextFormatter.cpp
@@ -414,6 +414,7 @@ void TextFormatter::printListPendingArchivesHeader() {
             "storage class",
             "copy no",
             "disk id",
+            "disk buffer",
             "checksum type",
             "checksum value",
             "size",
-- 
GitLab