Commit f02ae29a authored by Cedric Caffy's avatar Cedric Caffy
Browse files

[cta-admin] Added the readmaxdrives and writemaxdrives to cta-admin virtual organization add,ch,ls

parent 56e1abcf
......@@ -72,8 +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,
READ_MAX_DRIVES BIGINT UNSIGNED,
WRITE_MAX_DRIVES 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,8 +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),
READ_MAX_DRIVES NUMERIC(20, 0),
WRITE_MAX_DRIVES 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,8 +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),
READ_MAX_DRIVES NUMERIC(20, 0),
WRITE_MAX_DRIVES 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,8 +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,
READ_MAX_DRIVES INTEGER,
WRITE_MAX_DRIVES 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,8 +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),"
" READ_MAX_DRIVES NUMERIC(20, 0),"
" WRITE_MAX_DRIVES 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,"
......@@ -7486,8 +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,"
" READ_MAX_DRIVES BIGINT UNSIGNED,"
" WRITE_MAX_DRIVES 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,"
......@@ -7895,8 +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,"
" READ_MAX_DRIVES INTEGER,"
" WRITE_MAX_DRIVES 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,"
......@@ -8330,8 +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),"
" READ_MAX_DRIVES NUMERIC(20, 0),"
" WRITE_MAX_DRIVES 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,"
......
......@@ -301,17 +301,17 @@ public:
* 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
* @param readMaxDrives 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;
virtual void modifyVirtualOrganizationReadMaxDrives(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t readMaxDrives) = 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
* @param writeMaxDrives 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;
virtual void modifyVirtualOrganizationWriteMaxDrives(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t writeMaxDrives) = 0;
/**
* Modifies the comment of the specified Virtual Organization
......
......@@ -132,12 +132,12 @@ 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 modifyVirtualOrganizationReadMaxDrives(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t maxDrivesAllowedForRead) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyVirtualOrganizationReadMaxDrives(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 modifyVirtualOrganizationWriteMaxDrives(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t maxDrivesAllowedForWrite) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyVirtualOrganizationWriteMaxDrives(admin,voName,maxDrivesAllowedForWrite);}, m_maxTriesToConnect);
}
......
......@@ -75,8 +75,8 @@ namespace {
common::dataStructures::VirtualOrganization vo;
vo.name = "vo";
vo.comment = "Creation of virtual organization vo";
vo.maxDrivesAllowedForRead = 1;
vo.maxDrivesAllowedForWrite = 1;
vo.readMaxDrives = 1;
vo.writeMaxDrives = 1;
return vo;
}
 
......@@ -14648,8 +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.readMaxDrives,voRetrieved.readMaxDrives);
ASSERT_EQ(vo.writeMaxDrives,voRetrieved.writeMaxDrives);
ASSERT_EQ(vo.comment,voRetrieved.comment);
ASSERT_EQ(m_admin.host,voRetrieved.creationLog.host);
ASSERT_EQ(m_admin.username,voRetrieved.creationLog.username);
......@@ -14728,14 +14728,14 @@ TEST_P(cta_catalogue_CatalogueTest, modifyVirtualOrganizationMaxDrivesAllowedFor
ASSERT_NO_THROW(m_catalogue->createVirtualOrganization(m_admin,vo));
 
uint64_t newMaxDrivesAllowedForRead = 42;
ASSERT_NO_THROW(m_catalogue->modifyVirtualOrganizationMaxDrivesAllowedForRead(m_admin,vo.name,newMaxDrivesAllowedForRead));
ASSERT_NO_THROW(m_catalogue->modifyVirtualOrganizationReadMaxDrives(m_admin,vo.name,newMaxDrivesAllowedForRead));
auto vos = m_catalogue->getVirtualOrganizations();
auto &frontVo = vos.front();
ASSERT_EQ(newMaxDrivesAllowedForRead,frontVo.maxDrivesAllowedForRead);
ASSERT_EQ(newMaxDrivesAllowedForRead,frontVo.readMaxDrives);
ASSERT_THROW(m_catalogue->modifyVirtualOrganizationMaxDrivesAllowedForRead(m_admin,"DOES not exists",newMaxDrivesAllowedForRead),cta::exception::UserError);
ASSERT_THROW(m_catalogue->modifyVirtualOrganizationReadMaxDrives(m_admin,"DOES not exists",newMaxDrivesAllowedForRead),cta::exception::UserError);
}
 
TEST_P(cta_catalogue_CatalogueTest, modifyVirtualOrganizationMaxDrivesAllowedForWrite) {
......@@ -14746,14 +14746,14 @@ TEST_P(cta_catalogue_CatalogueTest, modifyVirtualOrganizationMaxDrivesAllowedFor
ASSERT_NO_THROW(m_catalogue->createVirtualOrganization(m_admin,vo));
uint64_t newMaxDrivesAllowedForWrite = 42;
ASSERT_NO_THROW(m_catalogue->modifyVirtualOrganizationMaxDrivesAllowedForWrite(m_admin,vo.name,newMaxDrivesAllowedForWrite));
ASSERT_NO_THROW(m_catalogue->modifyVirtualOrganizationWriteMaxDrives(m_admin,vo.name,newMaxDrivesAllowedForWrite));
auto vos = m_catalogue->getVirtualOrganizations();
auto &frontVo = vos.front();
ASSERT_EQ(newMaxDrivesAllowedForWrite,frontVo.maxDrivesAllowedForWrite);
ASSERT_EQ(newMaxDrivesAllowedForWrite,frontVo.writeMaxDrives);
ASSERT_THROW(m_catalogue->modifyVirtualOrganizationMaxDrivesAllowedForWrite(m_admin,"DOES not exists",newMaxDrivesAllowedForWrite),cta::exception::UserError);
ASSERT_THROW(m_catalogue->modifyVirtualOrganizationWriteMaxDrives(m_admin,"DOES not exists",newMaxDrivesAllowedForWrite),cta::exception::UserError);
}
 
TEST_P(cta_catalogue_CatalogueTest, updateDiskFileId) {
......
......@@ -107,8 +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 modifyVirtualOrganizationReadMaxDrives(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 modifyVirtualOrganizationWriteMaxDrives(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"); }
......
......@@ -326,8 +326,8 @@ void RdbmsCatalogue::createVirtualOrganization(const common::dataStructures::Sec
"VIRTUAL_ORGANIZATION_ID,"
"VIRTUAL_ORGANIZATION_NAME,"
"MAX_DRIVES_ALLOWED_FOR_READ,"
"MAX_DRIVES_ALLOWED_FOR_WRITE,"
"READ_MAX_DRIVES,"
"WRITE_MAX_DRIVES,"
"USER_COMMENT,"
......@@ -341,8 +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,"
":READ_MAX_DRIVES,"
":WRITE_MAX_DRIVES,"
":USER_COMMENT,"
......@@ -358,8 +358,8 @@ 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.bindUint64(":READ_MAX_DRIVES",vo.readMaxDrives);
stmt.bindUint64(":WRITE_MAX_DRIVES",vo.writeMaxDrives);
stmt.bindString(":USER_COMMENT", vo.comment);
......@@ -430,8 +430,8 @@ 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,"
"READ_MAX_DRIVES AS READ_MAX_DRIVES,"
"WRITE_MAX_DRIVES AS WRITE_MAX_DRIVES,"
"USER_COMMENT AS USER_COMMENT,"
......@@ -454,8 +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.readMaxDrives = rset.columnUint64("READ_MAX_DRIVES");
virtualOrganization.writeMaxDrives = rset.columnUint64("WRITE_MAX_DRIVES");
virtualOrganization.comment = rset.columnString("USER_COMMENT");
virtualOrganization.creationLog.username = rset.columnString("CREATION_LOG_USER_NAME");
virtualOrganization.creationLog.host = rset.columnString("CREATION_LOG_HOST_NAME");
......@@ -516,12 +516,12 @@ void RdbmsCatalogue::modifyVirtualOrganizationName(const common::dataStructures:
}
}
void RdbmsCatalogue::modifyVirtualOrganizationMaxDrivesAllowedForRead(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t maxDrivesAllowedForRead){
void RdbmsCatalogue::modifyVirtualOrganizationReadMaxDrives(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,"
"READ_MAX_DRIVES = :READ_MAX_DRIVES,"
"LAST_UPDATE_USER_NAME = :LAST_UPDATE_USER_NAME,"
"LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME,"
"LAST_UPDATE_TIME = :LAST_UPDATE_TIME "
......@@ -530,7 +530,7 @@ void RdbmsCatalogue::modifyVirtualOrganizationMaxDrivesAllowedForRead(const comm
auto conn = m_connPool.getConn();
auto stmt = conn.createStmt(sql);
stmt.bindUint64(":MAX_DRIVES_ALLOWED_FOR_READ", maxDrivesAllowedForRead);
stmt.bindUint64(":READ_MAX_DRIVES", maxDrivesAllowedForRead);
stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username);
stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host);
stmt.bindUint64(":LAST_UPDATE_TIME", now);
......@@ -549,12 +549,12 @@ void RdbmsCatalogue::modifyVirtualOrganizationMaxDrivesAllowedForRead(const comm
}
}
void RdbmsCatalogue::modifyVirtualOrganizationMaxDrivesAllowedForWrite(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t maxDrivesAllowedForWrite){
void RdbmsCatalogue::modifyVirtualOrganizationWriteMaxDrives(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,"
"WRITE_MAX_DRIVES = :WRITE_MAX_DRIVES,"
"LAST_UPDATE_USER_NAME = :LAST_UPDATE_USER_NAME,"
"LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME,"
"LAST_UPDATE_TIME = :LAST_UPDATE_TIME "
......@@ -563,7 +563,7 @@ void RdbmsCatalogue::modifyVirtualOrganizationMaxDrivesAllowedForWrite(const com
auto conn = m_connPool.getConn();
auto stmt = conn.createStmt(sql);
stmt.bindUint64(":MAX_DRIVES_ALLOWED_FOR_WRITE", maxDrivesAllowedForWrite);
stmt.bindUint64(":WRITE_MAX_DRIVES", maxDrivesAllowedForWrite);
stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username);
stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host);
stmt.bindUint64(":LAST_UPDATE_TIME", now);
......
......@@ -249,17 +249,17 @@ public:
* 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
* @param readMaxDrives 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;
void modifyVirtualOrganizationReadMaxDrives(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t readMaxDrives) 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
* @param writeMaxDrives 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;
void modifyVirtualOrganizationWriteMaxDrives(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t writeMaxDrives) override;
/**
* Modifies the comment of the specified Virtual Organization
*
......
......@@ -37,8 +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,
READ_MAX_DRIVES UINT64TYPE,
WRITE_MAX_DRIVES 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,
......
......@@ -290,6 +290,8 @@ const std::map<std::string, OptionUInt64::Key> uint64Options = {
{ "--refreshinterval", OptionUInt64::REFRESH_INTERVAL },
{ "--targetedfreespace", OptionUInt64::TARGETED_FREE_SPACE },
{ "--sleeptime", OptionUInt64::SLEEP_TIME },
{ "--readmaxdrives", OptionUInt64::READ_MAX_DRIVES },
{ "--writemaxdrives", OptionUInt64::WRITE_MAX_DRIVES },
};
......@@ -396,7 +398,15 @@ const std::map<AdminCmd::Cmd, CmdHelp> cmdHelp = {
" If the targeted free space is reach, the queue will sleep during this amount of seconds."
"\n\n"
}},
{ AdminCmd::CMD_VIRTUALORGANIZATION, { "virtualorganization", "vo", { "add", "ch", "rm", "ls" } }},
{ AdminCmd::CMD_VIRTUALORGANIZATION, { "virtualorganization", "vo", { "add", "ch", "rm", "ls" },
"\n This command allows to manage virtual organizations.\n"
" Add a virtual organization by using the \"add\" subcommand:\n"
" * Specify the name (--vo) of the virtual organization. It must be unique.\n"
" * Specify the maximum number of drives the virtual organization is allowed to use for writing with the --writemaxdrives parameter\n"
" * Specify the maximum number of drives the virtual organization is allowed to use for reading with the --readmaxdrives parameter\n"
" * Specify the comment (--comment) associated to the virtual organization"
"\n\n"
}},
{ AdminCmd::CMD_VERSION, { "version", "v", { } }},
{ AdminCmd::CMD_SCHEDULINGINFOS, { "schedulinginfo", "si", { "ls" } }},
{ AdminCmd::CMD_RECYCLETAPEFILE, { "recycletf", "rtf", { "ls" },
......@@ -474,6 +484,8 @@ const Option opt_sleep_time { Option::OPT_UINT, "--sleeptime",
const Option opt_reason { Option::OPT_STR, "--reason", "-r", " <reason_status_change>" };
const Option opt_no_recall { Option::OPT_FLAG, "--no-recall", "-nr", "" };
const Option opt_object_id { Option::OPT_STR, "--objectid", "-o", " <objectId>" };
const Option opt_read_max_drives { Option::OPT_UINT, "--readmaxdrives", "-rmd", " <read_max_drives>" };
const Option opt_write_max_drives { Option::OPT_UINT, "--writemaxdrives", "-wmd", " <write_max_drives>" };
const Option opt_state { Option::OPT_STR, "--state", "-s", std::string(" <\"") + Tape::stateToString(Tape::ACTIVE) +"\"" + " or \"" + Tape::stateToString(Tape::DISABLED) + "\" or \"" + Tape::stateToString(Tape::BROKEN) + "\">" };
......@@ -594,9 +606,9 @@ const std::map<cmd_key_t, cmd_val_t> cmdOptions = {
{{ AdminCmd::CMD_DISKSYSTEM, AdminCmd::SUBCMD_RM }, { opt_disksystem }},
{{ AdminCmd::CMD_DISKSYSTEM, AdminCmd::SUBCMD_LS }, { }},
{{ AdminCmd::CMD_VIRTUALORGANIZATION, AdminCmd::SUBCMD_ADD },
{ opt_vo, opt_comment }},
{ opt_vo, opt_read_max_drives, opt_write_max_drives, opt_comment }},
{{ AdminCmd::CMD_VIRTUALORGANIZATION, AdminCmd::SUBCMD_CH },
{ opt_vo, opt_comment }},
{ opt_vo, opt_comment.optional(), opt_read_max_drives.optional(), opt_write_max_drives.optional() }},
{{ AdminCmd::CMD_VIRTUALORGANIZATION, AdminCmd::SUBCMD_RM },
{ opt_vo }},
{{ AdminCmd::CMD_VIRTUALORGANIZATION, AdminCmd::SUBCMD_LS },
......
......@@ -991,6 +991,8 @@ void TextFormatter::printVirtualOrganizationLsHeader(){
push_back("HEADER");
push_back(
"name",
"read max drives",
"write max drives",
"c.user",
"c.host",
"c.time",
......@@ -1004,6 +1006,8 @@ void TextFormatter::printVirtualOrganizationLsHeader(){
void TextFormatter::print(const VirtualOrganizationLsItem& vols_item){
push_back(
vols_item.name(),
vols_item.read_max_drives(),
vols_item.write_max_drives(),
vols_item.creation_log().username(),
vols_item.creation_log().host(),
timeToStr(vols_item.creation_log().time()),
......
......@@ -35,13 +35,13 @@ struct VirtualOrganization {
*/
std::string comment;
/**
* Max number of drives allocated for writing per VO
* Maximum number of drives allocated for reading per VO
*/
uint64_t maxDrivesAllowedForWrite;
uint64_t readMaxDrives;
/**
* Maximum number of drives allocated for reading per VO
* Max number of drives allocated for writing per VO
*/
uint64_t maxDrivesAllowedForRead;
uint64_t writeMaxDrives;
/**
* The creation log.
*/
......
......@@ -108,6 +108,8 @@ kubectl --namespace ${NAMESPACE} exec ctacli -- cta-admin --json version | jq
kubectl --namespace ${NAMESPACE} exec ctacli -- cta-admin virtualorganization add \
--vo vo \
--readmaxdrives 1 \
--writemaxdrives 1 \
--comment "vo"
kubectl --namespace ${NAMESPACE} exec ctacli -- cta-admin tapepool add \
--name ctasystest \
......
......@@ -76,6 +76,8 @@ int VirtualOrganizationLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *strea
auto vo_item = record.mutable_vols_item();
vo_item->set_name(vo.name);
vo_item->set_read_max_drives(vo.readMaxDrives);
vo_item->set_write_max_drives(vo.writeMaxDrives);
vo_item->mutable_creation_log()->set_username(vo.creationLog.username);
vo_item->mutable_creation_log()->set_host(vo.creationLog.host);
vo_item->mutable_creation_log()->set_time(vo.creationLog.time);
......
......@@ -2039,10 +2039,14 @@ void RequestMessage::processVirtualOrganization_Add(cta::xrd::Response &response
using namespace cta::admin;
const auto &name = getRequired(OptionString::VO);
const auto &readMaxDrives = getRequired(OptionUInt64::READ_MAX_DRIVES);
const auto &writeMaxDrives = getRequired(OptionUInt64::WRITE_MAX_DRIVES);
const auto &comment = getRequired(OptionString::COMMENT);
cta::common::dataStructures::VirtualOrganization vo;
vo.name = name;
vo.readMaxDrives = readMaxDrives;
vo.writeMaxDrives = writeMaxDrives;
vo.comment = comment;
m_catalogue.createVirtualOrganization(m_cliIdentity,vo);
......@@ -2054,9 +2058,18 @@ void RequestMessage::processVirtualOrganization_Ch(cta::xrd::Response &response)
using namespace cta::admin;
const auto &name = getRequired(OptionString::VO);
const auto &comment = getRequired(OptionString::COMMENT);
const auto readMaxDrives = getOptional(OptionUInt64::READ_MAX_DRIVES);
const auto writeMaxDrives = getOptional(OptionUInt64::WRITE_MAX_DRIVES);
const auto comment = getOptional(OptionString::COMMENT);
if(comment)
m_catalogue.modifyVirtualOrganizationComment(m_cliIdentity,name,comment.value());
if(readMaxDrives)
m_catalogue.modifyVirtualOrganizationReadMaxDrives(m_cliIdentity,name,readMaxDrives.value());
m_catalogue.modifyVirtualOrganizationComment(m_cliIdentity,name,comment);
if(writeMaxDrives)
m_catalogue.modifyVirtualOrganizationWriteMaxDrives(m_cliIdentity,name,writeMaxDrives.value());
response.set_type(cta::xrd::Response::RSP_SUCCESS);
}
......
Subproject commit 2e446b975ee7b02b6294933be3a3de05c926d558
Subproject commit 511cc4ae58d813d94bc531302f4f3ae0af172115
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