Commit 3514fa6f authored by Victor Kotlyar's avatar Victor Kotlyar
Browse files

cta/CTA#535: "Read only" and "from CASTOR" flags in the catalogue for

tapes

Add read-only tape flag support in the catalogue for the TAPE table.
Add RdbmsCatalogue::setTapeReadOnly method to modify this flag with
  "cta-admin tape ch" command.
Add RdbmsCatalogue::setTapeReadOnlyOnError to set this flag from taped.
Add support for rdonly flag listing for "cta-admin tape ls" and
  "cta-admin sq" command.
parent 3640b55a
......@@ -138,7 +138,7 @@ public:
/**
* Returns the list of tapes that can be written to by a tape drive in the
* specified logical library, in other words tapes that are labelled, not
* disabled, not full and are in the specified logical library.
* disabled, not full, not read-only and are in the specified logical library.
*
* @param logicalLibraryName The name of the logical library.
* @return The list of tapes for writing.
......@@ -296,6 +296,7 @@ public:
const uint64_t capacityInBytes,
const bool disabled,
const bool full,
const bool readOnly,
const std::string &comment) = 0;
virtual void deleteTape(const std::string &vid) = 0;
......@@ -360,6 +361,26 @@ public:
* @param fullValue Set to true if the tape is full.
*/
virtual void setTapeFull(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const bool fullValue) = 0;
/**
* Sets the read-only status of the specified tape.
*
* Please note that this method is to be called by the CTA front-end in
* response to a command from the CTA command-line interface (CLI).
*
* @param admin The administrator.
* @param vid The volume identifier of the tape to be marked as read-only.
* @param readOnlyValue Set to true if the tape is read-only.
*/
virtual void setTapeReadOnly(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const bool readOnlyValue) = 0;
/**
* This method notifies the CTA catalogue to set the specified tape read-only
* in case of a problem.
*
* @param vid The volume identifier of the tape.
*/
virtual void setTapeReadOnlyOnError(const std::string &vid) = 0;
virtual void setTapeDisabled(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const bool disabledValue) = 0;
virtual void modifyTapeComment(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const std::string &comment) = 0;
......
......@@ -209,8 +209,8 @@ public:
return retryOnLostConnection(m_log, [&]{return m_catalogue->setLogicalLibraryDisabled(admin, name, disabledValue);}, m_maxTriesToConnect);
}
void createTape(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const std::string &mediaType, const std::string &vendor, const std::string &logicalLibraryName, const std::string &tapePoolName, const uint64_t capacityInBytes, const bool disabled, const bool full, const std::string &comment) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->createTape(admin, vid, mediaType, vendor, logicalLibraryName, tapePoolName, capacityInBytes, disabled, full, comment);}, m_maxTriesToConnect);
void createTape(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const std::string &mediaType, const std::string &vendor, const std::string &logicalLibraryName, const std::string &tapePoolName, const uint64_t capacityInBytes, const bool disabled, const bool full, const bool readOnly, const std::string &comment) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->createTape(admin, vid, mediaType, vendor, logicalLibraryName, tapePoolName, capacityInBytes, disabled, full, readOnly, comment);}, m_maxTriesToConnect);
}
void deleteTape(const std::string &vid) override {
......@@ -260,6 +260,14 @@ public:
void setTapeFull(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const bool fullValue) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->setTapeFull(admin, vid, fullValue);}, m_maxTriesToConnect);
}
void setTapeReadOnly(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const bool readOnlyValue) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->setTapeReadOnly(admin, vid, readOnlyValue);}, m_maxTriesToConnect);
}
void setTapeReadOnlyOnError(const std::string &vid) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->setTapeReadOnlyOnError(vid);}, m_maxTriesToConnect);
}
void setTapeDisabled(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const bool disabledValue) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->setTapeDisabled(admin, vid, disabledValue);}, m_maxTriesToConnect);
......
This diff is collapsed.
......@@ -42,7 +42,7 @@ public:
void createRequesterGroupMountRule(const common::dataStructures::SecurityIdentity& admin, const std::string& mountPolicyName, const std::string& diskInstanceName, const std::string& requesterGroupName, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void createRequesterMountRule(const common::dataStructures::SecurityIdentity& admin, const std::string& mountPolicyName, const std::string& diskInstance, const std::string& requesterName, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
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 &mediaType, const std::string &vendor, 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 createTape(const common::dataStructures::SecurityIdentity& admin, const std::string& vid, const std::string &mediaType, const std::string &vendor, const std::string& logicalLibraryName, const std::string& tapePoolName, const uint64_t capacityInBytes, const bool disabled, const bool full, const bool readOnly, 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 std::string & vo, const uint64_t nbPartialTapes, const bool encryptionValue, const cta::optional<std::string> &supply, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void deleteActivitiesFairShareWeight(const common::dataStructures::SecurityIdentity& admin, const std::string& diskInstanceName, const std::string& acttivity) 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"); }
......@@ -114,6 +114,8 @@ public:
void reclaimTape(const common::dataStructures::SecurityIdentity& admin, const std::string& vid) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void setTapeDisabled(const common::dataStructures::SecurityIdentity& admin, const std::string& vid, const bool disabledValue) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void setTapeFull(const common::dataStructures::SecurityIdentity& admin, const std::string& vid, const bool fullValue) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void setTapeReadOnly(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const bool readOnlyValue) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void setTapeReadOnlyOnError(const std::string &vid) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void setTapePoolEncryption(const common::dataStructures::SecurityIdentity& admin, const std::string& name, const bool encryptionValue) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
bool tapeExists(const std::string& vid) const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void tapeLabelled(const std::string& vid, const std::string& drive) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
......
......@@ -156,6 +156,7 @@ common::dataStructures::Tape MysqlCatalogue::selectTapeForUpdate(rdbms::Conn &co
"LAST_FSEQ AS LAST_FSEQ,"
"IS_DISABLED AS IS_DISABLED,"
"IS_FULL AS IS_FULL,"
"IS_READ_ONLY AS IS_READ_ONLY,"
"LABEL_DRIVE AS LABEL_DRIVE,"
"LABEL_TIME AS LABEL_TIME,"
......@@ -198,6 +199,7 @@ common::dataStructures::Tape MysqlCatalogue::selectTapeForUpdate(rdbms::Conn &co
tape.lastFSeq = rset.columnUint64("LAST_FSEQ");
tape.disabled = rset.columnBool("IS_DISABLED");
tape.full = rset.columnBool("IS_FULL");
tape.readOnly = rset.columnBool("IS_READ_ONLY");
tape.labelLog = getTapeLogFromRset(rset, "LABEL_DRIVE", "LABEL_TIME");
tape.lastReadLog = getTapeLogFromRset(rset, "LAST_READ_DRIVE", "LAST_READ_TIME");
......
......@@ -220,6 +220,7 @@ common::dataStructures::Tape OracleCatalogue::selectTapeForUpdate(rdbms::Conn &c
"LAST_FSEQ AS LAST_FSEQ,"
"IS_DISABLED AS IS_DISABLED,"
"IS_FULL AS IS_FULL,"
"IS_READ_ONLY AS IS_READ_ONLY,"
"LABEL_DRIVE AS LABEL_DRIVE,"
"LABEL_TIME AS LABEL_TIME,"
......@@ -262,6 +263,7 @@ common::dataStructures::Tape OracleCatalogue::selectTapeForUpdate(rdbms::Conn &c
tape.lastFSeq = rset.columnUint64("LAST_FSEQ");
tape.disabled = rset.columnBool("IS_DISABLED");
tape.full = rset.columnBool("IS_FULL");
tape.readOnly = rset.columnBool("IS_READ_ONLY");
tape.labelLog = getTapeLogFromRset(rset, "LABEL_DRIVE", "LABEL_TIME");
tape.lastReadLog = getTapeLogFromRset(rset, "LAST_READ_DRIVE", "LAST_READ_TIME");
......
......@@ -211,6 +211,7 @@ common::dataStructures::Tape PostgresCatalogue::selectTapeForUpdate(rdbms::Conn
"LAST_FSEQ AS LAST_FSEQ,"
"IS_DISABLED AS IS_DISABLED,"
"IS_FULL AS IS_FULL,"
"IS_READ_ONLY AS IS_READ_ONLY,"
"LABEL_DRIVE AS LABEL_DRIVE,"
"LABEL_TIME AS LABEL_TIME,"
......@@ -253,6 +254,7 @@ common::dataStructures::Tape PostgresCatalogue::selectTapeForUpdate(rdbms::Conn
tape.lastFSeq = rset.columnUint64("LAST_FSEQ");
tape.disabled = rset.columnBool("IS_DISABLED");
tape.full = rset.columnBool("IS_FULL");
tape.readOnly = rset.columnBool("IS_READ_ONLY");
tape.labelLog = getTapeLogFromRset(rset, "LABEL_DRIVE", "LABEL_TIME");
tape.lastReadLog = getTapeLogFromRset(rset, "LAST_READ_DRIVE", "LAST_READ_TIME");
......
......@@ -1732,6 +1732,7 @@ void RdbmsCatalogue::createTape(
const uint64_t capacityInBytes,
const bool disabled,
const bool full,
const bool readOnly,
const std::string &comment) {
try {
if(vid.empty()) {
......@@ -1789,6 +1790,7 @@ void RdbmsCatalogue::createTape(
"LAST_FSEQ,"
"IS_DISABLED,"
"IS_FULL,"
"IS_READ_ONLY,"
"USER_COMMENT,"
......@@ -1810,6 +1812,7 @@ void RdbmsCatalogue::createTape(
":LAST_FSEQ,"
":IS_DISABLED,"
":IS_FULL,"
":IS_READ_ONLY,"
":USER_COMMENT,"
......@@ -1832,6 +1835,7 @@ void RdbmsCatalogue::createTape(
stmt.bindUint64(":LAST_FSEQ", 0);
stmt.bindBool(":IS_DISABLED", disabled);
stmt.bindBool(":IS_FULL", full);
stmt.bindBool(":IS_READ_ONLY", readOnly);
stmt.bindString(":USER_COMMENT", comment);
......@@ -1969,6 +1973,7 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(rdbms::Conn &co
"TAPE.LAST_FSEQ AS LAST_FSEQ,"
"TAPE.IS_DISABLED AS IS_DISABLED,"
"TAPE.IS_FULL AS IS_FULL,"
"TAPE.IS_READ_ONLY AS IS_READ_ONLY,"
"TAPE.LABEL_DRIVE AS LABEL_DRIVE,"
"TAPE.LABEL_TIME AS LABEL_TIME,"
......@@ -2001,7 +2006,8 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(rdbms::Conn &co
searchCriteria.vo ||
searchCriteria.capacityInBytes ||
searchCriteria.disabled ||
searchCriteria.full) {
searchCriteria.full ||
searchCriteria.readOnly) {
sql += " WHERE ";
}
......@@ -2051,6 +2057,11 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(rdbms::Conn &co
sql += " TAPE.IS_FULL = :IS_FULL";
addedAWhereConstraint = true;
}
if(searchCriteria.readOnly) {
if(addedAWhereConstraint) sql += " AND ";
sql += " TAPE.IS_READ_ONLY = :IS_READ_ONLY";
addedAWhereConstraint = true;
}
sql += " ORDER BY TAPE.VID";
......@@ -2065,6 +2076,7 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(rdbms::Conn &co
if(searchCriteria.capacityInBytes) stmt.bindUint64(":CAPACITY_IN_BYTES", searchCriteria.capacityInBytes.value());
if(searchCriteria.disabled) stmt.bindBool(":IS_DISABLED", searchCriteria.disabled.value());
if(searchCriteria.full) stmt.bindBool(":IS_FULL", searchCriteria.full.value());
if(searchCriteria.readOnly) stmt.bindBool(":IS_READ_ONLY", searchCriteria.readOnly.value());
auto rset = stmt.executeQuery();
while (rset.next()) {
......@@ -2082,6 +2094,7 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(rdbms::Conn &co
tape.lastFSeq = rset.columnUint64("LAST_FSEQ");
tape.disabled = rset.columnBool("IS_DISABLED");
tape.full = rset.columnBool("IS_FULL");
tape.readOnly = rset.columnBool("IS_READ_ONLY");
tape.labelLog = getTapeLogFromRset(rset, "LABEL_DRIVE", "LABEL_TIME");
tape.lastReadLog = getTapeLogFromRset(rset, "LAST_READ_DRIVE", "LAST_READ_TIME");
......@@ -2127,6 +2140,7 @@ common::dataStructures::VidToTapeMap RdbmsCatalogue::getTapesByVid(const std::se
"TAPE.LAST_FSEQ AS LAST_FSEQ,"
"TAPE.IS_DISABLED AS IS_DISABLED,"
"TAPE.IS_FULL AS IS_FULL,"
"TAPE.IS_READ_ONLY AS IS_READ_ONLY,"
"TAPE.LABEL_DRIVE AS LABEL_DRIVE,"
"TAPE.LABEL_TIME AS LABEL_TIME,"
......@@ -2194,6 +2208,7 @@ common::dataStructures::VidToTapeMap RdbmsCatalogue::getTapesByVid(const std::se
tape.lastFSeq = rset.columnUint64("LAST_FSEQ");
tape.disabled = rset.columnBool("IS_DISABLED");
tape.full = rset.columnBool("IS_FULL");
tape.readOnly = rset.columnBool("IS_READ_ONLY");
tape.labelLog = getTapeLogFromRset(rset, "LABEL_DRIVE", "LABEL_TIME");
tape.lastReadLog = getTapeLogFromRset(rset, "LAST_READ_DRIVE", "LAST_READ_TIME");
......@@ -2243,6 +2258,7 @@ common::dataStructures::VidToTapeMap RdbmsCatalogue::getAllTapes() const {
"TAPE.LAST_FSEQ AS LAST_FSEQ,"
"TAPE.IS_DISABLED AS IS_DISABLED,"
"TAPE.IS_FULL AS IS_FULL,"
"TAPE.IS_READ_ONLY AS IS_READ_ONLY,"
"TAPE.LABEL_DRIVE AS LABEL_DRIVE,"
"TAPE.LABEL_TIME AS LABEL_TIME,"
......@@ -2286,6 +2302,7 @@ common::dataStructures::VidToTapeMap RdbmsCatalogue::getAllTapes() const {
tape.lastFSeq = rset.columnUint64("LAST_FSEQ");
tape.disabled = rset.columnBool("IS_DISABLED");
tape.full = rset.columnBool("IS_FULL");
tape.readOnly = rset.columnBool("IS_READ_ONLY");
tape.labelLog = getTapeLogFromRset(rset, "LABEL_DRIVE", "LABEL_TIME");
tape.lastReadLog = getTapeLogFromRset(rset, "LAST_READ_DRIVE", "LAST_READ_TIME");
......@@ -2776,6 +2793,67 @@ void RdbmsCatalogue::noSpaceLeftOnTape(const std::string &vid) {
}
}
//------------------------------------------------------------------------------
// setTapeReadOnly
//------------------------------------------------------------------------------
void RdbmsCatalogue::setTapeReadOnly(const common::dataStructures::SecurityIdentity &admin, const std::string &vid,
const bool readOnlyValue) {
try {
const time_t now = time(nullptr);
const char *const sql =
"UPDATE TAPE SET "
"IS_READ_ONLY = :IS_READ_ONLY,"
"LAST_UPDATE_USER_NAME = :LAST_UPDATE_USER_NAME,"
"LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME,"
"LAST_UPDATE_TIME = :LAST_UPDATE_TIME "
"WHERE "
"VID = :VID";
auto conn = m_connPool.getConn();
auto stmt = conn.createStmt(sql);
stmt.bindBool(":IS_READ_ONLY", readOnlyValue);
stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username);
stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host);
stmt.bindUint64(":LAST_UPDATE_TIME", now);
stmt.bindString(":VID", vid);
stmt.executeNonQuery();
if(0 == stmt.getNbAffectedRows()) {
throw exception::UserError(std::string("Cannot modify tape ") + vid + " because it does not exist");
}
} catch(exception::UserError &) {
throw;
} catch(exception::Exception &ex) {
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
}
//------------------------------------------------------------------------------
// setTapeReadOnlyOnError
//------------------------------------------------------------------------------
void RdbmsCatalogue::setTapeReadOnlyOnError(const std::string &vid) {
try {
const char *const sql =
"UPDATE TAPE SET "
"IS_READ_ONLY = '1' "
"WHERE "
"VID = :VID";
auto conn = m_connPool.getConn();
auto stmt = conn.createStmt(sql);
stmt.bindString(":VID", vid);
stmt.executeNonQuery();
if (0 == stmt.getNbAffectedRows()) {
throw exception::Exception(std::string("Tape ") + vid + " does not exist");
}
} catch(exception::UserError &) {
throw;
} catch(exception::Exception &ex) {
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
}
//------------------------------------------------------------------------------
// setTapeDisabled
//------------------------------------------------------------------------------
......@@ -5168,6 +5246,7 @@ std::list<TapeForWriting> RdbmsCatalogue::getTapesForWriting(const std::string &
// "LABEL_TIME IS NOT NULL AND " // Set when the tape has been labelled
"IS_DISABLED = '0' AND "
"IS_FULL = '0' AND "
"IS_READ_ONLY = '0' AND "
"LOGICAL_LIBRARY_NAME = :LOGICAL_LIBRARY_NAME";
auto conn = m_connPool.getConn();
......
......@@ -140,7 +140,7 @@ public:
/**
* Returns the list of tapes that can be written to by a tape drive in the
* specified logical library, in other words tapes that are labelled, not
* disabled, not full and are in the specified logical library.
* disabled, not full, not read-only and are in the specified logical library.
*
* @param logicalLibraryName The name of the logical library.
* @return The list of tapes for writing.
......@@ -291,6 +291,7 @@ public:
const uint64_t capacityInBytes,
const bool disabled,
const bool full,
const bool readOnly,
const std::string &comment) override;
void deleteTape(const std::string &vid) override;
......@@ -374,7 +375,27 @@ public:
* @param fullValue Set to true if the tape is full.
*/
void setTapeFull(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const bool fullValue) override;
/**
* Sets the read-only status of the specified tape.
*
* Please note that this method is to be called by the CTA front-end in
* response to a command from the CTA command-line interface (CLI).
*
* @param admin The administrator.
* @param vid The volume identifier of the tape to be marked as read-only.
* @param readOnlyValue Set to true if the tape is read-only.
*/
void setTapeReadOnly(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const bool readOnlyValue) override;
/**
* This method notifies the CTA catalogue to set the specified tape read-only
* in case of a problem.
*
* @param vid The volume identifier of the tape.
*/
void setTapeReadOnlyOnError(const std::string &vid) override;
void setTapeDisabled(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const bool disabledValue) override;
void modifyTapeComment(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const std::string &comment) override;
......
......@@ -80,6 +80,11 @@ struct TapeSearchCriteria {
* Set to true if searching for full tapes.
*/
optional<bool> full;
/**
* Set to true if searching for read-only tapes.
*/
optional<bool> readOnly;
}; // struct TapeSearchCriteria
......
......@@ -86,6 +86,7 @@ CREATE TABLE TAPE(
LAST_FSEQ NUMERIC(20, 0) CONSTRAINT TAPE_LF_NN NOT NULL,
IS_DISABLED CHAR(1) CONSTRAINT TAPE_ID_NN NOT NULL,
IS_FULL CHAR(1) CONSTRAINT TAPE_IF_NN NOT NULL,
IS_READ_ONLY CHAR(1) CONSTRAINT TAPE_IRO_NN NOT NULL,
LABEL_DRIVE VARCHAR(100),
LABEL_TIME NUMERIC(20, 0),
LAST_READ_DRIVE VARCHAR(100),
......@@ -107,7 +108,8 @@ CREATE TABLE TAPE(
CONSTRAINT TAPE_TAPE_POOL_FK FOREIGN KEY(TAPE_POOL_NAME)
REFERENCES TAPE_POOL(TAPE_POOL_NAME),
CONSTRAINT TAPE_IS_DISABLED_BOOL_CK CHECK(IS_DISABLED IN ('0', '1')),
CONSTRAINT TAPE_IS_FULL_BOOL_CK CHECK(IS_FULL IN ('0', '1'))
CONSTRAINT TAPE_IS_FULL_BOOL_CK CHECK(IS_FULL IN ('0', '1')),
CONSTRAINT TAPE_IS_READ_ONLY_BOOL_CK CHECK(IS_READ_ONLY IN ('0', '1'))
);
CREATE INDEX TAPE_TAPE_POOL_NAME_IDX ON TAPE(TAPE_POOL_NAME);
CREATE TABLE MOUNT_POLICY(
......
......@@ -45,6 +45,10 @@ CREATE TRIGGER `CHECK_TAPE_BEFORE_INSERT` BEFORE INSERT ON `TAPE`
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'TAPE.IS_FULL should be 0 or 1';
END IF;
IF new.IS_READ_ONLY not in ('0','1') THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'TAPE.IS_READ_ONLY should be 0 or 1';
END IF;
END;
CREATE TRIGGER `CHECK_TAPE_BEFORE_UPDATE` BEFORE UPDATE ON `TAPE`
......@@ -58,6 +62,10 @@ CREATE TRIGGER `CHECK_TAPE_BEFORE_UPDATE` BEFORE UPDATE ON `TAPE`
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'TAPE.IS_FULL should be 0 or 1';
END IF;
IF new.IS_READ_ONLY not in ('0','1') THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'TAPE.IS_READ_ONLY should be 0 or 1';
END IF;
END;
CREATE TRIGGER `TAPE_FILE_COPY_NB_GT_ZERO_BEFORE_INSERT` BEFORE INSERT ON `TAPE_FILE`
......
......@@ -244,6 +244,7 @@ const std::map<std::string, OptionBoolean::Key> boolOptions = {
{ "--encrypted", OptionBoolean::ENCRYPTED },
{ "--force", OptionBoolean::FORCE },
{ "--full", OptionBoolean::FULL },
{ "--rdonly", OptionBoolean::READ_ONLY },
// hasOption options
{ "--checkchecksum", OptionBoolean::CHECK_CHECKSUM },
......@@ -418,6 +419,7 @@ const Option opt_vid { Option::OPT_STR, "--vid",
const Option opt_vo { Option::OPT_STR, "--vo", "--vo", " <vo>" };
const Option opt_vidfile { Option::OPT_STR_LIST, "--vidfile", "-f", " <filename>" };
const Option opt_full { Option::OPT_BOOL, "--full", "-f", " <\"true\" or \"false\">" };
const Option opt_rdonly { Option::OPT_BOOL, "--rdonly", "-r", " <\"true\" or \"false\">" };
......@@ -508,18 +510,18 @@ const std::map<cmd_key_t, cmd_val_t> cmdOptions = {
{{ AdminCmd::CMD_STORAGECLASS, AdminCmd::SUBCMD_LS }, { }},
/*----------------------------------------------------------------------------------------------------*/
{{ AdminCmd::CMD_TAPE, AdminCmd::SUBCMD_ADD },
{ opt_vid, opt_mediatype, opt_vendor, opt_logicallibrary, opt_tapepool, opt_capacity, opt_disabled, opt_full,
{ opt_vid, opt_mediatype, opt_vendor, opt_logicallibrary, opt_tapepool, opt_capacity, opt_disabled, opt_full, opt_rdonly,
opt_comment.optional() }},
{{ AdminCmd::CMD_TAPE, AdminCmd::SUBCMD_CH },
{ opt_vid, opt_mediatype.optional(), opt_vendor.optional(), opt_logicallibrary.optional(),
opt_tapepool.optional(), opt_capacity.optional(), opt_encryptionkey.optional(), opt_disabled.optional(),
opt_full.optional(), opt_comment.optional() }},
opt_full.optional(), opt_rdonly.optional(), opt_comment.optional() }},
{{ AdminCmd::CMD_TAPE, AdminCmd::SUBCMD_RM }, { opt_vid }},
{{ AdminCmd::CMD_TAPE, AdminCmd::SUBCMD_RECLAIM }, { opt_vid }},
{{ AdminCmd::CMD_TAPE, AdminCmd::SUBCMD_LS },
{ opt_vid.optional(), opt_mediatype.optional(), opt_vendor.optional(),
opt_logicallibrary.optional(), opt_tapepool.optional(), opt_vo.optional(), opt_capacity.optional(),
opt_disabled.optional(), opt_full.optional(), opt_all.optional() }},
opt_disabled.optional(), opt_full.optional(), opt_rdonly.optional(), opt_all.optional() }},
{{ AdminCmd::CMD_TAPE, AdminCmd::SUBCMD_LABEL },
{ opt_vid, opt_force.optional() }},
/*----------------------------------------------------------------------------------------------------*/
......
......@@ -662,6 +662,7 @@ void TextFormatter::printShowQueuesHeader() {
"full tapes",
"empty tapes",
"disabled tapes",
"rdonly tapes",
"writable tapes"
);
}
......@@ -700,6 +701,7 @@ void TextFormatter::print(const ShowQueuesItem &sq_item) {
sq_item.full_tapes(),
sq_item.empty_tapes(),
sq_item.disabled_tapes(),
sq_item.rdonly_tapes(),
sq_item.writable_tapes()
);
}
......@@ -750,6 +752,7 @@ void TextFormatter::printTapeLsHeader() {
"last fseq",
"full",
"disabled",
"rdonly",
"label drive",
"label time",
"last w drive",
......@@ -779,6 +782,7 @@ void TextFormatter::print(const TapeLsItem &tals_item) {
tals_item.last_fseq(),
tals_item.full(),
tals_item.disabled(),
tals_item.rdonly(),
tals_item.has_label_log() ? tals_item.label_log().drive() : "",
tals_item.has_label_log() ? timeToStr(tals_item.label_log().time()) : "",
tals_item.has_last_written_log() ? tals_item.last_written_log().drive() : "",
......
......@@ -48,6 +48,7 @@ struct QueueAndMountSummary {
uint64_t filesOnTapes=0;
uint64_t dataOnTapes=0;
uint64_t fullTapes=0;
uint64_t readOnlyTapes=0;
uint64_t emptyTapes=0;
uint64_t disabledTapes=0;
uint64_t writableTapes=0;
......
......@@ -29,8 +29,11 @@ namespace dataStructures {
//------------------------------------------------------------------------------
Tape::Tape():
lastFSeq(0),
capacityInBytes(0),
dataOnTapeInBytes(0) {}
capacityInBytes(0),
dataOnTapeInBytes(0),
full(false),
disabled(false),
readOnly(false) {}
//------------------------------------------------------------------------------
// operator==
......@@ -45,6 +48,7 @@ bool Tape::operator==(const Tape &rhs) const {
&& encryptionKey==rhs.encryptionKey
&& full==rhs.full
&& disabled==rhs.disabled
&& readOnly==rhs.readOnly
&& creationLog==rhs.creationLog
&& lastModificationLog==rhs.lastModificationLog
&& comment==rhs.comment
......@@ -73,6 +77,7 @@ std::ostream &operator<<(std::ostream &os, const Tape &obj) {
<< " encryptionKey=" << (obj.encryptionKey ? obj.encryptionKey.value() : "null")
<< " full=" << obj.full
<< " disabled=" << obj.disabled
<< " readOnly=" << obj.readOnly
<< " creationLog=" << obj.creationLog
<< " lastModificationLog=" << obj.lastModificationLog
<< " comment=" << obj.comment
......
......@@ -62,6 +62,7 @@ struct Tape {
bool full;
bool disabled;
bool readOnly;
EntryLog creationLog;
EntryLog lastModificationLog;
std::string comment;
......
......@@ -96,6 +96,7 @@ echo "Preparing CTA configuration for tests"
--vid ${VID} \
--disabled false \
--full false \
--rdonly false \
--comment "ctasystest"
done
kubectl --namespace ${NAMESPACE} exec ctacli -- cta-admin storageclass add \
......
......@@ -6,7 +6,7 @@ cta logicallibrary add --name VLSTK --comment "ctasystest"
cta tapepool add --name ctasystest --partialtapesnumber 5 --encrypted false --comment "ctasystest"
cta tape add --logicallibrary VLSTK --tapepool ctasystest --capacity 1000000000 --comment "ctasystest" --vid ${VID} --disabled false --full false
cta tape add --logicallibrary VLSTK --tapepool ctasystest --capacity 1000000000 --comment "ctasystest" --vid ${VID} --disabled false --full false --rdonly false
cta storageclass add --instance root --name ctaStorageClass --copynb 1 --comment "ctasystest"
......
......@@ -78,6 +78,7 @@ echo "Preparing CTA for tests"
--vid ${VID} \
--disabled false \
--full false \
--rdonly false \
--comment "ctasystest"
done
kubectl --namespace ${NAMESPACE} exec ctacli -- cta storageclass add \
......
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