From 18399b54d1dbb51b36fb710fc074a4c68c575f61 Mon Sep 17 00:00:00 2001 From: Steven Murray <Steven.Murray@cern.ch> Date: Wed, 20 Jun 2018 18:21:36 +0200 Subject: [PATCH] cta/CTA#289 Remove the concept of admin host Done --- catalogue/CMakeLists.txt | 15 -- catalogue/Catalogue.hpp | 6 - catalogue/CatalogueFactoryTest.cpp | 20 -- catalogue/CatalogueRetryWrapper.hpp | 16 -- catalogue/CatalogueTest.cpp | 191 -------------- catalogue/CatalogueTest.hpp | 10 - catalogue/CreateAdminHostCmd.cpp | 81 ------ catalogue/CreateAdminHostCmd.hpp | 68 ----- catalogue/CreateAdminHostCmdLineArgs.cpp | 131 ---------- catalogue/CreateAdminHostCmdLineArgs.hpp | 70 ------ catalogue/CreateAdminHostCmdLineArgsTest.cpp | 154 ------------ catalogue/CreateAdminHostCmdMain.cpp | 29 --- catalogue/DropSchemaCmd.cpp | 1 - catalogue/DummyCatalogue.hpp | 4 - catalogue/RdbmsCatalogue.cpp | 235 +----------------- catalogue/RdbmsCatalogue.hpp | 34 --- catalogue/common_catalogue_schema.sql | 11 - .../cta-catalogue-admin-host-create.1cta | 50 ---- cmdline/CtaAdminCmdParse.hpp | 7 - common/CMakeLists.txt | 2 - common/admin/AdminHost.cpp | 39 --- common/admin/AdminHost.hpp | 71 ------ common/dataStructures/AdminHost.cpp | 62 ----- common/dataStructures/AdminHost.hpp | 54 ---- .../orchestration/tests/prepare_tests.sh | 4 - .../orchestration/tests/systest.sh | 1 - .../systest_xrdcp_many_concurrent_files.sh | 1 - .../tests/systest_xrdcp_many_files.sh | 1 - cta.spec.in | 2 - scheduler/OStoreDB/OStoreDB.cpp | 1 - scheduler/SchedulerDatabase.hpp | 2 - scheduler/SchedulerDatabaseTest.cpp | 1 - scheduler/SchedulerTest.cpp | 1 - xroot_plugins/XrdSsiCtaRequestMessage.cpp | 89 ------- xroot_plugins/XrdSsiCtaRequestMessage.hpp | 4 - 35 files changed, 2 insertions(+), 1466 deletions(-) delete mode 100644 catalogue/CreateAdminHostCmd.cpp delete mode 100644 catalogue/CreateAdminHostCmd.hpp delete mode 100644 catalogue/CreateAdminHostCmdLineArgs.cpp delete mode 100644 catalogue/CreateAdminHostCmdLineArgs.hpp delete mode 100644 catalogue/CreateAdminHostCmdLineArgsTest.cpp delete mode 100644 catalogue/CreateAdminHostCmdMain.cpp delete mode 100644 catalogue/cta-catalogue-admin-host-create.1cta delete mode 100644 common/admin/AdminHost.cpp delete mode 100644 common/admin/AdminHost.hpp delete mode 100644 common/dataStructures/AdminHost.cpp delete mode 100644 common/dataStructures/AdminHost.hpp diff --git a/catalogue/CMakeLists.txt b/catalogue/CMakeLists.txt index 7454507fa6..f4aa3e87f0 100644 --- a/catalogue/CMakeLists.txt +++ b/catalogue/CMakeLists.txt @@ -168,22 +168,7 @@ set_property (TARGET cta-catalogue-admin-user-create APPEND PROPERTY INSTALL_RPA install (TARGETS cta-catalogue-admin-user-create DESTINATION /usr/bin) install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-catalogue-admin-user-create.1cta DESTINATION /usr/share/man/man1) -add_executable(cta-catalogue-admin-host-create - CreateAdminHostCmd.cpp - CreateAdminHostCmdLineArgs.cpp - CreateAdminHostCmdMain.cpp) - -target_link_libraries (cta-catalogue-admin-host-create - ctacatalogue) - -set_property (TARGET cta-catalogue-admin-host-create APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH}) - -install (TARGETS cta-catalogue-admin-host-create DESTINATION /usr/bin) -install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-catalogue-admin-host-create.1cta DESTINATION /usr/share/man/man1) - set (CATALOGUE_CMD_LINE_UNIT_TESTS_LIB_SRC_FILES - CreateAdminHostCmdLineArgs.cpp - CreateAdminHostCmdLineArgsTest.cpp CreateAdminUserCmdLineArgs.cpp CreateAdminUserCmdLineArgsTest.cpp CreateSchemaCmdLineArgs.cpp diff --git a/catalogue/Catalogue.hpp b/catalogue/Catalogue.hpp index aad4db5813..6ff737317a 100644 --- a/catalogue/Catalogue.hpp +++ b/catalogue/Catalogue.hpp @@ -24,7 +24,6 @@ #include "catalogue/TapeForWriting.hpp" #include "catalogue/TapePool.hpp" #include "catalogue/TapeSearchCriteria.hpp" -#include "common/dataStructures/AdminHost.hpp" #include "common/dataStructures/AdminUser.hpp" #include "common/dataStructures/ArchiveFile.hpp" #include "common/dataStructures/ArchiveFileQueueCriteria.hpp" @@ -240,11 +239,6 @@ public: virtual std::list<common::dataStructures::AdminUser> getAdminUsers() const = 0; virtual void modifyAdminUserComment(const common::dataStructures::SecurityIdentity &admin, const std::string &username, const std::string &comment) = 0; - virtual void createAdminHost(const common::dataStructures::SecurityIdentity &admin, const std::string &hostName, const std::string &comment) = 0; - virtual void deleteAdminHost(const std::string &hostName) = 0; - virtual std::list<common::dataStructures::AdminHost> getAdminHosts() const = 0; - virtual void modifyAdminHostComment(const common::dataStructures::SecurityIdentity &admin, const std::string &hostName, const std::string &comment) = 0; - /** * Creates the specified storage class. * diff --git a/catalogue/CatalogueFactoryTest.cpp b/catalogue/CatalogueFactoryTest.cpp index 958727665e..c9f6415b98 100644 --- a/catalogue/CatalogueFactoryTest.cpp +++ b/catalogue/CatalogueFactoryTest.cpp @@ -61,14 +61,10 @@ TEST_F(cta_catalogue_CatalogueFactoryTest, instance_in_memory) { ASSERT_TRUE(nullptr != catalogue.get()); ASSERT_TRUE(catalogue->getAdminUsers().empty()); - ASSERT_TRUE(catalogue->getAdminHosts().empty()); const std::string createAdminUserComment = "Create admin user"; catalogue->createAdminUser(m_localAdmin, m_admin.username, createAdminUserComment); - const std::string createAdminHostComment = "Create admin host"; - catalogue->createAdminHost(m_localAdmin, m_admin.host, createAdminHostComment); - { std::list<common::dataStructures::AdminUser> admins; admins = catalogue->getAdminUsers(); @@ -84,22 +80,6 @@ TEST_F(cta_catalogue_CatalogueFactoryTest, instance_in_memory) { const common::dataStructures::EntryLog lastModificationLog = admin.lastModificationLog; ASSERT_EQ(creationLog, lastModificationLog); } - - { - std::list<common::dataStructures::AdminHost> hosts; - hosts = catalogue->getAdminHosts(); - ASSERT_EQ(1, hosts.size()); - - const common::dataStructures::AdminHost host = hosts.front(); - ASSERT_EQ(createAdminHostComment, host.comment); - - const common::dataStructures::EntryLog creationLog = host.creationLog; - ASSERT_EQ(m_localAdmin.username, creationLog.username); - ASSERT_EQ(m_localAdmin.host, creationLog.host); - - const common::dataStructures::EntryLog lastModificationLog = host.lastModificationLog; - ASSERT_EQ(creationLog, lastModificationLog); - } } } // namespace unitTests diff --git a/catalogue/CatalogueRetryWrapper.hpp b/catalogue/CatalogueRetryWrapper.hpp index b477e7fbad..97739b4095 100644 --- a/catalogue/CatalogueRetryWrapper.hpp +++ b/catalogue/CatalogueRetryWrapper.hpp @@ -121,22 +121,6 @@ public: return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyAdminUserComment(admin, username, comment);}, m_maxTriesToConnect); } - void createAdminHost(const common::dataStructures::SecurityIdentity &admin, const std::string &hostName, const std::string &comment) override { - return retryOnLostConnection(m_log, [&]{return m_catalogue->createAdminHost(admin, hostName, comment);}, m_maxTriesToConnect); - } - - void deleteAdminHost(const std::string &hostName) override { - return retryOnLostConnection(m_log, [&]{return m_catalogue->deleteAdminHost(hostName);}, m_maxTriesToConnect); - } - - std::list<common::dataStructures::AdminHost> getAdminHosts() const override { - return retryOnLostConnection(m_log, [&]{return m_catalogue->getAdminHosts();}, m_maxTriesToConnect); - } - - void modifyAdminHostComment(const common::dataStructures::SecurityIdentity &admin, const std::string &hostName, const std::string &comment) override { - return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyAdminHostComment(admin, hostName, comment);}, m_maxTriesToConnect); - } - void createStorageClass(const common::dataStructures::SecurityIdentity &admin, const common::dataStructures::StorageClass &storageClass) override { return retryOnLostConnection(m_log, [&]{return m_catalogue->createStorageClass(admin, storageClass);}, m_maxTriesToConnect); } diff --git a/catalogue/CatalogueTest.cpp b/catalogue/CatalogueTest.cpp index 0e38815115..5a3124147f 100644 --- a/catalogue/CatalogueTest.cpp +++ b/catalogue/CatalogueTest.cpp @@ -70,12 +70,6 @@ void cta_catalogue_CatalogueTest::SetUp() { m_catalogue->deleteAdminUser(adminUser.name); } } - { - const std::list<common::dataStructures::AdminHost> adminHosts = m_catalogue->getAdminHosts(); - for(auto &adminHost: adminHosts) { - m_catalogue->deleteAdminHost(adminHost.name); - } - } { const std::list<common::dataStructures::ArchiveRoute> archiveRoutes = m_catalogue->getArchiveRoutes(); for(auto &archiveRoute: archiveRoutes) { @@ -224,30 +218,6 @@ std::map<std::string, cta::common::dataStructures::AdminUser> cta_catalogue_Cata } } -//------------------------------------------------------------------------------ -// adminHostListToMap -//------------------------------------------------------------------------------ -std::map<std::string, cta::common::dataStructures::AdminHost> cta_catalogue_CatalogueTest::adminHostListToMap( - const std::list<cta::common::dataStructures::AdminHost> &listOfAdminHosts) { - using namespace cta; - - try { - std::map<std::string, common::dataStructures::AdminHost> m; - - for(auto &adminHost: listOfAdminHosts) { - if(m.end() != m.find(adminHost.name)) { - exception::Exception ex; - ex.getMessage() << "Admin host " << adminHost.name << " is a duplicate"; - throw ex; - } - m[adminHost.name] = adminHost; - } - return m; - } catch(exception::Exception &ex) { - throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - } -} - //------------------------------------------------------------------------------ // tapePoolListToMap //------------------------------------------------------------------------------ @@ -395,133 +365,6 @@ TEST_P(cta_catalogue_CatalogueTest, modifyAdminUserComment_nonExtistentAdminUser exception::UserError); } -TEST_P(cta_catalogue_CatalogueTest, createAdminHost) { - using namespace cta; - - ASSERT_TRUE(m_catalogue->getAdminHosts().empty()); - - const std::string createAdminHostComment = "Create admin host"; - m_catalogue->createAdminHost(m_localAdmin, m_admin.host, createAdminHostComment); - - { - std::list<common::dataStructures::AdminHost> hosts; - hosts = m_catalogue->getAdminHosts(); - ASSERT_EQ(1, hosts.size()); - - const common::dataStructures::AdminHost h = hosts.front(); - - ASSERT_EQ(m_admin.host, h.name); - ASSERT_EQ(createAdminHostComment, h.comment); - ASSERT_EQ(m_localAdmin.username, h.creationLog.username); - ASSERT_EQ(m_localAdmin.host, h.creationLog.host); - ASSERT_EQ(m_localAdmin.username, h.lastModificationLog.username); - ASSERT_EQ(m_localAdmin.host, h.lastModificationLog.host); - } -} - -TEST_P(cta_catalogue_CatalogueTest, createAdminHost_same_twice) { - using namespace cta; - - ASSERT_TRUE(m_catalogue->getAdminHosts().empty()); - - const std::string createAdminHostComment = "Create admin host"; - m_catalogue->createAdminHost(m_localAdmin, m_admin.host, createAdminHostComment); - - { - std::list<common::dataStructures::AdminHost> hosts; - hosts = m_catalogue->getAdminHosts(); - ASSERT_EQ(1, hosts.size()); - - const common::dataStructures::AdminHost h = hosts.front(); - - ASSERT_EQ(m_admin.host, h.name); - ASSERT_EQ(createAdminHostComment, h.comment); - ASSERT_EQ(m_localAdmin.username, h.creationLog.username); - ASSERT_EQ(m_localAdmin.host, h.creationLog.host); - ASSERT_EQ(m_localAdmin.username, h.lastModificationLog.username); - ASSERT_EQ(m_localAdmin.host, h.lastModificationLog.host); - } - - ASSERT_THROW(m_catalogue->createAdminHost(m_localAdmin, m_admin.host, "comment 2"), exception::UserError); -} - -TEST_P(cta_catalogue_CatalogueTest, deleteAdminHost) { - using namespace cta; - - ASSERT_TRUE(m_catalogue->getAdminHosts().empty()); - - const std::string createAdminHostComment = "Create admin host"; - m_catalogue->createAdminHost(m_localAdmin, m_admin.host, createAdminHostComment); - - { - std::list<common::dataStructures::AdminHost> hosts; - hosts = m_catalogue->getAdminHosts(); - ASSERT_EQ(1, hosts.size()); - - const common::dataStructures::AdminHost h = hosts.front(); - - ASSERT_EQ(m_admin.host, h.name); - ASSERT_EQ(createAdminHostComment, h.comment); - ASSERT_EQ(m_localAdmin.username, h.creationLog.username); - ASSERT_EQ(m_localAdmin.host, h.creationLog.host); - ASSERT_EQ(m_localAdmin.username, h.lastModificationLog.username); - ASSERT_EQ(m_localAdmin.host, h.lastModificationLog.host); - } - - m_catalogue->deleteAdminHost(m_admin.host); - - ASSERT_TRUE(m_catalogue->getAdminHosts().empty()); -} - -TEST_P(cta_catalogue_CatalogueTest, deleteAdminHost_non_existant) { - using namespace cta; - - ASSERT_TRUE(m_catalogue->getAdminHosts().empty()); - ASSERT_THROW(m_catalogue->deleteAdminHost("non_exstant_admin_host"), exception::UserError); -} - -TEST_P(cta_catalogue_CatalogueTest, modifyAdminHostComment) { - using namespace cta; - - ASSERT_TRUE(m_catalogue->getAdminHosts().empty()); - - const std::string createAdminHostComment = "Create admin host"; - m_catalogue->createAdminHost(m_localAdmin, m_admin.host, createAdminHostComment); - - { - std::list<common::dataStructures::AdminHost> hosts; - hosts = m_catalogue->getAdminHosts(); - ASSERT_EQ(1, hosts.size()); - - const common::dataStructures::AdminHost h = hosts.front(); - - ASSERT_EQ(m_admin.host, h.name); - ASSERT_EQ(createAdminHostComment, h.comment); - ASSERT_EQ(m_localAdmin.username, h.creationLog.username); - ASSERT_EQ(m_localAdmin.host, h.creationLog.host); - ASSERT_EQ(m_localAdmin.username, h.lastModificationLog.username); - ASSERT_EQ(m_localAdmin.host, h.lastModificationLog.host); - } - - const std::string modifiedComment = "Modified comment"; - m_catalogue->modifyAdminHostComment(m_localAdmin, m_admin.host, modifiedComment); - - { - std::list<common::dataStructures::AdminHost> hosts; - hosts = m_catalogue->getAdminHosts(); - ASSERT_EQ(1, hosts.size()); - - const common::dataStructures::AdminHost h = hosts.front(); - - ASSERT_EQ(m_admin.host, h.name); - ASSERT_EQ(modifiedComment, h.comment); - ASSERT_EQ(m_localAdmin.username, h.creationLog.username); - ASSERT_EQ(m_localAdmin.host, h.creationLog.host); - ASSERT_EQ(m_localAdmin.username, h.lastModificationLog.username); - ASSERT_EQ(m_localAdmin.host, h.lastModificationLog.host); - } -} - TEST_P(cta_catalogue_CatalogueTest, isAdmin_false) { using namespace cta; @@ -551,26 +394,6 @@ TEST_P(cta_catalogue_CatalogueTest, isAdmin_true) { ASSERT_EQ(m_localAdmin.host, a.lastModificationLog.host); } - ASSERT_TRUE(m_catalogue->getAdminHosts().empty()); - - const std::string createAdminHostComment = "Create admin host"; - m_catalogue->createAdminHost(m_localAdmin, m_admin.host, createAdminHostComment); - - { - std::list<common::dataStructures::AdminHost> hosts; - hosts = m_catalogue->getAdminHosts(); - ASSERT_EQ(1, hosts.size()); - - const common::dataStructures::AdminHost h = hosts.front(); - - ASSERT_EQ(m_admin.host, h.name); - ASSERT_EQ(createAdminHostComment, h.comment); - ASSERT_EQ(m_localAdmin.username, h.creationLog.username); - ASSERT_EQ(m_localAdmin.host, h.creationLog.host); - ASSERT_EQ(m_localAdmin.username, h.lastModificationLog.username); - ASSERT_EQ(m_localAdmin.host, h.lastModificationLog.host); - } - ASSERT_TRUE(m_catalogue->isAdmin(m_admin)); } @@ -9168,7 +8991,6 @@ TEST_P(cta_catalogue_CatalogueTest, schemaTables) { tableNameToListPos[tableName] = listPos++; } - ASSERT_NE(tableNameToListPos.end(), tableNameToListPos.find("ADMIN_HOST")); ASSERT_NE(tableNameToListPos.end(), tableNameToListPos.find("ADMIN_USER")); ASSERT_NE(tableNameToListPos.end(), tableNameToListPos.find("ARCHIVE_FILE")); ASSERT_NE(tableNameToListPos.end(), tableNameToListPos.find("ARCHIVE_ROUTE")); @@ -9181,19 +9003,6 @@ TEST_P(cta_catalogue_CatalogueTest, schemaTables) { ASSERT_NE(tableNameToListPos.end(), tableNameToListPos.find("TAPE")); ASSERT_NE(tableNameToListPos.end(), tableNameToListPos.find("TAPE_FILE")); ASSERT_NE(tableNameToListPos.end(), tableNameToListPos.find("TAPE_POOL")); - - ASSERT_LT(tableNameToListPos.at("ADMIN_HOST") , tableNameToListPos.at("ADMIN_USER")); - ASSERT_LT(tableNameToListPos.at("ADMIN_USER") , tableNameToListPos.at("ARCHIVE_FILE")); - ASSERT_LT(tableNameToListPos.at("ARCHIVE_FILE") , tableNameToListPos.at("ARCHIVE_ROUTE")); - ASSERT_LT(tableNameToListPos.at("ARCHIVE_ROUTE") , tableNameToListPos.at("CTA_CATALOGUE")); - ASSERT_LT(tableNameToListPos.at("CTA_CATALOGUE") , tableNameToListPos.at("LOGICAL_LIBRARY")); - ASSERT_LT(tableNameToListPos.at("LOGICAL_LIBRARY") , tableNameToListPos.at("MOUNT_POLICY")); - ASSERT_LT(tableNameToListPos.at("MOUNT_POLICY") , tableNameToListPos.at("REQUESTER_GROUP_MOUNT_RULE")); - ASSERT_LT(tableNameToListPos.at("REQUESTER_GROUP_MOUNT_RULE"), tableNameToListPos.at("REQUESTER_MOUNT_RULE")); - ASSERT_LT(tableNameToListPos.at("REQUESTER_MOUNT_RULE") , tableNameToListPos.at("STORAGE_CLASS")); - ASSERT_LT(tableNameToListPos.at("STORAGE_CLASS") , tableNameToListPos.at("TAPE")); - ASSERT_LT(tableNameToListPos.at("TAPE") , tableNameToListPos.at("TAPE_FILE")); - ASSERT_LT(tableNameToListPos.at("TAPE_FILE") , tableNameToListPos.at("TAPE_POOL")); } } // namespace unitTests diff --git a/catalogue/CatalogueTest.hpp b/catalogue/CatalogueTest.hpp index b190b87120..b9c8e8920a 100644 --- a/catalogue/CatalogueTest.hpp +++ b/catalogue/CatalogueTest.hpp @@ -83,16 +83,6 @@ protected: std::map<std::string, cta::common::dataStructures::AdminUser> adminUserListToMap( const std::list<cta::common::dataStructures::AdminUser> &listOfAdminUsers); - /** - * Creates a map from admin host name to admin user from the specified list of - * admin users. - * - * @param listOfAdminHosts The list of admin hosts. - * @return Map from host name to admin host. - */ - std::map<std::string, cta::common::dataStructures::AdminHost> adminHostListToMap( - const std::list<cta::common::dataStructures::AdminHost> &listOfAdminHosts); - /** * Creates a map from tape pool name to tape pool from the specified list of * tape pools. diff --git a/catalogue/CreateAdminHostCmd.cpp b/catalogue/CreateAdminHostCmd.cpp deleted file mode 100644 index cec425916e..0000000000 --- a/catalogue/CreateAdminHostCmd.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 "catalogue/CatalogueFactory.hpp" -#include "catalogue/CreateAdminHostCmd.hpp" -#include "catalogue/CreateAdminHostCmdLineArgs.hpp" -#include "common/exception/Exception.hpp" -#include "common/log/DummyLogger.hpp" -#include "rdbms/wrapper/ConnFactoryFactory.hpp" -#include "common/utils/utils.hpp" - -namespace cta { -namespace catalogue { - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -CreateAdminHostCmd::CreateAdminHostCmd( - std::istream &inStream, - std::ostream &outStream, - std::ostream &errStream): - CmdLineTool(inStream, outStream, errStream) { -} - -//------------------------------------------------------------------------------ -// destructor -//------------------------------------------------------------------------------ -CreateAdminHostCmd::~CreateAdminHostCmd() noexcept { -} - -//------------------------------------------------------------------------------ -// exceptionThrowingMain -//------------------------------------------------------------------------------ -int CreateAdminHostCmd::exceptionThrowingMain(const int argc, char *const *const argv) { - const CreateAdminHostCmdLineArgs cmdLineArgs(argc, argv); - - if(cmdLineArgs.help) { - printUsage(m_out); - return 0; - } - - const rdbms::Login dbLogin = rdbms::Login::parseFile(cmdLineArgs.dbConfigPath); - const uint64_t nbDbConns = 1; - const uint64_t nbArchiveFileListingDbConns = 0; - log::DummyLogger dummyLog("dummy", "dummy"); - auto catalogue = CatalogueFactory::create(dummyLog, dbLogin, nbDbConns, nbArchiveFileListingDbConns); - const common::dataStructures::SecurityIdentity adminRunningCommand(getUsername(), getHostname()); - - // Validate that the hostname is a valid IPv4 or IPv6 address, or a Fully-Qualified Domain Name - if(!utils::isValidIPAddress(cmdLineArgs.adminHostname)) { - utils::assertIsFQDN(cmdLineArgs.adminHostname); - } - - catalogue->createAdminHost(adminRunningCommand, cmdLineArgs.adminHostname, cmdLineArgs.comment); - return 0; -} - -//------------------------------------------------------------------------------ -// printUsage -//------------------------------------------------------------------------------ -void CreateAdminHostCmd::printUsage(std::ostream &os) { - CreateAdminHostCmdLineArgs::printUsage(os); -} - -} // namespace catalogue -} // namespace cta diff --git a/catalogue/CreateAdminHostCmd.hpp b/catalogue/CreateAdminHostCmd.hpp deleted file mode 100644 index 1b9a680568..0000000000 --- a/catalogue/CreateAdminHostCmd.hpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 "catalogue/Catalogue.hpp" -#include "catalogue/CmdLineTool.hpp" - -namespace cta { -namespace catalogue { - -/** - * Command-line tool that creates an admin host. - */ -class CreateAdminHostCmd: public CmdLineTool { -public: - - /** - * Constructor. - * - * @param inStream Standard input stream. - * @param outStream Standard output stream. - * @param errStream Standard error stream. - */ - CreateAdminHostCmd(std::istream &inStream, std::ostream &outStream, std::ostream &errStream); - - /** - * Destructor. - */ - ~CreateAdminHostCmd() noexcept; - -private: - - /** - * An exception throwing version of main(). - * - * @param argc The number of command-line arguments including the program name. - * @param argv The command-line arguments. - * @return The exit value of the program. - */ - int exceptionThrowingMain(const int argc, char *const *const argv) override; - - /** - * Prints the usage message of the command-line tool. - * - * @param os The output stream to which the usage message is to be printed. - */ - void printUsage(std::ostream &os) override; - -}; // class CreateAdminHostCmd - -} // namespace catalogue -} // namespace cta diff --git a/catalogue/CreateAdminHostCmdLineArgs.cpp b/catalogue/CreateAdminHostCmdLineArgs.cpp deleted file mode 100644 index df55d7fee5..0000000000 --- a/catalogue/CreateAdminHostCmdLineArgs.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - * 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 "catalogue/CreateAdminHostCmdLineArgs.hpp" -#include "common/exception/CommandLineNotParsed.hpp" - -#include <getopt.h> -#include <ostream> - -namespace cta { -namespace catalogue { - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -CreateAdminHostCmdLineArgs::CreateAdminHostCmdLineArgs(const int argc, char *const *const argv): - help(false) { - static struct option longopts[] = { - {"comment" , required_argument, NULL, 'm'}, - {"help" , no_argument, NULL, 'h'}, - {"hostname" , required_argument, NULL, 'n'}, - {NULL , 0, NULL, 0} - }; - - // Prevent getopt() from printing an error message if it does not recognize - // an option character - opterr = 0; - - int opt = 0; - while((opt = getopt_long(argc, argv, ":m:hn:", longopts, NULL)) != -1) { - switch(opt) { - case 'm': - comment = optarg ? optarg : ""; - break; - case 'h': - help = true; - break; - case 'n': - adminHostname = optarg ? optarg : ""; - break; - case ':': // Missing parameter - { - exception::CommandLineNotParsed ex; - ex.getMessage() << "The -" << (char)opt << " option requires a parameter"; - throw ex; - } - case '?': // Unknown option - { - exception::CommandLineNotParsed ex; - if(0 == optopt) { - ex.getMessage() << "Unknown command-line option"; - } else { - ex.getMessage() << "Unknown command-line option: -" << (char)optopt; - } - throw ex; - } - default: - { - exception::CommandLineNotParsed ex; - ex.getMessage() << - "getopt_long returned the following unknown value: 0x" << - std::hex << (int)opt; - throw ex; - } - } // switch(opt) - } // while getopt_long() - - // There is no need to continue parsing when the help option is set - if(help) { - return; - } - - if(adminHostname.empty()) { - throw exception::CommandLineNotParsed("The hostname option must be specified with a non-empty string"); - } - - if(comment.empty()) { - throw exception::CommandLineNotParsed("The comment option must be specified with a non-empty string"); - } - - // Calculate the number of non-option ARGV-elements - const int nbArgs = argc - optind; - - // Check the number of arguments - if(nbArgs != 1) { - exception::CommandLineNotParsed ex; - ex.getMessage() << "Wrong number of command-line arguments: expected=1 actual=" << nbArgs; - throw ex; - } - - dbConfigPath = argv[optind]; -} - -//------------------------------------------------------------------------------ -// printUsage -//------------------------------------------------------------------------------ -void CreateAdminHostCmdLineArgs::printUsage(std::ostream &os) { - os << - "Usage:" << std::endl << - " cta-catalogue-admin-host-create databaseConnectionFile -n <hostname> -m <comment> [-h]" << std::endl << - "Where:" << std::endl << - " databaseConnectionFile" << std::endl << - " The path to the file containing the connection details of the CTA" << std::endl << - " catalogue database" << std::endl << - "Options:" << std::endl << - " -n,--hostname <hostname>" << std::endl << - " The name of the admin host to be created" << std::endl << - " -m,--comment <comment>" << std::endl << - " Comment to describe the creation of the admin host" << std::endl << - " -h,--help" << std::endl << - " Prints this usage message" << std::endl << - "" << std::endl;; -} - -} // namespace catalogue -} // namespace cta diff --git a/catalogue/CreateAdminHostCmdLineArgs.hpp b/catalogue/CreateAdminHostCmdLineArgs.hpp deleted file mode 100644 index db1d1585dc..0000000000 --- a/catalogue/CreateAdminHostCmdLineArgs.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 <string> - -namespace cta { -namespace catalogue { - -/** - * Structure to store the command-line arguments of the command-line tool - * named cta-catalogue-admin-host-create - */ -struct CreateAdminHostCmdLineArgs { - /** - * True if the usage message should be printed. - */ - bool help; - - /** - * Path to the file containing the connection details of the catalogue - * database. - */ - std::string dbConfigPath; - - /** - * The name of the admin host to be created in the catalogue database. - */ - std::string adminHostname; - - /** - * The optional comment describing the creation of the admin host. - */ - std::string comment; - - /** - * Constructor that parses the specified command-line arguments. - * - * @param argc The number of command-line arguments including the name of the - * executable. - * @param argv The vector of command-line arguments. - */ - CreateAdminHostCmdLineArgs(const int argc, char *const *const argv); - - /** - * Prints the usage message of the command-line tool. - * - * @param os The output stream to which the usage message is to be printed. - */ - static void printUsage(std::ostream &os); -}; - -} // namespace catalogue -} // namespace cta diff --git a/catalogue/CreateAdminHostCmdLineArgsTest.cpp b/catalogue/CreateAdminHostCmdLineArgsTest.cpp deleted file mode 100644 index eae7e14835..0000000000 --- a/catalogue/CreateAdminHostCmdLineArgsTest.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - * 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/exception/Exception.hpp" -#include "catalogue/CreateAdminHostCmdLineArgs.hpp" - -#include <gtest/gtest.h> -#include <list> - -namespace unitTests { - -class cta_catalogue_CreateAdminHostCmdLineArgsTest : public ::testing::Test { -protected: - - struct Argcv { - int argc; - char **argv; - Argcv(): argc(0), argv(NULL) { - } - }; - typedef std::list<Argcv*> ArgcvList; - ArgcvList m_argsList; - - /** - * Creates a duplicate string using the new operator. - */ - char *dupString(const char *str) { - const size_t len = strlen(str); - char *duplicate = new char[len+1]; - strncpy(duplicate, str, len); - duplicate[len] = '\0'; - return duplicate; - } - - virtual void SetUp() { - // Allow getopt_long to be called again - optind = 0; - } - - virtual void TearDown() { - // Allow getopt_long to be called again - optind = 0; - - for(ArgcvList::const_iterator itor = m_argsList.begin(); - itor != m_argsList.end(); itor++) { - for(int i=0; i < (*itor)->argc; i++) { - delete[] (*itor)->argv[i]; - } - delete[] (*itor)->argv; - delete *itor; - } - } -}; - -TEST_F(cta_catalogue_CreateAdminHostCmdLineArgsTest, help_short) { - using namespace cta::catalogue; - - Argcv *args = new Argcv(); - m_argsList.push_back(args); - args->argc = 2; - args->argv = new char *[3]; - args->argv[0] = dupString("cta-catalogue-admin-host-create"); - args->argv[1] = dupString("-h"); - args->argv[2] = NULL; - - CreateAdminHostCmdLineArgs cmdLine(args->argc, args->argv); - - ASSERT_TRUE(cmdLine.help); - ASSERT_TRUE(cmdLine.dbConfigPath.empty()); - ASSERT_TRUE(cmdLine.adminHostname.empty()); - ASSERT_TRUE(cmdLine.comment.empty()); -} - -TEST_F(cta_catalogue_CreateAdminHostCmdLineArgsTest, help_long) { - using namespace cta::catalogue; - - Argcv *args = new Argcv(); - m_argsList.push_back(args); - args->argc = 2; - args->argv = new char *[3]; - args->argv[0] = dupString("cta-catalogue-admin-host-create"); - args->argv[1] = dupString("--help"); - args->argv[2] = NULL; - - CreateAdminHostCmdLineArgs cmdLine(args->argc, args->argv); - - ASSERT_TRUE(cmdLine.help); - ASSERT_TRUE(cmdLine.dbConfigPath.empty()); - ASSERT_TRUE(cmdLine.adminHostname.empty()); - ASSERT_TRUE(cmdLine.comment.empty()); -} - -TEST_F(cta_catalogue_CreateAdminHostCmdLineArgsTest, hostname_short) { - using namespace cta::catalogue; - - Argcv *args = new Argcv(); - m_argsList.push_back(args); - args->argc = 6; - args->argv = new char *[7]; - args->argv[0] = dupString("cta-catalogue-admin-host-create"); - args->argv[1] = dupString("dbConfigPath"); - args->argv[2] = dupString("-n"); - args->argv[3] = dupString("adminHostname"); - args->argv[4] = dupString("-m"); - args->argv[5] = dupString("comment"); - args->argv[6] = NULL; - - CreateAdminHostCmdLineArgs cmdLine(args->argc, args->argv); - - ASSERT_FALSE(cmdLine.help); - ASSERT_EQ(std::string("dbConfigPath"), cmdLine.dbConfigPath); - ASSERT_EQ(std::string("adminHostname"), cmdLine.adminHostname); - ASSERT_EQ(std::string("comment"), cmdLine.comment); -} - -TEST_F(cta_catalogue_CreateAdminHostCmdLineArgsTest, hostname_long) { - using namespace cta::catalogue; - - Argcv *args = new Argcv(); - m_argsList.push_back(args); - args->argc = 6; - args->argv = new char *[7]; - args->argv[0] = dupString("cta-catalogue-admin-host-create"); - args->argv[1] = dupString("dbConfigPath"); - args->argv[2] = dupString("--hostname"); - args->argv[3] = dupString("adminHostname"); - args->argv[4] = dupString("--comment"); - args->argv[5] = dupString("comment"); - args->argv[6] = NULL; - - CreateAdminHostCmdLineArgs cmdLine(args->argc, args->argv); - - ASSERT_FALSE(cmdLine.help); - ASSERT_EQ(std::string("dbConfigPath"), cmdLine.dbConfigPath); - ASSERT_EQ(std::string("adminHostname"), cmdLine.adminHostname); - ASSERT_EQ(std::string("comment"), cmdLine.comment); -} - -} // namespace unitTests diff --git a/catalogue/CreateAdminHostCmdMain.cpp b/catalogue/CreateAdminHostCmdMain.cpp deleted file mode 100644 index 6817752c4d..0000000000 --- a/catalogue/CreateAdminHostCmdMain.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 "catalogue/CreateAdminHostCmd.hpp" - -#include <iostream> - -//------------------------------------------------------------------------------ -// main -//------------------------------------------------------------------------------ -int main(const int argc, char *const *const argv) { - cta::catalogue::CreateAdminHostCmd cmd(std::cin, std::cout, std::cerr); - return cmd.main(argc, argv); -} diff --git a/catalogue/DropSchemaCmd.cpp b/catalogue/DropSchemaCmd.cpp index 3baf444260..a3855e476f 100644 --- a/catalogue/DropSchemaCmd.cpp +++ b/catalogue/DropSchemaCmd.cpp @@ -137,7 +137,6 @@ void DropSchemaCmd::dropSqliteCatalogueSchema(rdbms::Conn &conn) { "REQUESTER_MOUNT_RULE", "REQUESTER_GROUP_MOUNT_RULE", "ADMIN_USER", - "ADMIN_HOST", "STORAGE_CLASS", "STORAGE_CLASS_ID", "TAPE_POOL", diff --git a/catalogue/DummyCatalogue.hpp b/catalogue/DummyCatalogue.hpp index 8e958ca033..54525df130 100644 --- a/catalogue/DummyCatalogue.hpp +++ b/catalogue/DummyCatalogue.hpp @@ -33,7 +33,6 @@ class DummyCatalogue: public Catalogue { public: DummyCatalogue() {} virtual ~DummyCatalogue() { } - void createAdminHost(const common::dataStructures::SecurityIdentity& admin, const std::string& hostName, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void createAdminUser(const common::dataStructures::SecurityIdentity& admin, const std::string& username, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void createArchiveRoute(const common::dataStructures::SecurityIdentity& admin, const std::string& diskInstanceName, const std::string& storageClassName, const uint64_t copyNb, const std::string& tapePoolName, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } @@ -44,7 +43,6 @@ public: void createStorageClass(const common::dataStructures::SecurityIdentity& admin, const common::dataStructures::StorageClass& storageClass) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void createTape(const common::dataStructures::SecurityIdentity& admin, const std::string& vid, const std::string& logicalLibraryName, const std::string& tapePoolName, const uint64_t capacityInBytes, const bool disabled, const bool full, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void createTapePool(const common::dataStructures::SecurityIdentity& admin, const std::string& name, const uint64_t nbPartialTapes, const bool encryptionValue, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } - void deleteAdminHost(const std::string& hostName) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void deleteAdminUser(const std::string& username) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void deleteArchiveFile(const std::string& instanceName, const uint64_t archiveFileId, log::LogContext &lc) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void deleteArchiveFileByDiskFileId(const std::string &diskInstanceName, const std::string &diskFileId, log::LogContext &lc) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } @@ -57,7 +55,6 @@ public: void deleteTape(const std::string& vid) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void deleteTapePool(const std::string& name) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void filesWrittenToTape(const std::set<TapeFileWritten>& event) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } - std::list<common::dataStructures::AdminHost> getAdminHosts() const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } std::list<common::dataStructures::AdminUser> getAdminUsers() const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } common::dataStructures::ArchiveFile getArchiveFileById(const uint64_t id) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } ArchiveFileItor getArchiveFiles(const TapeFileSearchCriteria& searchCriteria) const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } @@ -74,7 +71,6 @@ public: common::dataStructures::VidToTapeMap getAllTapes() const override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } std::list<TapeForWriting> getTapesForWriting(const std::string& logicalLibraryName) const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } bool isAdmin(const common::dataStructures::SecurityIdentity& admin) const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } - void modifyAdminHostComment(const common::dataStructures::SecurityIdentity& admin, const std::string& hostName, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void modifyAdminUserComment(const common::dataStructures::SecurityIdentity& admin, const std::string& username, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void modifyArchiveRouteComment(const common::dataStructures::SecurityIdentity& admin, const std::string& instanceName, const std::string& storageClassName, const uint64_t copyNb, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void modifyArchiveRouteTapePoolName(const common::dataStructures::SecurityIdentity& admin, const std::string& instanceName, const std::string& storageClassName, const uint64_t copyNb, const std::string& tapePoolName) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } diff --git a/catalogue/RdbmsCatalogue.cpp b/catalogue/RdbmsCatalogue.cpp index 8ff199384b..0ad88be477 100644 --- a/catalogue/RdbmsCatalogue.cpp +++ b/catalogue/RdbmsCatalogue.cpp @@ -256,199 +256,6 @@ void RdbmsCatalogue::modifyAdminUserComment(const common::dataStructures::Securi } } -//------------------------------------------------------------------------------ -// createAdminHost -//------------------------------------------------------------------------------ -void RdbmsCatalogue::createAdminHost( - const common::dataStructures::SecurityIdentity &admin, - const std::string &hostName, - const std::string &comment) { - try { - auto conn = m_connPool.getConn(); - if(adminHostExists(conn, hostName)) { - throw exception::UserError(std::string("Cannot create admin host " + hostName + - " because an admin host with the same name already exists")); - } - const uint64_t now = time(nullptr); - const char *const sql = - "INSERT INTO ADMIN_HOST(" - "ADMIN_HOST_NAME," - - "USER_COMMENT," - - "CREATION_LOG_USER_NAME," - "CREATION_LOG_HOST_NAME," - "CREATION_LOG_TIME," - - "LAST_UPDATE_USER_NAME," - "LAST_UPDATE_HOST_NAME," - "LAST_UPDATE_TIME)" - "VALUES(" - ":ADMIN_HOST_NAME," - - ":USER_COMMENT," - - ":CREATION_LOG_USER_NAME," - ":CREATION_LOG_HOST_NAME," - ":CREATION_LOG_TIME," - - ":LAST_UPDATE_USER_NAME," - ":LAST_UPDATE_HOST_NAME," - ":LAST_UPDATE_TIME)"; - auto stmt = conn.createStmt(sql, rdbms::AutocommitMode::ON); - - stmt.bindString(":ADMIN_HOST_NAME", hostName); - - stmt.bindString(":USER_COMMENT", comment); - - stmt.bindString(":CREATION_LOG_USER_NAME", admin.username); - stmt.bindString(":CREATION_LOG_HOST_NAME", admin.host); - stmt.bindUint64(":CREATION_LOG_TIME", now); - - stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username); - stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host); - stmt.bindUint64(":LAST_UPDATE_TIME", now); - - stmt.executeNonQuery(); - } catch(exception::UserError &) { - throw; - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str()); - throw; - } -} - -//------------------------------------------------------------------------------ -// adminHostExists -//------------------------------------------------------------------------------ -bool RdbmsCatalogue::adminHostExists(rdbms::Conn &conn, const std::string adminHost) const { - try { - const char *const sql = - "SELECT " - "ADMIN_HOST_NAME AS ADMIN_HOST_NAME " - "FROM " - "ADMIN_HOST " - "WHERE " - "ADMIN_HOST_NAME = :ADMIN_HOST_NAME"; - auto stmt = conn.createStmt(sql, rdbms::AutocommitMode::OFF); - stmt.bindString(":ADMIN_HOST_NAME", adminHost); - auto rset = stmt.executeQuery(); - return rset.next(); - } catch(exception::UserError &) { - throw; - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str()); - throw; - } -} - -//------------------------------------------------------------------------------ -// deleteAdminHost -//------------------------------------------------------------------------------ -void RdbmsCatalogue::deleteAdminHost(const std::string &hostName) { - try { - const char *const sql = "DELETE FROM ADMIN_HOST WHERE ADMIN_HOST_NAME = :ADMIN_HOST_NAME"; - auto conn = m_connPool.getConn(); - auto stmt = conn.createStmt(sql, rdbms::AutocommitMode::ON); - stmt.bindString(":ADMIN_HOST_NAME", hostName); - stmt.executeNonQuery(); - - if(0 == stmt.getNbAffectedRows()) { - throw exception::UserError(std::string("Cannot delete admin-host ") + hostName + " because it does not exist"); - } - } catch(exception::UserError &) { - throw; - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str()); - throw; - } -} - -//------------------------------------------------------------------------------ -// getAdminHosts -//------------------------------------------------------------------------------ -std::list<common::dataStructures::AdminHost> RdbmsCatalogue::getAdminHosts() const { - try { - std::list<common::dataStructures::AdminHost> hosts; - const char *const sql = - "SELECT " - "ADMIN_HOST_NAME AS ADMIN_HOST_NAME," - - "USER_COMMENT AS USER_COMMENT," - - "CREATION_LOG_USER_NAME AS CREATION_LOG_USER_NAME," - "CREATION_LOG_HOST_NAME AS CREATION_LOG_HOST_NAME," - "CREATION_LOG_TIME AS CREATION_LOG_TIME," - - "LAST_UPDATE_USER_NAME AS LAST_UPDATE_USER_NAME," - "LAST_UPDATE_HOST_NAME AS LAST_UPDATE_HOST_NAME," - "LAST_UPDATE_TIME AS LAST_UPDATE_TIME " - "FROM " - "ADMIN_HOST " - "ORDER BY " - "ADMIN_HOST_NAME"; - auto conn = m_connPool.getConn(); - auto stmt = conn.createStmt(sql, rdbms::AutocommitMode::OFF); - auto rset = stmt.executeQuery(); - while (rset.next()) { - common::dataStructures::AdminHost host; - - host.name = rset.columnString("ADMIN_HOST_NAME"); - host.comment = rset.columnString("USER_COMMENT"); - host.creationLog.username = rset.columnString("CREATION_LOG_USER_NAME"); - host.creationLog.host = rset.columnString("CREATION_LOG_HOST_NAME"); - host.creationLog.time = rset.columnUint64("CREATION_LOG_TIME"); - host.lastModificationLog.username = rset.columnString("LAST_UPDATE_USER_NAME"); - host.lastModificationLog.host = rset.columnString("LAST_UPDATE_HOST_NAME"); - host.lastModificationLog.time = rset.columnUint64("LAST_UPDATE_TIME"); - - hosts.push_back(host); - } - - return hosts; - } catch(exception::UserError &) { - throw; - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str()); - throw; - } -} - -//------------------------------------------------------------------------------ -// modifyAdminHostComment -//------------------------------------------------------------------------------ -void RdbmsCatalogue::modifyAdminHostComment(const common::dataStructures::SecurityIdentity &admin, - const std::string &hostName, const std::string &comment) { - try { - const time_t now = time(nullptr); - const char *const sql = - "UPDATE ADMIN_HOST SET " - "USER_COMMENT = :USER_COMMENT," - "LAST_UPDATE_USER_NAME = :LAST_UPDATE_USER_NAME," - "LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME," - "LAST_UPDATE_TIME = :LAST_UPDATE_TIME " - "WHERE " - "ADMIN_HOST_NAME = :ADMIN_HOST_NAME"; - auto conn = m_connPool.getConn(); - auto stmt = conn.createStmt(sql, rdbms::AutocommitMode::ON); - stmt.bindString(":USER_COMMENT", comment); - stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username); - stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host); - stmt.bindUint64(":LAST_UPDATE_TIME", now); - stmt.bindString(":ADMIN_HOST_NAME", hostName); - stmt.executeNonQuery(); - - if(0 == stmt.getNbAffectedRows()) { - throw exception::UserError(std::string("Cannot modify admin host ") + hostName + " because it does not exist"); - } - } catch(exception::UserError &) { - throw; - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str()); - throw; - } -} - //------------------------------------------------------------------------------ // createStorageClass //------------------------------------------------------------------------------ @@ -4571,21 +4378,6 @@ RequesterAndGroupMountPolicies RdbmsCatalogue::getMountPolicies( // isAdmin //------------------------------------------------------------------------------ bool RdbmsCatalogue::isAdmin(const common::dataStructures::SecurityIdentity &admin) const { - try { - auto conn = m_connPool.getConn(); - return userIsAdmin(conn, admin.username) && hostIsAdmin(conn, admin.host); - } catch(exception::UserError &) { - throw; - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str()); - throw; - } -} - -//------------------------------------------------------------------------------ -// userIsAdmin -//------------------------------------------------------------------------------ -bool RdbmsCatalogue::userIsAdmin(rdbms::Conn &conn, const std::string &userName) const { try { const char *const sql = "SELECT " @@ -4594,32 +4386,9 @@ bool RdbmsCatalogue::userIsAdmin(rdbms::Conn &conn, const std::string &userName) "ADMIN_USER " "WHERE " "ADMIN_USER_NAME = :ADMIN_USER_NAME"; + auto conn = m_connPool.getConn(); auto stmt = conn.createStmt(sql, rdbms::AutocommitMode::OFF); - stmt.bindString(":ADMIN_USER_NAME", userName); - auto rset = stmt.executeQuery(); - return rset.next(); - } catch(exception::UserError &) { - throw; - } catch(exception::Exception &ex) { - ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str()); - throw; - } -} - -//------------------------------------------------------------------------------ -// hostIsAdmin -//------------------------------------------------------------------------------ -bool RdbmsCatalogue::hostIsAdmin(rdbms::Conn &conn, const std::string &hostName) const { - try { - const char *const sql = - "SELECT " - "ADMIN_HOST_NAME AS ADMIN_HOST_NAME " - "FROM " - "ADMIN_HOST " - "WHERE " - "ADMIN_HOST_NAME = :ADMIN_HOST_NAME"; - auto stmt = conn.createStmt(sql, rdbms::AutocommitMode::OFF); - stmt.bindString(":ADMIN_HOST_NAME", hostName); + stmt.bindString(":ADMIN_USER_NAME", admin.username); auto rset = stmt.executeQuery(); return rset.next(); } catch(exception::UserError &) { diff --git a/catalogue/RdbmsCatalogue.hpp b/catalogue/RdbmsCatalogue.hpp index 8a98d744b3..690ccb7b5d 100644 --- a/catalogue/RdbmsCatalogue.hpp +++ b/catalogue/RdbmsCatalogue.hpp @@ -240,11 +240,6 @@ public: std::list<common::dataStructures::AdminUser> getAdminUsers() const override; void modifyAdminUserComment(const common::dataStructures::SecurityIdentity &admin, const std::string &username, const std::string &comment) override; - void createAdminHost(const common::dataStructures::SecurityIdentity &admin, const std::string &hostName, const std::string &comment) override; - void deleteAdminHost(const std::string &hostName) override; - std::list<common::dataStructures::AdminHost> getAdminHosts() const override; - void modifyAdminHostComment(const common::dataStructures::SecurityIdentity &admin, const std::string &hostName, const std::string &comment) override; - /** * Creates the specified storage class. * @@ -600,15 +595,6 @@ protected: */ bool adminUserExists(rdbms::Conn &conn, const std::string adminUsername) const; - /** - * Returns true if the specified admin host exists. - * - * @param conn The database connection. - * @param adminHost The name of the admin host. - * @return True if the admin host exists. - */ - bool adminHostExists(rdbms::Conn &conn, const std::string adminHost) const; - /** * Returns true if the specified storage class exists. * @@ -927,26 +913,6 @@ protected: */ void createDbSchema(); - /** - * Returns true if the specified user name is listed in the ADMIN_USER table. - * - * @param conn The database connection. - * @param userName The name of the user to be search for in the ADMIN_USER - * table. - * @return true if the specified user name is listed in the ADMIN_USER table. - */ - bool userIsAdmin(rdbms::Conn &conn, const std::string &userName) const; - - /** - * Returns true if the specified host name is listed in the ADMIN_HOST table. - * - * @param conn The database connection. - * @param userName The name of the host to be search for in the ADMIN_HOST - * table. - * @return true if the specified host name is listed in the ADMIN_HOST table. - */ - bool hostIsAdmin(rdbms::Conn &conn, const std::string &userName) const; - /** * A fully qualified storage class, in other words the name of the disk * instance and the name of the storage class. diff --git a/catalogue/common_catalogue_schema.sql b/catalogue/common_catalogue_schema.sql index 7dd48c42ad..97cef8a300 100644 --- a/catalogue/common_catalogue_schema.sql +++ b/catalogue/common_catalogue_schema.sql @@ -13,17 +13,6 @@ CREATE TABLE ADMIN_USER( LAST_UPDATE_TIME INTEGER CONSTRAINT ADMIN_USER_LUT_NN NOT NULL, CONSTRAINT ADMIN_USER_PK PRIMARY KEY(ADMIN_USER_NAME) ); -CREATE TABLE ADMIN_HOST( - ADMIN_HOST_NAME VARCHAR2(100) CONSTRAINT ADMIN_HOST_AHN_NN NOT NULL, - USER_COMMENT VARCHAR2(1000) CONSTRAINT ADMIN_HOST_UC_NN NOT NULL, - CREATION_LOG_USER_NAME VARCHAR2(100) CONSTRAINT ADMIN_HOST_CLUN_NN NOT NULL, - CREATION_LOG_HOST_NAME VARCHAR2(100) CONSTRAINT ADMIN_HOST_CLHN_NN NOT NULL, - CREATION_LOG_TIME INTEGER CONSTRAINT ADMIN_HOST_CLT_NN NOT NULL, - LAST_UPDATE_USER_NAME VARCHAR2(100) CONSTRAINT ADMIN_HOST_LUUN_NN NOT NULL, - LAST_UPDATE_HOST_NAME VARCHAR2(100) CONSTRAINT ADMIN_HOST_LUHN_NN NOT NULL, - LAST_UPDATE_TIME INTEGER CONSTRAINT ADMIN_HOST_LUT_NN NOT NULL, - CONSTRAINT ADMIN_HOST_PK PRIMARY KEY(ADMIN_HOST_NAME) -); CREATE TABLE STORAGE_CLASS( STORAGE_CLASS_ID INTEGER CONSTRAINT STORAGE_CLASS_SCI_NN NOT NULL, DISK_INSTANCE_NAME VARCHAR2(100) CONSTRAINT STORAGE_CLASS_DIN_NN NOT NULL, diff --git a/catalogue/cta-catalogue-admin-host-create.1cta b/catalogue/cta-catalogue-admin-host-create.1cta deleted file mode 100644 index 8876802544..0000000000 --- a/catalogue/cta-catalogue-admin-host-create.1cta +++ /dev/null @@ -1,50 +0,0 @@ -.\" 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/>. -.TH CTA-CATALOGUE-ADMIN-HOST-CREATE 1CTA "December 2016" CTA CTA -.SH NAME -cta-catalogue-admin-host-create \- Create a CTA admin host -.SH SYNOPSIS -.BI "cta-catalogue-admin-host-create databaseConnectionFile -n <hostname> -m <comment> [-h]" - -.SH DESCRIPTION -\fBcta-catalogue-admin-host-create\fP is a command-line tool that creates an -admin host in the catalogue database. \fBcta-catalogue-admin-host-create\fP -connects directly to the catalogue database as opposed to the cta command-line -tool that connects to the CTA front end. \fBcta-catalogue-admin-host-create\fP -can therefore be used to bootstrap the creation of CTA admin hosts. -.P -.SH ARGUMENTS -.TP -\fBdatabaseConnectionFile -The path to the configuration file containing the connection details of the -CTA catalogue database. -.SH OPTIONS -.TP -\fB\-n, \-\-hostname <hostname> -The name of the admin host to be created. -.TP -\fB\-m, \-\-comment <comment> -Comment describing the creation of the admin host. -.TP -\fB\-h, \-\-help -Prints the usage message. -.SH RETURN VALUE -Zero on success and non-zero on failure. -.SH EXAMPLES -cta-catalogue-admin-host-create /etc/cta/cta-catalogue.conf -u ctaadminhost -c "The CTA admin host" - -.SH AUTHOR -\fBCTA\fP Team diff --git a/cmdline/CtaAdminCmdParse.hpp b/cmdline/CtaAdminCmdParse.hpp index 32ee2ff625..579c6009af 100644 --- a/cmdline/CtaAdminCmdParse.hpp +++ b/cmdline/CtaAdminCmdParse.hpp @@ -181,8 +181,6 @@ private: const cmdLookup_t cmdLookup = { { "admin", AdminCmd::CMD_ADMIN }, { "ad", AdminCmd::CMD_ADMIN }, - { "adminhost", AdminCmd::CMD_ADMINHOST }, - { "ah", AdminCmd::CMD_ADMINHOST }, { "archivefile", AdminCmd::CMD_ARCHIVEFILE }, { "af", AdminCmd::CMD_ARCHIVEFILE }, { "archiveroute", AdminCmd::CMD_ARCHIVEROUTE }, @@ -326,7 +324,6 @@ const std::map<std::string, OptionStrList::Key> strListOptions = { */ const std::map<AdminCmd::Cmd, CmdHelp> cmdHelp = { { AdminCmd::CMD_ADMIN, { "admin", "ad", { "add", "ch", "rm", "ls" } }}, - { AdminCmd::CMD_ADMINHOST, { "adminhost", "ah", { "add", "ch", "rm", "ls" } }}, { AdminCmd::CMD_ARCHIVEFILE, { "archivefile", "af", { "ls" } }}, { AdminCmd::CMD_ARCHIVEROUTE, { "archiveroute", "ar", { "add", "ch", "rm", "ls" } }}, { AdminCmd::CMD_DRIVE, { "drive", "dr", { "up", "down", "ls", "rm" }, @@ -431,10 +428,6 @@ const std::map<cmd_key_t, cmd_val_t> cmdOptions = { {{ AdminCmd::CMD_ADMIN, AdminCmd::SUBCMD_CH }, { opt_username, opt_comment }}, {{ AdminCmd::CMD_ADMIN, AdminCmd::SUBCMD_RM }, { opt_username }}, {{ AdminCmd::CMD_ADMIN, AdminCmd::SUBCMD_LS }, { opt_header.optional() }}, - {{ AdminCmd::CMD_ADMINHOST, AdminCmd::SUBCMD_ADD }, { opt_hostname_alias, opt_comment }}, - {{ AdminCmd::CMD_ADMINHOST, AdminCmd::SUBCMD_CH }, { opt_hostname_alias, opt_comment }}, - {{ AdminCmd::CMD_ADMINHOST, AdminCmd::SUBCMD_RM }, { opt_hostname_alias }}, - {{ AdminCmd::CMD_ADMINHOST, AdminCmd::SUBCMD_LS }, { opt_header.optional() }}, {{ AdminCmd::CMD_ARCHIVEFILE, AdminCmd::SUBCMD_LS }, { opt_header.optional(), opt_archivefileid.optional(), opt_diskid.optional(), opt_copynb.optional(), opt_vid.optional(), opt_tapepool.optional(), opt_owner.optional(), opt_group.optional(), diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 078c2eaf7e..0e84bc0dc6 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -28,7 +28,6 @@ include_directories (${XROOTD_INCLUDE_DIR}) set_source_files_properties(CRC.cpp PROPERTIES COMPILE_FLAGS -O2) set (COMMON_LIB_SRC_FILES - dataStructures/AdminHost.cpp dataStructures/AdminUser.cpp dataStructures/ArchiveFile.cpp dataStructures/ArchiveFileQueueCriteria.cpp @@ -69,7 +68,6 @@ set (COMMON_LIB_SRC_FILES dataStructures/VerifyInfo.cpp dataStructures/WriteTestResult.cpp dataStructures/utils.cpp - admin/AdminHost.cpp admin/AdminUser.cpp archiveRoutes/ArchiveRoute.cpp checksum/Checksum.cpp diff --git a/common/admin/AdminHost.cpp b/common/admin/AdminHost.cpp deleted file mode 100644 index f26a722249..0000000000 --- a/common/admin/AdminHost.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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/admin/AdminHost.hpp" - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -cta::common::admin::AdminHost::AdminHost() { -} - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -cta::common::admin::AdminHost::~AdminHost() throw() { -} - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -cta::common::admin::AdminHost::AdminHost( - const std::string &name, - const CreationLog &creationLog): - name(name), creationLog(creationLog) {} \ No newline at end of file diff --git a/common/admin/AdminHost.hpp b/common/admin/AdminHost.hpp deleted file mode 100644 index 35747332e4..0000000000 --- a/common/admin/AdminHost.hpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * The CERN Tape Archive (CTA) project - * Copyright (C) 2015 CERN - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#pragma once - -#include "common/UserIdentity.hpp" -#include "common/CreationLog.hpp" - -#include <string> - -namespace cta { namespace common { namespace admin { - -/** - * An administration host. - */ -struct AdminHost { - - /** - * Constructor. - */ - AdminHost(); - - /** - * Destructor. - */ - ~AdminHost() throw(); - - /** - * Constructor. - * - * @param name The network name of the administration host. - * @param creator The identity of the user that created this configuration - * item. - * @param comment The comment made by the creator of this configuration - * item. - * @param creationTime Optionally the absolute time at which this - * configuration item was created. If no value is given then the current - * time is used. - */ - AdminHost( - const std::string &name, - const CreationLog &creationLog); - - /** - * The network name of the administration host. - */ - std::string name; - - /** - * The why, who, when, where of the creation of the admin host - */ - CreationLog creationLog; - -}; // struct AdminHost - -}}} // namespace cta::common::admin diff --git a/common/dataStructures/AdminHost.cpp b/common/dataStructures/AdminHost.cpp deleted file mode 100644 index ca90283695..0000000000 --- a/common/dataStructures/AdminHost.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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/AdminHost.hpp" -#include "common/dataStructures/utils.hpp" -#include "common/exception/Exception.hpp" - -namespace cta { -namespace common { -namespace dataStructures { - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -AdminHost::AdminHost() {} - -//------------------------------------------------------------------------------ -// operator== -//------------------------------------------------------------------------------ -bool AdminHost::operator==(const AdminHost &rhs) const { - return name==rhs.name - && creationLog==rhs.creationLog - && lastModificationLog==rhs.lastModificationLog - && comment==rhs.comment; -} - -//------------------------------------------------------------------------------ -// operator!= -//------------------------------------------------------------------------------ -bool AdminHost::operator!=(const AdminHost &rhs) const { - return !operator==(rhs); -} - -//------------------------------------------------------------------------------ -// operator<< -//------------------------------------------------------------------------------ -std::ostream &operator<<(std::ostream &os, const AdminHost &obj) { - os << "(name=" << obj.name - << " creationLog=" << obj.creationLog - << " lastModificationLog=" << obj.lastModificationLog - << " comment=" << obj.comment << ")"; - return os; -} - -} // namespace dataStructures -} // namespace common -} // namespace cta diff --git a/common/dataStructures/AdminHost.hpp b/common/dataStructures/AdminHost.hpp deleted file mode 100644 index 7dfdb008a2..0000000000 --- a/common/dataStructures/AdminHost.hpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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> - -#include "common/dataStructures/EntryLog.hpp" - -namespace cta { -namespace common { -namespace dataStructures { - -/** - * This is the host on which an admin is allowed to issue CTA commands - */ -struct AdminHost { - - AdminHost(); - - bool operator==(const AdminHost &rhs) const; - - bool operator!=(const AdminHost &rhs) const; - - std::string name; - EntryLog creationLog; - EntryLog lastModificationLog; - std::string comment; - -}; // struct AdminHost - -std::ostream &operator<<(std::ostream &os, const AdminHost &obj); - -} // namespace dataStructures -} // namespace common -} // namespace cta diff --git a/continuousintegration/orchestration/tests/prepare_tests.sh b/continuousintegration/orchestration/tests/prepare_tests.sh index d911505184..ad8c274fef 100755 --- a/continuousintegration/orchestration/tests/prepare_tests.sh +++ b/continuousintegration/orchestration/tests/prepare_tests.sh @@ -58,10 +58,6 @@ cat ${tempdir}/library-rc.sh ctacliIP=`kubectl --namespace ${NAMESPACE} describe pod ctacli | grep IP | sed -E 's/IP:[[:space:]]+//'` echo "Preparing CTA configuration for tests" - kubectl --namespace ${NAMESPACE} exec ctafrontend -- cta-catalogue-admin-host-create /etc/cta/cta-catalogue.conf --hostname ${ctacliIP} -m "docker cli" - # to allow client connecting to dual stack IPv6/IPv4 xrootd server - # otherwise only use IPv4 by adding '-I v4' to ExecStart line in /etc/systemd/system/cta-frontend.service - kubectl --namespace ${NAMESPACE} exec ctafrontend -- cta-catalogue-admin-host-create /etc/cta/cta-catalogue.conf --hostname [::ffff:${ctacliIP}] -m "docker cli" kubectl --namespace ${NAMESPACE} exec ctafrontend -- cta-catalogue-admin-user-create /etc/cta/cta-catalogue.conf --username ctaadmin1 -m "docker cli" kubectl --namespace ${NAMESPACE} exec ctacli -- cta-admin logicallibrary add \ --name ${LIBRARYNAME} \ diff --git a/continuousintegration/orchestration/tests/systest.sh b/continuousintegration/orchestration/tests/systest.sh index b040006485..9b22b63aba 100755 --- a/continuousintegration/orchestration/tests/systest.sh +++ b/continuousintegration/orchestration/tests/systest.sh @@ -58,7 +58,6 @@ cat ${tempdir}/library-rc.sh ctacliIP=`kubectl --namespace ${NAMESPACE} describe pod ctacli | grep IP | sed -E 's/IP:[[:space:]]+//'` echo "Preparing CTA for tests" - kubectl --namespace ${NAMESPACE} exec ctafrontend -- cta-catalogue-admin-host-create /etc/cta/cta-catalogue.conf --hostname ${ctacliIP} -m "docker cli" kubectl --namespace ${NAMESPACE} exec ctafrontend -- cta-catalogue-admin-user-create /etc/cta/cta-catalogue.conf --username admin1 -m "docker cli" kubectl --namespace ${NAMESPACE} exec ctacli -- cta logicallibrary add \ --name ${LIBRARYNAME} \ diff --git a/continuousintegration/orchestration/tests/systest_xrdcp_many_concurrent_files.sh b/continuousintegration/orchestration/tests/systest_xrdcp_many_concurrent_files.sh index 45622843a1..e579c4e1f7 100755 --- a/continuousintegration/orchestration/tests/systest_xrdcp_many_concurrent_files.sh +++ b/continuousintegration/orchestration/tests/systest_xrdcp_many_concurrent_files.sh @@ -58,7 +58,6 @@ cat ${tempdir}/library-rc.sh ctacliIP=`kubectl --namespace ${NAMESPACE} describe pod ctacli | grep IP | sed -E 's/IP:[[:space:]]+//'` echo "Preparing CTA for tests" -kubectl --namespace ${NAMESPACE} exec ctafrontend -- cta-catalogue-admin-host-create /etc/cta/cta-catalogue.conf --hostname ${ctacliIP} -m "docker cli" kubectl --namespace ${NAMESPACE} exec ctafrontend -- cta-catalogue-admin-user-create /etc/cta/cta-catalogue.conf --username admin1 -m "docker cli" kubectl --namespace ${NAMESPACE} exec ctacli -- cta logicallibrary add \ --name ${LIBRARYNAME} \ diff --git a/continuousintegration/orchestration/tests/systest_xrdcp_many_files.sh b/continuousintegration/orchestration/tests/systest_xrdcp_many_files.sh index 28d123f22d..a2a3cbb541 100755 --- a/continuousintegration/orchestration/tests/systest_xrdcp_many_files.sh +++ b/continuousintegration/orchestration/tests/systest_xrdcp_many_files.sh @@ -58,7 +58,6 @@ cat ${tempdir}/library-rc.sh ctacliIP=`kubectl --namespace ${NAMESPACE} describe pod ctacli | grep IP | sed -E 's/IP:[[:space:]]+//'` echo "Preparing CTA for tests" -kubectl --namespace ${NAMESPACE} exec ctafrontend -- cta-catalogue-admin-host-create /etc/cta/cta-catalogue.conf --hostname ${ctacliIP} -m "docker cli" kubectl --namespace ${NAMESPACE} exec ctafrontend -- cta-catalogue-admin-user-create /etc/cta/cta-catalogue.conf --username admin1 -m "docker cli" kubectl --namespace ${NAMESPACE} exec ctacli -- cta logicallibrary add \ --name ${LIBRARYNAME} \ diff --git a/cta.spec.in b/cta.spec.in index 9240065686..822bb154a1 100644 --- a/cta.spec.in +++ b/cta.spec.in @@ -270,11 +270,9 @@ CERN Tape Archive: Scripts and utilities to faciliate working with the CTA catalogue %files -n cta-catalogueutils %attr(0755,root,root) %{_bindir}/cta-catalogue-admin-user-create -%attr(0755,root,root) %{_bindir}/cta-catalogue-admin-host-create %attr(0755,root,root) %{_bindir}/cta-catalogue-schema-create %attr(0755,root,root) %{_bindir}/cta-catalogue-schema-drop %attr(0755,root,root) %{_bindir}/cta-database-poll -%attr(0644,root,root) %doc /usr/share/man/man1/cta-catalogue-admin-host-create.1cta.gz %attr(0644,root,root) %doc /usr/share/man/man1/cta-catalogue-admin-user-create.1cta.gz %attr(0644,root,root) %doc /usr/share/man/man1/cta-catalogue-schema-create.1cta.gz %attr(0644,root,root) %doc /usr/share/man/man1/cta-catalogue-schema-drop.1cta.gz diff --git a/scheduler/OStoreDB/OStoreDB.cpp b/scheduler/OStoreDB/OStoreDB.cpp index 2186aeff01..0b98d7e5bd 100644 --- a/scheduler/OStoreDB/OStoreDB.cpp +++ b/scheduler/OStoreDB/OStoreDB.cpp @@ -25,7 +25,6 @@ //#include "objectstore/RetrieveRequest.hpp" #include "objectstore/Helpers.hpp" #include "common/exception/Exception.hpp" -#include "common/admin/AdminHost.hpp" #include "common/admin/AdminUser.hpp" #include "common/archiveRoutes/ArchiveRoute.hpp" #include "common/utils/utils.hpp" diff --git a/scheduler/SchedulerDatabase.hpp b/scheduler/SchedulerDatabase.hpp index 64fa0ec233..932500150d 100644 --- a/scheduler/SchedulerDatabase.hpp +++ b/scheduler/SchedulerDatabase.hpp @@ -19,7 +19,6 @@ #pragma once #include "common/admin/AdminUser.hpp" -#include "common/admin/AdminHost.hpp" #include "common/archiveRoutes/ArchiveRoute.hpp" #include "common/dataStructures/RetrieveFileQueueCriteria.hpp" #include "common/dataStructures/DriveState.hpp" @@ -53,7 +52,6 @@ namespace cta { // Forward declarations for opaque references. namespace common { namespace admin { - class AdminHost; class AdminUser; } // cta::common::admin namespace archiveRoute { diff --git a/scheduler/SchedulerDatabaseTest.cpp b/scheduler/SchedulerDatabaseTest.cpp index 68c8377c9e..74a670db62 100644 --- a/scheduler/SchedulerDatabaseTest.cpp +++ b/scheduler/SchedulerDatabaseTest.cpp @@ -19,7 +19,6 @@ #include "objectstore/BackendRadosTestSwitch.hpp" #include "tests/TestsCompileTimeSwitches.hpp" #include "common/UserIdentity.hpp" -#include "common/admin/AdminHost.hpp" #include "common/admin/AdminUser.hpp" #include "common/archiveRoutes/ArchiveRoute.hpp" #include "scheduler/SchedulerDatabase.hpp" diff --git a/scheduler/SchedulerTest.cpp b/scheduler/SchedulerTest.cpp index ac08a40a42..b3b1feff30 100644 --- a/scheduler/SchedulerTest.cpp +++ b/scheduler/SchedulerTest.cpp @@ -19,7 +19,6 @@ #include "catalogue/InMemoryCatalogue.hpp" #include "catalogue/SchemaCreatingSqliteCatalogue.hpp" #include "common/admin/AdminUser.hpp" -#include "common/admin/AdminHost.hpp" #include "common/archiveRoutes/ArchiveRoute.hpp" #include "common/log/DummyLogger.hpp" #include "common/make_unique.hpp" diff --git a/xroot_plugins/XrdSsiCtaRequestMessage.cpp b/xroot_plugins/XrdSsiCtaRequestMessage.cpp index 2106aa87b5..e3c1ec0a7a 100644 --- a/xroot_plugins/XrdSsiCtaRequestMessage.cpp +++ b/xroot_plugins/XrdSsiCtaRequestMessage.cpp @@ -111,18 +111,6 @@ void RequestMessage::process(const cta::xrd::Request &request, cta::xrd::Respons case cmd_pair(AdminCmd::CMD_ADMIN, AdminCmd::SUBCMD_LS): processAdmin_Ls(request.admincmd(), response); break; - case cmd_pair(AdminCmd::CMD_ADMINHOST, AdminCmd::SUBCMD_ADD): - processAdminHost_Add(request.admincmd(), response); - break; - case cmd_pair(AdminCmd::CMD_ADMINHOST, AdminCmd::SUBCMD_CH): - processAdminHost_Ch(request.admincmd(), response); - break; - case cmd_pair(AdminCmd::CMD_ADMINHOST, AdminCmd::SUBCMD_RM): - processAdminHost_Rm(request.admincmd(), response); - break; - case cmd_pair(AdminCmd::CMD_ADMINHOST, AdminCmd::SUBCMD_LS): - processAdminHost_Ls(request.admincmd(), response); - break; case cmd_pair(AdminCmd::CMD_ARCHIVEFILE, AdminCmd::SUBCMD_LS): processArchiveFile_Ls(request.admincmd(), response, stream); break; @@ -736,83 +724,6 @@ void RequestMessage::processAdmin_Ls(const cta::admin::AdminCmd &admincmd, cta:: -void RequestMessage::processAdminHost_Add(const cta::admin::AdminCmd &admincmd, cta::xrd::Response &response) -{ - using namespace cta::admin; - - auto &hostname = getRequired(OptionString::HOSTNAME); - auto &comment = getRequired(OptionString::COMMENT); - - // Validate that the hostname is a valid IPv4 or IPv6 address, or a Fully-Qualified Domain Name - if(!utils::isValidIPAddress(hostname)) { - utils::assertIsFQDN(hostname); - } - - m_catalogue.createAdminHost(m_cliIdentity, hostname, comment); - - response.set_type(cta::xrd::Response::RSP_SUCCESS); -} - - - -void RequestMessage::processAdminHost_Ch(const cta::admin::AdminCmd &admincmd, cta::xrd::Response &response) -{ - using namespace cta::admin; - - auto &hostname = getRequired(OptionString::HOSTNAME); - auto &comment = getRequired(OptionString::COMMENT); - - m_catalogue.modifyAdminHostComment(m_cliIdentity, hostname, comment); - - response.set_type(cta::xrd::Response::RSP_SUCCESS); -} - - - -void RequestMessage::processAdminHost_Rm(const cta::admin::AdminCmd &admincmd, cta::xrd::Response &response) -{ - using namespace cta::admin; - - auto &hostname = getRequired(OptionString::HOSTNAME); - - m_catalogue.deleteAdminHost(hostname); - - response.set_type(cta::xrd::Response::RSP_SUCCESS); -} - - - -void RequestMessage::processAdminHost_Ls(const cta::admin::AdminCmd &admincmd, cta::xrd::Response &response) -{ - using namespace cta::admin; - - std::stringstream cmdlineOutput; - - std::list<cta::common::dataStructures::AdminHost> list= m_catalogue.getAdminHosts(); - - if(!list.empty()) - { - std::vector<std::vector<std::string>> responseTable; - std::vector<std::string> header = { - "hostname","c.user","c.host","c.time","m.user","m.host","m.time","comment" - }; - if(has_flag(OptionBoolean::SHOW_HEADER)) responseTable.push_back(header); - for(auto it = list.cbegin(); it != list.cend(); it++) { - std::vector<std::string> currentRow; - currentRow.push_back(it->name); - addLogInfoToResponseRow(currentRow, it->creationLog, it->lastModificationLog); - currentRow.push_back(it->comment); - responseTable.push_back(currentRow); - } - cmdlineOutput << formatResponse(responseTable); - } - - response.set_message_txt(cmdlineOutput.str()); - response.set_type(cta::xrd::Response::RSP_SUCCESS); -} - - - void RequestMessage::processArchiveFile_Ls(const cta::admin::AdminCmd &admincmd, cta::xrd::Response &response, XrdSsiStream* &stream) { using namespace cta::admin; diff --git a/xroot_plugins/XrdSsiCtaRequestMessage.hpp b/xroot_plugins/XrdSsiCtaRequestMessage.hpp index f7deb96a3b..7749c66343 100644 --- a/xroot_plugins/XrdSsiCtaRequestMessage.hpp +++ b/xroot_plugins/XrdSsiCtaRequestMessage.hpp @@ -83,10 +83,6 @@ private: admincmd_t processAdmin_Ch; admincmd_t processAdmin_Rm; admincmd_t processAdmin_Ls; - admincmd_t processAdminHost_Add; - admincmd_t processAdminHost_Ch; - admincmd_t processAdminHost_Rm; - admincmd_t processAdminHost_Ls; admincmd_t processArchiveRoute_Add; admincmd_t processArchiveRoute_Ch; admincmd_t processArchiveRoute_Rm; -- GitLab