Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
67dc8577
Commit
67dc8577
authored
Feb 16, 2016
by
Daniele Kruse
Browse files
More work on CLI, plus changed the dedication interface
parent
6f01b27b
Changes
11
Hide whitespace changes
Inline
Side-by-side
catalogue/Catalogue.hpp
View file @
67dc8577
...
...
@@ -33,6 +33,7 @@
#include
"common/dataStructures/ArchiveRoute.hpp"
#include
"common/dataStructures/CancelRetrieveRequest.hpp"
#include
"common/dataStructures/Dedication.hpp"
#include
"common/dataStructures/DedicationType.hpp"
#include
"common/dataStructures/DeleteArchiveRequest.hpp"
#include
"common/dataStructures/DRData.hpp"
#include
"common/dataStructures/DriveState.hpp"
...
...
@@ -150,12 +151,11 @@ public:
virtual
void
modifyUserGroupMaxDrivesAllowed
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
name
,
const
uint64_t
maxDrivesAllowed
)
=
0
;
virtual
void
modifyUserGroupComment
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
name
,
const
std
::
string
&
comment
)
=
0
;
virtual
void
createDedication
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
bool
readonly
,
const
bool
writeonly
,
const
std
::
string
&
userGroup
,
virtual
void
createDedication
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
cta
::
common
::
dataStructures
::
DedicationType
dedicationType
,
const
std
::
string
&
userGroup
,
const
std
::
string
&
tag
,
const
std
::
string
&
vid
,
const
uint64_t
fromTimestamp
,
const
uint64_t
untilTimestamp
,
const
std
::
string
&
comment
)
=
0
;
virtual
void
deleteDedication
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
)
=
0
;
virtual
std
::
list
<
cta
::
common
::
dataStructures
::
Dedication
>
getDedications
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
)
const
=
0
;
virtual
void
modifyDedicationReadonly
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
bool
readonly
)
=
0
;
virtual
void
modifyDedicationWriteonly
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
bool
writeonly
)
=
0
;
virtual
void
modifyDedicationType
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
cta
::
common
::
dataStructures
::
DedicationType
dedicationType
)
=
0
;
virtual
void
modifyDedicationUserGroup
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
std
::
string
&
userGroup
)
=
0
;
virtual
void
modifyDedicationTag
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
std
::
string
&
tag
)
=
0
;
virtual
void
modifyDedicationVid
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
std
::
string
&
vid
)
=
0
;
...
...
catalogue/MockCatalogue.cpp
View file @
67dc8577
...
...
@@ -342,7 +342,7 @@ void cta::catalogue::MockCatalogue::modifyUserGroupComment(const cta::common::da
//------------------------------------------------------------------------------
// createDedication
//------------------------------------------------------------------------------
void
cta
::
catalogue
::
MockCatalogue
::
createDedication
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
bool
readonly
,
const
bool
writeonly
,
const
std
::
string
&
userGroup
,
void
cta
::
catalogue
::
MockCatalogue
::
createDedication
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
cta
::
common
::
dataStructures
::
DedicationType
dedicationType
,
const
std
::
string
&
userGroup
,
const
std
::
string
&
tag
,
const
std
::
string
&
vid
,
const
uint64_t
fromTimestamp
,
const
uint64_t
untilTimestamp
,
const
std
::
string
&
comment
)
{}
//------------------------------------------------------------------------------
...
...
@@ -356,14 +356,9 @@ void cta::catalogue::MockCatalogue::deleteDedication(const cta::common::dataStru
std
::
list
<
cta
::
common
::
dataStructures
::
Dedication
>
cta
::
catalogue
::
MockCatalogue
::
getDedications
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
)
const
{
return
std
::
list
<
cta
::
common
::
dataStructures
::
Dedication
>
();}
//------------------------------------------------------------------------------
// modifyDedication
Readonly
// modifyDedication
Type
//------------------------------------------------------------------------------
void
cta
::
catalogue
::
MockCatalogue
::
modifyDedicationReadonly
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
bool
readonly
)
{}
//------------------------------------------------------------------------------
// modifyDedicationWriteonly
//------------------------------------------------------------------------------
void
cta
::
catalogue
::
MockCatalogue
::
modifyDedicationWriteonly
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
bool
writeonly
)
{}
void
cta
::
catalogue
::
MockCatalogue
::
modifyDedicationType
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
cta
::
common
::
dataStructures
::
DedicationType
dedicationType
)
{}
//------------------------------------------------------------------------------
// modifyDedicationUserGroup
...
...
catalogue/MockCatalogue.hpp
View file @
67dc8577
...
...
@@ -122,12 +122,11 @@ public:
virtual
void
modifyUserGroupMaxDrivesAllowed
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
name
,
const
uint64_t
maxDrivesAllowed
);
virtual
void
modifyUserGroupComment
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
name
,
const
std
::
string
&
comment
);
virtual
void
createDedication
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
bool
readonly
,
const
bool
writeonly
,
const
std
::
string
&
userGroup
,
const
std
::
string
&
tag
,
const
std
::
string
&
vid
,
const
uint64_t
fromTimestamp
,
const
uint64_t
untilTimestamp
,
const
std
::
string
&
comment
);
virtual
void
createDedication
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
cta
::
common
::
dataStructures
::
DedicationType
dedicationType
,
const
std
::
string
&
userGroup
,
const
std
::
string
&
tag
,
const
std
::
string
&
vid
,
const
uint64_t
fromTimestamp
,
const
uint64_t
untilTimestamp
,
const
std
::
string
&
comment
);
virtual
void
deleteDedication
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
);
virtual
std
::
list
<
cta
::
common
::
dataStructures
::
Dedication
>
getDedications
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
)
const
;
virtual
void
modifyDedicationReadonly
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
bool
readonly
);
virtual
void
modifyDedicationWriteonly
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
bool
writeonly
);
virtual
void
modifyDedicationType
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
cta
::
common
::
dataStructures
::
DedicationType
dedicationType
);
virtual
void
modifyDedicationUserGroup
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
std
::
string
&
userGroup
);
virtual
void
modifyDedicationTag
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
std
::
string
&
tag
);
virtual
void
modifyDedicationVid
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
std
::
string
&
vid
);
...
...
common/dataStructures/Dedication.cpp
View file @
67dc8577
...
...
@@ -25,15 +25,14 @@
cta
::
common
::
dataStructures
::
Dedication
::
Dedication
()
{
m_commentSet
=
false
;
m_creationLogSet
=
false
;
m_dedicationTypeSet
=
false
;
m_driveNameSet
=
false
;
m_fromTimestampSet
=
false
;
m_lastModificationLogSet
=
false
;
m_readonlySet
=
false
;
m_tagSet
=
false
;
m_untilTimestampSet
=
false
;
m_userGroupSet
=
false
;
m_vidSet
=
false
;
m_writeonlySet
=
false
;
}
//------------------------------------------------------------------------------
...
...
@@ -48,15 +47,14 @@ cta::common::dataStructures::Dedication::~Dedication() throw() {
bool
cta
::
common
::
dataStructures
::
Dedication
::
allFieldsSet
()
const
{
return
m_commentSet
&&
m_creationLogSet
&&
m_dedicationTypeSet
&&
m_driveNameSet
&&
m_fromTimestampSet
&&
m_lastModificationLogSet
&&
m_readonlySet
&&
m_tagSet
&&
m_untilTimestampSet
&&
m_userGroupSet
&&
m_vidSet
&&
m_writeonlySet
;
&&
m_vidSet
;
}
//------------------------------------------------------------------------------
...
...
@@ -95,6 +93,24 @@ cta::common::dataStructures::EntryLog cta::common::dataStructures::Dedication::g
return
m_creationLog
;
}
//------------------------------------------------------------------------------
// setDedicationType
//------------------------------------------------------------------------------
void
cta
::
common
::
dataStructures
::
Dedication
::
setDedicationType
(
const
cta
::
common
::
dataStructures
::
DedicationType
&
dedicationType
)
{
m_dedicationType
=
dedicationType
;
m_dedicationTypeSet
=
true
;
}
//------------------------------------------------------------------------------
// getDedicationType
//------------------------------------------------------------------------------
cta
::
common
::
dataStructures
::
DedicationType
cta
::
common
::
dataStructures
::
Dedication
::
getDedicationType
()
const
{
if
(
!
allFieldsSet
())
{
throw
cta
::
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" Error: not all fields of the Dedication have been set!"
);
}
return
m_dedicationType
;
}
//------------------------------------------------------------------------------
// setDriveName
//------------------------------------------------------------------------------
...
...
@@ -149,24 +165,6 @@ cta::common::dataStructures::EntryLog cta::common::dataStructures::Dedication::g
return
m_lastModificationLog
;
}
//------------------------------------------------------------------------------
// setReadonly
//------------------------------------------------------------------------------
void
cta
::
common
::
dataStructures
::
Dedication
::
setReadonly
(
const
bool
readonly
)
{
m_readonly
=
readonly
;
m_readonlySet
=
true
;
}
//------------------------------------------------------------------------------
// getReadonly
//------------------------------------------------------------------------------
bool
cta
::
common
::
dataStructures
::
Dedication
::
getReadonly
()
const
{
if
(
!
allFieldsSet
())
{
throw
cta
::
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" Error: not all fields of the Dedication have been set!"
);
}
return
m_readonly
;
}
//------------------------------------------------------------------------------
// setTag
//------------------------------------------------------------------------------
...
...
@@ -238,21 +236,3 @@ std::string cta::common::dataStructures::Dedication::getVid() const {
}
return
m_vid
;
}
//------------------------------------------------------------------------------
// setWriteonly
//------------------------------------------------------------------------------
void
cta
::
common
::
dataStructures
::
Dedication
::
setWriteonly
(
const
bool
writeonly
)
{
m_writeonly
=
writeonly
;
m_writeonlySet
=
true
;
}
//------------------------------------------------------------------------------
// getWriteonly
//------------------------------------------------------------------------------
bool
cta
::
common
::
dataStructures
::
Dedication
::
getWriteonly
()
const
{
if
(
!
allFieldsSet
())
{
throw
cta
::
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" Error: not all fields of the Dedication have been set!"
);
}
return
m_writeonly
;
}
common/dataStructures/Dedication.hpp
View file @
67dc8577
...
...
@@ -23,6 +23,7 @@
#include
<stdint.h>
#include
<string>
#include
"common/dataStructures/DedicationType.hpp"
#include
"common/dataStructures/EntryLog.hpp"
namespace
cta
{
...
...
@@ -49,6 +50,9 @@ public:
void
setCreationLog
(
const
cta
::
common
::
dataStructures
::
EntryLog
&
creationLog
);
cta
::
common
::
dataStructures
::
EntryLog
getCreationLog
()
const
;
void
setDedicationType
(
const
cta
::
common
::
dataStructures
::
DedicationType
&
dedicationType
);
cta
::
common
::
dataStructures
::
DedicationType
getDedicationType
()
const
;
void
setDriveName
(
const
std
::
string
&
driveName
);
std
::
string
getDriveName
()
const
;
...
...
@@ -58,9 +62,6 @@ public:
void
setLastModificationLog
(
const
cta
::
common
::
dataStructures
::
EntryLog
&
lastModificationLog
);
cta
::
common
::
dataStructures
::
EntryLog
getLastModificationLog
()
const
;
void
setReadonly
(
const
bool
readonly
);
bool
getReadonly
()
const
;
void
setTag
(
const
std
::
string
&
tag
);
std
::
string
getTag
()
const
;
...
...
@@ -72,9 +73,6 @@ public:
void
setVid
(
const
std
::
string
&
vid
);
std
::
string
getVid
()
const
;
void
setWriteonly
(
const
bool
writeonly
);
bool
getWriteonly
()
const
;
private:
...
...
@@ -90,6 +88,9 @@ private:
cta
::
common
::
dataStructures
::
EntryLog
m_creationLog
;
bool
m_creationLogSet
;
cta
::
common
::
dataStructures
::
DedicationType
m_dedicationType
;
bool
m_dedicationTypeSet
;
std
::
string
m_driveName
;
bool
m_driveNameSet
;
...
...
@@ -99,9 +100,6 @@ private:
cta
::
common
::
dataStructures
::
EntryLog
m_lastModificationLog
;
bool
m_lastModificationLogSet
;
bool
m_readonly
;
bool
m_readonlySet
;
std
::
string
m_tag
;
bool
m_tagSet
;
...
...
@@ -114,9 +112,6 @@ private:
std
::
string
m_vid
;
bool
m_vidSet
;
bool
m_writeonly
;
bool
m_writeonlySet
;
};
// class Dedication
}
// namespace dataStructures
...
...
common/dataStructures/DedicationType.hpp
0 → 100644
View file @
67dc8577
/*
* 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
namespace
cta
{
namespace
common
{
namespace
dataStructures
{
enum
DedicationType
{
readonly
,
writeonly
,
readwrite
};
}
// namespace dataStructures
}
// namespace common
}
// namespace cta
doc/4_5_Scheduler_Interface.txt
View file @
67dc8577
...
...
@@ -161,12 +161,11 @@ virtual void modifyUserGroup
virtual void modifyUserGroupMaxDrivesAllowed (const SecurityIdentity &requester, const std::string &name, const uint64_t maxDrivesAllowed);
virtual void modifyUserGroupComment (const SecurityIdentity &requester, const std::string &name, const std::string &comment);
virtual void createDedication (const SecurityIdentity &requester, const std::string &drivename, const
bool readonly, const bool writeonly
, const std::string &userGroup,
virtual void createDedication (const SecurityIdentity &requester, const std::string &drivename, const
DedicationType dedicationType
, const std::string &userGroup,
const std::string &tag, const std::string &vid, const uint64_t fromTimestamp, const uint64_t untilTimestamp,const std::string &comment);
virtual void deleteDedication (const SecurityIdentity &requester, const std::string &drivename);
virtual std::list<Dedication> getDedications (const SecurityIdentity &requester) const;
virtual void modifyDedicationReadonly (const SecurityIdentity &requester, const std::string &drivename, const bool readonly);
virtual void modifyDedicationWriteonly (const SecurityIdentity &requester, const std::string &drivename, const bool writeonly);
virtual void modifyDedicationType (const SecurityIdentity &requester, const std::string &drivename, const cta::common::dataStructures::DedicationType dedicationType);
virtual void modifyDedicationUserGroup (const SecurityIdentity &requester, const std::string &drivename, const std::string &userGroup);
virtual void modifyDedicationTag (const SecurityIdentity &requester, const std::string &drivename, const std::string &tag);
virtual void modifyDedicationVid (const SecurityIdentity &requester, const std::string &drivename, const std::string &vid);
...
...
@@ -300,6 +299,14 @@ enum repackType {
}; // enum repackType
enum dedicationType {
readonly,
writeonly,
readwrite
}; // enum dedicationType
struct RepackInfo {
std::string vid;
...
...
doc/7_Catalogue_Interface.txt
View file @
67dc8577
...
...
@@ -72,12 +72,11 @@ virtual void modifyUserGroup
virtual void modifyUserGroupMaxDrivesAllowed (const SecurityIdentity &requester, const std::string &name, const uint64_t maxDrivesAllowed);
virtual void modifyUserGroupComment (const SecurityIdentity &requester, const std::string &name, const std::string &comment);
virtual void createDedication (const SecurityIdentity &requester, const std::string &drivename, const
bool readonly, const bool writeonly
, const std::string &userGroup,
virtual void createDedication (const SecurityIdentity &requester, const std::string &drivename, const
DedicationType dedicationType
, const std::string &userGroup,
const std::string &tag, const std::string &vid, const uint64_t fromTimestamp, const uint64_t untilTimestamp,const std::string &comment);
virtual void deleteDedication (const SecurityIdentity &requester, const std::string &drivename);
virtual std::list<Dedication> getDedications (const SecurityIdentity &requester) const;
virtual void modifyDedicationReadonly (const SecurityIdentity &requester, const std::string &drivename, const bool readonly);
virtual void modifyDedicationWriteonly (const SecurityIdentity &requester, const std::string &drivename, const bool writeonly);
virtual void modifyDedicationType (const SecurityIdentity &requester, const std::string &drivename, const cta::common::dataStructures::DedicationType dedicationType);
virtual void modifyDedicationUserGroup (const SecurityIdentity &requester, const std::string &drivename, const std::string &userGroup);
virtual void modifyDedicationTag (const SecurityIdentity &requester, const std::string &drivename, const std::string &tag);
virtual void modifyDedicationVid (const SecurityIdentity &requester, const std::string &drivename, const std::string &vid);
...
...
scheduler/Scheduler.cpp
View file @
67dc8577
...
...
@@ -507,7 +507,7 @@ void cta::Scheduler::modifyUserGroupComment(const cta::common::dataStructures::S
//------------------------------------------------------------------------------
// createDedication
//------------------------------------------------------------------------------
void
cta
::
Scheduler
::
createDedication
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
bool
readonly
,
const
bool
writeonly
,
const
std
::
string
&
userGroup
,
void
cta
::
Scheduler
::
createDedication
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
cta
::
common
::
dataStructures
::
DedicationType
dedicationType
,
const
std
::
string
&
userGroup
,
const
std
::
string
&
tag
,
const
std
::
string
&
vid
,
const
uint64_t
fromTimestamp
,
const
uint64_t
untilTimestamp
,
const
std
::
string
&
comment
)
{
}
...
...
@@ -527,16 +527,9 @@ std::list<cta::common::dataStructures::Dedication> cta::Scheduler::getDedication
}
//------------------------------------------------------------------------------
// modifyDedication
Readonly
// modifyDedication
Type
//------------------------------------------------------------------------------
void
cta
::
Scheduler
::
modifyDedicationReadonly
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
bool
readonly
)
{
}
//------------------------------------------------------------------------------
// modifyDedicationWriteonly
//------------------------------------------------------------------------------
void
cta
::
Scheduler
::
modifyDedicationWriteonly
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
bool
writeonly
)
{
void
cta
::
Scheduler
::
modifyDedicationType
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
cta
::
common
::
dataStructures
::
DedicationType
dedicationType
)
{
}
...
...
scheduler/Scheduler.hpp
View file @
67dc8577
...
...
@@ -30,6 +30,7 @@
#include
"common/dataStructures/ArchiveRoute.hpp"
#include
"common/dataStructures/CancelRetrieveRequest.hpp"
#include
"common/dataStructures/Dedication.hpp"
#include
"common/dataStructures/DedicationType.hpp"
#include
"common/dataStructures/DeleteArchiveRequest.hpp"
#include
"common/dataStructures/DRData.hpp"
#include
"common/dataStructures/DriveState.hpp"
...
...
@@ -177,12 +178,11 @@ public:
virtual
void
modifyUserGroupMaxDrivesAllowed
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
name
,
const
uint64_t
maxDrivesAllowed
);
virtual
void
modifyUserGroupComment
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
name
,
const
std
::
string
&
comment
);
virtual
void
createDedication
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
bool
readonly
,
const
bool
writeonly
,
const
std
::
string
&
userGroup
,
virtual
void
createDedication
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
cta
::
common
::
dataStructures
::
DedicationType
dedicationType
,
const
std
::
string
&
userGroup
,
const
std
::
string
&
tag
,
const
std
::
string
&
vid
,
const
uint64_t
fromTimestamp
,
const
uint64_t
untilTimestamp
,
const
std
::
string
&
comment
);
virtual
void
deleteDedication
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
);
virtual
std
::
list
<
cta
::
common
::
dataStructures
::
Dedication
>
getDedications
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
)
const
;
virtual
void
modifyDedicationReadonly
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
bool
readonly
);
virtual
void
modifyDedicationWriteonly
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
bool
writeonly
);
virtual
void
modifyDedicationType
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
cta
::
common
::
dataStructures
::
DedicationType
dedicationType
);
virtual
void
modifyDedicationUserGroup
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
std
::
string
&
userGroup
);
virtual
void
modifyDedicationTag
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
std
::
string
&
tag
);
virtual
void
modifyDedicationVid
(
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
,
const
std
::
string
&
drivename
,
const
std
::
string
&
vid
);
...
...
xroot_plugins/XrdCtaFile.cpp
View file @
67dc8577
...
...
@@ -30,6 +30,7 @@
#include
<pwd.h>
#include
<sstream>
#include
<string>
#include
<time.h>
namespace
cta
{
namespace
xrootPlugins
{
...
...
@@ -1164,6 +1165,143 @@ void XrdProFile::xCom_dedication(const std::vector<std::string> &tokens, const c
<<
"
\t
ch --name/-n <drive_name> [--readonly/-r or --writeonly/-w] [--usergroup/-u <user_group_name>] [--vid/-v <tape_vid>] [--tag/-t <tag_name>] [--from/-f <DD/MM/YYYY>] [--until/-u <DD/MM/YYYY>] [--comment/-m <
\"
comment
\"
>]"
<<
std
::
endl
<<
"
\t
rm --name/-n <drive_name>"
<<
std
::
endl
<<
"
\t
ls"
<<
std
::
endl
;
if
(
"add"
==
tokens
[
2
]
||
"ch"
==
tokens
[
2
]
||
"rm"
==
tokens
[
2
])
{
std
::
string
drive
=
getOptionValue
(
tokens
,
"-n"
,
"--name"
);
if
(
drive
.
empty
())
{
m_data
=
help
.
str
();
return
;
}
if
(
"add"
==
tokens
[
2
]
||
"ch"
==
tokens
[
2
])
{
bool
readonly
=
hasOption
(
tokens
,
"-r"
,
"--readonly"
);
bool
writeonly
=
hasOption
(
tokens
,
"-w"
,
"--writeonly"
);
std
::
string
usergroup
=
getOptionValue
(
tokens
,
"-u"
,
"--usergroup"
);
std
::
string
vid
=
getOptionValue
(
tokens
,
"-v"
,
"--vid"
);
std
::
string
tag
=
getOptionValue
(
tokens
,
"-t"
,
"--tag"
);
std
::
string
from_s
=
getOptionValue
(
tokens
,
"-f"
,
"--from"
);
std
::
string
until_s
=
getOptionValue
(
tokens
,
"-u"
,
"--until"
);
std
::
string
comment
=
getOptionValue
(
tokens
,
"-m"
,
"--comment"
);
if
(
"add"
==
tokens
[
2
])
{
//add
if
(
comment
.
empty
()
||
from_s
.
empty
()
||
until_s
.
empty
()
||
(
usergroup
.
empty
()
&&
vid
.
empty
()
&&
tag
.
empty
()
&&!
readonly
&&!
writeonly
)
||
(
readonly
&&
writeonly
))
{
m_data
=
help
.
str
();
return
;
}
struct
tm
time
;
if
(
NULL
==
strptime
(
from_s
.
c_str
(),
"%d/%m/%Y"
,
&
time
))
{
m_data
=
help
.
str
();
return
;
}
time_t
from
=
mktime
(
&
time
);
// timestamp in current timezone
if
(
NULL
==
strptime
(
until_s
.
c_str
(),
"%d/%m/%Y"
,
&
time
))
{
m_data
=
help
.
str
();
return
;
}
time_t
until
=
mktime
(
&
time
);
// timestamp in current timezone
cta
::
common
::
dataStructures
::
DedicationType
type
=
cta
::
common
::
dataStructures
::
DedicationType
::
readwrite
;
if
(
readonly
)
{
type
=
cta
::
common
::
dataStructures
::
DedicationType
::
readonly
;
}
else
if
(
writeonly
)
{
type
=
cta
::
common
::
dataStructures
::
DedicationType
::
writeonly
;
}
m_scheduler
->
createDedication
(
requester
,
drive
,
type
,
usergroup
,
tag
,
vid
,
from
,
until
,
comment
);
}
else
if
(
"ch"
==
tokens
[
2
])
{
//ch
if
((
comment
.
empty
()
&&
from_s
.
empty
()
&&
until_s
.
empty
()
&&
usergroup
.
empty
()
&&
vid
.
empty
()
&&
tag
.
empty
()
&&!
readonly
&&!
writeonly
)
||
(
readonly
&&
writeonly
))
{
m_data
=
help
.
str
();
return
;
}
if
(
!
comment
.
empty
())
{
m_scheduler
->
modifyDedicationComment
(
requester
,
drive
,
comment
);
}
if
(
!
from_s
.
empty
())
{
struct
tm
time
;
if
(
NULL
==
strptime
(
from_s
.
c_str
(),
"%d/%m/%Y"
,
&
time
))
{
m_data
=
help
.
str
();
return
;
}
time_t
from
=
mktime
(
&
time
);
// timestamp in current timezone
m_scheduler
->
modifyDedicationFrom
(
requester
,
drive
,
from
);
}
if
(
!
until_s
.
empty
())
{
struct
tm
time
;
if
(
NULL
==
strptime
(
until_s
.
c_str
(),
"%d/%m/%Y"
,
&
time
))
{
m_data
=
help
.
str
();
return
;
}
time_t
until
=
mktime
(
&
time
);
// timestamp in current timezone
m_scheduler
->
modifyDedicationUntil
(
requester
,
drive
,
until
);
}
if
(
!
usergroup
.
empty
())
{
m_scheduler
->
modifyDedicationUserGroup
(
requester
,
drive
,
usergroup
);
}
if
(
!
vid
.
empty
())
{
m_scheduler
->
modifyDedicationVid
(
requester
,
drive
,
vid
);
}
if
(
!
tag
.
empty
())
{
m_scheduler
->
modifyDedicationTag
(
requester
,
drive
,
tag
);
}
if
(
readonly
)
{
m_scheduler
->
modifyDedicationType
(
requester
,
drive
,
cta
::
common
::
dataStructures
::
DedicationType
::
readonly
);
}
if
(
writeonly
)
{
m_scheduler
->
modifyDedicationType
(
requester
,
drive
,
cta
::
common
::
dataStructures
::
DedicationType
::
writeonly
);
}
}
}
else
{
//rm
m_scheduler
->
deleteDedication
(
requester
,
drive
);
}
}
else
if
(
"ls"
==
tokens
[
2
])
{
//ls
std
::
list
<
cta
::
common
::
dataStructures
::
Dedication
>
list
=
m_scheduler
->
getDedications
(
requester
);
if
(
list
.
size
()
>
0
)
{
std
::
vector
<
std
::
vector
<
std
::
string
>>
responseTable
;
std
::
vector
<
std
::
string
>
header
=
{
"drive"
,
"type"
,
"vid"
,
"user group"
,
"tag"
,
"from"
,
"until"
,
"c.uid"
,
"c.gid"
,
"c.host"
,
"c.time"
,
"m.uid"
,
"m.gid"
,
"m.host"
,
"m.time"
,
"comment"
};
responseTable
.
push_back
(
header
);
for
(
auto
it
=
list
.
cbegin
();
it
!=
list
.
cend
();
it
++
)
{
std
::
vector
<
std
::
string
>
currentRow
;
std
::
string
type_s
;
switch
(
it
->
getDedicationType
())
{
case
cta
::
common
::
dataStructures
::
DedicationType
::
readonly
:
type_s
=
"readonly"
;
break
;
case
cta
::
common
::
dataStructures
::
DedicationType
::
writeonly
:
type_s
=
"writeonly"
;
break
;
default:
type_s
=
"readwrite"
;
break
;
}
char
timebuffer
[
100
];
time_t
fromtimeStamp
=
it
->
getFromTimestamp
();
time_t
untiltimeStamp
=
it
->
getUntilTimestamp
();
struct
tm
*
tm
=
localtime
(
&
fromtimeStamp
);
if
(
strftime
(
timebuffer
,
100
,
"%d/%m/%Y"
,
tm
)
==
0
)
{
m_data
=
"Error converting
\"
from
\"
date!
\n
"
;
}
std
::
string
fromTime_s
(
timebuffer
);
tm
=
localtime
(
&
untiltimeStamp
);
if
(
strftime
(
timebuffer
,
100
,
"%d/%m/%Y"
,
tm
)
==
0
)
{
m_data
=
"Error converting
\"
to
\"
date!
\n
"
;
}
std
::
string
untilTime_s
(
timebuffer
);
currentRow
.
push_back
(
it
->
getDriveName
());
currentRow
.
push_back
(
type_s
);
currentRow
.
push_back
(
it
->
getVid
());
currentRow
.
push_back
(
it
->
getUserGroup
());
currentRow
.
push_back
(
it
->
getTag
());
currentRow
.
push_back
(
fromTime_s
);
currentRow
.
push_back
(
untilTime_s
);
addLogInfoToResponseRow
(
currentRow
,
it
->
getCreationLog
(),
it
->
getLastModificationLog
());
currentRow
.
push_back
(
it
->
getComment
());
responseTable
.
push_back
(
currentRow
);
}
m_data
=
formatResponse
(
responseTable
);
}
}
else
{
m_data
=
help
.
str
();
}
}
//------------------------------------------------------------------------------
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment