Back to index

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

List of all members.

Public Member Functions

def __init__
def stat
def delete
def get
def put
def toggleReport
def RegistrationCollector
def GetAdditionalLocalInformation
def GetLocalInformation
def process

Public Attributes

 service_name
 shepherd
 ssl_config
 state
 request_config
 ns

Private Member Functions

def _putget_in
def _putget_out

Detailed Description

Definition at line 627 of file shepherd.py.


Constructor & Destructor Documentation

Definition at line 629 of file shepherd.py.

00629 
00630     def __init__(self, cfg):
00631         try:
00632             serviceID = str(cfg.Get('ServiceID')).split('/')[-1]
00633         except:
00634             serviceID = "Shepherd"
00635         self.service_name = serviceID
00636         # names of provided methods
00637         request_names = ['get', 'put', 'stat', 'delete', 'toggleReport']
00638         # create the business-logic class
00639         self.shepherd = Shepherd(cfg)
00640         # get the additional request names from the backend
00641         backend_request_names = self.shepherd.backend.public_request_names
00642         # bring the additional request methods into the namespace of this object
00643         for name in backend_request_names:
00644             if not hasattr(self, name):
00645                 setattr(self, name, getattr(self.shepherd.backend, name))
00646                 request_names.append(name)
00647         # call the Service's constructor
00648         Service.__init__(self, [{'request_names' : request_names, 'namespace_prefix': 'she', 'namespace_uri': shepherd_uri}], cfg)

Here is the call graph for this function:


Member Function Documentation

def storage.shepherd.shepherd.ShepherdService._putget_in (   self,
  putget,
  inpayload 
) [private]

Definition at line 673 of file shepherd.py.

00673 
00674     def _putget_in(self, putget, inpayload):
00675         request = dict([
00676             (str(node.Get('requestID')), [
00677                 (str(n.Get('property')), str(n.Get('value')))
00678                     for n in get_child_nodes(node.Get(putget + 'RequestDataList'))
00679             ]) for node in get_child_nodes(inpayload.Child().Child())])
00680         return request

Here is the call graph for this function:

Here is the caller graph for this function:

def storage.shepherd.shepherd.ShepherdService._putget_out (   self,
  putget,
  response 
) [private]

Definition at line 681 of file shepherd.py.

00681 
00682     def _putget_out(self, putget, response):
00683         #print response
00684         tree = XMLTree(from_tree =
00685             ('she:' + putget + 'ResponseList', [
00686                 ('she:' + putget + 'ResponseElement', [
00687                     ('she:requestID', requestID),
00688                     ('she:' + putget + 'ResponseDataList', [
00689                         ('she:' + putget + 'ResponseDataElement', [
00690                             ('she:property', property),
00691                             ('she:value', value)
00692                         ]) for property, value in responseData
00693                     ])
00694                 ]) for requestID, responseData in response.items()
00695             ])
00696         )
00697         out = self._new_soap_payload()
00698         response_node = out.NewChild(putget + 'response')
00699         tree.add_to_node(response_node)
00700         return out

Here is the call graph for this function:

Here is the caller graph for this function:

def storage.shepherd.shepherd.ShepherdService.delete (   self,
  inpayload 
)

Definition at line 657 of file shepherd.py.

00657 
00658     def delete(self, inpayload):
00659         request = parse_node(inpayload.Child().Child(), ['requestID', 'referenceID'], single = True)
00660         response = self.shepherd.delete(request)
00661         tree = XMLTree(from_tree = 
00662             ('she:deleteResponseList',[
00663                 ('she:deleteResponseElement',[
00664                     ('she:requestID', requestID),
00665                     ('she:status', status)
00666                     ]) for requestID, status in response.items()
00667                 ])
00668             )
00669         out = self._new_soap_payload()
00670         response_node = out.NewChild('deleteresponse')
00671         tree.add_to_node(response_node)
00672         return out

Here is the call graph for this function:

def storage.shepherd.shepherd.ShepherdService.get (   self,
  inpayload 
)

Definition at line 701 of file shepherd.py.

00701 
00702     def get(self, inpayload):
00703         # if inpayload.auth:
00704         #     print 'Shepherd auth "get": ', inpayload.auth
00705         request = self._putget_in('get', inpayload)
00706         response = self.shepherd.get(request)
00707         return self._putget_out('get', response)

Here is the call graph for this function:

Definition at line 728 of file shepherd.py.

00728 
00729     def GetAdditionalLocalInformation(self, service_node):
00730         service_node.Name('StorageService')
00731         service_node.NewChild('Type').Set(shepherd_servicetype)
00732         capacity_node = service_node.NewChild('StorageServiceCapacity')
00733         free_size, used_size, total_size = self.shepherd.getSpaceInformation()
00734         print free_size, used_size, total_size
00735         gigabyte = 1073741824.0
00736         capacity_node.NewChild('FreeSize').Set(str(free_size/gigabyte))
00737         capacity_node.NewChild('UsedSize').Set(str(used_size/gigabyte))
00738         capacity_node.NewChild('TotalSize').Set(str(total_size/gigabyte))

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:

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:

def storage.shepherd.shepherd.ShepherdService.put (   self,
  inpayload 
)

Definition at line 708 of file shepherd.py.

00708 
00709     def put(self, inpayload):
00710         request = self._putget_in('put', inpayload)
00711         response = self.shepherd.put(request)
00712         return self._putget_out('put', response)

Here is the call graph for this function:

Definition at line 721 of file shepherd.py.

00721 
00722     def RegistrationCollector(self, doc):
00723         regentry = arc.XMLNode('<RegEntry />')
00724         regentry.NewChild('SrcAdv').NewChild('Type').Set(shepherd_servicetype)
00725         #Place the document into the doc attribute
00726         doc.Replace(regentry)
00727         return True

def storage.shepherd.shepherd.ShepherdService.stat (   self,
  inpayload 
)

Definition at line 649 of file shepherd.py.

00649 
00650     def stat(self, inpayload):
00651         request = parse_node(inpayload.Child().Child(), ['requestID', 'referenceID'], single = True)
00652         response = self.shepherd.stat(request)
00653         #print response
00654         return create_response('she:stat',
00655             ['she:requestID', 'she:referenceID', 'she:state', 'she:checksumType', 'she:checksum', 'she:acl', 'she:size', 'she:GUID', 'she:localID'], response, self._new_soap_payload())
00656     

Here is the call graph for this function:

Definition at line 713 of file shepherd.py.

00713 
00714     def toggleReport(self, inpayload):
00715         doReporting = str(inpayload.Child().Get('doReporting'))
00716         response = self.shepherd.toggleReport(doReporting == true)
00717         out = self._new_soap_payload()
00718         response_node = out.NewChild('lbr:toggleReportResponse')
00719         response_node.Set(response)
00720         return out

Here is the call graph for this function:


Member Data Documentation

Definition at line 92 of file service.py.

Definition at line 91 of file service.py.

Reimplemented from arcom.service.Service.

Definition at line 634 of file shepherd.py.

Definition at line 638 of file shepherd.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: