- Timestamp:
- Mar 18, 2010 8:35:10 AM (15 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
- Children:
- 114d24b
- Parents:
- 3159f5d
- Location:
- fedd/federation
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/emulab_access.py
r3159f5d r1dcaff4 1318 1318 1319 1319 def StartSegment(self, req, fid): 1320 def get_url(url, cf, destdir, fn=None):1321 po = urlparse(url)1322 if not fn:1323 fn = po.path.rpartition('/')[2]1324 ok = False1325 retries = 01326 while not ok and retries < 5:1327 try:1328 conn = httplib.HTTPSConnection(po.hostname, port=po.port,1329 cert_file=cf, key_file=cf)1330 conn.putrequest('GET', po.path)1331 conn.endheaders()1332 response = conn.getresponse()1333 1334 lf = open("%s/%s" % (destdir, fn), "w")1335 buf = response.read(4096)1336 while buf:1337 lf.write(buf)1338 buf = response.read(4096)1339 lf.close()1340 ok = True1341 except IOError, e:1342 print e1343 raise service_error(service_error.internal,1344 "Error writing tempfile: %s" %e)1345 except httplib.HTTPException, e:1346 print e1347 raise service_error(service_error.internal,1348 "Error retrieving data: %s" % e)1349 except SSLError, e:1350 print "SSL error %s" %e1351 retries += 11352 1353 if retries > 5:1354 raise service_error(service_error.internal,1355 "Repeated SSL failures")1356 1320 1357 1321 configs = set(('hosts', 'ssh_pubkey', 'ssh_secretkey')) … … 1396 1360 for s in getattr(e, 'software', []): 1397 1361 sw.add(s.location) 1398 if len(sw) > 0: 1399 os.mkdir(softdir) 1362 os.mkdir(softdir) 1400 1363 for s in sw: 1401 1364 self.log.debug("Retrieving %s" % s) 1402 get_url(s, certfile, softdir) 1365 try: 1366 get_url(s, certfile, softdir) 1367 except: 1368 t, v, st = sys.exc_info() 1369 raise service_error(service_error.internal, 1370 "Error retrieving %s: %s" % (s, v)) 1403 1371 1404 1372 # Copy local federation and portal node software to the tempdir … … 1410 1378 for a in attrs: 1411 1379 if a['attribute'] in configs: 1412 get_url(a['value'], certfile, tmpdir) 1380 try: 1381 get_url(a['value'], certfile, tmpdir) 1382 except: 1383 t, v, st = sys.exc_info() 1384 raise service_error(service_error.internal, 1385 "Error retrieving %s: %s" % (s, v)) 1413 1386 if a['attribute'] == 'ssh_pubkey': 1414 1387 pubkey_base = a['value'].rpartition('/')[2] … … 1447 1420 "Cannot create temp file for " + 1448 1421 "userconfig certificates: %s e") 1422 except: 1423 t, v, st = sys.exc_info() 1424 raise service_error(service_error.internal, 1425 "Error retrieving %s: %s" % (s, v)) 1449 1426 finally: 1450 1427 if tn: os.remove(tn) -
fedd/federation/experiment_control.py
r3159f5d r1dcaff4 936 936 if r.has_key('Ns2SplitResponseBody'): 937 937 r = r['Ns2SplitResponseBody'] 938 if r.has_key('output'): 939 return r['output'].splitlines() 938 ed = r.get('experimentdescription', None) 939 if ed.has_key('topdldescription'): 940 return topdl.Topology(**ed['topdldescription']) 940 941 else: 941 942 raise service_error(service_error.protocol, … … 2116 2117 self.log.debug("Calling remote splitter at %s" % \ 2117 2118 self.splitter_url) 2118 split_data= self.remote_splitter(self.splitter_url,2119 top = self.remote_splitter(self.splitter_url, 2119 2120 file_content, master) 2120 2121 else: … … 2133 2134 split_data = tclparser.stdout 2134 2135 2135 2136 top = topdl.topology_from_xml(file=split_data, top="experiment") 2136 2137 2137 2138 hosts, ip_allocator = self.allocate_ips_to_topo(top) -
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() -
fedd/federation/remote_service.py
r3159f5d r1dcaff4 9 9 from M2Crypto.m2xmlrpclib import SSL_Transport 10 10 from M2Crypto.SSL import SSLError 11 from M2Crypto.BIO import BIOError 11 12 from ZSI import ParseException, FaultException, SoapWriter 12 13 … … 364 365 raise service_error(service_error.connect, 365 366 "Cannot connect to %s: %s" % (url, e[1])) 367 except BIOError, e: 368 print "BIO error contacting %s: %s" % (url, e.message) 369 retries += 1 366 370 except SSLError, e: 367 371 print "SSL error contacting %s: %s" % (url, e.message) … … 439 443 raise service_error(service_error.connect, 440 444 "Cannot connect to %s: %s" % (url, e[1])) 445 except BIOError, e: 446 print "BIO error contacting %s: %s" % (url, e.message) 447 retries += 1 441 448 except SSLError, e: 442 449 print "SSL error contacting %s: %s" % (url, e.message) -
fedd/federation/util.py
r3159f5d r1dcaff4 5 5 import logging 6 6 7 import httplib 8 7 9 from M2Crypto import SSL 10 from M2Crypto.SSL import SSLError 8 11 from fedid import fedid 12 from service_error import service_error 13 from urlparse import urlparse 9 14 10 15 … … 169 174 d.close() 170 175 176 def get_url(url, cf, destdir, fn=None, max_retries=5): 177 """ 178 Get data from a federated data store. This presents the client cert/fedid 179 to the http server. We retry up to max_retries times. 180 """ 181 po = urlparse(url) 182 if not fn: 183 fn = po.path.rpartition('/')[2] 184 retries = 0 185 ok = False 186 failed_exception = None 187 while not ok and retries < 5: 188 try: 189 conn = httplib.HTTPSConnection(po.hostname, port=po.port, 190 cert_file=cf, key_file=cf) 191 conn.putrequest('GET', po.path) 192 conn.endheaders() 193 response = conn.getresponse() 194 195 lf = open("%s/%s" % (destdir, fn), "w") 196 buf = response.read(4096) 197 while buf: 198 lf.write(buf) 199 buf = response.read(4096) 200 lf.close() 201 ok = True 202 except IOError, e: 203 failed_excpetion = e 204 retries += 1 205 except httplib.HTTPException, e: 206 failed_exception = e 207 retries += 1 208 except SSLError, e: 209 failed_exception = e 210 retries += 1 211 212 if retries > 5 and failed_exception: 213 raise failed_excpetion 214
Note: See TracChangeset
for help on using the changeset viewer.