Commit 92b389c0 authored by Daniele Kruse's avatar Daniele Kruse
Browse files

Added logical library commands and the get archive jobs command

parent 410f7aec
......@@ -20,10 +20,11 @@ void CTACmd::usage(std::ostream &os) const throw() {
os <<
"Usage:\n"
"\t" << m_programName << " archive <source_file1> [<source_file2> [<source_file3> [...]]] <destination_path>\n"
"\t" << m_programName << " mkclass <storage_class_name> <number_of_tape_copies> <\"comment\">\n"
"\t" << m_programName << " getarchivejobs <tape_pool>\n"
"\t" << m_programName << " chdirclass <directory_name> <storage_class_name>\n"
"\t" << m_programName << " cldirclass <directory_name>\n"
"\t" << m_programName << " getdirclass <directory_name>\n"
"\t" << m_programName << " mkclass <storage_class_name> <number_of_tape_copies> <\"comment\">\n"
"\t" << m_programName << " rmclass <storage_class_name>\n"
"\t" << m_programName << " lsclass\n"
"\t" << m_programName << " mkdir <directory_name>\n"
......@@ -34,7 +35,10 @@ void CTACmd::usage(std::ostream &os) const throw() {
"\t" << m_programName << " lspool\n"
"\t" << m_programName << " mkroute <storage_class_name> <copy_number> <tapepool_name> <\"comment\">\n"
"\t" << m_programName << " rmroute <storage_class_name> <copy_number>\n"
"\t" << m_programName << " lsroute\n"
"\t" << m_programName << " lsroute\n"
"\t" << m_programName << " mkllib <logical_library_name> <\"comment\">\n"
"\t" << m_programName << " rmllib <logical_library_name>\n"
"\t" << m_programName << " lsllib\n"
"\t" << m_programName << " mkadminuser <uid> <gid>\n"
"\t" << m_programName << " rmadminuser <uid> <gid>\n"
"\t" << m_programName << " lsadminuser\n"
......
......@@ -138,6 +138,48 @@ int XrdProFilesystem::executeArchiveCommand(const ParsedRequest &req, XrdOucErrI
}
}
//------------------------------------------------------------------------------
// executeGetArchiveJobsCommand
//------------------------------------------------------------------------------
int XrdProFilesystem::executeGetArchiveJobsCommand(const ParsedRequest &req, XrdOucErrInfo &eInfo, const cta::SecurityIdentity &requester) {
if(req.args.size() != 1) {
std::string response = "[ERROR] Wrong number of arguments provided";
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
}
try {
std::list<cta::ArchiveJob> jobs = m_userApi.getArchiveJobs(requester, req.args.at(0));
std::ostringstream responseSS;
responseSS << "[OK] List of archive jobs for tape pool " << req.args.at(0) << ":\n";
for(std::list<cta::ArchiveJob>::iterator it = jobs.begin(); it != jobs.end(); it++) {
responseSS << "[OK]\t" << it->getId()
<< " " << it->getCreator().getUid()
<< " " << it->getCreator().getGid()
<< " " << it->getCreationTime()
<< " " << it->getState()
<< " " << it->getNbFailedFileTransfers()
<< " " << it->getTotalNbFileTransfers()
<< " " << it->getComment()<< "\n";
}
eInfo.setErrInfo(responseSS.str().length()+1, responseSS.str().c_str());
return SFS_DATA;
} catch (cta::Exception &ex) {
std::string response = "[ERROR] CTA exception caught: ";
response += ex.what();
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
} catch (std::exception &ex) {
std::string response = "[ERROR] Exception caught: ";
response += ex.what();
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
} catch (...) {
std::string response = "[ERROR] Unknown exception caught!";
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
}
}
//------------------------------------------------------------------------------
// executeMkclassCommand
//------------------------------------------------------------------------------
......@@ -670,6 +712,109 @@ int XrdProFilesystem::executeLsrouteCommand(const ParsedRequest &req, XrdOucErrI
}
}
//------------------------------------------------------------------------------
// executeMkllibCommand
//------------------------------------------------------------------------------
int XrdProFilesystem::executeMkllibCommand(const ParsedRequest &req, XrdOucErrInfo &eInfo, const cta::SecurityIdentity &requester) {
if(req.args.size() != 2) {
std::string response = "[ERROR] Wrong number of arguments provided";
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
}
try {
m_adminApi.createLogicalLibrary(requester, req.args.at(0), req.args.at(1));
std::ostringstream responseSS;
responseSS << "[OK] Logical library " << req.args.at(0) << " created with comment \"" << req.args.at(1) << "\"";
eInfo.setErrInfo(responseSS.str().length()+1, responseSS.str().c_str());
return SFS_DATA;
} catch (cta::Exception &ex) {
std::string response = "[ERROR] CTA exception caught: ";
response += ex.what();
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
} catch (std::exception &ex) {
std::string response = "[ERROR] Exception caught: ";
response += ex.what();
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
} catch (...) {
std::string response = "[ERROR] Unknown exception caught!";
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
}
}
//------------------------------------------------------------------------------
// executeRmllibCommand
//------------------------------------------------------------------------------
int XrdProFilesystem::executeRmllibCommand(const ParsedRequest &req, XrdOucErrInfo &eInfo, const cta::SecurityIdentity &requester) {
if(req.args.size() != 1) {
std::string response = "[ERROR] Wrong number of arguments provided";
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
}
try {
m_adminApi.deleteLogicalLibrary(requester, req.args.at(0));
std::ostringstream responseSS;
responseSS << "[OK] Logical library " << req.args.at(0) << " removed";
eInfo.setErrInfo(responseSS.str().length()+1, responseSS.str().c_str());
return SFS_DATA;
} catch (cta::Exception &ex) {
std::string response = "[ERROR] CTA exception caught: ";
response += ex.what();
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
} catch (std::exception &ex) {
std::string response = "[ERROR] Exception caught: ";
response += ex.what();
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
} catch (...) {
std::string response = "[ERROR] Unknown exception caught!";
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
}
}
//------------------------------------------------------------------------------
// executeLsllibCommand
//------------------------------------------------------------------------------
int XrdProFilesystem::executeLsllibCommand(const ParsedRequest &req, XrdOucErrInfo &eInfo, const cta::SecurityIdentity &requester) const {
if(req.args.size() != 0) {
std::string response = "[ERROR] Wrong number of arguments provided";
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
}
try {
std::list<cta::LogicalLibrary> llibs = m_adminApi.getLogicalLibraries(requester);
std::ostringstream responseSS;
responseSS << "[OK] Listing of the migration routes:";
for(std::list<cta::LogicalLibrary>::iterator it = llibs.begin(); it != llibs.end(); it++) {
responseSS << "\n" << it->getName()
<< " " << it->getCreator().getUid()
<< " " << it->getCreator().getGid()
<< " " << it->getCreationTime()
<< " \"" << it->getComment() << "\"";
}
eInfo.setErrInfo(responseSS.str().length()+1, responseSS.str().c_str());
return SFS_DATA;
} catch (cta::Exception &ex) {
std::string response = "[ERROR] CTA exception caught: ";
response += ex.what();
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
} catch (std::exception &ex) {
std::string response = "[ERROR] Exception caught: ";
response += ex.what();
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
} catch (...) {
std::string response = "[ERROR] Unknown exception caught!";
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
}
}
//------------------------------------------------------------------------------
// executeMkadminuserCommand
//------------------------------------------------------------------------------
......@@ -901,6 +1046,10 @@ int XrdProFilesystem::dispatchRequest(const XrdSfsFSctl &args, XrdOucErrInfo &eI
{
return executeArchiveCommand(req, eInfo, requester);
}
else if(strcmp(req.cmd.c_str(), "/getarchivejobs") == 0)
{
return executeGetArchiveJobsCommand(req, eInfo, requester);
}
else if(strcmp(req.cmd.c_str(), "/mkclass") == 0)
{
return executeMkclassCommand(req, eInfo, requester);
......@@ -960,6 +1109,18 @@ int XrdProFilesystem::dispatchRequest(const XrdSfsFSctl &args, XrdOucErrInfo &eI
else if(strcmp(req.cmd.c_str(), "/lsroute") == 0)
{
return executeLsrouteCommand(req, eInfo, requester);
}
else if(strcmp(req.cmd.c_str(), "/mkllib") == 0)
{
return executeMkllibCommand(req, eInfo, requester);
}
else if(strcmp(req.cmd.c_str(), "/rmllib") == 0)
{
return executeRmllibCommand(req, eInfo, requester);
}
else if(strcmp(req.cmd.c_str(), "/lsllib") == 0)
{
return executeLsllibCommand(req, eInfo, requester);
}
else if(strcmp(req.cmd.c_str(), "/mkadminuser") == 0)
{
......
......@@ -77,6 +77,16 @@ protected:
*/
int executeArchiveCommand(const ParsedRequest &req, XrdOucErrInfo &eInfo, const cta::SecurityIdentity &requester);
/**
* Executes the command contained within the request structure
*
* @param req parsed request
* @param eInfo Error information
* @param requester The UserIdentity structure of the requester
* @return SFS_DATA
*/
int executeGetArchiveJobsCommand(const ParsedRequest &req, XrdOucErrInfo &eInfo, const cta::SecurityIdentity &requester);
/**
* Executes the command contained within the request structure
*
......@@ -227,6 +237,36 @@ protected:
*/
int executeLsrouteCommand(const ParsedRequest &req, XrdOucErrInfo &eInfo, const cta::SecurityIdentity &requester) const;
/**
* Executes the command contained within the request structure
*
* @param req parsed request
* @param eInfo Error information
* @param requester The UserIdentity structure of the requester
* @return SFS_DATA
*/
int executeMkllibCommand(const ParsedRequest &req, XrdOucErrInfo &eInfo, const cta::SecurityIdentity &requester);
/**
* Executes the command contained within the request structure
*
* @param req parsed request
* @param eInfo Error information
* @param requester The UserIdentity structure of the requester
* @return SFS_DATA
*/
int executeRmllibCommand(const ParsedRequest &req, XrdOucErrInfo &eInfo, const cta::SecurityIdentity &requester);
/**
* Executes the command contained within the request structure
*
* @param req parsed request
* @param eInfo Error information
* @param requester The UserIdentity structure of the requester
* @return SFS_DATA
*/
int executeLsllibCommand(const ParsedRequest &req, XrdOucErrInfo &eInfo, const cta::SecurityIdentity &requester) const;
/**
* Executes the command contained within the request structure
*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment