Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dCache
cta
Commits
1d78c1aa
Commit
1d78c1aa
authored
8 years ago
by
Steven Murray
Browse files
Options
Downloads
Patches
Plain Diff
Implemented RdbmsCatalogue::modifyTapeEncryptionKey()
parent
c04dc7e6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
catalogue/CatalogueTest.cpp
+85
-0
85 additions, 0 deletions
catalogue/CatalogueTest.cpp
catalogue/RdbmsCatalogue.cpp
+30
-3
30 additions, 3 deletions
catalogue/RdbmsCatalogue.cpp
with
115 additions
and
3 deletions
catalogue/CatalogueTest.cpp
+
85
−
0
View file @
1d78c1aa
...
...
@@ -2417,6 +2417,91 @@ TEST_P(cta_catalogue_CatalogueTest, modifyTapeCapacityInBytes) {
}
}
TEST_P
(
cta_catalogue_CatalogueTest
,
modifyTapeEncryptionKey
)
{
using
namespace
cta
;
ASSERT_TRUE
(
m_catalogue
->
getTapes
().
empty
());
const
std
::
string
vid
=
"vid"
;
const
std
::
string
logicalLibraryName
=
"logical_library_name"
;
const
std
::
string
tapePoolName
=
"tape_pool_name"
;
const
std
::
string
encryptionKey
=
"encryption_key"
;
const
uint64_t
capacityInBytes
=
(
uint64_t
)
10
*
1000
*
1000
*
1000
*
1000
;
const
bool
disabledValue
=
true
;
const
bool
fullValue
=
false
;
const
std
::
string
comment
=
"Create tape"
;
m_catalogue
->
createLogicalLibrary
(
m_cliSI
,
logicalLibraryName
,
"Create logical library"
);
m_catalogue
->
createTapePool
(
m_cliSI
,
tapePoolName
,
2
,
true
,
"Create tape pool"
);
m_catalogue
->
createTape
(
m_cliSI
,
vid
,
logicalLibraryName
,
tapePoolName
,
encryptionKey
,
capacityInBytes
,
disabledValue
,
fullValue
,
comment
);
{
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
();
ASSERT_EQ
(
1
,
tapes
.
size
());
const
common
::
dataStructures
::
Tape
tape
=
tapes
.
front
();
ASSERT_EQ
(
vid
,
tape
.
vid
);
ASSERT_EQ
(
logicalLibraryName
,
tape
.
logicalLibraryName
);
ASSERT_EQ
(
tapePoolName
,
tape
.
tapePoolName
);
ASSERT_EQ
(
encryptionKey
,
tape
.
encryptionKey
);
ASSERT_EQ
(
capacityInBytes
,
tape
.
capacityInBytes
);
ASSERT_TRUE
(
disabledValue
==
tape
.
disabled
);
ASSERT_TRUE
(
fullValue
==
tape
.
full
);
ASSERT_EQ
(
comment
,
tape
.
comment
);
ASSERT_FALSE
(
tape
.
labelLog
);
ASSERT_FALSE
(
tape
.
lastReadLog
);
ASSERT_FALSE
(
tape
.
lastWriteLog
);
const
common
::
dataStructures
::
EntryLog
creationLog
=
tape
.
creationLog
;
ASSERT_EQ
(
m_cliSI
.
username
,
creationLog
.
username
);
ASSERT_EQ
(
m_cliSI
.
host
,
creationLog
.
host
);
const
common
::
dataStructures
::
EntryLog
lastModificationLog
=
tape
.
lastModificationLog
;
ASSERT_EQ
(
creationLog
,
lastModificationLog
);
}
const
std
::
string
modifiedEncryptionKey
=
"modified_encryption_key"
;
m_catalogue
->
modifyTapeEncryptionKey
(
m_cliSI
,
vid
,
modifiedEncryptionKey
);
{
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
();
ASSERT_EQ
(
1
,
tapes
.
size
());
const
common
::
dataStructures
::
Tape
tape
=
tapes
.
front
();
ASSERT_EQ
(
vid
,
tape
.
vid
);
ASSERT_EQ
(
logicalLibraryName
,
tape
.
logicalLibraryName
);
ASSERT_EQ
(
tapePoolName
,
tape
.
tapePoolName
);
ASSERT_EQ
(
modifiedEncryptionKey
,
tape
.
encryptionKey
);
ASSERT_EQ
(
capacityInBytes
,
tape
.
capacityInBytes
);
ASSERT_TRUE
(
disabledValue
==
tape
.
disabled
);
ASSERT_TRUE
(
fullValue
==
tape
.
full
);
ASSERT_EQ
(
comment
,
tape
.
comment
);
ASSERT_FALSE
(
tape
.
labelLog
);
ASSERT_FALSE
(
tape
.
lastReadLog
);
ASSERT_FALSE
(
tape
.
lastWriteLog
);
const
common
::
dataStructures
::
EntryLog
creationLog
=
tape
.
creationLog
;
ASSERT_EQ
(
m_cliSI
.
username
,
creationLog
.
username
);
ASSERT_EQ
(
m_cliSI
.
host
,
creationLog
.
host
);
}
}
TEST_P
(
cta_catalogue_CatalogueTest
,
modifyTapeEncryptionKey_nonExistentTape
)
{
using
namespace
cta
;
ASSERT_TRUE
(
m_catalogue
->
getTapes
().
empty
());
const
std
::
string
vid
=
"vid"
;
const
std
::
string
encryptionKey
=
"encryption_key"
;
ASSERT_THROW
(
m_catalogue
->
modifyTapeEncryptionKey
(
m_cliSI
,
vid
,
encryptionKey
),
exception
::
UserError
);
}
TEST_P
(
cta_catalogue_CatalogueTest
,
modifyTapeCapacityInBytes_nonExistentTape
)
{
using
namespace
cta
;
...
...
This diff is collapsed.
Click to expand it.
catalogue/RdbmsCatalogue.cpp
+
30
−
3
View file @
1d78c1aa
...
...
@@ -1877,8 +1877,35 @@ void RdbmsCatalogue::modifyTapeCapacityInBytes(const common::dataStructures::Sec
//------------------------------------------------------------------------------
// modifyTapeEncryptionKey
//------------------------------------------------------------------------------
void
RdbmsCatalogue
::
modifyTapeEncryptionKey
(
const
common
::
dataStructures
::
SecurityIdentity
&
cliIdentity
,
const
std
::
string
&
vid
,
const
std
::
string
&
encryptionKey
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" not implemented"
);
void
RdbmsCatalogue
::
modifyTapeEncryptionKey
(
const
common
::
dataStructures
::
SecurityIdentity
&
cliIdentity
,
const
std
::
string
&
vid
,
const
std
::
string
&
encryptionKey
)
{
try
{
const
time_t
now
=
time
(
nullptr
);
const
char
*
const
sql
=
"UPDATE TAPE SET "
"ENCRYPTION_KEY = :ENCRYPTION_KEY,"
"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
,
rdbms
::
Stmt
::
AutocommitMode
::
ON
);
stmt
->
bindString
(
":ENCRYPTION_KEY"
,
encryptionKey
);
stmt
->
bindString
(
":LAST_UPDATE_USER_NAME"
,
cliIdentity
.
username
);
stmt
->
bindString
(
":LAST_UPDATE_HOST_NAME"
,
cliIdentity
.
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
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed: "
+
ex
.
getMessage
().
str
());
}
}
//------------------------------------------------------------------------------
...
...
@@ -1959,7 +1986,7 @@ void RdbmsCatalogue::modifyRequesterGroupMountPolicy(const common::dataStructure
}
//------------------------------------------------------------------------------
// modifyRequesterComment
// modifyRequester
Group
Comment
//------------------------------------------------------------------------------
void
RdbmsCatalogue
::
modifyRequesterGroupComment
(
const
common
::
dataStructures
::
SecurityIdentity
&
cliIdentity
,
const
std
::
string
&
instanceName
,
const
std
::
string
&
requesterGroupName
,
const
std
::
string
&
comment
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" not implemented"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment