Changeset 1dcaff4 for fedd/federation/emulab_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/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)
Note: See TracChangeset
for help on using the changeset viewer.