Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Public Attributes
storage.bartender.gateway.gateway.Gateway Class Reference

List of all members.

Public Member Functions

def __init__
def get
def put
def list
def remove

Public Attributes

 service_name
 cfg
 proxy_store
 ca_dir

Detailed Description

Definition at line 22 of file gateway.py.


Constructor & Destructor Documentation

Definition at line 24 of file gateway.py.

00024 
00025     def __init__(self,cfg):
00026         #print "Gateway constructor..."
00027         self.service_name = 'Gateway'
00028         self.cfg = cfg
00029         self.proxy_store = str(self.cfg.Get('ProxyStore'))
00030         self.ca_dir = str(self.cfg.Get('CACertificatesDir'))
00031         if len(self.proxy_store) == 0:
00032            log.msg(arc.VERBOSE,'proxy store is not accessable.')
         

Member Function Documentation

def storage.bartender.gateway.gateway.Gateway.get (   self,
  auth,
  sourceURL,
  flags 
)

Definition at line 33 of file gateway.py.

00033 
00034     def get(self, auth ,sourceURL, flags):
00035         response = {}  
00036         status = ''  
00037         protocol = ''
00038         proxyfile = base64.b64encode(auth.get_identity()) 
00039         if len(self.proxy_store) == 0:
00040            log.msg(arc.VERBOSE,'proxy store is not accessable.')
00041         filepath = self.proxy_store+'/'+proxyfile+'.proxy'
00042         if os.path.isfile(filepath):
00043             url = arc.URL(sourceURL);
00044             handle = arc.DataHandle(url);
00045             handle.__deref__().AssignCredentials(filepath,'','',self.ca_dir) 
00046             (files, status) = handle.__deref__().ListFiles(True);
00047             if files:
00048                 status  = 'successful'
00049                 for file in files:
00050                     #print file.GetName()
00051                     if sourceURL[:6] == 'gsiftp':
00052                         protocol = 'gridftp'
00053                     elif sourceURL[:3] == 'srm':
00054                         protocol = 'srm'
00055                     response[file.GetName()] = {'turl':sourceURL,'status': status,'protocol':protocol}
00056             else:
00057                 status = 'failed: cannot access file'
00058                 response[url] = {'turl':'','status': status,'protocol':''}
00059         else:
00060             status = 'cannot find valid credentials'
00061             response[url] = {'turl':'','status': status,'protocol':''}
00062         log.msg(arc.VERBOSE,'get response: %s',response)
00063         return response
            
def storage.bartender.gateway.gateway.Gateway.list (   self,
  auth,
  url,
  flags = '' 
)
Input arguments
URL of the file or directory 

Definition at line 78 of file gateway.py.

00078 
00079     def list(self, auth, url, flags=''):
00080         """Input arguments
00081         URL of the file or directory """
00082         response = {}
00083         tmpList = []
00084         longlisting = '-l' in flags
00085         status = ''
00086         if url.startswith('gsiftp'):
00087             protocol = 'gridftp'
00088         elif url.startswith('srm'):
00089             protocol = 'srm'
00090         else:
00091             protocol = 'unkonwn'
00092         if len(self.proxy_store) == 0:
00093             log.msg(arc.VERBOSE,'proxy store is not accessable.')
00094         if protocol != 'unknown':
00095             proxyfile = base64.b64encode(auth.get_identity())
00096             filepath = self.proxy_store + '/' + proxyfile + '.proxy'
00097             if os.path.isfile(filepath):
00098                 dp = datapoint_from_url(url)
00099                 dp.AssignCredentials(filepath, '', '', self.ca_dir)
00100                 (files, stat) = dp.ListFiles(longlisting)
00101                 if files:
00102                     status = 'found'
00103                     for f in files:
00104                         if longlisting:
00105                             #print f.GetName(), " ", f.GetSize(), " ", f.GetCreated()
00106                             if (f.GetType() == 1):
00107                                 type = 'file'
00108                             elif (f.GetType() == 2):
00109                                 type = 'dir'
00110                             else:
00111                                 type = 'known'       
00112                             tmpList.append(f.GetName() + ':' + str(f.GetSize()) + ':' + type + '\n')
00113                         else:
00114                             tmpList.append(f.GetName())
00115                 else:
00116                     status = 'Cannot access external store. Reason: %s' % str(stat)
00117             else:
00118                 status = 'Your proxy cannot be found. Please delegate your credentials!'
00119         response[url] = {'list': tmpList, 'status': status, 'protocol': protocol}
00120         log.msg(arc.VERBOSE, 'list response: %s', response)
00121         return response
        

Here is the call graph for this function:

def storage.bartender.gateway.gateway.Gateway.put (   self,
  auth,
  url,
  flags 
)

Definition at line 64 of file gateway.py.

00064 
00065     def put(self, auth, url, flags):
00066         response = {}
00067         if url[:6] == 'gsiftp':
00068             protocol = 'gridftp'
00069             status = 'done'
00070         elif url[:3] == 'srm':
00071             protocol = 'srm'
00072             status = 'done'
00073         else:
00074             protocol = 'unkonwn'
00075             status = 'failed' 
00076         response[url] = {'turl':url,'status':status, 'protocol':protocol}
00077         return response

def storage.bartender.gateway.gateway.Gateway.remove (   self,
  auth,
  url,
  flags 
)
remove file or direcotory 

Definition at line 122 of file gateway.py.

00122 
00123     def remove(self, auth, url, flags):
00124         """ remove file or direcotory """
00125         response = {}
00126         protocol = ''
00127         status = ''
00128         if url[:6] == 'gsiftp':
00129             protocol = 'gridftp'
00130         elif url[:3] == 'srm':
00131             protocol = 'srm'
00132         else:
00133             protocol = 'unkonwn'
00134         if len(self.proxy_store) == 0:
00135             status = 'failed' 
00136             log.msg(arc.VERBOSE,'proxy store is not accessable.')
00137         if protocol != 'unknown':
00138             proxyfile = base64.b64encode(auth.get_identity())
00139             filepath = self.proxy_store+'/'+proxyfile+'.proxy'
00140             if os.path.isfile(filepath):
00141                 externalURL = arc.URL(url)
00142                 handle = arc.DataHandle(externalURL)
00143                 handle.__deref__().AssignCredentials(filepath,'','',self.ca_dir)
00144                 status = handle.__deref__().Remove()
00145                 #status = 'successful'
00146         else:
00147             status = 'failed'  
00148         response[url]={'status':str(status),'protocol':protocol}
00149         #print "File or directory removed"     
00150         return response 

Here is the call graph for this function:


Member Data Documentation

Definition at line 29 of file gateway.py.

Definition at line 27 of file gateway.py.

Definition at line 28 of file gateway.py.

Definition at line 26 of file gateway.py.


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