Skip to content
Snippets Groups Projects
Commit c58e0400 authored by Daniele Kruse's avatar Daniele Kruse
Browse files

Added tape commands

parent 39f28901
Branches
Tags
No related merge requests found
...@@ -38,7 +38,10 @@ void CTACmd::usage(std::ostream &os) const throw() { ...@@ -38,7 +38,10 @@ void CTACmd::usage(std::ostream &os) const throw() {
"\t" << m_programName << " lsroute\n" "\t" << m_programName << " lsroute\n"
"\t" << m_programName << " mkllib <logical_library_name> <\"comment\">\n" "\t" << m_programName << " mkllib <logical_library_name> <\"comment\">\n"
"\t" << m_programName << " rmllib <logical_library_name>\n" "\t" << m_programName << " rmllib <logical_library_name>\n"
"\t" << m_programName << " lsllib\n" "\t" << m_programName << " lsllib\n"
"\t" << m_programName << " mktape <vid> <logical_library_name> <tapepool_name> <capacity_in_bytes> <\"comment\">\n"
"\t" << m_programName << " rmtape <vid>\n"
"\t" << m_programName << " lstape\n"
"\t" << m_programName << " mkadminuser <uid> <gid>\n" "\t" << m_programName << " mkadminuser <uid> <gid>\n"
"\t" << m_programName << " rmadminuser <uid> <gid>\n" "\t" << m_programName << " rmadminuser <uid> <gid>\n"
"\t" << m_programName << " lsadminuser\n" "\t" << m_programName << " lsadminuser\n"
......
...@@ -815,6 +815,116 @@ int XrdProFilesystem::executeLsllibCommand(const ParsedRequest &req, XrdOucErrIn ...@@ -815,6 +815,116 @@ int XrdProFilesystem::executeLsllibCommand(const ParsedRequest &req, XrdOucErrIn
} }
} }
//------------------------------------------------------------------------------
// executeMktapeCommand
//------------------------------------------------------------------------------
int XrdProFilesystem::executeMktapeCommand(const ParsedRequest &req, XrdOucErrInfo &eInfo, const cta::SecurityIdentity &requester) {
if(req.args.size() != 5) {
std::string response = "[ERROR] Wrong number of arguments provided";
eInfo.setErrInfo(response.length()+1, response.c_str());
return SFS_DATA;
}
try {
uint64_t capacity;
std::istringstream ss(req.args.at(3));
ss >> capacity;
m_adminApi.createTape(requester, req.args.at(0), req.args.at(1), req.args.at(2), capacity, req.args.at(4));
std::ostringstream responseSS;
responseSS << "[OK] Tape " << req.args.at(0) << " of logical library " << req.args.at(1) << " of " << capacity << " bytes of capacity " << " was created in tapepool " << req.args.at(2) << " with comment \"" << req.args.at(4) << "\"";
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;
}
}
//------------------------------------------------------------------------------
// executeRmtapeCommand
//------------------------------------------------------------------------------
int XrdProFilesystem::executeRmtapeCommand(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.deleteTape(requester, req.args.at(0));
std::ostringstream responseSS;
responseSS << "[OK] Tape " << 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;
}
}
//------------------------------------------------------------------------------
// executeLstapeCommand
//------------------------------------------------------------------------------
int XrdProFilesystem::executeLstapeCommand(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::Tape> tapes = m_adminApi.getTapes(requester);
std::ostringstream responseSS;
responseSS << "[OK] Listing of tapes:";
for(std::list<cta::Tape>::iterator it = tapes.begin(); it != tapes.end(); it++) {
responseSS << "\n" << it->getVid()
<< " " << it->getCapacityInBytes()
<< " " << it->getDataOnTapeInBytes()
<< " " << it->getLogicalLibraryName()
<< " " << it->getTapePoolName()
<< " " << 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 // executeMkadminuserCommand
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -1121,6 +1231,18 @@ int XrdProFilesystem::dispatchRequest(const XrdSfsFSctl &args, XrdOucErrInfo &eI ...@@ -1121,6 +1231,18 @@ int XrdProFilesystem::dispatchRequest(const XrdSfsFSctl &args, XrdOucErrInfo &eI
else if(strcmp(req.cmd.c_str(), "/lsllib") == 0) else if(strcmp(req.cmd.c_str(), "/lsllib") == 0)
{ {
return executeLsllibCommand(req, eInfo, requester); return executeLsllibCommand(req, eInfo, requester);
}
else if(strcmp(req.cmd.c_str(), "/mktape") == 0)
{
return executeMktapeCommand(req, eInfo, requester);
}
else if(strcmp(req.cmd.c_str(), "/rmtape") == 0)
{
return executeRmtapeCommand(req, eInfo, requester);
}
else if(strcmp(req.cmd.c_str(), "/lstape") == 0)
{
return executeLstapeCommand(req, eInfo, requester);
} }
else if(strcmp(req.cmd.c_str(), "/mkadminuser") == 0) else if(strcmp(req.cmd.c_str(), "/mkadminuser") == 0)
{ {
......
...@@ -267,6 +267,36 @@ protected: ...@@ -267,6 +267,36 @@ protected:
*/ */
int executeLsllibCommand(const ParsedRequest &req, XrdOucErrInfo &eInfo, const cta::SecurityIdentity &requester) const; int executeLsllibCommand(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 executeMktapeCommand(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 executeRmtapeCommand(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 executeLstapeCommand(const ParsedRequest &req, XrdOucErrInfo &eInfo, const cta::SecurityIdentity &requester) const;
/** /**
* Executes the command contained within the request structure * Executes the command contained within the request structure
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment