Skip to content
Snippets Groups Projects
Commit 8aff857f authored by Michael Davis's avatar Michael Davis
Browse files

[XrdSsi] Moves resource checking into Service::Prepare method

parent a7eb072f
No related branches found
No related tags found
No related merge requests found
......@@ -124,6 +124,7 @@ The xroot plugin
%files -n cta-cli
%defattr(-,root,root)
%attr(0755,root,root) %{_bindir}/cta
%attr(0755,root,root) %{_bindir}/cta_admin
%attr(0755,root,root) %{_bindir}/eoscta_stub
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/cta/cta-cli.conf
......@@ -187,6 +188,7 @@ The xroot plugin
%files -n cta-cli
%defattr(-,root,root)
%attr(0755,root,root) %{_bindir}/cta
%attr(0755,root,root) %{_bindir}/cta_admin
%attr(0755,root,root) %{_bindir}/eoscta_stub
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/cta/cta-cli.conf
......
......@@ -23,7 +23,6 @@
#include "XrdSsiPbDebug.hpp"
#endif
#include "XrdSsiPbException.hpp"
#include "XrdSsiPbResource.hpp"
#include "XrdSsiPbRequestProc.hpp"
#include "xroot_plugins/messages/cta_frontend.pb.h"
......@@ -72,7 +71,7 @@ void RequestProc<cta::xrd::Request, cta::xrd::Response, cta::xrd::Alert>::Execut
//const cta::eos::Notification &notification = m_request.notification();
cta::frontend::EosNotificationRequest eos_rq(getClient(m_resource), cta_service_ptr);
cta::frontend::EosNotificationRequest eos_rq(*(m_resource.client), cta_service_ptr);
eos_rq.process(m_request.notification(), m_metadata);
}
catch(std::exception &ex)
......
/*!
* @project The CERN Tape Archive (CTA)
* @brief Interface to XRootD SSI Resource class
* @copyright Copyright 2017 CERN
* @license 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 <XrdSsi/XrdSsiResource.hh>
#include <XrdSsi/XrdSsiEntity.hh>
#include "XrdSsiPbException.hpp"
namespace XrdSsiPb {
/*!
* Get the client username from the Resource.
*
* The following fields are available in the client:
*
* prot char* Protocol used
* name const char* Entity's name
* host const char* Entity's host name or address
* vorg const char* Entity's virtual organization
* role const char* Entity's role
* grps const char* Entity's group names
* endorsements const char* Protocol-specific endorsements
* creds const char* Raw client credentials or certificate
* credslen int Length of the 'creds' field
* rsvd int Reserved
* tident const char* Trace identifier (always preset)
*/
static const XrdSsiEntity &getClient(const XrdSsiResource &resource)
{
#ifdef XRDSSI_DEBUG
std::cerr << "[DEBUG] Resource name: " << resource.rName << std::endl
<< "[DEBUG] Resource user: " << resource.rUser << std::endl
<< "[DEBUG] Resource info: " << resource.rInfo << std::endl
<< "[DEBUG] Hosts to avoid: " << resource.hAvoid << std::endl
<< "[DEBUG] Affinity: ";
switch(resource.affinity)
{
case XrdSsiResource::None: std::cerr << "None" << std::endl; break;
case XrdSsiResource::Default: std::cerr << "Default" << std::endl; break;
case XrdSsiResource::Weak: std::cerr << "Weak" << std::endl; break;
case XrdSsiResource::Strong: std::cerr << "Strong" << std::endl; break;
case XrdSsiResource::Strict: std::cerr << "Strict" << std::endl; break;
}
std::cerr << "[DEBUG] Resource options: "
<< (resource.rOpts & XrdSsiResource::Reusable ? "Resuable " : "")
<< (resource.rOpts & XrdSsiResource::Discard ? "Discard" : "")
<< std::endl;
#endif
if(resource.client == nullptr)
{
throw XrdSsiException("getClient(): resource.client is a null pointer");
}
return *(resource.client);
}
} // namespace XrdSsiPb
......@@ -19,6 +19,7 @@
#pragma once
#include <XrdSsi/XrdSsiService.hh>
#include <XrdSsi/XrdSsiEntity.hh>
#include "XrdSsiPbRequestProc.hpp"
namespace XrdSsiPb {
......@@ -28,7 +29,6 @@ namespace XrdSsiPb {
*
* Obtained using GetService() method of the XrdSsiPbServiceProvider factory
*/
template <typename RequestType, typename MetadataType, typename AlertType>
class Service : public XrdSsiService
{
......@@ -51,7 +51,6 @@ public:
* Currently not implemented as it would require tracking all in-flight Requests by the application
* when this is really the job of the framework.
*/
virtual bool Stop() override
{
#ifdef XRDSSI_DEBUG
......@@ -65,12 +64,37 @@ public:
/*!
* Perform Request pre-authorisation and/or resource optimisation.
*/
virtual bool Prepare(XrdSsiErrInfo &eInfo, const XrdSsiResource &rDesc) override
virtual bool Prepare(XrdSsiErrInfo &eInfo, const XrdSsiResource &resource) override
{
#ifdef XRDSSI_DEBUG
std::cout << "[DEBUG] Service::Prepare()" << std::endl;
std::cout << "[DEBUG] Service::Prepare():" << std::endl;
std::cerr << "[DEBUG] Resource name: " << resource.rName << std::endl
<< "[DEBUG] Resource user: " << resource.rUser << std::endl
<< "[DEBUG] Resource info: " << resource.rInfo << std::endl
<< "[DEBUG] Hosts to avoid: " << resource.hAvoid << std::endl
<< "[DEBUG] Affinity: ";
switch(resource.affinity)
{
case XrdSsiResource::None: std::cerr << "None" << std::endl; break;
case XrdSsiResource::Default: std::cerr << "Default" << std::endl; break;
case XrdSsiResource::Weak: std::cerr << "Weak" << std::endl; break;
case XrdSsiResource::Strong: std::cerr << "Strong" << std::endl; break;
case XrdSsiResource::Strict: std::cerr << "Strict" << std::endl; break;
}
std::cerr << "[DEBUG] Resource options: "
<< (resource.rOpts & XrdSsiResource::Reusable ? "Resuable " : "")
<< (resource.rOpts & XrdSsiResource::Discard ? "Discard" : "")
<< std::endl;
#endif
if(resource.client == nullptr || resource.client->name == nullptr)
{
eInfo.Set("Service::Prepare(): XRootD client name is not set. "
"Possible misconfiguration of the KRB5 or SSS keyfile.", EACCES);
return false;
}
return true;
}
......@@ -80,7 +104,6 @@ public:
* This is required only if the service needs to make decisions on how to run a request based on whether
* it is attached or detached. See Sect. 3.3.1 "Detached Requests" in the XRootD SSI documentation.
*/
virtual bool Attach(XrdSsiErrInfo &eInfo, const std::string &handle,
XrdSsiRequest &reqRef, XrdSsiResource *resp) override
{
......@@ -100,7 +123,6 @@ public:
* Request and Resource objects are transmitted to the server and passed into the service's ProcessRequest()
* method.
*/
template <typename RequestType, typename MetadataType, typename AlertType>
void Service<RequestType, MetadataType, AlertType>::ProcessRequest(XrdSsiRequest &reqRef, XrdSsiResource &resRef)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment