Commit 643ccbf2 authored by Daniele Kruse's avatar Daniele Kruse
Browse files

Implemented persistent path for mock name server

parent 55d30f6e
......@@ -320,7 +320,7 @@ This command will return the newly created path to the mock nameserver base dire
\end{verbatim}
Now we need to add it as a configuration parameter in the \texttt{castor.conf}, as in the following example:
\begin{verbatim}
TapeServer MockNameServerPath /tmp/CTAMockNS9r236q
TapeServer MockNameServerPath /tmp/CTAMockNS9r236q/
\end{verbatim}
\section{Set up the objectstore VFS backend}
......
......@@ -437,8 +437,8 @@ void cta::MockNameServer::setOwner(
const std::string gidStr = Utils::toString(owner.gid);
const std::string fsPath = m_fsDir + path;
Utils::setXattr(fsPath, "user.uid", uidStr);
Utils::setXattr(fsPath, "user.gid", gidStr);
Utils::setXattr(fsPath, "user.CTAuid", uidStr);
Utils::setXattr(fsPath, "user.CTAgid", gidStr);
}
//------------------------------------------------------------------------------
......@@ -449,8 +449,8 @@ cta::UserIdentity cta::MockNameServer::getOwner(
const std::string &path) const {
Utils::assertAbsolutePathSyntax(path);
const std::string fsPath = m_fsDir + path;
const std::string uidStr = Utils::getXattr(fsPath, "user.uid");
const std::string gidStr = Utils::getXattr(fsPath, "user.gid");
const std::string uidStr = Utils::getXattr(fsPath, "user.CTAuid");
const std::string gidStr = Utils::getXattr(fsPath, "user.CTAgid");
if(uidStr.empty() || gidStr.empty()) {
std::ostringstream msg;
......@@ -680,7 +680,27 @@ std::string cta::MockNameServer::getVidOfFile(
const SecurityIdentity &requester,
const std::string &path,
const uint16_t copyNb) const {
return "T00001"; //everything is on one tape for the moment:)
if(copyNb!=1 || copyNb!=2) {
std::ostringstream msg;
msg << "cta::MockNameServer::getVidOfFile() - The mock nameserver only supports the copy number to be 1 or 2. Instead the one supplied is: " << copyNb;
throw(exception::Exception(msg.str()));
}
const std::string fsPath = m_fsDir + path;
assertFsFileExists(fsPath);
std::list<cta::NameServerTapeFile> tapeFileList;
std::string copyOne = Utils::getXattr(fsPath, "user.CTATapeFileCopyOne");
std::string copyTwo = Utils::getXattr(fsPath, "user.CTATapeFileCopyTwo");
if(copyNb==1) {
return fromStringToNameServerTapeFile(copyOne).tapeFileLocation.vid;
}
else if(copyNb==2) {
return fromStringToNameServerTapeFile(copyTwo).tapeFileLocation.vid;
}
else {
std::ostringstream msg;
msg << "cta::MockNameServer::getVidOfFile() - The mock nameserver only supports the copy number to be 1 or 2. Instead the one supplied is: " << copyNb;
throw(exception::Exception(msg.str()));
}
}
//------------------------------------------------------------------------------
......
......@@ -25,6 +25,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <attr/xattr.h>
#include <unistd.h>
#include "common/exception/Errnum.hpp"
#include "common/exception/Exception.hpp"
......@@ -53,9 +54,13 @@ int main(void) {
cta::exception::Errnum::throwOnNull(mkdtemp(path), "MockNameServer() - Failed to create temporary directory");
std::string pathString(path);
pathString+="/";
std::stringstream uidss;
uidss << getuid();
std::stringstream gidss;
gidss << getgid();
setXattr(pathString.c_str(), "user.CTAStorageClass", "");
setXattr(pathString.c_str(), "user.uid", "0");
setXattr(pathString.c_str(), "user.gid", "0");
setXattr(pathString.c_str(), "user.CTAuid", uidss.str());
setXattr(pathString.c_str(), "user.CTAgid", gidss.str());
std::cout << "New mock name server path: " << pathString << std::endl;
} catch (cta::exception::Exception & e) {
std::cerr << "Failed to create a new directory for the mock name server. CTA Exception: " << e.getMessageValue() << std::endl;
......
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