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
a416f0ea
Commit
a416f0ea
authored
Aug 16, 2016
by
Steven Murray
Browse files
Added command-line tool cta-catalogue-schema-status
parent
6f94d002
Changes
8
Hide whitespace changes
Inline
Side-by-side
catalogue/CMakeLists.txt
View file @
a416f0ea
...
...
@@ -117,3 +117,14 @@ target_link_libraries (cta-catalogue-schema-unlock
install
(
TARGETS cta-catalogue-schema-unlock DESTINATION /usr/bin
)
install
(
FILES
${
CMAKE_CURRENT_SOURCE_DIR
}
/cta-catalogue-schema-unlock.1cta DESTINATION /usr/share/man/man1
)
add_executable
(
cta-catalogue-schema-status
SchemaStatusCmd.cpp
SchemaStatusCmdLineArgs.cpp
SchemaStatusCmdMain.cpp
)
target_link_libraries
(
cta-catalogue-schema-status
ctacatalogue
)
install
(
TARGETS cta-catalogue-schema-status DESTINATION /usr/bin
)
install
(
FILES
${
CMAKE_CURRENT_SOURCE_DIR
}
/cta-catalogue-schema-status.1cta DESTINATION /usr/share/man/man1
)
catalogue/SchemaStatusCmd.cpp
0 → 100644
View file @
a416f0ea
/*
* 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
"catalogue/CatalogueFactory.hpp"
#include
"catalogue/SchemaStatusCmd.hpp"
#include
"catalogue/SchemaStatusCmdLineArgs.hpp"
namespace
cta
{
namespace
catalogue
{
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
SchemaStatusCmd
::
SchemaStatusCmd
(
std
::
istream
&
inStream
,
std
::
ostream
&
outStream
,
std
::
ostream
&
errStream
)
:
CmdLineTool
(
inStream
,
outStream
,
errStream
)
{
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
SchemaStatusCmd
::~
SchemaStatusCmd
()
noexcept
{
}
//------------------------------------------------------------------------------
// exceptionThrowingMain
//------------------------------------------------------------------------------
int
SchemaStatusCmd
::
exceptionThrowingMain
(
const
int
argc
,
char
*
const
*
const
argv
)
{
const
SchemaStatusCmdLineArgs
cmdLineArgs
(
argc
,
argv
);
const
auto
dbLogin
=
rdbms
::
Login
::
parseFile
(
cmdLineArgs
.
dbConfigPath
);
const
uint64_t
nbDbConns
=
1
;
auto
catalogue
=
CatalogueFactory
::
create
(
dbLogin
,
nbDbConns
);
m_out
<<
(
catalogue
->
schemaIsLocked
()
?
"LOCKED"
:
"UNLOCKED"
)
<<
std
::
endl
;
return
0
;
}
}
// namespace catalogue
}
// namespace cta
catalogue/SchemaStatusCmd.hpp
0 → 100644
View file @
a416f0ea
/*
* 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
"catalogue/CmdLineTool.hpp"
namespace
cta
{
namespace
catalogue
{
/**
* Command-line tool for printing the current status of the catalogue schema.
*/
class
SchemaStatusCmd
:
public
CmdLineTool
{
public:
/**
* Constructor.
*
* @param inStream Standard input stream.
* @param outStream Standard output stream.
* @param errStream Standard error stream.
*/
SchemaStatusCmd
(
std
::
istream
&
inStream
,
std
::
ostream
&
outStream
,
std
::
ostream
&
errStream
);
/**
* Destructor.
*/
~
SchemaStatusCmd
()
noexcept
;
/**
* An exception throwing version of main().
*
* @param argc The number of command-line arguments including the program name.
* @param argv The command-line arguments.
* @return The exit value of the program.
*/
int
exceptionThrowingMain
(
const
int
argc
,
char
*
const
*
const
argv
);
};
// class SchemaStatusCmd
}
// namespace catalogue
}
// namespace cta
catalogue/SchemaStatusCmdLineArgs.cpp
0 → 100644
View file @
a416f0ea
/*
* 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
"catalogue/SchemaStatusCmdLineArgs.hpp"
#include
"common/exception/Exception.hpp"
#include
<ostream>
namespace
cta
{
namespace
catalogue
{
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
SchemaStatusCmdLineArgs
::
SchemaStatusCmdLineArgs
(
const
int
argc
,
const
char
*
const
*
const
argv
)
{
if
(
argc
!=
2
)
{
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"Wrong number of command-line arguments: excepted=1 actual="
<<
(
argc
-
1
)
<<
std
::
endl
<<
std
::
endl
;
printUsage
(
ex
.
getMessage
());
throw
ex
;
}
dbConfigPath
=
argv
[
1
];
}
//------------------------------------------------------------------------------
// printUsage
//------------------------------------------------------------------------------
void
SchemaStatusCmdLineArgs
::
printUsage
(
std
::
ostream
&
os
)
{
os
<<
"Usage:"
<<
std
::
endl
<<
" cta-catalogue-schema-status databaseConnectionFile"
<<
std
::
endl
<<
"Where:"
<<
std
::
endl
<<
" databaseConnectionFile"
<<
std
::
endl
<<
" The path to the file containing the connection details of the CTA"
<<
std
::
endl
<<
" catalogue database"
<<
std
::
endl
;
}
}
// namespace catalogue
}
// namespace cta
catalogue/SchemaStatusCmdLineArgs.hpp
0 → 100644
View file @
a416f0ea
/*
* 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
<string>
namespace
cta
{
namespace
catalogue
{
/**
* Structure to store the command-line arguments of the command-line tool
* named cta-catalogue-schema-status.
*/
struct
SchemaStatusCmdLineArgs
{
/**
* Path to the file containing the connection details of the catalogue
* database.
*/
std
::
string
dbConfigPath
;
/**
* Constructor that parses the specified command-line arguments.
*
* @param argc The number of command-line arguments including the name of the
* executable.
* @param argv The vector of command-line arguments.
*/
SchemaStatusCmdLineArgs
(
const
int
argc
,
const
char
*
const
*
const
argv
);
/**
* Prints the usage message of the command-line tool.
*
* @param os The output stream to which the usage message is to be printed.
*/
static
void
printUsage
(
std
::
ostream
&
os
);
};
}
// namespace catalogue
}
// namespace cta
catalogue/SchemaStatusCmdMain.cpp
0 → 100644
View file @
a416f0ea
/*
* 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
"catalogue/SchemaStatusCmd.hpp"
#include
"common/exception/Exception.hpp"
#include
<iostream>
/**
* An exception throwing version of main().
*
* @param argc The number of command-line arguments including the program name.
* @param argv The command-line arguments.
* @return The exit value of the program.
*/
static
int
exceptionThrowingMain
(
const
int
argc
,
char
*
const
*
const
argv
);
//------------------------------------------------------------------------------
// main
//------------------------------------------------------------------------------
int
main
(
const
int
argc
,
char
*
const
*
const
argv
)
{
using
namespace
cta
;
std
::
string
errorMessage
;
try
{
return
exceptionThrowingMain
(
argc
,
argv
);
}
catch
(
exception
::
Exception
&
ex
)
{
errorMessage
=
ex
.
getMessage
().
str
();
}
catch
(
std
::
exception
&
se
)
{
errorMessage
=
se
.
what
();
}
catch
(...)
{
errorMessage
=
"An unknown exception was thrown"
;
}
// Reaching this point means the command has failed, an exception was throw
// and errorMessage has been set accordingly
std
::
cerr
<<
"Aborting: "
<<
errorMessage
<<
std
::
endl
;
return
1
;
}
//------------------------------------------------------------------------------
// exceptionThrowingMain
//------------------------------------------------------------------------------
static
int
exceptionThrowingMain
(
const
int
argc
,
char
*
const
*
const
argv
)
{
using
namespace
cta
;
catalogue
::
SchemaStatusCmd
cmd
(
std
::
cin
,
std
::
cout
,
std
::
cerr
);
return
cmd
.
exceptionThrowingMain
(
argc
,
argv
);
}
catalogue/cta-catalogue-schema-status.1cta
0 → 100644
View file @
a416f0ea
.\" 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/>.
.TH CTA-CATALOGUE-SCHEMA-STATUS 1CTA "August 2016" CTA "CTA"
.SH NAME
cta-catalogue-schema-status \- Lock the CTA catalogue schema
.SH SYNOPSIS
.BI "cta-catalogue-schema-status databaseConnectionFile"
.SH DESCRIPTION
\fBcta-catalogue-schema-status\fP is a command-line tool that prints status of
the CTA catalogue database schema.
.P
.SH ARGUMENTS
.TP
\fBdatabaseConnectionFile
The path to the configuration file containing the connection details of the
CTA catalogue database.
.SH RETURN VALUE
Zero on success and non-zero on failure.
.SH EXAMPLES
cta-catalogue-schema-status /etc/cta/cta_catalogue_db.conf
.SH AUTHOR
\fBCTA\fP Team
cta.spec.in
View file @
a416f0ea
...
...
@@ -213,6 +213,8 @@ CERN Tape Archive:
Scripts and utilities to faciliate working with the CTA catalogue
%files -n cta-catalogueutils
%attr(0755,root,root) %{_bindir}/cta-catalogue-schema-lock
%attr(0755,root,root) %{_bindir}/cta-catalogue-schema-status
%attr(0755,root,root) %{_bindir}/cta-catalogue-schema-unlock
%attr(0644,root,bin) %doc /usr/share/man/man1/cta-catalogue-schema-lock.1cta.gz
%attr(0644,root,bin) %doc /usr/share/man/man1/cta-catalogue-schema-status.1cta.gz
%attr(0644,root,bin) %doc /usr/share/man/man1/cta-catalogue-schema-unlock.1cta.gz
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