Package pilot :: Package filemanagement :: Module bliss_adaptor

Source Code for Module pilot.filemanagement.bliss_adaptor

  1  ''' 
  2  Bliss based File Transfer Implementation 
  3  ''' 
  4  import urlparse 
  5   
  6  import errno 
  7  import sys 
  8  import os 
  9  import stat 
 10  import logging 
 11  import traceback 
 12  import time 
 13   
 14  sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../..")) 
 15  #sys.path.append(os.path.join(os.path.dirname(__file__), "..")) 
 16  from pilot.api import State 
 17  from bigjob import logger 
 18  import bliss.saga as saga 
 19   
20 -class BlissFileAdaptor(object):
21 """ BigData File Management for Pilot Data """ 22 23 24
25 - def __init__(self, service_url):
26 self.service_url = service_url 27 result = urlparse.urlparse(service_url) 28 self.host = result.netloc 29 self.query = result.path 30 31 self.__state=State.New
32 33
34 - def get_security_context(self):
35 """ Returns security context that needs to be available on the distributed 36 node in order to access this Pilot Data """ 37 return None
38 39
40 - def initialize_pilotdata(self):
41 # check whether directory exists 42 43 self.__state=State.Running
44 45
46 - def get_pilotdata_size(self):
47 # check size 48 return None
49 50
51 - def delete_pilotdata(self):
52 self.__state=State.Done
53 54
55 - def get_state(self):
56 return self.__state
57 58
59 - def create_du(self, du_id):
60 du_dir = os.path.join(self.path, str(du_id)) 61 logger.debug("mkdir: " + du_dir)
62 63 64
65 - def put_du(self, du):
66 pass
67 68
69 - def copy_du_to_url(self, du, local_url, remote_url):
70 pass
71 72 73
74 - def copy_du(self, du, pd_new):
75 remote_url = pd_new.service_url + "/" + str(du.id) 76 local_url = self.service_url + "/" + str(du.id) 77 self.copy_du_to_url(du, local_url, remote_url)
78 79
80 - def get_du(self, du, target_url):
81 remote_url = target_url 82 local_url = self.service_url + "/" + str(du.id) 83 self.copy_du_to_url(du, local_url, remote_url)
84 85
86 - def remove_du(self, du):
87 self.__remove_directory(os.path.join(self.path, du.id))
88 89 90 ########################################################################### 91 # Pure File Management APIs 92
93 - def transfer(self, source_url, target_url):
94 pass
95
96 - def create_remote_directory(self, target_url):
97 return True
98 99
100 - def get_path(self, target_url):
101 result = urlparse.urlparse(target_url) 102 target_query = result.path
103 104 105 ########################################################################### 106 107
108 - def __print_traceback(self):
109 exc_type, exc_value, exc_traceback = sys.exc_info() 110 print "*** print_tb:" 111 traceback.print_tb(exc_traceback, limit=1, file=sys.stdout) 112 print "*** print_exception:" 113 traceback.print_exception(exc_type, exc_value, exc_traceback, 114 limit=2, file=sys.stdout)
115 116 117 if __name__ == "__main__": 118 go = GlobusOnlineFileAdaptor("http://drelu:bigjob@cli.globusonline.org?ep=drelu#egi&path=/ho") 119 go.transfer("go://cli.globusonline.org?ep=drelu#MacBook&path=/~/cert.tar.gz", "go://cli.globusonline.org?ep=xsede#kraken&path=/~/") 120