Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Public Attributes
storage.librarian.librarian.LibrarianService Class Reference
Inheritance diagram for storage.librarian.librarian.LibrarianService:
Inheritance graph
[legend]
Collaboration diagram for storage.librarian.librarian.LibrarianService:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __del__
def new
def get
def traverseLN
def modifyMetadata
def remove
def report
def RegistrationCollector
def GetAdditionalLocalInformation
def GetLocalInformation
def process

Public Attributes

 service_name
 librarian
 ssl_config
 state
 request_config
 ns

Detailed Description

LibrarianService class implementing the XML interface of the storage Librarian service. 

Definition at line 417 of file librarian.py.


Constructor & Destructor Documentation

Constructor of the LibrarianService

LibrarianService(cfg)

'cfg' is an XMLNode which containes the config of this service.

Definition at line 420 of file librarian.py.

00420 
00421     def __init__(self, cfg):
00422         """ Constructor of the LibrarianService
00423 
00424         LibrarianService(cfg)
00425 
00426         'cfg' is an XMLNode which containes the config of this service.
00427         """
00428         self.service_name = 'Librarian'
00429         # init logging
00430         # names of provided methods
00431         request_names = ['new','get','traverseLN', 'modifyMetadata', 'remove', 'report']
00432         # call the Service's constructor
00433         Service.__init__(self, [{'request_names' : request_names, 'namespace_prefix': 'lbr', 'namespace_uri': librarian_uri}], cfg, start_service = False)
00434         # this causes trouble on shutdown (the Librarian class would have a reference to the LibrarianService class, so the destructor would not be called)
00435         #ssl_config['get_trusted_dns_method'] = self._get_trusted_dns
00436         self.librarian = Librarian(cfg, self.ssl_config, self.state)
    

Reimplemented from arcom.service.Service.

Definition at line 437 of file librarian.py.

00437 
00438     def __del__(self):
00439         try:
00440             self.librarian.thread_is_running = False
00441         except:
00442             pass
00443         Service.__del__(self)
    

Member Function Documentation

def storage.librarian.librarian.LibrarianService.get (   self,
  inpayload 
)

Definition at line 453 of file librarian.py.

00453 
00454     def get(self, inpayload):
00455         requests = [str(node.Get('GUID')) for node in get_child_nodes(inpayload.Child().Get('getRequestList'))]
00456         neededMetadata = [
00457             node_to_data(node, ['section', 'property'], single = True)
00458                 for node in get_child_nodes(inpayload.Child().Get('neededMetadataList'))
00459         ]
00460         tree = self.librarian.get(requests, neededMetadata)
00461         out = arc.PayloadSOAP(self._new_soap_payload())
00462         response_node = out.NewChild('lbr:getResponse')
00463         tree.add_to_node(response_node)
00464         return out

Here is the call graph for this function:

Definition at line 516 of file librarian.py.

00516 
00517     def GetAdditionalLocalInformation(self, service_node):
00518         service_node.NewChild('Type').Set(librarian_servicetype)
00519 

Here is the caller graph for this function:

def arcom.service.Service.GetLocalInformation (   self) [inherited]

Definition at line 162 of file service.py.

00162 
00163     def GetLocalInformation(self):
00164         ns = arc.NS({'':'http://schemas.ogf.org/glue/2008/05/spec_2.0_d41_r01'})
00165         info = arc.XMLNode(ns,'Domains')
00166         service_node = info.NewChild('AdminDomain').NewChild('Services').NewChild('Service')
00167         endpoint_node = service_node.NewChild('Endpoint')
00168         endpoint_node.NewChild('HealthState').Set('ok')
00169         if self.state.running:
00170             serving_state = 'production'
00171         else:
00172             serving_state = 'closed'
00173         endpoint_node.NewChild('ServingState').Set(serving_state)
00174         try:
00175             self.GetAdditionalLocalInformation(service_node)
00176         except:
00177             pass
00178         return info
    

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 484 of file librarian.py.

00484 
00485     def modifyMetadata(self, inpayload):
00486         requests = parse_node(inpayload.Child().Child(), ['lbr:changeID',
00487             'lbr:GUID', 'lbr:changeType', 'lbr:section', 'lbr:property', 'lbr:value'])
00488         response = self.librarian.modifyMetadata(requests)
00489         return create_response('lbr:modifyMetadata', ['lbr:changeID', 'lbr:success'],
00490             response, self._new_soap_payload(), single = True)

Here is the call graph for this function:

def storage.librarian.librarian.LibrarianService.new (   self,
  inpayload 
)

Definition at line 444 of file librarian.py.

00444 
00445     def new(self, inpayload):
00446         requests0 = parse_node(inpayload.Child().Child(),
00447             ['requestID', 'metadataList'], single = True, string = False)
00448         requests = dict([(str(requestID), parse_metadata(metadataList)) 
00449             for requestID, metadataList in requests0.items()])
00450         resp = self.librarian.new(requests)
00451         return create_response('lbr:new',
00452             ['lbr:requestID', 'lbr:GUID', 'lbr:success'], resp, self._new_soap_payload())

Here is the call graph for this function:

def arcom.service.Service.process (   self,
  inmsg,
  outmsg 
) [inherited]
Method to process incoming message and create outgoing one. 

Definition at line 179 of file service.py.

