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
8b245379
Commit
8b245379
authored
6 years ago
by
Michael Davis
Browse files
Options
Downloads
Patches
Plain Diff
[cta-admin] JSON output as an array of structs
parent
5b109e21
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
cmdline/CtaAdminCmd.cpp
+10
-4
10 additions, 4 deletions
cmdline/CtaAdminCmd.cpp
cmdline/CtaAdminCmd.hpp
+6
-0
6 additions, 0 deletions
cmdline/CtaAdminCmd.hpp
with
16 additions
and
4 deletions
cmdline/CtaAdminCmd.cpp
+
10
−
4
View file @
8b245379
...
...
@@ -59,12 +59,15 @@ void IStreamBuffer<cta::xrd::Data>::DataCallback(cta::xrd::Data record) const
// Output results in JSON format for parsing by a script
if
(
CtaAdminCmd
::
isJson
())
{
std
::
cout
<<
CtaAdminCmd
::
jsonDelim
()
<<
Log
::
DumpProtobuf
(
&
record
);
#if 0
switch(record.data_case()) {
case
Data
::
kAfItemFieldNumber
:
Log
::
DumpProtobuf
(
Log
::
ERROR
,
&
record
.
af_item
());
break
;
case
Data
::
kAfSummaryItemFieldNumber
:
Log
::
DumpProtobuf
(
Log
::
ERROR
,
&
record
.
af_summary_item
());
break
;
case Data::kAfItemFieldNumber:
std::cout <<
Log::DumpProtobuf(&record.af_item()); break;
case Data::kAfSummaryItemFieldNumber:
std::cout <<
Log::DumpProtobuf(&record.af_summary_item()); break;
default:
throw std::runtime_error("Received invalid stream data from CTA Frontend.");
}
#endif
return
;
}
...
...
@@ -103,7 +106,8 @@ void IStreamBuffer<cta::xrd::Data>::DataCallback(cta::xrd::Data record) const
namespace
cta
{
namespace
admin
{
bool
CtaAdminCmd
::
is_json
=
false
;
bool
CtaAdminCmd
::
is_json
=
false
;
bool
CtaAdminCmd
::
is_first_record
=
true
;
CtaAdminCmd
::
CtaAdminCmd
(
int
argc
,
const
char
*
const
*
const
argv
)
:
m_execname
(
argv
[
0
])
...
...
@@ -202,7 +206,6 @@ void CtaAdminCmd::send() const
throw
std
::
runtime_error
(
"Configuration error: cta.endpoint missing from "
+
config_file
);
}
// Obtain a Service Provider
XrdSsiPbServiceType
cta_service
(
config
);
...
...
@@ -239,6 +242,9 @@ void CtaAdminCmd::send() const
// If there is a Data/Stream payload, wait until it has been processed before exiting
stream_future
.
wait
();
// JSON output is an array of structs, close bracket
if
(
isJson
())
{
std
::
cout
<<
']'
;
}
}
...
...
This diff is collapsed.
Click to expand it.
cmdline/CtaAdminCmd.hpp
+
6
−
0
View file @
8b245379
...
...
@@ -37,6 +37,11 @@ public:
// Static methods to format streaming responses
static
bool
isJson
()
{
return
is_json
;
}
static
char
jsonDelim
()
{
char
c
=
is_first_record
?
'['
:
','
;
is_first_record
=
false
;
return
c
;
}
// "archivefile ls" command
static
void
printAfLsHeader
();
...
...
@@ -92,6 +97,7 @@ private:
cta
::
xrd
::
Request
m_request
;
//!< Protocol Buffer for the command and parameters
static
bool
is_json
;
//!< Display results in JSON format
static
bool
is_first_record
;
//!< Delimiter for JSON records
static
constexpr
const
char
*
const
TEXT_RED
=
"
\x1b
[31;1m"
;
//!< Terminal formatting code for red text
static
constexpr
const
char
*
const
TEXT_NORMAL
=
"
\x1b
[0m"
;
//!< Terminal formatting code for normal text
...
...
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