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

Added more commands and fixed create-storage-class

parent 6e45991c
No related branches found
No related tags found
No related merge requests found
Showing
with 388 additions and 4 deletions
......@@ -19,7 +19,11 @@ CTACmd::CTACmd() throw(): m_programName("CTA_cmd") {
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 << " archive <source_file1> [<source_file2> [<source_file3> [...]]] <destination_path>\n"
"\t" << m_programName << " create-storage-class <storage_class_name> <number_of_tape_copies>\n"
"\t" << m_programName << " delete-storage-class <storage_class_name>\n"
"\t" << m_programName << " mkdir <directory_name>\n"
"\t" << m_programName << " rmdir <directory_name>\n";
}
//------------------------------------------------------------------------------
......
......@@ -4,4 +4,4 @@ list (APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
find_package (xrootd REQUIRED)
include_directories (${XROOTD_INCLUDE_DIR} ${XROOTD_PRIVATE_INCLUDE_DIR} ${CMAKE_SOURCE_DIR})
add_library (XrdProFst MODULE XrdProFilesystem.cpp ParsedArchiveCmdLine.cpp ParsedCreateStorageClassCmdLine.cpp)
add_library (XrdProFst MODULE XrdProFilesystem.cpp ParsedArchiveCmdLine.cpp ParsedCreateStorageClassCmdLine.cpp ParsedDeleteStorageClassCmdLine.cpp ParsedMkdirCmdLine.cpp ParsedRmdirCmdLine.cpp ParsedChangeStorageClassCmdLine.cpp)
#include "ParsedChangeStorageClassCmdLine.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
ParsedChangeStorageClassCmdLine::ParsedChangeStorageClassCmdLine() throw()
{
}
#pragma once
#include "XrdOuc/XrdOucString.hh"
#include <list>
#include <string>
/**
* Data type used to store the results of parsing the create-storage-class command-line.
*/
struct ParsedChangeStorageClassCmdLine {
/**
* The directory name
*/
std::string dirName;
/**
* The storage class name
*/
std::string storageClassName;
/**
* Constructor.
*/
ParsedChangeStorageClassCmdLine() throw();
}; // struct ParsedChangeStorageClassCmdLine
......@@ -3,7 +3,7 @@
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
ParsedCreateStorageClassCmdLine::ParsedCreateStorageClassCmdLine() throw()
ParsedCreateStorageClassCmdLine::ParsedCreateStorageClassCmdLine() throw(): numberOfCopies(0)
{
}
......@@ -15,6 +15,11 @@ struct ParsedCreateStorageClassCmdLine {
*/
std::string storageClassName;
/**
* The number of copies on tape
*/
int numberOfCopies;
/**
* Constructor.
*/
......
#include "ParsedDeleteStorageClassCmdLine.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
ParsedDeleteStorageClassCmdLine::ParsedDeleteStorageClassCmdLine() throw()
{
}
#pragma once
#include "XrdOuc/XrdOucString.hh"
#include <list>
#include <string>
/**
* Data type used to store the results of parsing the delete-storage-class command-line.
*/
struct ParsedDeleteStorageClassCmdLine {
/**
* The storage class name
*/
std::string storageClassName;
/**
* Constructor.
*/
ParsedDeleteStorageClassCmdLine() throw();
}; // struct ParsedDeleteStorageClassCmdLine
#include "ParsedMkdirCmdLine.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
ParsedMkdirCmdLine::ParsedMkdirCmdLine() throw()
{
}
#pragma once
#include "XrdOuc/XrdOucString.hh"
#include <list>
#include <string>
/**
* Data type used to store the results of parsing the mkdir command-line.
*/
struct ParsedMkdirCmdLine {
/**
* The directory name
*/
std::string dirName;
/**
* Constructor.
*/
ParsedMkdirCmdLine() throw();
}; // struct ParsedMkdirCmdLine
#include "ParsedRmdirCmdLine.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
ParsedRmdirCmdLine::ParsedRmdirCmdLine() throw()
{
}
#pragma once
#include "XrdOuc/XrdOucString.hh"
#include <list>
#include <string>
/**
* Data type used to store the results of parsing the rmdir command-line.
*/
struct ParsedRmdirCmdLine {
/**
* The directory name
*/
std::string dirName;
/**
* Constructor.
*/
ParsedRmdirCmdLine() throw();
}; // struct ParsedRmdirCmdLine
......@@ -123,7 +123,9 @@ int XrdProFilesystem::parseCreateStorageClassRequest(const XrdSfsFSctl &args, Pa
getline(ss, s, '?');
getline(ss, s, '+');
cmdLine.storageClassName = s;
if(cmdLine.storageClassName.empty()) {
getline(ss, s, '+');
cmdLine.numberOfCopies = atoi(s.c_str());
if(cmdLine.storageClassName.empty() || cmdLine.numberOfCopies==0) {
eInfo.setErrInfo(EINVAL, "[ERROR] Wrong arguments supplied");
return SFS_ERROR;
}
......@@ -136,6 +138,110 @@ int XrdProFilesystem::parseCreateStorageClassRequest(const XrdSfsFSctl &args, Pa
int XrdProFilesystem::executeCreateStorageClassCommand(ParsedCreateStorageClassCmdLine &cmdLine, XrdOucErrInfo &eInfo) {
std::cout << "create-storage-class request received:\n";
std::cout << "NAME: " << cmdLine.storageClassName << std::endl;
std::cout << "Number of copies on tape: " << cmdLine.numberOfCopies << std::endl;
return SFS_OK;
}
//------------------------------------------------------------------------------
// parseChangeStorageClassRequest
//------------------------------------------------------------------------------
int XrdProFilesystem::parseChangeStorageClassRequest(const XrdSfsFSctl &args, ParsedChangeStorageClassCmdLine &cmdLine, XrdOucErrInfo &eInfo) {
std::stringstream ss(args.Arg1);
std::string s;
getline(ss, s, '?');
getline(ss, s, '+');
cmdLine.dirName = s;
getline(ss, s, '+');
cmdLine.storageClassName = s;
if(cmdLine.storageClassName.empty() || cmdLine.dirName.empty()) {
eInfo.setErrInfo(EINVAL, "[ERROR] Wrong arguments supplied");
return SFS_ERROR;
}
return SFS_OK;
}
//------------------------------------------------------------------------------
// executeCreateStorageClassCommand
//------------------------------------------------------------------------------
int XrdProFilesystem::executeChangeStorageClassCommand(ParsedChangeStorageClassCmdLine &cmdLine, XrdOucErrInfo &eInfo) {
std::cout << "change-storage-class request received:\n";
std::cout << "DIR: " << cmdLine.dirName << std::endl;
std::cout << "NAME: " << cmdLine.storageClassName << std::endl;
return SFS_OK;
}
//------------------------------------------------------------------------------
// parseDeleteStorageClassRequest
//------------------------------------------------------------------------------
int XrdProFilesystem::parseDeleteStorageClassRequest(const XrdSfsFSctl &args, ParsedDeleteStorageClassCmdLine &cmdLine, XrdOucErrInfo &eInfo) {
std::stringstream ss(args.Arg1);
std::string s;
getline(ss, s, '?');
getline(ss, s, '+');
cmdLine.storageClassName = s;
if(cmdLine.storageClassName.empty()) {
eInfo.setErrInfo(EINVAL, "[ERROR] Wrong arguments supplied");
return SFS_ERROR;
}
return SFS_OK;
}
//------------------------------------------------------------------------------
// executeDeleteStorageClassCommand
//------------------------------------------------------------------------------
int XrdProFilesystem::executeDeleteStorageClassCommand(ParsedDeleteStorageClassCmdLine &cmdLine, XrdOucErrInfo &eInfo) {
std::cout << "delete-storage-class request received:\n";
std::cout << "NAME: " << cmdLine.storageClassName << std::endl;
return SFS_OK;
}
//------------------------------------------------------------------------------
// parseMkdirRequest
//------------------------------------------------------------------------------
int XrdProFilesystem::parseMkdirRequest(const XrdSfsFSctl &args, ParsedMkdirCmdLine &cmdLine, XrdOucErrInfo &eInfo) {
std::stringstream ss(args.Arg1);
std::string s;
getline(ss, s, '?');
getline(ss, s, '+');
cmdLine.dirName = s;
if(cmdLine.dirName.empty()) {
eInfo.setErrInfo(EINVAL, "[ERROR] Wrong arguments supplied");
return SFS_ERROR;
}
return SFS_OK;
}
//------------------------------------------------------------------------------
// executeMkdirCommand
//------------------------------------------------------------------------------
int XrdProFilesystem::executeMkdirCommand(ParsedMkdirCmdLine &cmdLine, XrdOucErrInfo &eInfo) {
std::cout << "mkdir request received:\n";
std::cout << "DIR: " << cmdLine.dirName << std::endl;
return SFS_OK;
}
//------------------------------------------------------------------------------
// parseRmdirRequest
//------------------------------------------------------------------------------
int XrdProFilesystem::parseRmdirRequest(const XrdSfsFSctl &args, ParsedRmdirCmdLine &cmdLine, XrdOucErrInfo &eInfo) {
std::stringstream ss(args.Arg1);
std::string s;
getline(ss, s, '?');
getline(ss, s, '+');
cmdLine.dirName = s;
if(cmdLine.dirName.empty()) {
eInfo.setErrInfo(EINVAL, "[ERROR] Wrong arguments supplied");
return SFS_ERROR;
}
return SFS_OK;
}
//------------------------------------------------------------------------------
// executeRmdirCommand
//------------------------------------------------------------------------------
int XrdProFilesystem::executeRmdirCommand(ParsedRmdirCmdLine &cmdLine, XrdOucErrInfo &eInfo) {
std::cout << "rmdir request received:\n";
std::cout << "DIR: " << cmdLine.dirName << std::endl;
return SFS_OK;
}
......@@ -168,6 +274,58 @@ int XrdProFilesystem::dispatchRequest(XrdSfsFSctl &args, XrdOucErrInfo &eInfo) {
return checkExecute;
}
return SFS_OK;
}
else if(strncmp(args.Arg1, "/change-storage-class?", strlen("/change-storage-class?")) == 0)
{
ParsedChangeStorageClassCmdLine cmdLine;
int checkParse = parseChangeStorageClassRequest(args, cmdLine, eInfo);
if(SFS_OK!=checkParse) {
return checkParse;
}
int checkExecute = executeChangeStorageClassCommand(cmdLine, eInfo);
if(SFS_OK!=checkExecute) {
return checkExecute;
}
return SFS_OK;
}
else if(strncmp(args.Arg1, "/delete-storage-class?", strlen("/delete-storage-class?")) == 0)
{
ParsedDeleteStorageClassCmdLine cmdLine;
int checkParse = parseDeleteStorageClassRequest(args, cmdLine, eInfo);
if(SFS_OK!=checkParse) {
return checkParse;
}
int checkExecute = executeDeleteStorageClassCommand(cmdLine, eInfo);
if(SFS_OK!=checkExecute) {
return checkExecute;
}
return SFS_OK;
}
else if(strncmp(args.Arg1, "/mkdir?", strlen("/mkdir?")) == 0)
{
ParsedMkdirCmdLine cmdLine;
int checkParse = parseMkdirRequest(args, cmdLine, eInfo);
if(SFS_OK!=checkParse) {
return checkParse;
}
int checkExecute = executeMkdirCommand(cmdLine, eInfo);
if(SFS_OK!=checkExecute) {
return checkExecute;
}
return SFS_OK;
}
else if(strncmp(args.Arg1, "/rmdir?", strlen("/rmdir?")) == 0)
{
ParsedRmdirCmdLine cmdLine;
int checkParse = parseRmdirRequest(args, cmdLine, eInfo);
if(SFS_OK!=checkParse) {
return checkParse;
}
int checkExecute = executeRmdirCommand(cmdLine, eInfo);
if(SFS_OK!=checkExecute) {
return checkExecute;
}
return SFS_OK;
}
else
{
......
......@@ -4,6 +4,10 @@
#include "ParsedArchiveCmdLine.hpp"
#include "ParsedCreateStorageClassCmdLine.hpp"
#include "ParsedDeleteStorageClassCmdLine.hpp"
#include "ParsedChangeStorageClassCmdLine.hpp"
#include "ParsedMkdirCmdLine.hpp"
#include "ParsedRmdirCmdLine.hpp"
class XrdProFilesystem : public XrdSfsFileSystem {
public:
......@@ -86,6 +90,82 @@ protected:
*/
int executeCreateStorageClassCommand(ParsedCreateStorageClassCmdLine &cmdLine, XrdOucErrInfo &eInfo);
/**
* Parses the change-storage-class request into the command line structure
*
* @param args the request string
* @param cmdLine the resulting command line structure
* @param eInfo Error information
* @return SFS_OK in case parsing is done correctly, SFS_ERROR otherwise
*/
int parseChangeStorageClassRequest(const XrdSfsFSctl &args, ParsedChangeStorageClassCmdLine &cmdLine, XrdOucErrInfo &eInfo);
/**
* Executes the command contained within the command line structure
*
* @param cmdLine command to execute
* @param eInfo Error information
* @return SFS_OK in case executed correctly, SFS_ERROR otherwise
*/
int executeChangeStorageClassCommand(ParsedChangeStorageClassCmdLine &cmdLine, XrdOucErrInfo &eInfo);
/**
* Parses the delete-storage-class request into the command line structure
*
* @param args the request string
* @param cmdLine the resulting command line structure
* @param eInfo Error information
* @return SFS_OK in case parsing is done correctly, SFS_ERROR otherwise
*/
int parseDeleteStorageClassRequest(const XrdSfsFSctl &args, ParsedDeleteStorageClassCmdLine &cmdLine, XrdOucErrInfo &eInfo);
/**
* Executes the command contained within the command line structure
*
* @param cmdLine command to execute
* @param eInfo Error information
* @return SFS_OK in case executed correctly, SFS_ERROR otherwise
*/
int executeDeleteStorageClassCommand(ParsedDeleteStorageClassCmdLine &cmdLine, XrdOucErrInfo &eInfo);
/**
* Parses the mkdir request into the command line structure
*
* @param args the request string
* @param cmdLine the resulting command line structure
* @param eInfo Error information
* @return SFS_OK in case parsing is done correctly, SFS_ERROR otherwise
*/
int parseMkdirRequest(const XrdSfsFSctl &args, ParsedMkdirCmdLine &cmdLine, XrdOucErrInfo &eInfo);
/**
* Executes the command contained within the command line structure
*
* @param cmdLine command to execute
* @param eInfo Error information
* @return SFS_OK in case executed correctly, SFS_ERROR otherwise
*/
int executeMkdirCommand(ParsedMkdirCmdLine &cmdLine, XrdOucErrInfo &eInfo);
/**
* Parses the rmdir request into the command line structure
*
* @param args the request string
* @param cmdLine the resulting command line structure
* @param eInfo Error information
* @return SFS_OK in case parsing is done correctly, SFS_ERROR otherwise
*/
int parseRmdirRequest(const XrdSfsFSctl &args, ParsedRmdirCmdLine &cmdLine, XrdOucErrInfo &eInfo);
/**
* Executes the command contained within the command line structure
*
* @param cmdLine command to execute
* @param eInfo Error information
* @return SFS_OK in case executed correctly, SFS_ERROR otherwise
*/
int executeRmdirCommand(ParsedRmdirCmdLine &cmdLine, XrdOucErrInfo &eInfo);
/**
* Dispatches the request based on the query
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment