Back to index

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

List of all members.

Public Member Functions

def __init__
def get
def traverseLN
def new
def modifyMetadata
def remove
def report
def reset
def call
def call_raw

Public Attributes

 ns
 urls
 https
 print_xml
 xmlnode_class
 ssl_config
 cfg
 get_trusted_dns_method
 connection_cache
 semapool

Static Public Attributes

 NS_class = arc.NS

Detailed Description

Definition at line 132 of file client.py.


Constructor & Destructor Documentation

def storage.client.LibrarianClient.__init__ (   self,
  url,
  print_xml = False,
  ssl_config = {} 
)

Definition at line 134 of file client.py.

00134 
00135     def __init__(self, url, print_xml = False, ssl_config = {}):
00136         ns = self.NS_class('lbr', librarian_uri)
00137         Client.__init__(self, url, ns, print_xml, ssl_config = ssl_config)


Member Function Documentation

def arcom.client.Client.call (   self,
  tree,
  return_tree_only = False 
) [inherited]
Create a SOAP message from an XMLTree and send it to the service.

call(tree, return_tree_only = False)

tree is an XMLTree object containing the content of the request
return_tree_only indicates that we only need to put the response into an XMLTree

Definition at line 60 of file client.py.

00060 
00061     def call(self, tree, return_tree_only = False):
00062         """ Create a SOAP message from an XMLTree and send it to the service.
00063         
00064         call(tree, return_tree_only = False)
00065         
00066         tree is an XMLTree object containing the content of the request
00067         return_tree_only indicates that we only need to put the response into an XMLTree
00068         """
00069         # create a new PayloadSOAP object with the given namespace
00070         out = arc.PayloadSOAP(self.ns)
00071         # add the content of the XMLTree to the XMLNode of the SOAP object
00072         tree.add_to_node(out)
00073         if self.print_xml:
00074             msg = out.GetXML()
00075             print 'Request:'
00076             print XMLTree(out).pretty_xml(indent = '    ', prefix = '        #   ')
00077             print
00078         # call the service and get back the response, and the HTTP status
00079         resp = self.call_raw(out)
00080         if self.print_xml:
00081             print 'Response:'
00082             try:
00083                 print XMLTree(from_string = resp).pretty_xml(indent = '    ', prefix = '        #   ')
00084             except:
00085                 print resp
00086             print
00087         if return_tree_only:
00088             # wrap the response into an XMLTree and return only the tree
00089             return XMLTree(from_string = resp, forget_namespace = True).get_trees('///')[0]
00090         else:
00091             return resp

Here is the call graph for this function:

Here is the caller graph for this function:

def arcom.client.Client.call_raw (   self,
  outpayload 
) [inherited]
Send a POST request with the SOAP XML message.

call_raw(outpayload)

outpayload is an XMLNode with the SOAP message

Definition at line 99 of file client.py.

00099 
00100     def call_raw(self, outpayload):
00101         """ Send a POST request with the SOAP XML message.
00102         
00103         call_raw(outpayload)
00104         
00105         outpayload is an XMLNode with the SOAP message
00106         """
00107         tid = thread.get_ident()
00108         s = self.connection_cache.get(tid, None)
00109         if s:
00110             try:
00111                 resp, status = s.process(outpayload)
00112                 if not self._fawlty(resp, status):
00113                     return resp.GetXML()
00114             except:
00115                 pass
00116             self.connection_cache[tid] = None
00117         if len(self.urls) == 0:
00118             log.msg(arc.WARNING, 'No URLs to connect to (in %s)' % str(self.__class__.__name__))
00119             raise Exception, 'No URLs to connect'
00120         random.shuffle(self.urls)
00121         #print "available URLs", [url.fullstr() for url in self.urls]
00122         for url in self.urls:
00123             #print "trying URL", url.fullstr()
00124             try:
00125                 s = arc.ClientSOAP(self.cfg, url)
00126                 if self.get_trusted_dns_method:
00127                     dnlist = self.get_trusted_dns_method()
00128                     if dnlist:
00129                         dnlistconf = arc.DNListHandlerConfig(dnlist, 'outgoing')
00130                         # _s points to the superclass, but not the object, so it needs the object as first argument
00131                         s._s._s.AddSecHandler(s, dnlistconf, arc.TLSSec)
00132                 resp, status = s.process(outpayload)
00133                 fawlty = self._fawlty(resp, status)
00134                 if fawlty:
00135                     raise Exception, fawlty
00136                 resp = resp.GetXML()
00137                 self.connection_cache[tid] = s
00138                 return resp
00139             except:
00140                 log.msg(arc.WARNING, "ERROR connecting to", url.fullstr())
00141                 pass
00142         log.msg(arc.ERROR, "ERROR connecting to all of these:", ', '.join([url.fullstr() for url in self.urls]))
00143         raise

Here is the call graph for this function:

Here is the caller graph for this function:

def storage.client.LibrarianClient.get (   self,
  GUIDs,
  neededMetadata = [] 
)

Definition at line 138 of file client.py.

00138 
00139     def get(self, GUIDs, neededMetadata = []):
00140         tree = XMLTree(from_tree =
00141             ('lbr:get', [
00142                 ('lbr:neededMetadataList', [
00143                     ('lbr:neededMetadataElement', [
00144                         ('lbr:section', section),
00145                         ('lbr:property', property)
00146                     ]) for section, property in neededMetadata
00147                 ]),
00148                 ('lbr:getRequestList', [
00149                     ('lbr:getRequestElement', [
00150                         ('lbr:GUID', i)
00151                     ]) for i in GUIDs
00152                 ])
00153             ])
00154         )
00155         msg = self.call(tree)
00156         xml = self.xmlnode_class(msg)
00157         elements = parse_node(get_data_node(xml),
00158             ['GUID', 'metadataList'], single = True, string = False)
00159         return dict([(str(GUID), parse_metadata(metadataList))
00160             for GUID, metadataList in elements.items()])

Here is the call graph for this function:

def storage.client.LibrarianClient.modifyMetadata (   self,
  requests 
)

Definition at line 213 of file client.py.

00213 
00214     def modifyMetadata(self, requests):
00215         tree = XMLTree(from_tree =
00216             ('lbr:modifyMetadata', [
00217                 ('lbr:modifyMetadataRequestList', [
00218                     ('lbr:modifyMetadataRequestElement', [
00219                         ('lbr:changeID', changeID),
00220                         ('lbr:GUID', GUID),
00221                         ('lbr:changeType', changeType),
00222                         ('lbr:section', section),
00223                         ('lbr:property', property),
00224                         ('lbr:value', value)
00225                     ]) for changeID, (GUID, changeType, section, property, value) in requests.items()
00226                 ])
00227             ])
00228         )
00229         self.semapool.acquire()
00230         response = self.call(tree)
00231         self.semapool.release()
00232         node = self.xmlnode_class(response)
00233         return parse_node(get_data_node(node), ['changeID', 'success'], True)

Here is the call graph for this function:

def storage.client.LibrarianClient.new (   self,
  requests 
)

Definition at line 195 of file client.py.

00195 
00196     def new(self, requests):
00197         
00198         tree = XMLTree(from_tree =
00199             ('lbr:new', [
00200                 ('lbr:newRequestList', [
00201                     ('lbr:newRequestElement', [
00202                         ('lbr:requestID', requestID),
00203                         ('lbr:metadataList', create_metadata(metadata, 'lbr'))
00204                     ]) for requestID, metadata in requests.items()
00205                 ])
00206             ])
00207         )
00208         self.semapool.acquire()
00209         response = self.call(tree)
00210         self.semapool.release()
00211         node = self.xmlnode_class(response)
00212         return parse_node(get_data_node(node), ['requestID', 'GUID', 'success'])

Here is the call graph for this function:

def storage.client.LibrarianClient.remove (   self,
  requests 
)

Definition at line 234 of file client.py.

00234 
00235     def remove(self, requests):
00236         tree = XMLTree(from_tree =
00237             ('lbr:remove', [
00238                 ('lbr:removeRequestList', [
00239                     ('lbr:removeRequestElement', [
00240                         ('lbr:requestID', requestID),
00241                         ('lbr:GUID', GUID)
00242                     ]) for requestID, GUID in requests.items()
00243                 ])
00244             ])
00245         )
00246         self.semapool.acquire()
00247         response = self.call(tree)
00248         self.semapool.release()
00249         node = self.xmlnode_class(response)
00250         return parse_node(get_data_node(node), ['requestID', 'success'], True)

Here is the call graph for this function:

def storage.client.LibrarianClient.report (   self,
  serviceID,
  filelist 
)

Definition at line 251 of file client.py.

00251 
00252     def report(self, serviceID, filelist):
00253         tree = XMLTree(from_tree =
00254             ('lbr:report', [
00255                 ('lbr:serviceID', serviceID),
00256                 ('lbr:filelist', [
00257                     ('lbr:file', [
00258                         ('lbr:GUID', GUID),
00259                         ('lbr:referenceID', referenceID),
00260                         ('lbr:state', state)
00261                     ]) for GUID, referenceID, state in filelist
00262                 ])
00263             ])
00264         )
00265         response = self.call(tree)
00266         node = self.xmlnode_class(response)
00267         try:
00268             return int(str(node.Child().Child().Get('nextReportTime')))
00269         except:
00270             return None

Here is the call graph for this function:

def arcom.client.Client.reset (   self) [inherited]

Definition at line 56 of file client.py.

00056 
00057     def reset(self):
00058         tid = thread.get_ident()
00059         self.connection_cache[tid] = None

def storage.client.LibrarianClient.traverseLN (   self,
  requests 
)

Definition at line 161 of file client.py.

00161 
00162     def traverseLN(self, requests):
00163         tree = XMLTree(from_tree =
00164             ('lbr:traverseLN', [
00165                 ('lbr:traverseLNRequestList', [
00166                     ('lbr:traverseLNRequestElement', [
00167                         ('lbr:requestID', rID),
00168                         ('lbr:LN', LN)
00169                     ]) for rID, LN in requests.items()
00170                 ])
00171             ])
00172         )
00173         msg = self.call(tree)
00174         xml = self.xmlnode_class(msg)
00175         list_node = get_data_node(xml)
00176         list_number = list_node.Size()
00177         elements = {}
00178         for i in range(list_number):
00179             element_node = list_node.Child(i)
00180             requestID = str(element_node.Get('requestID'))
00181             traversedlist_node = element_node.Get('traversedList')
00182             traversedlist_number = traversedlist_node.Size()
00183             traversedlist = []
00184             for j in range(traversedlist_number):
00185                 tle_node = traversedlist_node.Child(j)
00186                 traversedlist.append((str(tle_node.Get('LNPart')), str(tle_node.Get('GUID'))))
00187             wasComplete = str(element_node.Get('wasComplete')) == true
00188             traversedLN = str(element_node.Get('traversedLN'))
00189             restLN = str(element_node.Get('restLN'))
00190             GUID = str(element_node.Get('GUID'))
00191             metadatalist_node = element_node.Get('metadataList')
00192             metadata = parse_metadata(metadatalist_node)
00193             elements[requestID] = (metadata, GUID, traversedLN, restLN, wasComplete, traversedlist)
00194         return elements

Here is the call graph for this function:


Member Data Documentation

Definition at line 34 of file client.py.

Definition at line 36 of file client.py.

Definition at line 35 of file client.py.

Definition at line 30 of file client.py.

Definition at line 24 of file client.py.

arcom.client.Client.NS_class = arc.NS [static, inherited]

Definition at line 13 of file client.py.

Definition at line 31 of file client.py.

Definition at line 38 of file client.py.

Definition at line 33 of file client.py.

Definition at line 29 of file client.py.

Definition at line 32 of file client.py.


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