Commit 56e1abcf authored by Cedric Caffy's avatar Cedric Caffy
Browse files

[catalogue] Added the MAX_DRIVES_ALLOWED_FOR_READ and...

[catalogue] Added the MAX_DRIVES_ALLOWED_FOR_READ and MAX_DRIVES_ALLOWED_FOR_WRITE columns in the VIRTUAL_ORGANIZATION table

- Modified the RdbmsCatalogue::createVirtualOrganization() method
- Added the RdbmsCatalogue::modifyVirtualOrganizationMaxDrivesAllowedForRead() method
- Added the RdbmsCatalogue::modifyVirtualOrganizationMaxDrivesAllowedForWrite() method
parent d2722f91
......@@ -72,6 +72,8 @@ CREATE TABLE DISK_SYSTEM(
CREATE TABLE VIRTUAL_ORGANIZATION(
VIRTUAL_ORGANIZATION_ID BIGINT UNSIGNED CONSTRAINT VIRTUAL_ORGANIZATION_VOI_NN NOT NULL,
VIRTUAL_ORGANIZATION_NAME VARCHAR(100) CONSTRAINT VIRTUAL_ORGANIZATION_VON_NN NOT NULL,
MAX_DRIVES_ALLOWED_FOR_READ BIGINT UNSIGNED,
MAX_DRIVES_ALLOWED_FOR_WRITE BIGINT UNSIGNED,
USER_COMMENT VARCHAR(1000) CONSTRAINT VIRTUAL_ORGANIZATION_UC_NN NOT NULL,
CREATION_LOG_USER_NAME VARCHAR(100) CONSTRAINT VIRTUAL_ORGANIZATION_CLUN_NN NOT NULL,
CREATION_LOG_HOST_NAME VARCHAR(100) CONSTRAINT VIRTUAL_ORGANIZATION_CLHN_NN NOT NULL,
......
......@@ -104,6 +104,8 @@ CREATE TABLE DISK_SYSTEM(
CREATE TABLE VIRTUAL_ORGANIZATION(
VIRTUAL_ORGANIZATION_ID NUMERIC(20, 0) CONSTRAINT VIRTUAL_ORGANIZATION_VOI_NN NOT NULL,
VIRTUAL_ORGANIZATION_NAME VARCHAR2(100) CONSTRAINT VIRTUAL_ORGANIZATION_VON_NN NOT NULL,
MAX_DRIVES_ALLOWED_FOR_READ NUMERIC(20, 0),
MAX_DRIVES_ALLOWED_FOR_WRITE NUMERIC(20, 0),
USER_COMMENT VARCHAR2(1000) CONSTRAINT VIRTUAL_ORGANIZATION_UC_NN NOT NULL,
CREATION_LOG_USER_NAME VARCHAR2(100) CONSTRAINT VIRTUAL_ORGANIZATION_CLUN_NN NOT NULL,
CREATION_LOG_HOST_NAME VARCHAR2(100) CONSTRAINT VIRTUAL_ORGANIZATION_CLHN_NN NOT NULL,
......
......@@ -86,6 +86,8 @@ CREATE TABLE DISK_SYSTEM(
CREATE TABLE VIRTUAL_ORGANIZATION(
VIRTUAL_ORGANIZATION_ID NUMERIC(20, 0) CONSTRAINT VIRTUAL_ORGANIZATION_VOI_NN NOT NULL,
VIRTUAL_ORGANIZATION_NAME VARCHAR(100) CONSTRAINT VIRTUAL_ORGANIZATION_VON_NN NOT NULL,
MAX_DRIVES_ALLOWED_FOR_READ NUMERIC(20, 0),
MAX_DRIVES_ALLOWED_FOR_WRITE NUMERIC(20, 0),
USER_COMMENT VARCHAR(1000) CONSTRAINT VIRTUAL_ORGANIZATION_UC_NN NOT NULL,
CREATION_LOG_USER_NAME VARCHAR(100) CONSTRAINT VIRTUAL_ORGANIZATION_CLUN_NN NOT NULL,
CREATION_LOG_HOST_NAME VARCHAR(100) CONSTRAINT VIRTUAL_ORGANIZATION_CLHN_NN NOT NULL,
......
......@@ -58,6 +58,8 @@ CREATE TABLE DISK_SYSTEM(
CREATE TABLE VIRTUAL_ORGANIZATION(
VIRTUAL_ORGANIZATION_ID INTEGER CONSTRAINT VIRTUAL_ORGANIZATION_VOI_NN NOT NULL,
VIRTUAL_ORGANIZATION_NAME VARCHAR(100) CONSTRAINT VIRTUAL_ORGANIZATION_VON_NN NOT NULL,
MAX_DRIVES_ALLOWED_FOR_READ INTEGER,
MAX_DRIVES_ALLOWED_FOR_WRITE INTEGER,
USER_COMMENT VARCHAR(1000) CONSTRAINT VIRTUAL_ORGANIZATION_UC_NN NOT NULL,
CREATION_LOG_USER_NAME VARCHAR(100) CONSTRAINT VIRTUAL_ORGANIZATION_CLUN_NN NOT NULL,
CREATION_LOG_HOST_NAME VARCHAR(100) CONSTRAINT VIRTUAL_ORGANIZATION_CLHN_NN NOT NULL,
......
......@@ -7062,6 +7062,8 @@ namespace catalogue{
"CREATE TABLE VIRTUAL_ORGANIZATION("
" VIRTUAL_ORGANIZATION_ID NUMERIC(20, 0) CONSTRAINT VIRTUAL_ORGANIZATION_VOI_NN NOT NULL,"
" VIRTUAL_ORGANIZATION_NAME VARCHAR2(100) CONSTRAINT VIRTUAL_ORGANIZATION_VON_NN NOT NULL,"
" MAX_DRIVES_ALLOWED_FOR_READ NUMERIC(20, 0),"
" MAX_DRIVES_ALLOWED_FOR_WRITE NUMERIC(20, 0),"
" USER_COMMENT VARCHAR2(1000) CONSTRAINT VIRTUAL_ORGANIZATION_UC_NN NOT NULL,"
" CREATION_LOG_USER_NAME VARCHAR2(100) CONSTRAINT VIRTUAL_ORGANIZATION_CLUN_NN NOT NULL,"
" CREATION_LOG_HOST_NAME VARCHAR2(100) CONSTRAINT VIRTUAL_ORGANIZATION_CLHN_NN NOT NULL,"
......@@ -7484,6 +7486,8 @@ namespace catalogue{
"CREATE TABLE VIRTUAL_ORGANIZATION("
" VIRTUAL_ORGANIZATION_ID BIGINT UNSIGNED CONSTRAINT VIRTUAL_ORGANIZATION_VOI_NN NOT NULL,"
" VIRTUAL_ORGANIZATION_NAME VARCHAR(100) CONSTRAINT VIRTUAL_ORGANIZATION_VON_NN NOT NULL,"
" MAX_DRIVES_ALLOWED_FOR_READ BIGINT UNSIGNED,"
" MAX_DRIVES_ALLOWED_FOR_WRITE BIGINT UNSIGNED,"
" USER_COMMENT VARCHAR(1000) CONSTRAINT VIRTUAL_ORGANIZATION_UC_NN NOT NULL,"
" CREATION_LOG_USER_NAME VARCHAR(100) CONSTRAINT VIRTUAL_ORGANIZATION_CLUN_NN NOT NULL,"
" CREATION_LOG_HOST_NAME VARCHAR(100) CONSTRAINT VIRTUAL_ORGANIZATION_CLHN_NN NOT NULL,"
......@@ -7891,6 +7895,8 @@ namespace catalogue{
"CREATE TABLE VIRTUAL_ORGANIZATION("
" VIRTUAL_ORGANIZATION_ID INTEGER CONSTRAINT VIRTUAL_ORGANIZATION_VOI_NN NOT NULL,"
" VIRTUAL_ORGANIZATION_NAME VARCHAR(100) CONSTRAINT VIRTUAL_ORGANIZATION_VON_NN NOT NULL,"
" MAX_DRIVES_ALLOWED_FOR_READ INTEGER,"
" MAX_DRIVES_ALLOWED_FOR_WRITE INTEGER,"
" USER_COMMENT VARCHAR(1000) CONSTRAINT VIRTUAL_ORGANIZATION_UC_NN NOT NULL,"
" CREATION_LOG_USER_NAME VARCHAR(100) CONSTRAINT VIRTUAL_ORGANIZATION_CLUN_NN NOT NULL,"
" CREATION_LOG_HOST_NAME VARCHAR(100) CONSTRAINT VIRTUAL_ORGANIZATION_CLHN_NN NOT NULL,"
......@@ -8324,6 +8330,8 @@ namespace catalogue{
"CREATE TABLE VIRTUAL_ORGANIZATION("
" VIRTUAL_ORGANIZATION_ID NUMERIC(20, 0) CONSTRAINT VIRTUAL_ORGANIZATION_VOI_NN NOT NULL,"
" VIRTUAL_ORGANIZATION_NAME VARCHAR(100) CONSTRAINT VIRTUAL_ORGANIZATION_VON_NN NOT NULL,"
" MAX_DRIVES_ALLOWED_FOR_READ NUMERIC(20, 0),"
" MAX_DRIVES_ALLOWED_FOR_WRITE NUMERIC(20, 0),"
" USER_COMMENT VARCHAR(1000) CONSTRAINT VIRTUAL_ORGANIZATION_UC_NN NOT NULL,"
" CREATION_LOG_USER_NAME VARCHAR(100) CONSTRAINT VIRTUAL_ORGANIZATION_CLUN_NN NOT NULL,"
" CREATION_LOG_HOST_NAME VARCHAR(100) CONSTRAINT VIRTUAL_ORGANIZATION_CLHN_NN NOT NULL,"
......
......@@ -297,6 +297,22 @@ public:
*/
virtual void modifyVirtualOrganizationName(const common::dataStructures::SecurityIdentity &admin, const std::string &currentVoName, const std::string &newVoName) = 0;
/**
* Modifies the max number of allocated drives for read for the specified Virtual Organization
*
* @param voName the VO name
* @param maxDrivesAllowedForRead the new max number of allocated drives for read for the specified Virtual Organization
*/
virtual void modifyVirtualOrganizationMaxDrivesAllowedForRead(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t maxDrivesAllowedForRead) = 0;
/**
* Modifies the max number of allocated drives for write for the specified Virtual Organization
*
* @param voName the VO name
* @param maxDrivesAllowedForRead the new max number of allocated drives for write for the specified Virtual Organization
*/
virtual void modifyVirtualOrganizationMaxDrivesAllowedForWrite(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t maxDrivesAllowedForWrite) = 0;
/**
* Modifies the comment of the specified Virtual Organization
*
......
......@@ -132,6 +132,16 @@ public:
return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyVirtualOrganizationName(admin,currentVoName,newVoName);}, m_maxTriesToConnect);
}
void modifyVirtualOrganizationMaxDrivesAllowedForRead(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t maxDrivesAllowedForRead) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyVirtualOrganizationMaxDrivesAllowedForRead(admin,voName,maxDrivesAllowedForRead);}, m_maxTriesToConnect);
}
void modifyVirtualOrganizationMaxDrivesAllowedForWrite(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t maxDrivesAllowedForWrite) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyVirtualOrganizationMaxDrivesAllowedForWrite(admin,voName,maxDrivesAllowedForWrite);}, m_maxTriesToConnect);
}
void modifyVirtualOrganizationComment(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const std::string &comment) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyVirtualOrganizationComment(admin,voName,comment);}, m_maxTriesToConnect);
}
......
......@@ -75,6 +75,8 @@ namespace {
common::dataStructures::VirtualOrganization vo;
vo.name = "vo";
vo.comment = "Creation of virtual organization vo";
vo.maxDrivesAllowedForRead = 1;
vo.maxDrivesAllowedForWrite = 1;
return vo;
}
 
......@@ -14558,9 +14560,7 @@ TEST_P(cta_catalogue_CatalogueTest, getSchemaVersion) {
TEST_P(cta_catalogue_CatalogueTest, createVirtualOrganization) {
using namespace cta;
 
common::dataStructures::VirtualOrganization vo;
vo.name = "VO";
vo.comment = "Comment";
common::dataStructures::VirtualOrganization vo = getVo();
ASSERT_NO_THROW(m_catalogue->createVirtualOrganization(m_admin,vo));
}
......@@ -14568,9 +14568,7 @@ TEST_P(cta_catalogue_CatalogueTest, createVirtualOrganization) {
TEST_P(cta_catalogue_CatalogueTest, createVirtualOrganizationAlreadyExists) {
using namespace cta;
 
common::dataStructures::VirtualOrganization vo;
vo.name = "VO";
vo.comment = "Comment";
common::dataStructures::VirtualOrganization vo = getVo();
ASSERT_NO_THROW(m_catalogue->createVirtualOrganization(m_admin,vo));
ASSERT_THROW(m_catalogue->createVirtualOrganization(m_admin,vo),cta::exception::UserError);
......@@ -14579,8 +14577,8 @@ TEST_P(cta_catalogue_CatalogueTest, createVirtualOrganizationAlreadyExists) {
TEST_P(cta_catalogue_CatalogueTest, createVirtualOrganizationEmptyComment) {
using namespace cta;
 
common::dataStructures::VirtualOrganization vo;
vo.name = "VO";
common::dataStructures::VirtualOrganization vo = getVo();
vo.comment = "";
ASSERT_THROW(m_catalogue->createVirtualOrganization(m_admin,vo),cta::exception::UserError);
}
......@@ -14588,7 +14586,9 @@ TEST_P(cta_catalogue_CatalogueTest, createVirtualOrganizationEmptyComment) {
TEST_P(cta_catalogue_CatalogueTest, createVirtualOrganizationEmptyName) {
using namespace cta;
 
common::dataStructures::VirtualOrganization vo;
common::dataStructures::VirtualOrganization vo = getVo();
vo.name = "";
vo.comment = "comment";
ASSERT_THROW(m_catalogue->createVirtualOrganization(m_admin,vo),cta::exception::UserError);
......@@ -14597,9 +14597,7 @@ TEST_P(cta_catalogue_CatalogueTest, createVirtualOrganizationEmptyName) {
TEST_P(cta_catalogue_CatalogueTest, deleteVirtualOrganization) {
using namespace cta;
 
common::dataStructures::VirtualOrganization vo;
vo.name = "vo";
vo.comment = "comment";
common::dataStructures::VirtualOrganization vo = getVo();
ASSERT_NO_THROW(m_catalogue->createVirtualOrganization(m_admin,vo));
......@@ -14623,9 +14621,7 @@ TEST_P(cta_catalogue_CatalogueTest, deleteVirtualOrganizationUsedByTapePool) {
TEST_P(cta_catalogue_CatalogueTest, deleteVirtualOrganizationNameDoesNotExist) {
using namespace cta;
 
common::dataStructures::VirtualOrganization vo;
vo.name = "vo";
vo.comment = "comment";
common::dataStructures::VirtualOrganization vo = getVo();
ASSERT_NO_THROW(m_catalogue->createVirtualOrganization(m_admin,vo));
......@@ -14643,9 +14639,7 @@ TEST_P(cta_catalogue_CatalogueTest, deleteVirtualOrganizationUsedByStorageClass)
TEST_P(cta_catalogue_CatalogueTest, getVirtualOrganizations) {
using namespace cta;
 
common::dataStructures::VirtualOrganization vo;
vo.name = "vo";
vo.comment = "comment";
common::dataStructures::VirtualOrganization vo = getVo();
ASSERT_NO_THROW(m_catalogue->createVirtualOrganization(m_admin,vo));
......@@ -14654,6 +14648,8 @@ TEST_P(cta_catalogue_CatalogueTest, getVirtualOrganizations) {
auto &voRetrieved = vos.front();
ASSERT_EQ(vo.name,voRetrieved.name);
ASSERT_EQ(vo.maxDrivesAllowedForRead,voRetrieved.maxDrivesAllowedForRead);
ASSERT_EQ(vo.maxDrivesAllowedForWrite,voRetrieved.maxDrivesAllowedForWrite);
ASSERT_EQ(vo.comment,voRetrieved.comment);
ASSERT_EQ(m_admin.host,voRetrieved.creationLog.host);
ASSERT_EQ(m_admin.username,voRetrieved.creationLog.username);
......@@ -14666,12 +14662,10 @@ TEST_P(cta_catalogue_CatalogueTest, getVirtualOrganizations) {
ASSERT_EQ(0,vos.size());
}
 
TEST_P(cta_catalogue_CatalogueTest, modifyVirtualOrganization) {
TEST_P(cta_catalogue_CatalogueTest, modifyVirtualOrganizationName) {
using namespace cta;
 
common::dataStructures::VirtualOrganization vo;
vo.name = "vo";
vo.comment = "comment";
common::dataStructures::VirtualOrganization vo = getVo();
ASSERT_NO_THROW(m_catalogue->createVirtualOrganization(m_admin,vo));
......@@ -14685,7 +14679,7 @@ TEST_P(cta_catalogue_CatalogueTest, modifyVirtualOrganization) {
ASSERT_EQ(newVoName,voFront.name);
}
 
TEST_P(cta_catalogue_CatalogueTest, modifyVirtualOrganizationDoesNotExists) {
TEST_P(cta_catalogue_CatalogueTest, modifyVirtualOrganizationNameVoDoesNotExists) {
using namespace cta;
ASSERT_THROW(m_catalogue->modifyVirtualOrganizationName(m_admin,"DOES_NOT_EXIST","NEW_NAME"),cta::exception::UserError);
......@@ -14694,27 +14688,23 @@ TEST_P(cta_catalogue_CatalogueTest, modifyVirtualOrganizationDoesNotExists) {
TEST_P(cta_catalogue_CatalogueTest, modifyVirtualOrganizationNameThatAlreadyExists) {
using namespace cta;
std::string voName = "vo";
std::string vo2Name = "vo2";
common::dataStructures::VirtualOrganization vo = getVo();
common::dataStructures::VirtualOrganization vo;
vo.name = voName;
vo.comment = "comment";
std::string vo2Name = "vo2";
std::string vo1Name = vo.name;
ASSERT_NO_THROW(m_catalogue->createVirtualOrganization(m_admin,vo));
vo.name = vo2Name;
ASSERT_NO_THROW(m_catalogue->createVirtualOrganization(m_admin,vo));
ASSERT_THROW(m_catalogue->modifyVirtualOrganizationName(m_admin,voName,vo2Name),cta::exception::UserError);
ASSERT_THROW(m_catalogue->modifyVirtualOrganizationName(m_admin,vo1Name,vo2Name),cta::exception::UserError);
}
 
TEST_P(cta_catalogue_CatalogueTest, modifyVirtualOrganizationComment) {
using namespace cta;
common::dataStructures::VirtualOrganization vo;
vo.name = "vo";
vo.comment = "comment";
common::dataStructures::VirtualOrganization vo = getVo();
ASSERT_NO_THROW(m_catalogue->createVirtualOrganization(m_admin,vo));
......@@ -14730,6 +14720,42 @@ TEST_P(cta_catalogue_CatalogueTest, modifyVirtualOrganizationComment) {
ASSERT_THROW(m_catalogue->modifyVirtualOrganizationComment(m_admin,"DOES not exists","COMMENT_DOES_NOT_EXIST"),cta::exception::UserError);
}
 
TEST_P(cta_catalogue_CatalogueTest, modifyVirtualOrganizationMaxDrivesAllowedForRead) {
using namespace cta;
common::dataStructures::VirtualOrganization vo = getVo();
ASSERT_NO_THROW(m_catalogue->createVirtualOrganization(m_admin,vo));
uint64_t newMaxDrivesAllowedForRead = 42;
ASSERT_NO_THROW(m_catalogue->modifyVirtualOrganizationMaxDrivesAllowedForRead(m_admin,vo.name,newMaxDrivesAllowedForRead));
auto vos = m_catalogue->getVirtualOrganizations();
auto &frontVo = vos.front();
ASSERT_EQ(newMaxDrivesAllowedForRead,frontVo.maxDrivesAllowedForRead);
ASSERT_THROW(m_catalogue->modifyVirtualOrganizationMaxDrivesAllowedForRead(m_admin,"DOES not exists",newMaxDrivesAllowedForRead),cta::exception::UserError);
}
TEST_P(cta_catalogue_CatalogueTest, modifyVirtualOrganizationMaxDrivesAllowedForWrite) {
using namespace cta;
common::dataStructures::VirtualOrganization vo = getVo();
ASSERT_NO_THROW(m_catalogue->createVirtualOrganization(m_admin,vo));
uint64_t newMaxDrivesAllowedForWrite = 42;
ASSERT_NO_THROW(m_catalogue->modifyVirtualOrganizationMaxDrivesAllowedForWrite(m_admin,vo.name,newMaxDrivesAllowedForWrite));
auto vos = m_catalogue->getVirtualOrganizations();
auto &frontVo = vos.front();
ASSERT_EQ(newMaxDrivesAllowedForWrite,frontVo.maxDrivesAllowedForWrite);
ASSERT_THROW(m_catalogue->modifyVirtualOrganizationMaxDrivesAllowedForWrite(m_admin,"DOES not exists",newMaxDrivesAllowedForWrite),cta::exception::UserError);
}
TEST_P(cta_catalogue_CatalogueTest, updateDiskFileId) {
using namespace cta;
 
......
......@@ -107,6 +107,8 @@ public:
void deleteVirtualOrganization(const std::string &voName) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
std::list<common::dataStructures::VirtualOrganization> getVirtualOrganizations() const override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void modifyVirtualOrganizationName(const common::dataStructures::SecurityIdentity &admin, const std::string &currentVoName, const std::string &newVoName) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void modifyVirtualOrganizationMaxDrivesAllowedForRead(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t maxDrivesAllowedForRead) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void modifyVirtualOrganizationMaxDrivesAllowedForWrite(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t maxDrivesAllowedForWrite) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void modifyVirtualOrganizationComment(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, 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& storageClassName, const uint32_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& storageClassName, const uint32_t copyNb, const std::string& tapePoolName) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
......
......@@ -325,6 +325,9 @@ void RdbmsCatalogue::createVirtualOrganization(const common::dataStructures::Sec
"INSERT INTO VIRTUAL_ORGANIZATION("
"VIRTUAL_ORGANIZATION_ID,"
"VIRTUAL_ORGANIZATION_NAME,"
"MAX_DRIVES_ALLOWED_FOR_READ,"
"MAX_DRIVES_ALLOWED_FOR_WRITE,"
"USER_COMMENT,"
......@@ -338,6 +341,8 @@ void RdbmsCatalogue::createVirtualOrganization(const common::dataStructures::Sec
"VALUES("
":VIRTUAL_ORGANIZATION_ID,"
":VIRTUAL_ORGANIZATION_NAME,"
":MAX_DRIVES_ALLOWED_FOR_READ,"
":MAX_DRIVES_ALLOWED_FOR_WRITE,"
":USER_COMMENT,"
......@@ -352,9 +357,12 @@ void RdbmsCatalogue::createVirtualOrganization(const common::dataStructures::Sec
stmt.bindUint64(":VIRTUAL_ORGANIZATION_ID", virtualOrganizationId);
stmt.bindString(":VIRTUAL_ORGANIZATION_NAME", vo.name);
stmt.bindUint64(":MAX_DRIVES_ALLOWED_FOR_READ",vo.maxDrivesAllowedForRead);
stmt.bindUint64(":MAX_DRIVES_ALLOWED_FOR_WRITE",vo.maxDrivesAllowedForWrite);
stmt.bindString(":USER_COMMENT", vo.comment);
stmt.bindString(":CREATION_LOG_USER_NAME", admin.username);
stmt.bindString(":CREATION_LOG_HOST_NAME", admin.host);
stmt.bindUint64(":CREATION_LOG_TIME", now);
......@@ -422,6 +430,9 @@ std::list<common::dataStructures::VirtualOrganization> RdbmsCatalogue::getVirtua
"SELECT "
"VIRTUAL_ORGANIZATION_NAME AS VIRTUAL_ORGANIZATION_NAME,"
"MAX_DRIVES_ALLOWED_FOR_READ AS MAX_DRIVES_ALLOWED_FOR_READ,"
"MAX_DRIVES_ALLOWED_FOR_WRITE AS MAX_DRIVES_ALLOWED_FOR_WRITE,"
"USER_COMMENT AS USER_COMMENT,"
"CREATION_LOG_USER_NAME AS CREATION_LOG_USER_NAME,"
......@@ -443,6 +454,8 @@ std::list<common::dataStructures::VirtualOrganization> RdbmsCatalogue::getVirtua
virtualOrganization.name = rset.columnString("VIRTUAL_ORGANIZATION_NAME");
virtualOrganization.maxDrivesAllowedForRead = rset.columnUint64("MAX_DRIVES_ALLOWED_FOR_READ");
virtualOrganization.maxDrivesAllowedForWrite = rset.columnUint64("MAX_DRIVES_ALLOWED_FOR_WRITE");
virtualOrganization.comment = rset.columnString("USER_COMMENT");
virtualOrganization.creationLog.username = rset.columnString("CREATION_LOG_USER_NAME");
virtualOrganization.creationLog.host = rset.columnString("CREATION_LOG_HOST_NAME");
......@@ -503,6 +516,72 @@ void RdbmsCatalogue::modifyVirtualOrganizationName(const common::dataStructures:
}
}
void RdbmsCatalogue::modifyVirtualOrganizationMaxDrivesAllowedForRead(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t maxDrivesAllowedForRead){
try {
const time_t now = time(nullptr);
const char *const sql =
"UPDATE VIRTUAL_ORGANIZATION SET "
"MAX_DRIVES_ALLOWED_FOR_READ = :MAX_DRIVES_ALLOWED_FOR_READ,"
"LAST_UPDATE_USER_NAME = :LAST_UPDATE_USER_NAME,"
"LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME,"
"LAST_UPDATE_TIME = :LAST_UPDATE_TIME "
"WHERE "
"VIRTUAL_ORGANIZATION_NAME = :VIRTUAL_ORGANIZATION_NAME";
auto conn = m_connPool.getConn();
auto stmt = conn.createStmt(sql);
stmt.bindUint64(":MAX_DRIVES_ALLOWED_FOR_READ", maxDrivesAllowedForRead);
stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username);
stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host);
stmt.bindUint64(":LAST_UPDATE_TIME", now);
stmt.bindString(":VIRTUAL_ORGANIZATION_NAME", voName);
stmt.executeNonQuery();
if(0 == stmt.getNbAffectedRows()) {
throw exception::UserError(std::string("Cannot modify virtual organization : ") + voName +
" because it does not exist");
}
} catch(exception::UserError &) {
throw;
} catch(exception::Exception &ex) {
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
}
void RdbmsCatalogue::modifyVirtualOrganizationMaxDrivesAllowedForWrite(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t maxDrivesAllowedForWrite){
try {
const time_t now = time(nullptr);
const char *const sql =
"UPDATE VIRTUAL_ORGANIZATION SET "
"MAX_DRIVES_ALLOWED_FOR_WRITE = :MAX_DRIVES_ALLOWED_FOR_WRITE,"
"LAST_UPDATE_USER_NAME = :LAST_UPDATE_USER_NAME,"
"LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME,"
"LAST_UPDATE_TIME = :LAST_UPDATE_TIME "
"WHERE "
"VIRTUAL_ORGANIZATION_NAME = :VIRTUAL_ORGANIZATION_NAME";
auto conn = m_connPool.getConn();
auto stmt = conn.createStmt(sql);
stmt.bindUint64(":MAX_DRIVES_ALLOWED_FOR_WRITE", maxDrivesAllowedForWrite);
stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username);
stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host);
stmt.bindUint64(":LAST_UPDATE_TIME", now);
stmt.bindString(":VIRTUAL_ORGANIZATION_NAME", voName);
stmt.executeNonQuery();
if(0 == stmt.getNbAffectedRows()) {
throw exception::UserError(std::string("Cannot modify virtual organization : ") + voName +
" because it does not exist");
}
} catch(exception::UserError &) {
throw;
} catch(exception::Exception &ex) {
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
}
void RdbmsCatalogue::modifyVirtualOrganizationComment(const common::dataStructures::SecurityIdentity& admin, const std::string& voName, const std::string& comment) {
try {
const time_t now = time(nullptr);
......
......@@ -245,6 +245,21 @@ public:
*/
void modifyVirtualOrganizationName(const common::dataStructures::SecurityIdentity &admin, const std::string &currentVoName, const std::string &newVoName) override;
/**
* Modifies the max number of allocated drives for read for the specified Virtual Organization
*
* @param voName the VO name
* @param maxDrivesAllowedForRead the new max number of allocated drives for read for the specified Virtual Organization
*/
void modifyVirtualOrganizationMaxDrivesAllowedForRead(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t maxDrivesAllowedForRead) override;
/**
* Modifies the max number of allocated drives for write for the specified Virtual Organization
*
* @param voName the VO name
* @param maxDrivesAllowedForRead the new max number of allocated drives for write for the specified Virtual Organization
*/
void modifyVirtualOrganizationMaxDrivesAllowedForWrite(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t maxDrivesAllowedForWrite) override;
/**
* Modifies the comment of the specified Virtual Organization
*
......
......@@ -37,6 +37,8 @@ CREATE TABLE DISK_SYSTEM(
CREATE TABLE VIRTUAL_ORGANIZATION(
VIRTUAL_ORGANIZATION_ID UINT64TYPE CONSTRAINT VIRTUAL_ORGANIZATION_VOI_NN NOT NULL,
VIRTUAL_ORGANIZATION_NAME VARCHAR(100) CONSTRAINT VIRTUAL_ORGANIZATION_VON_NN NOT NULL,
MAX_DRIVES_ALLOWED_FOR_READ UINT64TYPE,
MAX_DRIVES_ALLOWED_FOR_WRITE UINT64TYPE,
USER_COMMENT VARCHAR(1000) CONSTRAINT VIRTUAL_ORGANIZATION_UC_NN NOT NULL,
CREATION_LOG_USER_NAME VARCHAR(100) CONSTRAINT VIRTUAL_ORGANIZATION_CLUN_NN NOT NULL,
CREATION_LOG_HOST_NAME VARCHAR(100) CONSTRAINT VIRTUAL_ORGANIZATION_CLHN_NN NOT NULL,
......
......@@ -34,6 +34,14 @@ struct VirtualOrganization {
* The comment.
*/
std::string comment;
/**
* Max number of drives allocated for writing per VO
*/
uint64_t maxDrivesAllowedForWrite;
/**
* Maximum number of drives allocated for reading per VO
*/
uint64_t maxDrivesAllowedForRead;
/**
* The creation log.
*/
......
Markdown is supported
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