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
b7cf19b4
Commit
b7cf19b4
authored
Apr 11, 2019
by
Cedric CAFFY
Committed by
Eric Cano
Apr 15, 2019
Browse files
Added support for json output of cta-admin ta ls command
Simple repack on CI
parent
5480c97c
Changes
7
Hide whitespace changes
Inline
Side-by-side
cmdline/CtaAdminCmd.cpp
View file @
b7cf19b4
...
...
@@ -69,6 +69,7 @@ void IStreamBuffer<cta::xrd::Data>::DataCallback(cta::xrd::Data record) const
case
Data
::
kLprItem
:
std
::
cout
<<
Log
::
DumpProtobuf
(
&
record
.
lpr_item
());
break
;
case
Data
::
kLprSummary
:
std
::
cout
<<
Log
::
DumpProtobuf
(
&
record
.
lpr_summary
());
break
;
case
Data
::
kTplsItem
:
std
::
cout
<<
Log
::
DumpProtobuf
(
&
record
.
tpls_item
());
break
;
case
Data
::
kTalsItem
:
std
::
cout
<<
Log
::
DumpProtobuf
(
&
record
.
tals_item
());
break
;
default:
throw
std
::
runtime_error
(
"Received invalid stream data from CTA Frontend."
);
}
...
...
@@ -84,6 +85,7 @@ void IStreamBuffer<cta::xrd::Data>::DataCallback(cta::xrd::Data record) const
case
Data
::
kLprItem
:
CtaAdminCmd
::
print
(
record
.
lpr_item
());
break
;
case
Data
::
kLprSummary
:
CtaAdminCmd
::
print
(
record
.
lpr_summary
());
break
;
case
Data
::
kTplsItem
:
CtaAdminCmd
::
print
(
record
.
tpls_item
());
break
;
case
Data
::
kTalsItem
:
CtaAdminCmd
::
print
(
record
.
tals_item
());
break
;
default:
throw
std
::
runtime_error
(
"Received invalid stream data from CTA Frontend."
);
}
...
...
@@ -226,6 +228,7 @@ void CtaAdminCmd::send() const
case
HeaderType
::
LISTPENDINGRETRIEVES
:
printLprHeader
();
break
;
case
HeaderType
::
LISTPENDINGRETRIEVES_SUMMARY
:
printLprSummaryHeader
();
break
;
case
HeaderType
::
TAPEPOOL_LS
:
printTpLsHeader
();
break
;
case
HeaderType
::
TAPE_LS
:
printTapeLsHeader
();
break
;
case
HeaderType
::
NONE
:
default:
break
;
}
...
...
@@ -643,6 +646,80 @@ void CtaAdminCmd::printTpLsHeader()
<<
TEXT_NORMAL
<<
std
::
endl
;
}
void
CtaAdminCmd
::
printTapeLsHeader
(){
std
::
cout
<<
TEXT_RED
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
7
)
<<
std
::
right
<<
"vid"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
10
)
<<
std
::
right
<<
"media type"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
7
)
<<
std
::
right
<<
"vendor"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
20
)
<<
std
::
right
<<
"logical library"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
18
)
<<
std
::
right
<<
"tapepool"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
10
)
<<
std
::
right
<<
"vo"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
20
)
<<
std
::
right
<<
"encryption key"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
std
::
right
<<
"capacity"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
std
::
right
<<
"occupancy"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
9
)
<<
std
::
right
<<
"last fseq"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
5
)
<<
std
::
right
<<
"full"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
8
)
<<
std
::
right
<<
"disabled"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
std
::
right
<<
"label drive"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
std
::
right
<<
"label time"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
std
::
right
<<
"last w drive"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
std
::
right
<<
"last w time"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
std
::
right
<<
"last r drive"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
std
::
right
<<
"last r time"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
20
)
<<
std
::
right
<<
"c.user"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
25
)
<<
std
::
right
<<
"c.host"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
13
)
<<
std
::
right
<<
"c.time"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
20
)
<<
std
::
right
<<
"m.user"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
25
)
<<
std
::
right
<<
"m.host"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
13
)
<<
std
::
right
<<
"m.time"
<<
' '
<<
"comment"
<<
' '
<<
TEXT_NORMAL
<<
std
::
endl
;
}
void
CtaAdminCmd
::
print
(
const
cta
::
admin
::
TapeLsItem
&
tals_item
){
std
::
cout
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
7
)
<<
std
::
right
<<
tals_item
.
vid
()
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
10
)
<<
std
::
right
<<
tals_item
.
media_type
()
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
7
)
<<
std
::
right
<<
tals_item
.
vendor
()
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
20
)
<<
std
::
right
<<
tals_item
.
logical_library
()
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
18
)
<<
std
::
right
<<
tals_item
.
tapepool
()
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
10
)
<<
std
::
right
<<
tals_item
.
vo
()
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
20
)
<<
std
::
right
<<
tals_item
.
encryption_key
()
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
std
::
right
<<
tals_item
.
capacity
()
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
std
::
right
<<
tals_item
.
occupancy
()
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
9
)
<<
std
::
right
<<
tals_item
.
last_fseq
()
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
5
)
<<
std
::
right
<<
tals_item
.
full
()
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
8
)
<<
std
::
right
<<
tals_item
.
disabled
()
<<
' '
;
if
(
tals_item
.
has_label_log
()){
std
::
cout
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
std
::
right
<<
tals_item
.
label_log
().
drive
()
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
std
::
right
<<
tals_item
.
label_log
().
time
()
<<
' '
;
}
else
{
std
::
cout
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
std
::
right
<<
"-"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
std
::
right
<<
"-"
<<
' '
;
}
if
(
tals_item
.
has_last_written_log
()){
std
::
cout
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
std
::
right
<<
tals_item
.
last_written_log
().
drive
()
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
std
::
right
<<
tals_item
.
last_written_log
().
time
()
<<
' '
;
}
else
{
std
::
cout
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
"-"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
"-"
<<
' '
;
}
if
(
tals_item
.
has_last_read_log
()){
std
::
cout
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
std
::
right
<<
tals_item
.
last_read_log
().
drive
()
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
std
::
right
<<
tals_item
.
last_read_log
().
time
()
<<
' '
;
}
else
{
std
::
cout
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
std
::
right
<<
"-"
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
12
)
<<
std
::
right
<<
"-"
<<
' '
;
}
std
::
cout
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
20
)
<<
std
::
right
<<
tals_item
.
creation_log
().
username
()
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
25
)
<<
std
::
right
<<
tals_item
.
creation_log
().
host
()
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
13
)
<<
std
::
right
<<
tals_item
.
creation_log
().
time
()
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
20
)
<<
std
::
right
<<
tals_item
.
last_modification_log
().
username
()
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
25
)
<<
std
::
right
<<
tals_item
.
last_modification_log
().
host
()
<<
' '
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
13
)
<<
std
::
right
<<
tals_item
.
last_modification_log
().
time
()
<<
' '
<<
std
::
endl
;
}
void
CtaAdminCmd
::
print
(
const
cta
::
admin
::
TapePoolLsItem
&
tpls_item
)
{
std
::
string
encrypt_str
=
tpls_item
.
encrypt
()
?
"true"
:
"false"
;
...
...
@@ -711,4 +788,3 @@ int main(int argc, const char **argv)
return
1
;
}
cmdline/CtaAdminCmd.hpp
View file @
b7cf19b4
...
...
@@ -57,7 +57,8 @@ public:
static
void
printLprHeader
();
static
void
printLprSummaryHeader
();
static
void
printTpLsHeader
();
static
void
printTapeLsHeader
();
// Output records
static
void
print
(
const
ArchiveFileLsItem
&
afls_item
);
static
void
print
(
const
ArchiveFileLsSummary
&
afls_summary
);
...
...
@@ -68,6 +69,7 @@ public:
static
void
print
(
const
ListPendingRetrievesItem
&
lpr_item
);
static
void
print
(
const
ListPendingRetrievesSummary
&
lpr_summary
);
static
void
print
(
const
TapePoolLsItem
&
tpls_item
);
static
void
print
(
const
cta
::
admin
::
TapeLsItem
&
tals_item
);
private:
//! Parse the options for a specific command/subcommand
...
...
continuousintegration/orchestration/tests/simple_repack.sh
View file @
b7cf19b4
...
...
@@ -28,25 +28,30 @@ if [ ! -z "${error}" ]; then
fi
executeReclaim
()
{
kubectl
-n
${
NAMESPACE
}
exec
ctacli
-ti
--
cta-admin ta reclaim
-v
$1
kubectl
-n
${
NAMESPACE
}
exec
ctacli
--
cta-admin ta reclaim
-v
$1
echo
"Tape
$1
reclaimed"
}
getVidToRepack
()
{
vidToRepack
=
$(
kubectl
-n
${
NAMESPACE
}
exec
ctacli
-ti
--
cta-admin
--json
ta
ls
--all
| jq
'[.[] | select(.occupancy != "0") | select(.lastFseq != 0) | .vid] | .[0]'
|
tr
-d
'"'
)
echo
$vidToRepack
}
executeRepack
()
{
WAIT_FOR_REPACK_FILE_TIMEOUT
=
300
echo
echo
"Changing the tape
$1
to FULL status"
kubectl
-n
${
NAMESPACE
}
exec
ctacli
-ti
--
cta-admin ta ch
-v
$1
-f
true
kubectl
-n
${
NAMESPACE
}
exec
ctacli
--
cta-admin ta ch
-v
$1
-f
true
echo
"Creating the eos directory to put the retrieve files from the repack request"
kubectl
-n
${
NAMESPACE
}
exec
ctacli
-ti
--
rm
-rf
root://ctaeos.cta.svc.cluster.local:1094//eos/ctaeos/repack
kubectl
-n
${
NAMESPACE
}
exec
ctaeos
-ti
--
eos
mkdir
/eos/ctaeos/repack
kubectl
-n
${
NAMESPACE
}
exec
ctaeos
-ti
--
eos
chmod
1777 /eos/ctaeos/repack
kubectl
-n
${
NAMESPACE
}
exec
ctacli
--
rm
-rf
root://ctaeos.cta.svc.cluster.local:1094//eos/ctaeos/repack
kubectl
-n
${
NAMESPACE
}
exec
ctaeos
--
eos
mkdir
/eos/ctaeos/repack
kubectl
-n
${
NAMESPACE
}
exec
ctaeos
--
eos
chmod
1777 /eos/ctaeos/repack
echo
"Removing an eventual previous repack request for tape
$1
"
kubectl
-n
${
NAMESPACE
}
exec
ctacli
-ti
--
cta-admin re
rm
-v
$1
kubectl
-n
${
NAMESPACE
}
exec
ctacli
--
cta-admin re
rm
-v
$1
echo
"Launching the repack request on tape
$1
"
kubectl
-n
${
NAMESPACE
}
exec
ctacli
-ti
--
cta-admin re add
-v
$1
-m
-b
root://ctaeos.cta.svc.cluster.local:1094//eos/ctaeos/repack
kubectl
-n
${
NAMESPACE
}
exec
ctacli
--
cta-admin re add
-v
$1
-m
-b
root://ctaeos.cta.svc.cluster.local:1094//eos/ctaeos/repack
SECONDS_PASSED
=
0
while
test
0
=
`
kubectl
-n
${
NAMESPACE
}
exec
ctacli
-ti
--
cta-admin re
ls
-v
$1
|
grep
-E
"Complete|Failed"
|
wc
-l
`
;
do
while
test
0
=
`
kubectl
-n
${
NAMESPACE
}
exec
ctacli
--
cta-admin re
ls
-v
$1
|
grep
-E
"Complete|Failed"
|
wc
-l
`
;
do
echo
"Waiting for repack request on tape
$1
to be complete: Seconds passed =
$SECONDS_PASSED
"
sleep
1
let
SECONDS_PASSED
=
SECONDS_PASSED+1
...
...
@@ -56,7 +61,7 @@ executeRepack() {
exit
1
fi
done
if
test
1
=
`
kubectl
-n
${
NAMESPACE
}
exec
ctacli
-ti
--
cta-admin re
ls
-v
$1
|
grep
-E
"Failed"
|
wc
-l
`
;
then
if
test
1
=
`
kubectl
-n
${
NAMESPACE
}
exec
ctacli
--
cta-admin re
ls
-v
$1
|
grep
-E
"Failed"
|
wc
-l
`
;
then
echo
"Repack failed for tape
$1
"
exit
1
fi
...
...
@@ -64,27 +69,39 @@ executeRepack() {
echo
"Execution of simple_repack.sh"
kubectl
-n
${
NAMESPACE
}
exec
ctacli
-ti
--
cta-admin ta
ls
--all
-h
executeRepack V01001
vidToRepack1
=
$(
getVidToRepack
)
if
[
"
$vidToRepack1
"
!=
"null"
]
then
executeRepack
$vidToRepack1
else
echo
"No vid found to repack"
exit
1
fi
sleep
1
echo
"Reclaiming tape
V0100
1"
executeReclaim
V0100
1
echo
"Reclaiming tape
$vidToRepack
1
"
executeReclaim
$vidToRepack
1
executeRepack V01003
vidToRepack2
=
$(
getVidToRepack
)
if
[
"
$vidToRepack2
"
!=
"null"
]
then
executeRepack
$vidToRepack2
else
echo
"No vid found to repack"
exit
1
fi
echo
echo
"Reclaiming tape
$vidToRepack2
"
executeReclaim
$vidToRepack2
echo
"Summary of the content of the tapes"
kubectl
-n
${
NAMESPACE
}
exec
ctacli
-ti
--
cta-admin ta
ls
-v
V0100
1
-h
kubectl
-n
${
NAMESPACE
}
exec
ctacli
-ti
--
cta-admin ta
ls
-v
V01003
-h
kubectl
-n
${
NAMESPACE
}
exec
ctacli
--
cta-admin ta
ls
-v
$vidToRepack
1
-h
kubectl
-n
${
NAMESPACE
}
exec
ctacli
--
cta-admin ta
ls
-v
$vidToRepack2
-h
echo
echo
"Summary of the repack requests"
kubectl
-n
${
NAMESPACE
}
exec
ctacli
-ti
--
cta-admin re
ls
-h
echo
"Reclaiming tape V01003"
executeReclaim V01003
kubectl
-n
${
NAMESPACE
}
exec
ctacli
--
cta-admin re
ls
-h
echo
"End of test simple_repack"
\ No newline at end of file
xroot_plugins/XrdCtaTapeLs.hpp
0 → 100644
View file @
b7cf19b4
/**
* The CERN Tape Archive (CTA) project
* Copyright © 2018 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
<XrdSsiPbOStreamBuffer.hpp>
#include
<catalogue/Catalogue.hpp>
#include
<xrootd/private/XrdSsi/XrdSsiStream.hh>
namespace
cta
{
namespace
xrd
{
/*!
* Stream object which implements "ta ls" command.
*/
class
TapeLsStream
:
public
XrdSsiStream
{
public:
TapeLsStream
(
cta
::
catalogue
::
Catalogue
&
catalogue
,
const
cta
::
catalogue
::
TapeSearchCriteria
&
searchCriteria
)
:
XrdSsiStream
(
XrdSsiStream
::
isActive
),
m_catalogue
(
catalogue
),
m_searchCriteria
(
searchCriteria
),
m_tapeList
(
catalogue
.
getTapes
(
searchCriteria
))
{
XrdSsiPb
::
Log
::
Msg
(
XrdSsiPb
::
Log
::
DEBUG
,
LOG_SUFFIX
,
"TapeLsStream() constructor"
);
}
virtual
~
TapeLsStream
(){
XrdSsiPb
::
Log
::
Msg
(
XrdSsiPb
::
Log
::
DEBUG
,
LOG_SUFFIX
,
"~TapeLsStream() destructor"
);
}
virtual
Buffer
*
GetBuff
(
XrdSsiErrInfo
&
eInfo
,
int
&
dlen
,
bool
&
last
)
override
{
XrdSsiPb
::
Log
::
Msg
(
XrdSsiPb
::
Log
::
DEBUG
,
LOG_SUFFIX
,
"GetBuff(): XrdSsi buffer fill request ("
,
dlen
,
" bytes)"
);
XrdSsiPb
::
OStreamBuffer
<
Data
>
*
streambuf
;
try
{
if
(
m_tapeList
.
empty
())
{
// Nothing more to send, close the stream
last
=
true
;
return
nullptr
;
}
streambuf
=
new
XrdSsiPb
::
OStreamBuffer
<
Data
>
(
dlen
);
for
(
bool
is_buffer_full
=
false
;
!
m_tapeList
.
empty
()
&&
!
is_buffer_full
;
m_tapeList
.
pop_front
()){
Data
record
;
auto
&
tape
=
m_tapeList
.
front
();
auto
tape_item
=
record
.
mutable_tals_item
();
tape_item
->
set_vid
(
tape
.
vid
);
tape_item
->
set_media_type
(
tape
.
mediaType
);
tape_item
->
set_vendor
(
tape
.
vendor
);
tape_item
->
set_logical_library
(
tape
.
logicalLibraryName
);
tape_item
->
set_tapepool
(
tape
.
tapePoolName
);
tape_item
->
set_vo
(
tape
.
vo
);
tape_item
->
set_encryption_key
((
bool
)
tape
.
encryptionKey
?
tape
.
encryptionKey
.
value
()
:
"-"
);
tape_item
->
set_capacity
(
tape
.
capacityInBytes
);
tape_item
->
set_occupancy
(
tape
.
dataOnTapeInBytes
);
tape_item
->
set_last_fseq
(
tape
.
lastFSeq
);
tape_item
->
set_full
(
tape
.
full
);
tape_item
->
set_disabled
(
tape
.
disabled
);
if
(
tape
.
labelLog
)
{
::
cta
::
common
::
TapeLog
*
labelLog
=
tape_item
->
mutable_label_log
();
labelLog
->
set_drive
(
tape
.
labelLog
.
value
().
drive
);
labelLog
->
set_time
(
tape
.
labelLog
.
value
().
time
);
}
if
(
tape
.
lastWriteLog
){
::
cta
::
common
::
TapeLog
*
lastWriteLog
=
tape_item
->
mutable_last_written_log
();
lastWriteLog
->
set_drive
(
tape
.
lastWriteLog
.
value
().
drive
);
lastWriteLog
->
set_time
(
tape
.
lastWriteLog
.
value
().
time
);
}
if
(
tape
.
lastReadLog
){
::
cta
::
common
::
TapeLog
*
lastReadLog
=
tape_item
->
mutable_last_read_log
();
lastReadLog
->
set_drive
(
tape
.
lastReadLog
.
value
().
drive
);
lastReadLog
->
set_time
(
tape
.
lastReadLog
.
value
().
time
);
}
::
cta
::
common
::
EntryLog
*
creationLog
=
tape_item
->
mutable_creation_log
();
creationLog
->
set_username
(
tape
.
creationLog
.
username
);
creationLog
->
set_host
(
tape
.
creationLog
.
host
);
creationLog
->
set_time
(
tape
.
creationLog
.
time
);
::
cta
::
common
::
EntryLog
*
lastModificationLog
=
tape_item
->
mutable_last_modification_log
();
lastModificationLog
->
set_username
(
tape
.
lastModificationLog
.
username
);
lastModificationLog
->
set_host
(
tape
.
lastModificationLog
.
host
);
lastModificationLog
->
set_time
(
tape
.
lastModificationLog
.
time
);
is_buffer_full
=
streambuf
->
Push
(
record
);
}
dlen
=
streambuf
->
Size
();
XrdSsiPb
::
Log
::
Msg
(
XrdSsiPb
::
Log
::
DEBUG
,
LOG_SUFFIX
,
"GetBuff(): Returning buffer with "
,
dlen
,
" bytes of data."
);
}
catch
(
cta
::
exception
::
Exception
&
ex
)
{
std
::
ostringstream
errMsg
;
errMsg
<<
__FUNCTION__
<<
" failed: Caught CTA exception: "
<<
ex
.
what
();
eInfo
.
Set
(
errMsg
.
str
().
c_str
(),
ECANCELED
);
delete
streambuf
;
}
catch
(
std
::
exception
&
ex
)
{
std
::
ostringstream
errMsg
;
errMsg
<<
__FUNCTION__
<<
" failed: "
<<
ex
.
what
();
eInfo
.
Set
(
errMsg
.
str
().
c_str
(),
ECANCELED
);
delete
streambuf
;
}
catch
(...)
{
std
::
ostringstream
errMsg
;
errMsg
<<
__FUNCTION__
<<
" failed: Caught an unknown exception"
;
eInfo
.
Set
(
errMsg
.
str
().
c_str
(),
ECANCELED
);
delete
streambuf
;
}
return
streambuf
;
}
private:
cta
::
catalogue
::
Catalogue
&
m_catalogue
;
const
cta
::
catalogue
::
TapeSearchCriteria
m_searchCriteria
;
std
::
list
<
common
::
dataStructures
::
Tape
>
m_tapeList
;
static
constexpr
const
char
*
const
LOG_SUFFIX
=
"TapeLsStream"
;
};
}}
xroot_plugins/XrdSsiCtaRequestMessage.cpp
View file @
b7cf19b4
...
...
@@ -30,6 +30,7 @@ using XrdSsiPb::PbException;
#include
"XrdCtaListPendingQueue.hpp"
#include
"XrdCtaTapePoolLs.hpp"
#include
"XrdSsiCtaRequestMessage.hpp"
#include
"XrdCtaTapeLs.hpp"
...
...
@@ -240,7 +241,8 @@ void RequestMessage::process(const cta::xrd::Request &request, cta::xrd::Respons
processTape_Reclaim
(
request
.
admincmd
(),
response
);
break
;
case
cmd_pair
(
AdminCmd
::
CMD_TAPE
,
AdminCmd
::
SUBCMD_LS
):
processTape_Ls
(
request
.
admincmd
(),
response
);
//processTape_Ls(request.admincmd(), response);
processTape_Ls
(
request
.
admincmd
(),
response
,
stream
);
break
;
case
cmd_pair
(
AdminCmd
::
CMD_TAPE
,
AdminCmd
::
SUBCMD_LABEL
):
processTape_Label
(
request
.
admincmd
(),
response
);
...
...
@@ -1852,16 +1854,51 @@ void RequestMessage::processTape_Reclaim(const cta::admin::AdminCmd &admincmd, c
response
.
set_type
(
cta
::
xrd
::
Response
::
RSP_SUCCESS
);
}
void
RequestMessage
::
processTape_Ls
(
const
cta
::
admin
::
AdminCmd
&
admincmd
,
cta
::
xrd
::
Response
&
response
,
XrdSsiStream
*
&
stream
)
{
using
namespace
cta
::
admin
;
cta
::
catalogue
::
TapeSearchCriteria
searchCriteria
;
if
(
!
has_flag
(
OptionBoolean
::
ALL
))
{
bool
has_any
=
false
;
// set to true if at least one optional option is set
// Get the search criteria from the optional options
searchCriteria
.
disabled
=
getOptional
(
OptionBoolean
::
DISABLED
,
&
has_any
);
searchCriteria
.
full
=
getOptional
(
OptionBoolean
::
FULL
,
&
has_any
);
searchCriteria
.
capacityInBytes
=
getOptional
(
OptionUInt64
::
CAPACITY
,
&
has_any
);
searchCriteria
.
logicalLibrary
=
getOptional
(
OptionString
::
LOGICAL_LIBRARY
,
&
has_any
);
searchCriteria
.
tapePool
=
getOptional
(
OptionString
::
TAPE_POOL
,
&
has_any
);
searchCriteria
.
vo
=
getOptional
(
OptionString
::
VO
,
&
has_any
);
searchCriteria
.
vid
=
getOptional
(
OptionString
::
VID
,
&
has_any
);
searchCriteria
.
mediaType
=
getOptional
(
OptionString
::
MEDIA_TYPE
,
&
has_any
);
searchCriteria
.
vendor
=
getOptional
(
OptionString
::
VENDOR
,
&
has_any
);
if
(
!
has_any
)
{
throw
cta
::
exception
::
UserError
(
"Must specify at least one search option, or --all"
);
}
}
void
RequestMessage
::
processTape_Ls
(
const
cta
::
admin
::
AdminCmd
&
admincmd
,
cta
::
xrd
::
Response
&
response
)
// Create a XrdSsi stream object to return the results
stream
=
new
TapeLsStream
(
m_catalogue
,
searchCriteria
);
// Should the client display column headers?
if
(
has_flag
(
OptionBoolean
::
SHOW_HEADER
))
{
response
.
set_show_header
(
HeaderType
::
TAPE_LS
);
}
response
.
set_type
(
cta
::
xrd
::
Response
::
RSP_SUCCESS
);
}
/*void RequestMessage::processTape_Ls(const cta::admin::AdminCmd &admincmd, cta::xrd::Response &response)
{
using namespace cta::admin;
std::stringstream cmdlineOutput;
cta::catalogue::TapeSearchCriteria searchCriteria;
if(!has_flag(OptionBoolean::ALL))
{
bool has_any = false; // set to true if at least one optional option is set
...
...
@@ -1885,8 +1922,47 @@ void RequestMessage::processTape_Ls(const cta::admin::AdminCmd &admincmd, cta::x
std::list<cta::common::dataStructures::Tape> list= m_catalogue.getTapes(searchCriteria);
TapeLsItem tapeList;
if(!list.empty())
{
for(auto it = list.cbegin(); it != list.cend(); it++) {
::cta::common::Tape * tapeToAdd = tapeList.add_tapes();
tapeToAdd->set_vid(it->vid);
tapeToAdd->set_media_type(it->mediaType);
tapeToAdd->set_vendor(it->vendor);
tapeToAdd->set_logical_library(it->logicalLibraryName);
tapeToAdd->set_tapepool(it->tapePoolName);
tapeToAdd->set_vo(it->vo);
tapeToAdd->set_encryption_key((bool)it->encryptionKey ? it->encryptionKey.value() : "-");
tapeToAdd->set_capacity(it->capacityInBytes);
tapeToAdd->set_occupancy(it->dataOnTapeInBytes);
tapeToAdd->set_last_fseq(it->lastFSeq);
tapeToAdd->set_full(it->full);
tapeToAdd->set_disabled(it->disabled);
if(it->labelLog) {
::cta::common::TapeLog * labelLog = tapeToAdd->mutable_label_log();
labelLog->set_drive(it->labelLog.value().drive);
labelLog->set_time(it->labelLog.value().time);
}
if(it->lastWriteLog){
::cta::common::TapeLog * lastWriteLog = tapeToAdd->mutable_last_written_log();
lastWriteLog->set_drive(it->lastWriteLog.value().drive);
lastWriteLog->set_time(it->lastWriteLog.value().time);
}
if(it->lastReadLog){
::cta::common::TapeLog * lastReadLog = tapeToAdd->mutable_last_read_log();
lastReadLog->set_drive(it->lastReadLog.value().drive);
lastReadLog->set_time(it->lastReadLog.value().time);
}
::cta::common::EntryLog * creationLog = tapeToAdd->mutable_creation_log();
creationLog->set_username(it->creationLog.username);
creationLog->set_host(it->creationLog.host);
creationLog->set_time(it->creationLog.time);
::cta::common::EntryLog * lastModificationLog = tapeToAdd->mutable_last_modification_log();
lastModificationLog->set_username(it->lastModificationLog.username);
lastModificationLog->set_host(it->lastModificationLog.host);
lastModificationLog->set_time(it->lastModificationLog.time);
}
std::vector<std::vector<std::string>> responseTable;
std::vector<std::string> header = {
"vid","media type","vendor","logical library","tapepool","vo","encryption key","capacity","occupancy",
...
...
@@ -1942,7 +2018,7 @@ void RequestMessage::processTape_Ls(const cta::admin::AdminCmd &admincmd, cta::x
response.set_message_txt(cmdlineOutput.str());
response.set_type(cta::xrd::Response::RSP_SUCCESS);
}
}
*/
...
...
xroot_plugins/XrdSsiCtaRequestMessage.hpp
View file @
b7cf19b4
...
...
@@ -117,7 +117,7 @@ private:
void
processTape_Ch
(
const
cta
::
admin
::
AdminCmd
&
admincmd
,
cta
::
xrd
::
Response
&
response
);
void
processTape_Rm
(
const
cta
::
admin
::
AdminCmd
&
admincmd
,
cta
::
xrd
::
Response
&
response
);
void
processTape_Reclaim
(
const
cta
::
admin
::
AdminCmd
&
admincmd
,
cta
::
xrd
::
Response
&
response
);
void
processTape_Ls
(
const
cta
::
admin
::
AdminCmd
&
admincmd
,
cta
::
xrd
::
Response
&
response
);
//
void processTape_Ls (const cta::admin::AdminCmd &admincmd, cta::xrd::Response &response);
void
processTape_Label
(
const
cta
::
admin
::
AdminCmd
&
admincmd
,
cta
::
xrd
::
Response
&
response
);
void
processTapePool_Add
(
const
cta
::
admin
::
AdminCmd
&
admincmd
,
cta
::
xrd
::
Response
&
response
);
void
processTapePool_Ch
(
const
cta
::
admin
::
AdminCmd
&
admincmd
,
cta
::
xrd
::
Response
&
response
);
...
...
@@ -145,6 +145,7 @@ private:
admincmdstream_t
processListPendingArchives
;
admincmdstream_t
processListPendingRetrieves
;
admincmdstream_t
processTapePool_Ls
;
admincmdstream_t
processTape_Ls
;
/*!
* Log an admin command
...
...
xrootd-ssi-protobuf-interface
@
11a19bea
Subproject commit
cd734fca3b169394d58f8d163e93d252abb
20d
5f
Subproject commit
11a19bead16966721e6caaa3804ad86291c
20d
38
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