Changeset 1dcaff4 for fedd/federation/protogeni_access.py
- Timestamp:
- Mar 18, 2010 8:35:10 AM (14 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
- Children:
- 114d24b
- Parents:
- 3159f5d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/protogeni_access.py
r3159f5d r1dcaff4 253 253 (lineno, config)) 254 254 f.close() 255 256 # need this ?257 def get_users(self, obj):258 """259 Return a list of the IDs of the users in dict260 """261 if obj.has_key('user'):262 return [ unpack_id(u['userID']) \263 for u in obj['user'] if u.has_key('userID') ]264 else:265 return None266 # need this ?267 255 268 256 def write_state(self): … … 899 887 900 888 def StartSegment(self, req, fid): 901 def get_url(url, cf, destdir, fn=None):902 po = urlparse(url)903 if not fn:904 fn = po.path.rpartition('/')[2]905 retries = 0906 ok = False907 while not ok and retries < 5:908 try:909 conn = httplib.HTTPSConnection(po.hostname, port=po.port,910 cert_file=cf, key_file=cf)911 conn.putrequest('GET', po.path)912 conn.endheaders()913 response = conn.getresponse()914 915 lf = open("%s/%s" % (destdir, fn), "w")916 buf = response.read(4096)917 while buf:918 lf.write(buf)919 buf = response.read(4096)920 lf.close()921 ok = True922 except IOError, e:923 print e924 raise service_error(service_error.internal,925 "Error writing tempfile: %s" %e)926 except httplib.HTTPException, e:927 print e928 raise service_error(service_error.internal,929 "Error retrieving data: %s" % e)930 except SSLError, e:931 print "SSL error %s" %e932 retries += 1933 934 if retries > 5:935 raise service_error(service_error.internal,936 "Repeated SSL failures")937 938 889 939 890 configs = set(('hosts', 'ssh_pubkey', 'ssh_secretkey')) … … 979 930 for s in getattr(e, 'software', []): 980 931 sw.add(s.location) 981 if len(sw) > 0: 982 os.mkdir(softdir) 932 os.mkdir(softdir) 983 933 for s in sw: 984 934 self.log.debug("Retrieving %s" % s) 985 get_url(s, certfile, softdir) 935 try: 936 get_url(s, certfile, softdir) 937 except: 938 t, v, st = sys.exc_info() 939 raise service_error(service_error.internal, 940 "Error retrieving %s: %s" % (s, v)) 986 941 987 942 # Copy local portal node software to the tempdir … … 1000 955 for a in attrs: 1001 956 if a['attribute'] in configs: 1002 get_url(a['value'], certfile, tmpdir) 957 try: 958 self.log.debug("Retrieving %s" % a['value']) 959 get_url(a['value'], certfile, tmpdir) 960 except: 961 t, v, st = sys.exc_info() 962 raise service_error(service_error.internal, 963 "Error retrieving %s: %s" % (s, v)) 1003 964 if a['attribute'] == 'ssh_pubkey': 1004 965 pubkey_base = a['value'].rpartition('/')[2] … … 1037 998 "Cannot create temp file for " + 1038 999 "userconfig certificates: %s e") 1000 except: 1001 t, v, st = sys.exc_info() 1002 raise service_error(service_error.internal, 1003 "Error retrieving %s: %s" % (u, v)) 1039 1004 finally: 1040 1005 if tn: os.remove(tn) … … 1043 1008 "No certificate for retreiving userconfig") 1044 1009 break 1045 1046 1047 1010 1048 1011 self.state_lock.acquire()
Note: See TracChangeset
for help on using the changeset viewer.