Commit 194912de authored by Steven Murray's avatar Steven Murray
Browse files

Catalogue now creates, deletes and gets mount rules

parent f94c32d3
......@@ -45,7 +45,8 @@
#include "common/dataStructures/ReadTestResult.hpp"
#include "common/dataStructures/RepackInfo.hpp"
#include "common/dataStructures/RepackType.hpp"
#include "common/dataStructures/Requester.hpp"
#include "common/dataStructures/RequesterGroupMountRule.hpp"
#include "common/dataStructures/RequesterMountRule.hpp"
#include "common/dataStructures/RetrieveFileQueueCriteria.hpp"
#include "common/dataStructures/RetrieveJob.hpp"
#include "common/dataStructures/RetrieveRequest.hpp"
......@@ -136,14 +137,6 @@ public:
virtual void setTapeLbp(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const bool lbpValue) = 0; // internal function (noCLI)
virtual void modifyTapeComment(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const std::string &comment) = 0;
virtual void createRequester(
const common::dataStructures::SecurityIdentity &cliIdentity,
const std::string &requesterName,
const std::string &mountPolicy,
const std::string &comment) = 0;
virtual void deleteRequester(const std::string &requesterName) = 0;
virtual std::list<common::dataStructures::Requester> getRequesters() const = 0;
virtual void modifyRequesterMountPolicy(const common::dataStructures::SecurityIdentity &cliIdentity, const common::dataStructures::UserIdentity &user, const std::string &mountPolicy) = 0;
virtual void modifyRequesterComment(const common::dataStructures::SecurityIdentity &cliIdentity, const common::dataStructures::UserIdentity &user, const std::string &comment) = 0;
......@@ -158,36 +151,87 @@ public:
const std::string &comment) = 0;
/**
* Assigns the specified mount policy to the specified requester.
* Returns the list of all existing mount policies.
*
* Please note that requester mount-policies overrule requester-group
* mount-policies.
* @return the list of all existing mount policies.
*/
virtual std::list<common::dataStructures::MountPolicy> getMountPolicies() const = 0;
/**
* Deletes the specified mount policy.
*
* @param name The name of the mount policy.
*/
virtual void deleteMountPolicy(const std::string &name) = 0;
/**
* Creates the rule that the specified mount policy will be used for the
* specified requester.
*
* Please note that requester mount-rules overrule requester-group
* mount-rules.
*
* @param cliIdentity The user of the command-line tool.
* @param mountPolicyName The name of the mount policy.
* @param requesterName The name of the requester.
* @param comment Comment.
*/
virtual void assignMountPolicyToRequester(
virtual void createRequesterMountRule(
const common::dataStructures::SecurityIdentity &cliIdentity,
const std::string &mountPolicyName,
const std::string &requesterName,
const std::string &comment) = 0;
/**
* Assigns the specified mount policy to the specified requester group.
* Returns the rules that specify which mount policy is be used for which
* requester.
*
* @return the rules that specify which mount policy is be used for which
* requester.
*/
virtual std::list<common::dataStructures::RequesterMountRule> getRequesterMountRules() const = 0;
/**
* Deletes the specified mount rule.
*
* @param requesterName The name of the requester.
*/
virtual void deleteRequesterMountRule(const std::string &requesterName) = 0;
/**
* Creates the rule that the specified mount policy will be used for the
* specified requester group.
*
* Please note that requester mount-policies overrule requester-group
* mount-policies.
* Please note that requester mount-rules overrule requester-group
* mount-rules.
*
* @param cliIdentity The user of the command-line tool.
* @param mountPolicyName The name of the mount policy.
* @param requesterGrouprName The name of the requester group.
* @param requesterGroupName The name of the requester group.
* @param comment Comment.
*/
virtual void assignMountPolicyToRequesterGroup(const std::string &mountPolicyName,
const std::string &requesterGroupName) = 0;
virtual void createRequesterGroupMountRule(
const common::dataStructures::SecurityIdentity &cliIdentity,
const std::string &mountPolicyName,
const std::string &requesterGroupName,
const std::string &comment) = 0;
/**
* Returns the rules that specify which mount policy is be used for which
* requester group.
*
* @return the rules that specify which mount policy is be used for which
* requester group.
*/
virtual std::list<common::dataStructures::RequesterGroupMountRule> getRequesterGroupMountRules() const = 0;
/**
* Deletes the specified mount rule.
*
* @param requesterGroupName The name of the requester group.
*/
virtual void deleteRequesterGroupMountRule(const std::string &requesterGroupName) = 0;
virtual void deleteMountPolicy(const std::string &name) = 0;
virtual std::list<common::dataStructures::MountPolicy> getMountPolicies() const = 0;
virtual void modifyMountPolicyArchivePriority(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const uint64_t archivePriority) = 0;
virtual void modifyMountPolicyArchiveMinFilesQueued(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const uint64_t minArchiveFilesQueued) = 0;
virtual void modifyMountPolicyArchiveMinBytesQueued(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const uint64_t archiveMinBytesQueued) = 0;
......@@ -279,14 +323,6 @@ public:
virtual common::dataStructures::TapeCopyToPoolMap getTapeCopyToPoolMap(const std::string &storageClass) const = 0;
/**
* Returns the mount policy for the specified end user.
*
* @param username The name of the end user.
* @return The mount policy.
*/
virtual common::dataStructures::MountPolicy getMountPolicyForAUser(const std::string &username) const = 0;
virtual bool isAdmin(const common::dataStructures::SecurityIdentity &cliIdentity) const = 0;
/**
......
This diff is collapsed.
This diff is collapsed.
......@@ -119,14 +119,6 @@ public:
virtual void setTapeLbp(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const bool lbpValue); // internal function (noCLI)
virtual void modifyTapeComment(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const std::string &comment);
virtual void createRequester(
const common::dataStructures::SecurityIdentity &cliIdentity,
const std::string &requesterName,
const std::string &mountPolicy,
const std::string &comment);
virtual void deleteRequester(const std::string &requesterName);
virtual std::list<common::dataStructures::Requester> getRequesters() const;
virtual void modifyRequesterMountPolicy(const common::dataStructures::SecurityIdentity &cliIdentity, const common::dataStructures::UserIdentity &user, const std::string &mountPolicy);
virtual void modifyRequesterComment(const common::dataStructures::SecurityIdentity &cliIdentity, const common::dataStructures::UserIdentity &user, const std::string &comment);
......@@ -141,36 +133,87 @@ public:
const std::string &comment);
/**
* Assigns the specified mount policy to the specified requester.
* Returns the list of all existing mount policies.
*
* @return the list of all existing mount policies.
*/
virtual std::list<common::dataStructures::MountPolicy> getMountPolicies() const;
/**
* Deletes the specified mount policy.
*
* @param name The name of the mount policy.
*/
virtual void deleteMountPolicy(const std::string &name);
/**
* Creates the rule that the specified mount policy will be used for the
* specified requester.
*
* Please note that requester mount-policies overrule requester-group
* mount-policies.
* Please note that requester mount-rules overrule requester-group
* mount-rules.
*
* @param cliIdentity The user of the command-line tool.
* @param mountPolicyName The name of the mount policy.
* @param requesterName The name of the requester.
* @param comment Comment.
*/
virtual void assignMountPolicyToRequester(
virtual void createRequesterMountRule(
const common::dataStructures::SecurityIdentity &cliIdentity,
const std::string &mountPolicyName,
const std::string &requesterName,
const std::string &comment);
/**
* Assigns the specified mount policy to the specified requester group.
* Returns the rules that specify which mount policy is be used for which
* requester.
*
* @return the rules that specify which mount policy is be used for which
* requester.
*/
virtual std::list<common::dataStructures::RequesterMountRule> getRequesterMountRules() const;
/**
* Deletes the specified mount rule.
*
* Please note that requester mount-policies overrule requester-group
* mount-policies.
* @param requesterName The name of the requester.
*/
virtual void deleteRequesterMountRule(const std::string &requesterName);
/**
* Creates the rule that the specified mount policy will be used for the
* specified requester group.
*
* Please note that requester mount-rules overrule requester-group
* mount-rules.
*
* @param cliIdentity The user of the command-line tool.
* @param mountPolicyName The name of the mount policy.
* @param requesterGrouprName The name of the requester group.
* @param requesterGroupName The name of the requester group.
* @param comment Comment.
*/
virtual void assignMountPolicyToRequesterGroup(const std::string &mountPolicyName,
const std::string &requesterGroupName);
virtual void createRequesterGroupMountRule(
const common::dataStructures::SecurityIdentity &cliIdentity,
const std::string &mountPolicyName,
const std::string &requesterGroupName,
const std::string &comment);
/**
* Returns the rules that specify which mount policy is be used for which
* requester group.
*
* @return the rules that specify which mount policy is be used for which
* requester group.
*/
virtual std::list<common::dataStructures::RequesterGroupMountRule> getRequesterGroupMountRules() const;
/**
* Deletes the specified mount rule.
*
* @param requesterGroupName The name of the requester group.
*/
virtual void deleteRequesterGroupMountRule(const std::string &requesterGroupName);
virtual void deleteMountPolicy(const std::string &name);
virtual std::list<common::dataStructures::MountPolicy> getMountPolicies() const;
virtual void modifyMountPolicyArchivePriority(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const uint64_t archivePriority);
virtual void modifyMountPolicyArchiveMinFilesQueued(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const uint64_t minArchiveFilesQueued);
virtual void modifyMountPolicyArchiveMinBytesQueued(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const uint64_t archiveMinBytesQueued);
......@@ -345,7 +388,7 @@ protected:
* Returns the specified requester mount-policy or NULL if one does not exist.
*
* @param requesterName The name of the requester.
* @return The mount policy.
* @return The mount policy or NULL if one does not exists.
*/
common::dataStructures::MountPolicy *getRequesterMountPolicy(const std::string &requesterName) const;
......@@ -357,6 +400,15 @@ protected:
*/
bool requesterGroupExists(const std::string &requesterGroupName) const;
/**
* Returns the specified requester-group mount-policy or NULL if one does not
* exist.
*
* @param requesterGroupName The name of the requester group.
* @return The mount policy or NULL if one does not exists.
*/
common::dataStructures::MountPolicy *getRequesterGroupMountPolicy(const std::string &requesterGroupName) const;
/**
* An RdbmsCatalogue specific method that inserts the specified row into the
* ArchiveFile table.
......
......@@ -119,32 +119,32 @@ CREATE TABLE MOUNT_POLICY(
LAST_UPDATE_TIME INTEGER NOT NULL,
CONSTRAINT MOUNT_POLICY_PK PRIMARY KEY(MOUNT_POLICY_NAME)
);
CREATE TABLE REQUESTER(
REQUESTER_NAME VARCHAR2(100) NOT NULL,
MOUNT_POLICY_NAME VARCHAR2(100) NOT NULL,
USER_COMMENT VARCHAR2(1000) NOT NULL,
CREATION_LOG_USER_NAME VARCHAR2(100) NOT NULL,
CREATION_LOG_HOST_NAME VARCHAR2(100) NOT NULL,
CREATION_LOG_TIME INTEGER NOT NULL,
LAST_UPDATE_USER_NAME VARCHAR2(100) NOT NULL,
LAST_UPDATE_HOST_NAME VARCHAR2(100) NOT NULL,
LAST_UPDATE_TIME INTEGER NOT NULL,
CONSTRAINT REQUESTER_PK PRIMARY KEY(REQUESTER_NAME),
CONSTRAINT REQUESTER_MOUNT_POLICY_FK FOREIGN KEY(MOUNT_POLICY_NAME)
CREATE TABLE REQUESTER_MOUNT_RULE(
REQUESTER_NAME VARCHAR2(100) NOT NULL,
MOUNT_POLICY_NAME VARCHAR2(100) NOT NULL,
USER_COMMENT VARCHAR2(1000) NOT NULL,
CREATION_LOG_USER_NAME VARCHAR2(100) NOT NULL,
CREATION_LOG_HOST_NAME VARCHAR2(100) NOT NULL,
CREATION_LOG_TIME INTEGER NOT NULL,
LAST_UPDATE_USER_NAME VARCHAR2(100) NOT NULL,
LAST_UPDATE_HOST_NAME VARCHAR2(100) NOT NULL,
LAST_UPDATE_TIME INTEGER NOT NULL,
CONSTRAINT RQSTER_RULE_PK PRIMARY KEY(REQUESTER_NAME),
CONSTRAINT RQSTER_RULE_MNT_PLC_FK FOREIGN KEY(MOUNT_POLICY_NAME)
REFERENCES MOUNT_POLICY(MOUNT_POLICY_NAME)
);
CREATE TABLE REQUESTER_GROUP(
REQUESTER_GROUP_NAME VARCHAR2(100) NOT NULL,
MOUNT_POLICY_NAME VARCHAR2(100) NOT NULL,
USER_COMMENT VARCHAR2(1000) NOT NULL,
CREATION_LOG_USER_NAME VARCHAR2(100) NOT NULL,
CREATION_LOG_HOST_NAME VARCHAR2(100) NOT NULL,
CREATION_LOG_TIME INTEGER NOT NULL,
LAST_UPDATE_USER_NAME VARCHAR2(100) NOT NULL,
LAST_UPDATE_HOST_NAME VARCHAR2(100) NOT NULL,
LAST_UPDATE_TIME INTEGER NOT NULL,
CONSTRAINT REQUESTER_GROUP_PK PRIMARY KEY(REQUESTER_GROUP_NAME),
CONSTRAINT REQUESTER_GRP_MOUNT_POLICY_FK FOREIGN KEY(MOUNT_POLICY_NAME)
CREATE TABLE REQUESTER_GROUP_MOUNT_RULE(
REQUESTER_GROUP_NAME VARCHAR2(100) NOT NULL,
MOUNT_POLICY_NAME VARCHAR2(100) NOT NULL,
USER_COMMENT VARCHAR2(1000) NOT NULL,
CREATION_LOG_USER_NAME VARCHAR2(100) NOT NULL,
CREATION_LOG_HOST_NAME VARCHAR2(100) NOT NULL,
CREATION_LOG_TIME INTEGER NOT NULL,
LAST_UPDATE_USER_NAME VARCHAR2(100) NOT NULL,
LAST_UPDATE_HOST_NAME VARCHAR2(100) NOT NULL,
LAST_UPDATE_TIME INTEGER NOT NULL,
CONSTRAINT RQSTER_GRP_RULE_PK PRIMARY KEY(REQUESTER_GROUP_NAME),
CONSTRAINT RQSTER_GRP_RULE_MNT_PLC_FK FOREIGN KEY(MOUNT_POLICY_NAME)
REFERENCES MOUNT_POLICY(MOUNT_POLICY_NAME)
);
CREATE TABLE ARCHIVE_FILE(
......
......@@ -2,8 +2,8 @@ DROP TABLE ARCHIVE_ROUTE;
DROP TABLE TAPE_FILE;
DROP TABLE ARCHIVE_FILE;
DROP TABLE TAPE;
DROP TABLE REQUESTER;
DROP TABLE REQUESTER_GROUP;
DROP TABLE REQUESTER_MOUNT_RULE;
DROP TABLE REQUESTER_GROUP_MOUNT_RULE;
DROP TABLE ADMIN_USER;
DROP TABLE ADMIN_HOST;
DROP TABLE STORAGE_CLASS;
......
DROP TABLE ARCHIVE_ROUTE;
DROP TABLE TAPE_FILE;
DROP TABLE ARCHIVE_FILE;
DROP TABLE ARCHIVE_FILE_ID;
DROP TABLE TAPE;
DROP TABLE REQUESTER;
DROP TABLE REQUESTER_GROUP;
DROP TABLE REQUESTER_MOUNT_POLICY;
DROP TABLE REQUESTER_GROUP_MOUNT_POLICY;
DROP TABLE ADMIN_USER;
DROP TABLE ADMIN_HOST;
DROP TABLE STORAGE_CLASS;
......
......@@ -46,7 +46,8 @@ set (COMMON_LIB_SRC_FILES
dataStructures/ReadTestResult.cpp
dataStructures/RepackInfo.cpp
dataStructures/RepackType.cpp
dataStructures/Requester.cpp
dataStructures/RequesterGroupMountRule.cpp
dataStructures/RequesterMountRule.cpp
dataStructures/RetrieveFileQueueCriteria.cpp
dataStructures/RetrieveJob.cpp
dataStructures/RetrieveRequest.cpp
......
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "common/dataStructures/RequesterGroupMountRule.hpp"
#include "common/dataStructures/utils.hpp"
#include "common/exception/Exception.hpp"
namespace cta {
namespace common {
namespace dataStructures {
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
RequesterGroupMountRule::RequesterGroupMountRule() {}
//------------------------------------------------------------------------------
// operator==
//------------------------------------------------------------------------------
bool RequesterGroupMountRule::operator==(const RequesterGroupMountRule &rhs) const {
return name==rhs.name
&& mountPolicy==rhs.mountPolicy
&& creationLog==rhs.creationLog
&& lastModificationLog==rhs.lastModificationLog
&& comment==rhs.comment;
}
//------------------------------------------------------------------------------
// operator!=
//------------------------------------------------------------------------------
bool RequesterGroupMountRule::operator!=(const RequesterGroupMountRule &rhs) const {
return !operator==(rhs);
}
//------------------------------------------------------------------------------
// operator<<
//------------------------------------------------------------------------------
std::ostream &operator<<(std::ostream &os, const RequesterGroupMountRule &obj) {
os << "(name=" << obj.name
<< " mountPolicy=" << obj.mountPolicy
<< " creationLog=" << obj.creationLog
<< " lastModificationLog=" << obj.lastModificationLog
<< " comment=" << obj.comment << ")";
return os;
}
} // namespace dataStructures
} // namespace common
} // namespace cta
......@@ -30,29 +30,26 @@ namespace common {
namespace dataStructures {
/**
* This is the disk system user that triggered the request (any of: archival,
* retrieval, deletion of an archive file, cancel of an ongoing retrieval,
* update of a file metadata, listing of storage classes). It may or may not be
* the owner of the file (basically there's no relationship between the two)
* Rule specifying which mount policy will be used for a specific group of
* data-transfer requesters.
*/
struct Requester {
struct RequesterGroupMountRule {
Requester();
RequesterGroupMountRule();
bool operator==(const Requester &rhs) const;
bool operator==(const RequesterGroupMountRule &rhs) const;
bool operator!=(const Requester &rhs) const;
bool operator!=(const RequesterGroupMountRule &rhs) const;
std::string name;
std::string group;
std::string mountPolicy;
EntryLog creationLog;
EntryLog lastModificationLog;
std::string comment;
}; // struct Requester
}; // struct RequesterGroupMountRule
std::ostream &operator<<(std::ostream &os, const Requester &obj);
std::ostream &operator<<(std::ostream &os, const RequesterGroupMountRule &obj);
} // namespace dataStructures
} // namespace common
......
......@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "common/dataStructures/Requester.hpp"
#include "common/dataStructures/RequesterMountRule.hpp"
#include "common/dataStructures/utils.hpp"
#include "common/exception/Exception.hpp"
......@@ -27,33 +27,31 @@ namespace dataStructures {
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
Requester::Requester() {}
RequesterMountRule::RequesterMountRule() {}
//------------------------------------------------------------------------------
// operator==
//------------------------------------------------------------------------------
bool Requester::operator==(const Requester &rhs) const {
bool RequesterMountRule::operator==(const RequesterMountRule &rhs) const {
return name==rhs.name
&& group==rhs.group
&& mountPolicy==rhs.mountPolicy
&& creationLog==rhs.creationLog
&& lastModificationLog==rhs.lastModificationLog
&& comment==rhs.comment;
&& mountPolicy==rhs.mountPolicy
&& creationLog==rhs.creationLog
&& lastModificationLog==rhs.lastModificationLog
&& comment==rhs.comment;
}
//------------------------------------------------------------------------------
// operator!=
//------------------------------------------------------------------------------
bool Requester::operator!=(const Requester &rhs) const {
bool RequesterMountRule::operator!=(const RequesterMountRule &rhs) const {
return !operator==(rhs);
}
//------------------------------------------------------------------------------
// operator<<
//------------------------------------------------------------------------------
std::ostream &operator<<(std::ostream &os, const Requester &obj) {
std::ostream &operator<<(std::ostream &os, const RequesterMountRule &obj) {
os << "(name=" << obj.name
<< " group=" << obj.group
<< " mountPolicy=" << obj.mountPolicy
<< " creationLog=" << obj.creationLog
<< " lastModificationLog=" << obj.lastModificationLog
......
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <list>
#include <map>
#include <stdint.h>
#include <string>
#include "common/dataStructures/EntryLog.hpp"
namespace cta {
namespace common {
namespace dataStructures {
/**
* Rule specifying which mount policy will be used for a specific data-transfer
* requester.
*/
struct RequesterMountRule {
RequesterMountRule();
bool operator==(const RequesterMountRule &rhs) const;
bool operator!=(const RequesterMountRule &rhs) const;
std::string name;
std::string mountPolicy;
EntryLog creationLog;
EntryLog lastModificationLog;
std::string comment;
}; // struct RequesterMountRule
std::ostream &operator<<(std::ostream &os, const RequesterMountRule &obj);
} // namespace dataStructures
} // namespace common
} // namespace cta
......@@ -167,15 +167,14 @@ TEST_P(SchedulerTest, archive_to_new_file) {
const std::string userComment = "create user";
const std::string userName = "user_name";
const std::string userGroup = "group";
cta::common::dataStructures::UserIdentity userIdentity;
catalogue.createRequester(s_adminOnAdminHost, userName, mountPolicyName, userComment);
catalogue.createRequesterMountRule(s_adminOnAdminHost, mountPolicyName, userName, userComment);
std::list<common::dataStructures::Requester> users;
users = catalogue.getRequesters();
std::list<common::dataStructures::RequesterMountRule> users;
users = catalogue.getRequesterMountRules();
ASSERT_EQ(1, users.size());