Commit 80f2f29d authored by Cedric CAFFY's avatar Cedric CAFFY
Browse files

Created --temporary incorrect-- Schema version 2.0

Deleted Schema version 1.2
Adapted tapepool management so that it works with the new VIRTUAL_ORGANIZATION table
Adapted unit tests so that a VO is created before a tapePool is created
Adapted prepare_test.sh so that it creates a VO before creating the TapePool
parent b1ce1762
......@@ -90,11 +90,10 @@ CREATE TABLE STORAGE_CLASS(
CREATE TABLE TAPE_POOL(
TAPE_POOL_ID BIGINT UNSIGNED CONSTRAINT TAPE_POOL_TPI_NN NOT NULL,
TAPE_POOL_NAME VARCHAR(100) CONSTRAINT TAPE_POOL_TPN_NN NOT NULL,
VO VARCHAR(100) CONSTRAINT TAPE_POOL_VO_NN NOT NULL,
VIRTUAL_ORGANIZATION_ID BIGINT UNSIGNED CONSTRAINT TAPE_POOL_VOI_NN NOT NULL,
NB_PARTIAL_TAPES BIGINT UNSIGNED CONSTRAINT TAPE_POOL_NPT_NN NOT NULL,
IS_ENCRYPTED CHAR(1) CONSTRAINT TAPE_POOL_IE_NN NOT NULL,
SUPPLY VARCHAR(100),
VIRTUAL_ORGANIZATION_ID BIGINT UNSIGNED,
USER_COMMENT VARCHAR(1000) CONSTRAINT TAPE_POOL_UC_NN NOT NULL,
CREATION_LOG_USER_NAME VARCHAR(100) CONSTRAINT TAPE_POOL_CLUN_NN NOT NULL,
CREATION_LOG_HOST_NAME VARCHAR(100) CONSTRAINT TAPE_POOL_CLHN_NN NOT NULL,
......@@ -317,8 +316,8 @@ INSERT INTO CTA_CATALOGUE(
SCHEMA_VERSION_MINOR,
STATUS)
VALUES(
1,
2,
0,
'PRODUCTION');
ALTER TABLE CTA_CATALOGUE ADD CONSTRAINT
CATALOGUE_STATUS_CONTENT_CK CHECK((NEXT_SCHEMA_VERSION_MAJOR IS NULL AND NEXT_SCHEMA_VERSION_MINOR IS NULL AND STATUS='PRODUCTION') OR (STATUS='UPGRADING'));
\ No newline at end of file
......@@ -116,11 +116,10 @@ CREATE TABLE STORAGE_CLASS(
CREATE TABLE TAPE_POOL(
TAPE_POOL_ID NUMERIC(20, 0) CONSTRAINT TAPE_POOL_TPI_NN NOT NULL,
TAPE_POOL_NAME VARCHAR2(100) CONSTRAINT TAPE_POOL_TPN_NN NOT NULL,
VO VARCHAR2(100) CONSTRAINT TAPE_POOL_VO_NN NOT NULL,
VIRTUAL_ORGANIZATION_ID NUMERIC(20, 0) CONSTRAINT TAPE_POOL_VOI_NN NOT NULL,
NB_PARTIAL_TAPES NUMERIC(20, 0) CONSTRAINT TAPE_POOL_NPT_NN NOT NULL,
IS_ENCRYPTED CHAR(1) CONSTRAINT TAPE_POOL_IE_NN NOT NULL,
SUPPLY VARCHAR2(100),
VIRTUAL_ORGANIZATION_ID NUMERIC(20, 0),
USER_COMMENT VARCHAR2(1000) CONSTRAINT TAPE_POOL_UC_NN NOT NULL,
CREATION_LOG_USER_NAME VARCHAR2(100) CONSTRAINT TAPE_POOL_CLUN_NN NOT NULL,
CREATION_LOG_HOST_NAME VARCHAR2(100) CONSTRAINT TAPE_POOL_CLHN_NN NOT NULL,
......@@ -343,8 +342,8 @@ INSERT INTO CTA_CATALOGUE(
SCHEMA_VERSION_MINOR,
STATUS)
VALUES(
1,
2,
0,
'PRODUCTION');
ALTER TABLE CTA_CATALOGUE ADD CONSTRAINT CATALOGUE_STATUS_CONTENT_CK CHECK((NEXT_SCHEMA_VERSION_MAJOR IS NULL AND NEXT_SCHEMA_VERSION_MINOR IS NULL AND STATUS='PRODUCTION') OR (NEXT_SCHEMA_VERSION_MAJOR IS NOT NULL AND NEXT_SCHEMA_VERSION_MINOR IS NOT NULL AND STATUS='UPGRADING')) INITIALLY DEFERRED;
......
......@@ -100,11 +100,10 @@ CREATE TABLE STORAGE_CLASS(
CREATE TABLE TAPE_POOL(
TAPE_POOL_ID NUMERIC(20, 0) CONSTRAINT TAPE_POOL_TPI_NN NOT NULL,
TAPE_POOL_NAME VARCHAR(100) CONSTRAINT TAPE_POOL_TPN_NN NOT NULL,
VO VARCHAR(100) CONSTRAINT TAPE_POOL_VO_NN NOT NULL,
VIRTUAL_ORGANIZATION_ID NUMERIC(20, 0) CONSTRAINT TAPE_POOL_VOI_NN NOT NULL,
NB_PARTIAL_TAPES NUMERIC(20, 0) CONSTRAINT TAPE_POOL_NPT_NN NOT NULL,
IS_ENCRYPTED CHAR(1) CONSTRAINT TAPE_POOL_IE_NN NOT NULL,
SUPPLY VARCHAR(100),
VIRTUAL_ORGANIZATION_ID NUMERIC(20, 0),
USER_COMMENT VARCHAR(1000) CONSTRAINT TAPE_POOL_UC_NN NOT NULL,
CREATION_LOG_USER_NAME VARCHAR(100) CONSTRAINT TAPE_POOL_CLUN_NN NOT NULL,
CREATION_LOG_HOST_NAME VARCHAR(100) CONSTRAINT TAPE_POOL_CLHN_NN NOT NULL,
......@@ -327,8 +326,8 @@ INSERT INTO CTA_CATALOGUE(
SCHEMA_VERSION_MINOR,
STATUS)
VALUES(
1,
2,
0,
'PRODUCTION');
ALTER TABLE ARCHIVE_FILE DROP CONSTRAINT
ARCHIVE_FILE_DIN_DFI_UN;
......
......@@ -80,11 +80,10 @@ CREATE TABLE STORAGE_CLASS(
CREATE TABLE TAPE_POOL(
TAPE_POOL_ID INTEGER CONSTRAINT TAPE_POOL_TPI_NN NOT NULL,
TAPE_POOL_NAME VARCHAR(100) CONSTRAINT TAPE_POOL_TPN_NN NOT NULL,
VO VARCHAR(100) CONSTRAINT TAPE_POOL_VO_NN NOT NULL,
VIRTUAL_ORGANIZATION_ID INTEGER CONSTRAINT TAPE_POOL_VOI_NN NOT NULL,
NB_PARTIAL_TAPES INTEGER CONSTRAINT TAPE_POOL_NPT_NN NOT NULL,
IS_ENCRYPTED CHAR(1) CONSTRAINT TAPE_POOL_IE_NN NOT NULL,
SUPPLY VARCHAR(100),
VIRTUAL_ORGANIZATION_ID INTEGER,
USER_COMMENT VARCHAR(1000) CONSTRAINT TAPE_POOL_UC_NN NOT NULL,
CREATION_LOG_USER_NAME VARCHAR(100) CONSTRAINT TAPE_POOL_CLUN_NN NOT NULL,
CREATION_LOG_HOST_NAME VARCHAR(100) CONSTRAINT TAPE_POOL_CLHN_NN NOT NULL,
......@@ -307,6 +306,6 @@ INSERT INTO CTA_CATALOGUE(
SCHEMA_VERSION_MINOR,
STATUS)
VALUES(
1,
2,
0,
'PRODUCTION');
......@@ -2464,7 +2464,7 @@ namespace catalogue{
" CATALOGUE_STATUS_CONTENT_CK CHECK((NEXT_SCHEMA_VERSION_MAJOR IS NULL AND NEXT_SCHEMA_VERSION_MINOR IS NULL AND STATUS='PRODUCTION') OR (STATUS='UPGRADING'));"
},
} },
{"1.2",
{"2.0",
{
{"oracle", "CREATE SEQUENCE ARCHIVE_FILE_ID_SEQ"
" INCREMENT BY 1"
......@@ -2584,11 +2584,10 @@ namespace catalogue{
"CREATE TABLE TAPE_POOL("
" TAPE_POOL_ID NUMERIC(20, 0) CONSTRAINT TAPE_POOL_TPI_NN NOT NULL,"
" TAPE_POOL_NAME VARCHAR2(100) CONSTRAINT TAPE_POOL_TPN_NN NOT NULL,"
" VO VARCHAR2(100) CONSTRAINT TAPE_POOL_VO_NN NOT NULL,"
" VIRTUAL_ORGANIZATION_ID NUMERIC(20, 0) CONSTRAINT TAPE_POOL_VOI_NN NOT NULL,"
" NB_PARTIAL_TAPES NUMERIC(20, 0) CONSTRAINT TAPE_POOL_NPT_NN NOT NULL,"
" IS_ENCRYPTED CHAR(1) CONSTRAINT TAPE_POOL_IE_NN NOT NULL,"
" SUPPLY VARCHAR2(100),"
" VIRTUAL_ORGANIZATION_ID NUMERIC(20, 0),"
" USER_COMMENT VARCHAR2(1000) CONSTRAINT TAPE_POOL_UC_NN NOT NULL,"
" CREATION_LOG_USER_NAME VARCHAR2(100) CONSTRAINT TAPE_POOL_CLUN_NN NOT NULL,"
" CREATION_LOG_HOST_NAME VARCHAR2(100) CONSTRAINT TAPE_POOL_CLHN_NN NOT NULL,"
......@@ -2811,8 +2810,8 @@ namespace catalogue{
" SCHEMA_VERSION_MINOR,"
" STATUS)"
"VALUES("
" 1,"
" 2,"
" 0,"
" 'PRODUCTION');"
"ALTER TABLE CTA_CATALOGUE ADD CONSTRAINT CATALOGUE_STATUS_CONTENT_CK CHECK((NEXT_SCHEMA_VERSION_MAJOR IS NULL AND NEXT_SCHEMA_VERSION_MINOR IS NULL AND STATUS='PRODUCTION') OR (NEXT_SCHEMA_VERSION_MAJOR IS NOT NULL AND NEXT_SCHEMA_VERSION_MINOR IS NOT NULL AND STATUS='UPGRADING')) INITIALLY DEFERRED;"
""
......@@ -2910,11 +2909,10 @@ namespace catalogue{
"CREATE TABLE TAPE_POOL("
" TAPE_POOL_ID BIGINT UNSIGNED CONSTRAINT TAPE_POOL_TPI_NN NOT NULL,"
" TAPE_POOL_NAME VARCHAR(100) CONSTRAINT TAPE_POOL_TPN_NN NOT NULL,"
" VO VARCHAR(100) CONSTRAINT TAPE_POOL_VO_NN NOT NULL,"
" VIRTUAL_ORGANIZATION_ID BIGINT UNSIGNED CONSTRAINT TAPE_POOL_VOI_NN NOT NULL,"
" NB_PARTIAL_TAPES BIGINT UNSIGNED CONSTRAINT TAPE_POOL_NPT_NN NOT NULL,"
" IS_ENCRYPTED CHAR(1) CONSTRAINT TAPE_POOL_IE_NN NOT NULL,"
" SUPPLY VARCHAR(100),"
" VIRTUAL_ORGANIZATION_ID BIGINT UNSIGNED,"
" USER_COMMENT VARCHAR(1000) CONSTRAINT TAPE_POOL_UC_NN NOT NULL,"
" CREATION_LOG_USER_NAME VARCHAR(100) CONSTRAINT TAPE_POOL_CLUN_NN NOT NULL,"
" CREATION_LOG_HOST_NAME VARCHAR(100) CONSTRAINT TAPE_POOL_CLHN_NN NOT NULL,"
......@@ -3137,8 +3135,8 @@ namespace catalogue{
" SCHEMA_VERSION_MINOR,"
" STATUS)"
"VALUES("
" 1,"
" 2,"
" 0,"
" 'PRODUCTION');"
"ALTER TABLE CTA_CATALOGUE ADD CONSTRAINT "
" CATALOGUE_STATUS_CONTENT_CK CHECK((NEXT_SCHEMA_VERSION_MAJOR IS NULL AND NEXT_SCHEMA_VERSION_MINOR IS NULL AND STATUS='PRODUCTION') OR (STATUS='UPGRADING'));"
......@@ -3225,11 +3223,10 @@ namespace catalogue{
"CREATE TABLE TAPE_POOL("
" TAPE_POOL_ID INTEGER CONSTRAINT TAPE_POOL_TPI_NN NOT NULL,"
" TAPE_POOL_NAME VARCHAR(100) CONSTRAINT TAPE_POOL_TPN_NN NOT NULL,"
" VO VARCHAR(100) CONSTRAINT TAPE_POOL_VO_NN NOT NULL,"
" VIRTUAL_ORGANIZATION_ID INTEGER CONSTRAINT TAPE_POOL_VOI_NN NOT NULL,"
" NB_PARTIAL_TAPES INTEGER CONSTRAINT TAPE_POOL_NPT_NN NOT NULL,"
" IS_ENCRYPTED CHAR(1) CONSTRAINT TAPE_POOL_IE_NN NOT NULL,"
" SUPPLY VARCHAR(100),"
" VIRTUAL_ORGANIZATION_ID INTEGER,"
" USER_COMMENT VARCHAR(1000) CONSTRAINT TAPE_POOL_UC_NN NOT NULL,"
" CREATION_LOG_USER_NAME VARCHAR(100) CONSTRAINT TAPE_POOL_CLUN_NN NOT NULL,"
" CREATION_LOG_HOST_NAME VARCHAR(100) CONSTRAINT TAPE_POOL_CLHN_NN NOT NULL,"
......@@ -3452,8 +3449,8 @@ namespace catalogue{
" SCHEMA_VERSION_MINOR,"
" STATUS)"
"VALUES("
" 1,"
" 2,"
" 0,"
" 'PRODUCTION');"
},
{"postgres", "CREATE SEQUENCE ARCHIVE_FILE_ID_SEQ"
......@@ -3558,11 +3555,10 @@ namespace catalogue{
"CREATE TABLE TAPE_POOL("
" TAPE_POOL_ID NUMERIC(20, 0) CONSTRAINT TAPE_POOL_TPI_NN NOT NULL,"
" TAPE_POOL_NAME VARCHAR(100) CONSTRAINT TAPE_POOL_TPN_NN NOT NULL,"
" VO VARCHAR(100) CONSTRAINT TAPE_POOL_VO_NN NOT NULL,"
" VIRTUAL_ORGANIZATION_ID NUMERIC(20, 0) CONSTRAINT TAPE_POOL_VOI_NN NOT NULL,"
" NB_PARTIAL_TAPES NUMERIC(20, 0) CONSTRAINT TAPE_POOL_NPT_NN NOT NULL,"
" IS_ENCRYPTED CHAR(1) CONSTRAINT TAPE_POOL_IE_NN NOT NULL,"
" SUPPLY VARCHAR(100),"
" VIRTUAL_ORGANIZATION_ID NUMERIC(20, 0),"
" USER_COMMENT VARCHAR(1000) CONSTRAINT TAPE_POOL_UC_NN NOT NULL,"
" CREATION_LOG_USER_NAME VARCHAR(100) CONSTRAINT TAPE_POOL_CLUN_NN NOT NULL,"
" CREATION_LOG_HOST_NAME VARCHAR(100) CONSTRAINT TAPE_POOL_CLHN_NN NOT NULL,"
......@@ -3785,8 +3781,8 @@ namespace catalogue{
" SCHEMA_VERSION_MINOR,"
" STATUS)"
"VALUES("
" 1,"
" 2,"
" 0,"
" 'PRODUCTION');"
"ALTER TABLE ARCHIVE_FILE DROP CONSTRAINT"
" ARCHIVE_FILE_DIN_DFI_UN;"
......
This diff is collapsed.
......@@ -95,6 +95,8 @@ protected:
*/
std::map<std::string, cta::catalogue::TapePool> tapePoolListToMap(
const std::list<cta::catalogue::TapePool> &listOfTapePools);
void createVo(const std::string &voName);
}; // cta_catalogue_CatalogueTest
} // namespace unitTests
......@@ -403,13 +403,13 @@ void RdbmsCatalogue::deleteVirtualOrganization(const std::string &voName){
auto conn = m_connPool.getConn();
if(virtualOrganizationIsUsedByStorageClasses(conn, voName)) {
throw UserSpecifiedStorageClassUsedByArchiveRoutes(std::string("The ") + voName +
" Virtual Organization is being used by one or more storage classes");
throw UserSpecifiedStorageClassUsedByArchiveRoutes(std::string("The Virtual Organization ") + voName +
" is being used by one or more storage classes");
}
if(virtualOrganizationIsUsedByTapepools(conn, voName)) {
throw UserSpecifiedStorageClassUsedByArchiveFiles(std::string("The ") + voName +
" Virtual Organization is being used by one or more Tapepools");
throw UserSpecifiedStorageClassUsedByArchiveFiles(std::string("The Virtual Organization ") + voName +
" is being used by one or more Tapepools");
}
const char *const sql =
......@@ -1017,13 +1017,17 @@ void RdbmsCatalogue::createTapePool(
throw exception::UserError(std::string("Cannot create tape pool ") + name +
" because a tape pool with the same name already exists");
}
if(!virtualOrganizationExists(conn,vo)){
throw exception::UserError(std::string("Cannot create tape pool ") + name + \
" because vo : "+vo+" does not exist.");
}
const uint64_t tapePoolId = getNextTapePoolId(conn);
const time_t now = time(nullptr);
const char *const sql =
"INSERT INTO TAPE_POOL("
"TAPE_POOL_ID,"
"TAPE_POOL_NAME,"
"VO,"
"VIRTUAL_ORGANIZATION_ID,"
"NB_PARTIAL_TAPES,"
"IS_ENCRYPTED,"
"SUPPLY,"
......@@ -1037,10 +1041,10 @@ void RdbmsCatalogue::createTapePool(
"LAST_UPDATE_USER_NAME,"
"LAST_UPDATE_HOST_NAME,"
"LAST_UPDATE_TIME)"
"VALUES("
"SELECT "
":TAPE_POOL_ID,"
":TAPE_POOL_NAME,"
":VO,"
"VIRTUAL_ORGANIZATION_ID,"
":NB_PARTIAL_TAPES,"
":IS_ENCRYPTED,"
":SUPPLY,"
......@@ -1053,7 +1057,11 @@ void RdbmsCatalogue::createTapePool(
":LAST_UPDATE_USER_NAME,"
":LAST_UPDATE_HOST_NAME,"
":LAST_UPDATE_TIME)";
":LAST_UPDATE_TIME "
"FROM "
"VIRTUAL_ORGANIZATION "
"WHERE "
"VIRTUAL_ORGANIZATION_NAME = :VO";
auto stmt = conn.createStmt(sql);
stmt.bindUint64(":TAPE_POOL_ID", tapePoolId);
......@@ -1324,7 +1332,7 @@ std::list<TapePool> RdbmsCatalogue::getTapePools() const {
const char *const sql =
"SELECT "
"TAPE_POOL.TAPE_POOL_NAME AS TAPE_POOL_NAME,"
"COALESCE(TAPE_POOL.VO, 'NONE') AS VO," // TBD Remove COALESCE
"VIRTUAL_ORGANIZATION.VIRTUAL_ORGANIZATION_NAME AS VO,"
"TAPE_POOL.NB_PARTIAL_TAPES AS NB_PARTIAL_TAPES,"
"TAPE_POOL.IS_ENCRYPTED AS IS_ENCRYPTED,"
"TAPE_POOL.SUPPLY AS SUPPLY,"
......@@ -1345,11 +1353,13 @@ std::list<TapePool> RdbmsCatalogue::getTapePools() const {
"TAPE_POOL.LAST_UPDATE_TIME AS LAST_UPDATE_TIME "
"FROM "
"TAPE_POOL "
"INNER JOIN VIRTUAL_ORGANIZATION ON "
"TAPE_POOL.VIRTUAL_ORGANIZATION_ID = VIRTUAL_ORGANIZATION.VIRTUAL_ORGANIZATION_ID "
"LEFT OUTER JOIN TAPE ON "
"TAPE_POOL.TAPE_POOL_ID = TAPE.TAPE_POOL_ID "
"GROUP BY "
"TAPE_POOL.TAPE_POOL_NAME,"
"TAPE_POOL.VO,"
"VIRTUAL_ORGANIZATION.VIRTUAL_ORGANIZATION_NAME,"
"TAPE_POOL.NB_PARTIAL_TAPES,"
"TAPE_POOL.IS_ENCRYPTED,"
"TAPE_POOL.SUPPLY,"
......@@ -1370,7 +1380,7 @@ std::list<TapePool> RdbmsCatalogue::getTapePools() const {
TapePool pool;
pool.name = rset.columnString("TAPE_POOL_NAME");
pool.vo = rset.columnString("VO");
pool.vo.name = rset.columnString("VO");
pool.nbPartialTapes = rset.columnUint64("NB_PARTIAL_TAPES");
pool.encryption = rset.columnBool("IS_ENCRYPTED");
pool.supply = rset.columnOptionalString("SUPPLY");
......@@ -1416,13 +1426,18 @@ void RdbmsCatalogue::modifyTapePoolVo(const common::dataStructures::SecurityIden
const time_t now = time(nullptr);
const char *const sql =
"UPDATE TAPE_POOL SET "
"VO = :VO,"
"VIRTUAL_ORGANIZATION_ID = (SELECT VIRTUAL_ORGANIZATION_ID FROM VIRTUAL_ORGANIZATION WHERE VIRTUAL_ORGANIZATION_NAME=:VO),"
"LAST_UPDATE_USER_NAME = :LAST_UPDATE_USER_NAME,"
"LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME,"
"LAST_UPDATE_TIME = :LAST_UPDATE_TIME "
"WHERE "
"TAPE_POOL_NAME = :TAPE_POOL_NAME";
auto conn = m_connPool.getConn();
if(!virtualOrganizationExists(conn,vo)){
throw exception::UserError(std::string("Cannot modify tape pool ") + name +" because the vo " + vo + " does not exist");
}
auto stmt = conn.createStmt(sql);
stmt.bindString(":VO", vo);
stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username);
......@@ -2644,7 +2659,7 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(rdbms::Conn &co
"TAPE.VENDOR AS VENDOR,"
"LOGICAL_LIBRARY.LOGICAL_LIBRARY_NAME AS LOGICAL_LIBRARY_NAME,"
"TAPE_POOL.TAPE_POOL_NAME AS TAPE_POOL_NAME,"
"TAPE_POOL.VO AS VO,"
"VIRTUAL_ORGANIZATION.VIRTUAL_ORGANIZATION_NAME AS VO,"
"TAPE.ENCRYPTION_KEY_NAME AS ENCRYPTION_KEY_NAME,"
"TAPE.CAPACITY_IN_BYTES AS CAPACITY_IN_BYTES,"
"TAPE.DATA_IN_BYTES AS DATA_IN_BYTES,"
......@@ -2682,7 +2697,9 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(rdbms::Conn &co
"INNER JOIN TAPE_POOL ON "
"TAPE.TAPE_POOL_ID = TAPE_POOL.TAPE_POOL_ID "
"INNER JOIN LOGICAL_LIBRARY ON "
"TAPE.LOGICAL_LIBRARY_ID = LOGICAL_LIBRARY.LOGICAL_LIBRARY_ID";
"TAPE.LOGICAL_LIBRARY_ID = LOGICAL_LIBRARY.LOGICAL_LIBRARY_ID "
"INNER JOIN VIRTUAL_ORGANIZATION ON "
"TAPE_POOL.VIRTUAL_ORGANIZATION_ID = VIRTUAL_ORGANIZATION.VIRTUAL_ORGANIZATION_ID";
if(searchCriteria.vid ||
searchCriteria.mediaType ||
......@@ -2726,7 +2743,7 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(rdbms::Conn &co
}
if(searchCriteria.vo) {
if(addedAWhereConstraint) sql += " AND ";
sql += " TAPE_POOL.VO = :VO";
sql += " VIRTUAL_ORGANIZATION.VIRTUAL_ORGANIZATION_NAME = :VO";
addedAWhereConstraint = true;
}
if(searchCriteria.capacityInBytes) {
......@@ -2860,7 +2877,7 @@ common::dataStructures::VidToTapeMap RdbmsCatalogue::getTapesByVid(const std::se
"TAPE.VENDOR AS VENDOR,"
"LOGICAL_LIBRARY.LOGICAL_LIBRARY_NAME AS LOGICAL_LIBRARY_NAME,"
"TAPE_POOL.TAPE_POOL_NAME AS TAPE_POOL_NAME,"
"TAPE_POOL.VO AS VO,"
"VIRTUAL_ORGANIZATION.VIRTUAL_ORGANIZATION_NAME AS VO,"
"TAPE.ENCRYPTION_KEY_NAME AS ENCRYPTION_KEY_NAME,"
"TAPE.CAPACITY_IN_BYTES AS CAPACITY_IN_BYTES,"
"TAPE.DATA_IN_BYTES AS DATA_IN_BYTES,"
......@@ -2896,7 +2913,9 @@ common::dataStructures::VidToTapeMap RdbmsCatalogue::getTapesByVid(const std::se
"INNER JOIN TAPE_POOL ON "
"TAPE.TAPE_POOL_ID = TAPE_POOL.TAPE_POOL_ID "
"INNER JOIN LOGICAL_LIBRARY ON "
"TAPE.LOGICAL_LIBRARY_ID = LOGICAL_LIBRARY.LOGICAL_LIBRARY_ID";
"TAPE.LOGICAL_LIBRARY_ID = LOGICAL_LIBRARY.LOGICAL_LIBRARY_ID "
"INNER JOIN VIRTUAL_ORGANIZATION ON "
"TAPE_POOL.VIRTUAL_ORGANIZATION_ID = VIRTUAL_ORGANIZATION.VIRTUAL_ORGANIZATION_ID";
if(!vids.empty()) {
sql += " WHERE ";
......@@ -2988,7 +3007,7 @@ common::dataStructures::VidToTapeMap RdbmsCatalogue::getAllTapes() const {
"TAPE.VENDOR AS VENDOR,"
"LOGICAL_LIBRARY.LOGICAL_LIBRARY_NAME AS LOGICAL_LIBRARY_NAME,"
"TAPE_POOL.TAPE_POOL_NAME AS TAPE_POOL_NAME,"
"TAPE_POOL.VO AS VO,"
"VIRTUAL_ORGANIZATION.VIRTUAL_ORGANIZATION_NAME AS VO,"
"TAPE.ENCRYPTION_KEY_NAME AS ENCRYPTION_KEY_NAME,"
"TAPE.CAPACITY_IN_BYTES AS CAPACITY_IN_BYTES,"
"TAPE.DATA_IN_BYTES AS DATA_IN_BYTES,"
......@@ -3024,7 +3043,9 @@ common::dataStructures::VidToTapeMap RdbmsCatalogue::getAllTapes() const {
"INNER JOIN TAPE_POOL ON "
"TAPE.TAPE_POOL_ID = TAPE_POOL.TAPE_POOL_ID "
"INNER JOIN LOGICAL_LIBRARY ON "
"TAPE.LOGICAL_LIBRARY_ID = LOGICAL_LIBRARY.LOGICAL_LIBRARY_ID";
"TAPE.LOGICAL_LIBRARY_ID = LOGICAL_LIBRARY.LOGICAL_LIBRARY_ID "
"INNER JOIN VIRTUAL_ORGANIZATION ON "
"TAPE_POOL.VIRTUAL_ORGANIZATION_ID = VIRTUAL_ORGANIZATION.VIRTUAL_ORGANIZATION_ID";
auto conn = m_connPool.getConn();
auto stmt = conn.createStmt(sql);
......@@ -6692,7 +6713,7 @@ std::list<TapeForWriting> RdbmsCatalogue::getTapesForWriting(const std::string &
"TAPE.VENDOR AS VENDOR,"
"LOGICAL_LIBRARY.LOGICAL_LIBRARY_NAME AS LOGICAL_LIBRARY_NAME,"
"TAPE_POOL.TAPE_POOL_NAME AS TAPE_POOL_NAME,"
"TAPE_POOL.VO AS VO,"
"VIRTUAL_ORGANIZATION.VIRTUAL_ORGANIZATION_NAME AS VO,"
"TAPE.CAPACITY_IN_BYTES AS CAPACITY_IN_BYTES,"
"TAPE.DATA_IN_BYTES AS DATA_IN_BYTES,"
"TAPE.LAST_FSEQ AS LAST_FSEQ "
......@@ -6702,6 +6723,8 @@ std::list<TapeForWriting> RdbmsCatalogue::getTapesForWriting(const std::string &
"TAPE.TAPE_POOL_ID = TAPE_POOL.TAPE_POOL_ID "
"INNER JOIN LOGICAL_LIBRARY ON "
"TAPE.LOGICAL_LIBRARY_ID = LOGICAL_LIBRARY.LOGICAL_LIBRARY_ID "
"INNER JOIN VIRTUAL_ORGANIZATION ON "
"TAPE_POOL.VIRTUAL_ORGANIZATION_ID = VIRTUAL_ORGANIZATION.VIRTUAL_ORGANIZATION_ID "
"WHERE "
// "TAPE.LABEL_DRIVE IS NOT NULL AND " // Set when the tape has been labelled
// "TAPE.LABEL_TIME IS NOT NULL AND " // Set when the tape has been labelled
......
......@@ -17,6 +17,7 @@
*/
#include "catalogue/TapePool.hpp"
#include "common/dataStructures/VirtualOrganization.hpp"
namespace cta {
namespace catalogue {
......@@ -52,7 +53,7 @@ bool TapePool::operator!=(const TapePool &rhs) const {
//------------------------------------------------------------------------------
std::ostream &operator<<(std::ostream &os, const TapePool &obj) {
os << "(name=" << obj.name
<< " vo=" << obj.vo
<< " vo=" << obj.vo.name
<< " nbPartialTapes=" << obj.nbPartialTapes
<< " encryption=" << obj.encryption
<< " nbTapes=" << obj.nbTapes
......
......@@ -24,6 +24,7 @@
#include "common/dataStructures/EntryLog.hpp"
#include "common/optional.hpp"
#include "common/dataStructures/VirtualOrganization.hpp"
namespace cta {
namespace catalogue {
......@@ -62,7 +63,7 @@ struct TapePool {
/**
* The virtual organisation of the tape pool.
*/
std::string vo;
common::dataStructures::VirtualOrganization vo;
/**
* The desired number of tapes that should be empty or partially filled.
......
......@@ -65,11 +65,10 @@ CREATE TABLE STORAGE_CLASS(
CREATE TABLE TAPE_POOL(
TAPE_POOL_ID UINT64TYPE CONSTRAINT TAPE_POOL_TPI_NN NOT NULL,
TAPE_POOL_NAME VARCHAR(100) CONSTRAINT TAPE_POOL_TPN_NN NOT NULL,
VO VARCHAR(100) CONSTRAINT TAPE_POOL_VO_NN NOT NULL,
VIRTUAL_ORGANIZATION_ID UINT64TYPE CONSTRAINT TAPE_POOL_VOI_NN NOT NULL,
NB_PARTIAL_TAPES UINT64TYPE CONSTRAINT TAPE_POOL_NPT_NN NOT NULL,
IS_ENCRYPTED CHAR(1) CONSTRAINT TAPE_POOL_IE_NN NOT NULL,
SUPPLY VARCHAR(100),
VIRTUAL_ORGANIZATION_ID UINT64TYPE,
USER_COMMENT VARCHAR(1000) CONSTRAINT TAPE_POOL_UC_NN NOT NULL,
CREATION_LOG_USER_NAME VARCHAR(100) CONSTRAINT TAPE_POOL_CLUN_NN NOT NULL,
CREATION_LOG_HOST_NAME VARCHAR(100) CONSTRAINT TAPE_POOL_CLHN_NN NOT NULL,
......
......@@ -3,8 +3,8 @@ set(CTA_VERSION 0)
set(CTA_RELEASE 1)
# Catalogue Schema Version
set(CTA_CATALOGUE_SCHEMA_VERSION_MAJOR 1)
set(CTA_CATALOGUE_SCHEMA_VERSION_MINOR 2)
set(CTA_CATALOGUE_SCHEMA_VERSION_MAJOR 2)
set(CTA_CATALOGUE_SCHEMA_VERSION_MINOR 0)
# Shared object internal version (used in SONAME)
set(CTA_SOVERSION 0)
......
......@@ -100,6 +100,10 @@ echo "Preparing CTA configuration for tests"
--name ${TAPEDRIVES_IN_USE[${i}]} \
--comment "ctasystest library mapped to drive ${TAPEDRIVES_IN_USE[${i}]}"
done
kubectl --namespace ${NAMESPACE} exec ctacli -- cta-admin virtualorganization add \
--vo vo \
--comment "vo"
kubectl --namespace ${NAMESPACE} exec ctacli -- cta-admin tapepool add \
--name ctasystest \
--vo vo \
......
......@@ -217,10 +217,13 @@ public:
const uint16_t nbPartialTapes = 1;
const std::string tapePoolComment = "Tape-pool comment";
const std::string vo = "vo";
cta::common::dataStructures::VirtualOrganization vo;
vo.name = "vo";
vo.comment = "comment";
m_catalogue->createVirtualOrganization(s_adminOnAdminHost,vo);
const bool tapePoolEncryption = false;
const cta::optional<std::string> tapePoolSupply("value for the supply pool mechanism");
catalogue.createTapePool(s_adminOnAdminHost, s_tapePoolName, vo, nbPartialTapes, tapePoolEncryption, tapePoolSupply,
catalogue.createTapePool(s_adminOnAdminHost, s_tapePoolName, vo.name, nbPartialTapes, tapePoolEncryption, tapePoolSupply,
tapePoolComment);
const uint32_t copyNb = 1;
const std::string archiveRouteComment = "Archive-route comment";
......@@ -3412,7 +3415,7 @@ TEST_P(SchedulerTest, expandRepackRequestMoveAndAddCopies){
std::string tapepool2Name = "tapepool2";
const cta::optional<std::string> supply;
catalogue.createTapePool(admin,tapepool2Name,"vo",1,false,supply,"comment");
std::string tapepool3Name = "tapepool3";
catalogue.createTapePool(admin,tapepool3Name,"vo",1,false,supply,"comment");
......
......@@ -297,10 +297,14 @@ public:
const uint16_t nbPartialTapes = 1;
const std::string tapePoolComment = "Tape-pool comment";
const std::string vo = "vo";
cta::common::dataStructures::VirtualOrganization vo;
vo.name = "vo";
vo.comment = "comment";
catalogue.createVirtualOrganization(s_adminOnAdminHost,vo);
const bool tapePoolEncryption = false;
const cta::optional<std::string> tapePoolSupply("value for the supply pool mechanism");
ASSERT_NO_THROW(catalogue.createTapePool(s_adminOnAdminHost, s_tapePoolName, vo, nbPartialTapes, tapePoolEncryption,
ASSERT_NO_THROW(catalogue.createTapePool(s_adminOnAdminHost, s_tapePoolName, vo.name, nbPartialTapes, tapePoolEncryption,
tapePoolSupply, tapePoolComment));
const uint32_t copyNb = 1;
const std::string archiveRouteComment = "Archive-route comment";
......
......@@ -121,17 +121,21 @@ const uint32_t TEST_GROUP_2 = 9754;
const std::string logicalLibraryName = "logical_library_name";
const bool logicalLibraryIsDisabled = false;
const std::string tapePoolName = "tape_pool_name";
const std::string vo = "vo";
const cta::optional<std::string> supply("value for the supply pool mechanism");
const uint64_t capacityInBytes = (uint64_t)10 * 1000 * 1000 * 1000 * 1000;
const bool disabledValue = true;
const bool fullValue = false;
const bool readOnlyValue = false;
const std::string createTapeComment = "Create tape";
cta::common::dataStructures::VirtualOrganization vo;
vo.name = "vo";
vo.comment = "comment";
cta::common::dataStructures::SecurityIdentity admin = cta::common::dataStructures::SecurityIdentity("admin","localhost");
m_catalogue->createVirtualOrganization(admin,vo);
m_catalogue->createLogicalLibrary(admin, logicalLibraryName, logicalLibraryIsDisabled, "Create logical library");
m_catalogue->createTapePool(admin, tapePoolName, vo, 2, true, supply, "Create tape pool");
m_catalogue->createTapePool(admin, tapePoolName, vo.name, 2, true, supply, "Create tape pool");
m_catalogue->createTape(admin, vid1, mediaType, vendor, logicalLibraryName, tapePoolName, capacityInBytes,
disabledValue, fullValue, readOnlyValue, createTapeComment);
......@@ -266,7 +270,6 @@ const uint32_t TEST_GROUP_2 = 9754;
const std::string logicalLibraryName = "logical_library_name";
const bool logicalLibraryIsDisabled = false;
const std::string tapePoolName = "tape_pool_name";
const std::string vo = "vo";
const uint64_t nbPartialTapes = 2;
const bool isEncrypted = true;
const cta::optional<std::string> supply("value for the supply pool mechanism");
......@@ -277,8 +280,14 @@ const uint32_t TEST_GROUP_2 = 9754;
const std::string createTapeComment = "Create tape";
cta::common::dataStructures::SecurityIdentity admin = cta::common::dataStructures::SecurityIdentity("admin","localhost");
cta::common::dataStructures::VirtualOrganization vo;
vo.name = "vo";
vo.comment = "comment";
m_catalogue->createVirtualOrganization(admin,vo);
m_catalogue->createLogicalLibrary(admin, logicalLibraryName, logicalLibraryIsDisabled, "Create logical library");
m_catalogue->createTapePool(admin, tapePoolName, vo, nbPartialTapes, isEncrypted, supply, "Create tape pool");
m_catalogue->createTapePool(admin, tapePoolName, vo.name, nbPartialTapes, isEncrypted, supply, "Create tape pool");
m_catalogue->createTape(admin, vid1, mediaType, vendor, logicalLibraryName, tapePoolName, capacityInBytes,
disabledValue, fullValue, readOnlyValue, createTapeComment);
......
......@@ -74,7 +74,7 @@ int TapePoolLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf) {
auto tp_item = record.mutable_tpls_item();
tp_item->set_name(tp.name);
tp_item->set_vo(tp.vo);
tp_item->set_vo(tp.vo.name);
tp_item->set_num_tapes(tp.nbTapes);
tp_item->set_num_partial_tapes(tp.nbPartialTapes);
tp_item->set_num_physical_files(tp.nbPhysicalFiles);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment