diff --git a/catalogue/Catalogue.hpp b/catalogue/Catalogue.hpp index 153d0a6e1e60c377277dc095a139f5031ca8625a..05b7c31fa3ea2f2c7d937d524187453cd4a70851 100644 --- a/catalogue/Catalogue.hpp +++ b/catalogue/Catalogue.hpp @@ -546,6 +546,14 @@ public: */ virtual void ping() = 0; + /** + * Returns true if the specified tape pool exists. + * + * @param tapePoolName The name of the tape pool. + * @return True if the tape pool exists. + */ + virtual bool tapePoolExists(const std::string &tapePoolName) const = 0; + }; // class Catalogue } // namespace catalogue diff --git a/catalogue/CatalogueTest.cpp b/catalogue/CatalogueTest.cpp index 870fa0fbb87328381d8bfae88f4fb0d74714ae10..ef44e2dac8472abe0ed666ef200f8bc06aae0ceb 100644 --- a/catalogue/CatalogueTest.cpp +++ b/catalogue/CatalogueTest.cpp @@ -782,11 +782,16 @@ TEST_P(cta_catalogue_CatalogueTest, createTapePool) { ASSERT_TRUE(m_catalogue->getTapePools().empty()); const std::string tapePoolName = "tape_pool"; + + ASSERT_FALSE(m_catalogue->tapePoolExists(tapePoolName)); + const uint64_t nbPartialTapes = 2; const bool isEncrypted = true; const std::string comment = "Create tape pool"; m_catalogue->createTapePool(m_admin, tapePoolName, nbPartialTapes, isEncrypted, comment); + + ASSERT_TRUE(m_catalogue->tapePoolExists(tapePoolName)); const std::list<common::dataStructures::TapePool> pools = m_catalogue->getTapePools(); diff --git a/catalogue/RdbmsCatalogue.cpp b/catalogue/RdbmsCatalogue.cpp index eed2e0876da4c678631b5701d678913e01d94ffc..e9798699e73d45471a01da45454131982b87106f 100644 --- a/catalogue/RdbmsCatalogue.cpp +++ b/catalogue/RdbmsCatalogue.cpp @@ -726,6 +726,18 @@ void RdbmsCatalogue::createTapePool( } } +//------------------------------------------------------------------------------ +// tapePoolExists +//------------------------------------------------------------------------------ +bool RdbmsCatalogue::tapePoolExists(const std::string &tapePoolName) const { + try { + auto conn = m_connPool.getConn(); + return tapePoolExists(conn, tapePoolName); + } catch (exception::Exception &ex) { + throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); + } +} + //------------------------------------------------------------------------------ // tapePoolExists //------------------------------------------------------------------------------ diff --git a/catalogue/RdbmsCatalogue.hpp b/catalogue/RdbmsCatalogue.hpp index 306c1908d6156314eeed030e0d8b4df9ddd3276c..5895926e9112f170c4433458b2297bbc0ed2a3f6 100644 --- a/catalogue/RdbmsCatalogue.hpp +++ b/catalogue/RdbmsCatalogue.hpp @@ -572,6 +572,14 @@ protected: bool storageClassExists(rdbms::PooledConn &conn, const std::string &diskInstanceName, const std::string &storageClassName) const; + /** + * Returns true if the specified tape pool exists. + * + * @param tapePoolName The name of the tape pool. + * @return True if the tape pool exists. + */ + bool tapePoolExists(const std::string &tapePoolName) const override; + /** * Returns true if the specified tape pool exists. *