00179 
00180     def process(self, inmsg, outmsg):
00181         """ Method to process incoming message and create outgoing one. """
00182         # gets the payload from the incoming message
00183         inpayload = inmsg.Payload()
00184         try:
00185             # the first child of the payload should be the name of the request
00186             request_node = inpayload.Child()
00187             # get the namespace of the request node
00188             request_namespace = request_node.Namespace()
00189             matched_request_types = [request_type for request_type in self.request_config if request_type['namespace_uri'] == request_namespace]
00190             if len(matched_request_types) == 0:
00191                 # check if it is a LIDI request:
00192                 if request_namespace == wsrf_rp_uri:
00193                     outpayload = arc.PayloadSOAP(arc.NS({'wsrf-rp':wsrf_rp_uri}))
00194                     outpayload.NewChild('wsrf-rp:GetResourcePropertyDocumentResponse').NewChild(self.GetLocalInformation())
00195                     outmsg.Payload(outpayload)
00196                     return arc.MCC_Status(arc.STATUS_OK)
00197                 raise Exception, 'wrong namespace. expected: %s' % ', '.join([request_type['namespace_uri'] for request_type in self.request_config])
00198             current_request_type = matched_request_types[0]
00199             # get the name of the request without the namespace prefix
00200             request_name = request_node.Name()
00201             if request_name not in current_request_type['request_names']:
00202                 # if the name of the request is not in the list of supported request names
00203                 raise Exception, 'wrong request (%s)' % request_name
00204             log.msg(arc.VERBOSE,'%(sn)s.%(rn)s called' % {'sn':self.service_name, 'rn':request_name})
00205             if not self.state.running:
00206                 outpayload = arc.PayloadSOAP(self.ns, True)
00207                 fault = outpayload.Fault()
00208                 fault.Reason('%s service is inactive (not initialized yet or shutting down)' % self.service_name) 
00209                 outmsg.Payload(outpayload)
00210                 return arc.MCC_Status(arc.STATUS_OK)
00211             # if the request name is in the supported names,
00212             # then this class should have a method with this name
00213             # the 'getattr' method returns this method
00214             # which then we could call with the incoming payload
00215             # and which will return the response payload
00216             log.msg(arc.DEBUG, inpayload.GetXML())
00217             outpayload = self._call_request(request_name, inmsg)
00218             # sets the payload of the outgoing message
00219             outmsg.Payload(outpayload)
00220             # return with the STATUS_OK status
00221             return arc.MCC_Status(arc.STATUS_OK)
00222         except:
00223             # if there is any exception, print it
00224             msg = log.msg()
00225             outpayload = arc.PayloadSOAP(self.ns, True)
00226             fault = outpayload.Fault()
00227             fault.Reason('%s service raised a %s' % (self.service_name, msg))
00228             outmsg.Payload(outpayload)
00229             return arc.MCC_Status(arc.STATUS_OK)

Here is the call graph for this function:

Definition at line 509 of file librarian.py.

00509 
00510     def RegistrationCollector(self, doc):
00511         regentry = arc.XMLNode('<RegEntry />')
00512         regentry.NewChild('SrcAdv').NewChild('Type').Set(librarian_servicetype)
00513         #Place the document into the doc attribute
00514         doc.Replace(regentry)
00515         return True

def storage.librarian.librarian.LibrarianService.remove (   self,
  inpayload 
)

Definition at line 491 of file librarian.py.

00491 
00492     def remove(self, inpayload):
00493         requests = parse_node(inpayload.Child().Child(), ['lbr:requestID', 'lbr:GUID'], single = True)
00494         response = self.librarian.remove(requests)
00495         return create_response('lbr:remove', ['lbr:requestID', 'lbr:success'],
00496             response, self._new_soap_payload(), single = True)
    

Here is the call graph for this function:

def storage.librarian.librarian.LibrarianService.report (   self,
  inpayload 
)

Definition at line 497 of file librarian.py.

00497 
00498     def report(self, inpayload):
00499         request_node = inpayload.Child()
00500         serviceID = str(request_node.Get('serviceID'))
00501         filelist_node = request_node.Get('filelist')
00502         file_nodes = get_child_nodes(filelist_node)
00503         filelist = [(str(node.Get('GUID')), str(node.Get('referenceID')), str(node.Get('state'))) for node in file_nodes]
00504         nextReportTime = self.librarian.report(serviceID, filelist)
00505         out = self._new_soap_payload()
00506         response_node = out.NewChild('lbr:registerResponse')
00507         response_node.NewChild('lbr:nextReportTime').Set(str(nextReportTime))
00508         return out

Here is the call graph for this function:

Definition at line 465 of file librarian.py.

00465 
00466     def traverseLN(self, inpayload):
00467         # if inpayload.auth:
00468         #     print 'Librarian auth "traverseLN": ', inpayload.auth
00469         requests = parse_node(inpayload.Child().Child(), ['requestID', 'LN'], single = True)
00470         response = self.librarian.traverseLN(requests)
00471         for rID, (traversedList, wasComplete, traversedLN, GUID, metadata, restLN) in response.items():
00472             traversedListTree = [
00473                 ('lbr:traversedListElement', [
00474                     ('lbr:LNPart', LNpart),
00475                     ('lbr:GUID', partGUID)
00476                 ]) for (LNpart, partGUID) in traversedList
00477             ]
00478             metadataTree = create_metadata(metadata, 'lbr')
00479             response[rID] = (traversedListTree, wasComplete and true or false,
00480                 traversedLN, GUID, metadataTree, restLN)
00481         return create_response('lbr:traverseLN',
00482             ['lbr:requestID', 'lbr:traversedList', 'lbr:wasComplete',
00483                 'lbr:traversedLN', 'lbr:GUID', 'lbr:metadataList', 'lbr:restLN'], response, self._new_soap_payload())

Here is the call graph for this function:


Member Data Documentation

Definition at line 435 of file librarian.py.

Definition at line 92 of file service.py.

Definition at line 91 of file service.py.

Reimplemented from arcom.service.Service.

Definition at line 427 of file librarian.py.

Definition at line 47 of file service.py.

Definition at line 49 of file service.py.


The documentation for this class was generated from the following file: