Commit 0b9d801a authored by Cedric Caffy's avatar Cedric Caffy
Browse files

[cta-admin] tape comments can be deleted by passing an empty string to

the --comment option
parent 82b9c779
......@@ -607,7 +607,14 @@ public:
virtual void setTapeDirty(const std::string & vid) = 0;
virtual void modifyTapeComment(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const std::string &comment) = 0;
/**
* Modifies the tape comment
* If the comment == cta::nullopt, it will delete the comment from the tape table
* @param admin the admin who removes the comment
* @param vid the vid of the tape to remove the comment
* @param comment the new comment. If comment == cta::nullopt, the comment will be deleted.
*/
virtual void modifyTapeComment(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const cta::optional<std::string> &comment) = 0;
virtual void modifyRequesterMountRulePolicy(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &requesterName, const std::string &mountPolicy) = 0;
virtual void modifyRequesteMountRuleComment(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &requesterName, const std::string &comment) = 0;
......
......@@ -376,7 +376,7 @@ public:
return retryOnLostConnection(m_log,[&]{ return m_catalogue->setTapeDirty(vid);}, m_maxTriesToConnect);
}
void modifyTapeComment(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const std::string &comment) override {
void modifyTapeComment(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const cta::optional<std::string> &comment) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyTapeComment(admin, vid, comment);}, m_maxTriesToConnect);
}
......
......@@ -127,7 +127,7 @@ public:
void modifyStorageClassVo(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &vo) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void modifyStorageClassName(const common::dataStructures::SecurityIdentity& admin, const std::string& currentName, const std::string& newName) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void modifyStorageClassNbCopies(const common::dataStructures::SecurityIdentity& admin, const std::string& name, const uint64_t nbCopies) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void modifyTapeComment(const common::dataStructures::SecurityIdentity& admin, const std::string& vid, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void modifyTapeComment(const common::dataStructures::SecurityIdentity& admin, const std::string& vid, const cta::optional<std::string> &comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void modifyTapeEncryptionKeyName(const common::dataStructures::SecurityIdentity& admin, const std::string& vid, const std::string& encryptionKeyName) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void modifyTapeMediaType(const common::dataStructures::SecurityIdentity& admin, const std::string& vid, const std::string& mediaType) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void modifyTapeVendor(const common::dataStructures::SecurityIdentity& admin, const std::string& vid, const std::string& vendor) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
......
......@@ -4531,7 +4531,7 @@ void RdbmsCatalogue::setTapeDirty(const std::string& vid) {
// modifyTapeComment
//------------------------------------------------------------------------------
void RdbmsCatalogue::modifyTapeComment(const common::dataStructures::SecurityIdentity &admin,
const std::string &vid, const std::string &comment) {
const std::string &vid, const cta::optional<std::string> &comment) {
try {
const time_t now = time(nullptr);
const char *const sql =
......@@ -4559,7 +4559,7 @@ void RdbmsCatalogue::modifyTapeComment(const common::dataStructures::SecurityIde
log::LogContext lc(m_log);
log::ScopedParamContainer spc(lc);
spc.add("vid", vid)
.add("userComment", comment)
.add("userComment", comment ? comment.value() : "")
.add("lastUpdateUserName", admin.username)
.add("lastUpdateHostName", admin.host)
.add("lastUpdateTime", now);
......
......@@ -622,7 +622,7 @@ public:
void setTapeDisabled(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const bool disabledValue) override;
void setTapeDirty(const std::string & vid) override;
void modifyTapeComment(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const std::string &comment) override;
void modifyTapeComment(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const cta::optional<std::string> &comment) override;
void modifyRequesterMountRulePolicy(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &requesterName, const std::string &mountPolicy) override;
void modifyRequesteMountRuleComment(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &requesterName, const std::string &comment) override;
......
......@@ -1691,7 +1691,6 @@ void RequestMessage::processTape_Ch(cta::xrd::Response &response)
auto vendor = getOptional(OptionString::VENDOR);
auto logicallibrary = getOptional(OptionString::LOGICAL_LIBRARY);
auto tapepool = getOptional(OptionString::TAPE_POOL);
auto capacity = getOptional(OptionUInt64::CAPACITY);
auto comment = getOptional(OptionString::COMMENT);
auto encryptionkeyName = getOptional(OptionString::ENCRYPTION_KEY_NAME);
auto disabled = getOptional(OptionBoolean::DISABLED);
......@@ -1711,7 +1710,11 @@ void RequestMessage::processTape_Ch(cta::xrd::Response &response)
m_catalogue.modifyTapeTapePoolName(m_cliIdentity, vid, tapepool.value());
}
if(comment) {
m_catalogue.modifyTapeComment(m_cliIdentity, vid, comment.value());
if(comment.value().empty()){
//If the comment is an empty string, the user meant to delete it
comment = cta::nullopt;
}
m_catalogue.modifyTapeComment(m_cliIdentity, vid, comment);
}
if(encryptionkeyName) {
m_catalogue.modifyTapeEncryptionKeyName(m_cliIdentity, vid, encryptionkeyName.value());
......
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