Changeset 13e3dd2
- Timestamp:
- Sep 10, 2009 5:01:57 PM (15 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-2.00, version-3.01, version-3.02
- Children:
- 1d913e13
- Parents:
- e2a7a413
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/experiment_control.py
re2a7a413 r13e3dd2 918 918 919 919 try: 920 self.log.debug("Calling StartSegment at %s " % uri) 920 921 r = self.caller(uri, req, self.cert_file, self.cert_pwd, 921 922 self.trusted_certs) … … 1281 1282 if self.fedkit: self.add_kit(e, self.fedkit) 1282 1283 1284 def new_portal_node(self, st, dt, tbparams, master, eid, myname, desthost, 1285 portal_type, portal_subst, subst=None, addr=None): 1286 sproject = tbparams[st].get('project', 'project') 1287 dproject = tbparams[dt].get('project', 'project') 1288 mproject = tbparams[master].get('project', 'project') 1289 sdomain = tbparams[st].get('domain', ".example.com") 1290 ddomain = tbparams[dt].get('domain', ".example.com") 1291 mdomain = tbparams[master].get('domain', '.example.com') 1292 muser = tbparams[master].get('user', 'root') 1293 smbshare = tbparams[master].get('smbshare', 'USERS') 1294 aid = tbparams[dt]['allocID']['fedid'] 1295 if st == master or dt == master: 1296 active = ("%s" % (st == master)) 1297 else: 1298 active = ("%s" %(st > dt)) 1299 1300 ifaces = [ 1301 topdl.Interface( 1302 substrate=portal_subst, 1303 attribute=[ 1304 topdl.Attribute(attribute='portal', 1305 value='true') 1306 ] 1307 ), 1308 ] 1309 if subst and addr: 1310 ifaces.append( 1311 topdl.Interface( 1312 substrate=subst, 1313 attribute=[ 1314 topdl.Attribute( 1315 attribute='ip4_address', 1316 value=addr, 1317 ) 1318 ] 1319 )) 1320 1321 1322 return topdl.Computer( 1323 name=myname, 1324 attribute=[ 1325 topdl.Attribute(attribute=n,value=v) 1326 for n, v in (\ 1327 ('portal', 'true'), 1328 ('domain', sdomain), 1329 ('masterdomain', mdomain), 1330 ('masterexperiment', "%s/%s" % \ 1331 (mproject, eid)), 1332 ('masteruser', muser), 1333 ('smbshare', smbshare), 1334 ('experiment', "%s/%s" % \ 1335 (sproject, eid)), 1336 ('peer', "%s" % desthost), 1337 ('peer_segment', "%s" % aid), 1338 ('scriptdir', 1339 "/usr/local/federation/bin"), 1340 ('active', "%s" % active), 1341 ('portal_type', portal_type), 1342 ('startup', 'sudo -H /usr/local/federation/bin/fed-tun.pl -f /proj/%s/exp/%s/tmp/%s.%s.%s%s.gw.conf >& /tmp/bridge.log' % (sproject, eid, myname.lower(), eid.lower(), sproject.lower(), sdomain.lower()))) 1343 ], 1344 interface=ifaces, 1345 ) 1346 1347 def new_portal_substrate(self, st, dt, eid, tbparams): 1348 ddomain = tbparams[dt].get('domain', ".example.com") 1349 dproject = tbparams[dt].get('project', 'project') 1350 tsubstrate = \ 1351 topdl.Substrate(name='%s-%s' % (st, dt), 1352 attribute= [ 1353 topdl.Attribute( 1354 attribute='portal', 1355 value='true') 1356 ] 1357 ) 1358 segment_element = topdl.Segment( 1359 id= tbparams[dt]['allocID'], 1360 type='emulab', 1361 uri = self.tbmap.get(dt, None), 1362 interface=[ 1363 topdl.Interface( 1364 substrate=tsubstrate.name), 1365 ], 1366 attribute = [ 1367 topdl.Attribute(attribute=n, value=v) 1368 for n, v in (\ 1369 ('domain', ddomain), 1370 ('experiment', "%s/%s" % \ 1371 (dproject, eid)),) 1372 ], 1373 ) 1374 1375 return (tsubstrate, segment_element) 1376 1283 1377 def add_portals(self, top, topo, eid, master, tbparams): 1284 1378 """ … … 1287 1381 into the copies of those substrates on the sub topologies. 1288 1382 """ 1383 segment_substrate = { } 1384 portals = { } 1289 1385 for s in top.substrates: 1290 1386 # tbs will contain an ip address on this subsrate that is in … … 1304 1400 # some portals into the subtopologies. st == source testbed, 1305 1401 # dt == destination testbed. 1306 segment_substrate = { }1307 1402 for st in tbs.keys(): 1308 segment_substrate[st] = { } 1403 if not segment_substrate.has_key(st): 1404 segment_substrate[st] = { } 1405 if not portals.has_key(st): 1406 portals[st] = { } 1309 1407 for dt in [ t for t in tbs.keys() if t != st]: 1310 myname = "%stunnel" % dt1311 desthost = "%stunnel" % st1312 1408 sproject = tbparams[st].get('project', 'project') 1313 1409 dproject = tbparams[dt].get('project', 'project') … … 1318 1414 muser = tbparams[master].get('user', 'root') 1319 1415 smbshare = tbparams[master].get('smbshare', 'USERS') 1320 # XXX: active and type need to be unkludged 1321 active = ("%s" % (st == master)) 1416 aid = tbparams[dt]['allocID']['fedid'] 1417 if st == master or dt == master: 1418 active = ("%s" % (st == master)) 1419 else: 1420 active = ("%s" %(st > dt)) 1322 1421 if not segment_substrate[st].has_key(dt): 1323 1422 # Put a substrate and a segment for the connected 1324 1423 # testbed in there. 1325 tsubstrate = \ 1326 topdl.Substrate(name='%s-%s' % (st, dt), 1327 attribute= [ 1328 topdl.Attribute( 1329 attribute='portal', 1330 value='true') 1331 ] 1332 ) 1333 segment_element = topdl.Segment( 1334 id= tbparams[dt]['allocID'], 1335 type='emulab', 1336 uri = self.tbmap.get(dt, None), 1337 interface=[ 1338 topdl.Interface( 1339 substrate=tsubstrate.name), 1340 ], 1341 attribute = [ 1342 topdl.Attribute(attribute=n, value=v) 1343 for n, v in (\ 1344 ('domain', ddomain), 1345 ('experiment', "%s/%s" % \ 1346 (dproject, eid)),) 1347 ], 1348 ) 1424 tsubstrate, segment_element = \ 1425 self.new_portal_substrate(st, dt, eid, tbparams) 1349 1426 segment_substrate[st][dt] = tsubstrate 1350 1427 topo[st].substrates.append(tsubstrate) 1351 1428 topo[st].elements.append(segment_element) 1352 portal = topdl.Computer( 1353 name="%stunnel" % dt, 1354 attribute=[ 1355 topdl.Attribute(attribute=n,value=v) 1356 for n, v in (\ 1357 ('portal', 'true'), 1358 ('domain', sdomain), 1359 ('masterdomain', mdomain), 1360 ('masterexperiment', "%s/%s" % \ 1361 (mproject, eid)), 1362 ('masteruser', muser), 1363 ('smbshare', smbshare), 1364 ('experiment', "%s/%s" % \ 1365 (sproject, eid)), 1366 ('peer', "%s" % desthost), 1367 ('peer_segment', "%s" % \ 1368 tbparams[dt]['allocID']['fedid']), 1369 ('scriptdir', 1370 "/usr/local/federation/bin"), 1371 ('active', "%s" % active), 1372 ('portal_type', 'both'), 1373 ('startup', 'sudo -H /usr/local/federation/bin/fed-tun.pl -f /proj/%s/exp/%s/tmp/%s.%s.%s%s.gw.conf >& /tmp/bridge.log' % (sproject, eid, myname.lower(), eid.lower(), sproject.lower(), sdomain.lower()))) 1374 ], 1375 interface=[ 1376 topdl.Interface( 1429 1430 new_portal = False 1431 if portals[st].has_key(dt): 1432 # There's a portal set up to go to this destination. 1433 # See if there's room to multiples this connection on 1434 # it. If so, add an interface to the portal; if not, 1435 # set up to add a portal below. 1436 # [This little festival of braces is just a pop of the 1437 # last element in the list of portals between st and 1438 # dt.] 1439 portal = portals[st][dt][-1] 1440 mux = len([ i for i in portal.interface \ 1441 if not i.get_attribute('portal')]) 1442 if mux == self.muxmax: 1443 new_portal = True 1444 portal_type = "experiment" 1445 myname = "%stunnel%d" % (dt, len(portals[st][dt])) 1446 desthost = "%stunnel%d" % (st, len(portals[st][dt])) 1447 else: 1448 new_i = topdl.Interface( 1377 1449 substrate=s.name, 1378 1450 attribute=[ … … 1381 1453 value=tbs[dt] 1382 1454 ) 1383 ]), 1384 topdl.Interface( 1385 substrate=\ 1386 segment_substrate[st][dt].name, 1387 attribute=[ 1388 topdl.Attribute(attribute='portal', 1389 value='true') 1390 ] 1391 ), 1392 ], 1393 ) 1394 if self.fedkit: self.add_kit(portal, self.fedkit) 1395 if self.gatewaykit: self.add_kit(portal, self.gatewaykit) 1396 1397 topo[st].elements.append(portal) 1398 1399 # Connect the gateway nodes into the topologies and clear out 1455 ]) 1456 portal.interface.append(new_i) 1457 else: 1458 # First connection to this testbed, make an empty list 1459 # and set up to add the new portal below 1460 new_portal = True 1461 portals[st][dt] = [ ] 1462 myname = "%stunnel%d" % (dt, len(portals[st][dt])) 1463 desthost = "%stunnel%d" % (st, len(portals[st][dt])) 1464 1465 if dt == master or st == master: portal_type = "both" 1466 else: portal_type = "experiment" 1467 1468 if new_portal: 1469 portal = self.new_portal_node(st, dt, tbparams, 1470 master, eid, myname, desthost, portal_type, 1471 segment_substrate[st][dt].name, s.name, tbs[dt]) 1472 if self.fedkit: 1473 self.add_kit(portal, self.fedkit) 1474 if self.gatewaykit: 1475 self.add_kit(portal, self.gatewaykit) 1476 1477 topo[st].elements.append(portal) 1478 portals[st][dt].append(portal) 1479 1480 # Make sure that all the slaves have a control portal back to the 1481 # master. 1482 for tb in [ t for t in tbparams.keys() if t != master ]: 1483 if len([e for e in topo[tb].elements \ 1484 if isinstance(e, topdl.Computer) and \ 1485 e.get_attribute('portal') and \ 1486 e.get_attribute('portal_type') == 'both']) == 0: 1487 1488 # Add to the master testbed 1489 tsubstrate, segment_element = \ 1490 self.new_portal_substrate(master, tb, eid, tbparams) 1491 myname = "%stunnel" % tb 1492 desthost = "%stunnel" % master 1493 1494 portal = self.new_portal_node(master, tb, tbparams, master, 1495 eid, myname, desthost, "control", tsubstrate.name) 1496 if self.fedkit: 1497 self.add_kit(portal, self.fedkit) 1498 if self.gatewaykit: 1499 self.add_kit(portal, self.gatewaykit) 1500 1501 topo[master].substrates.append(tsubstrate) 1502 topo[master].elements.append(segment_element) 1503 topo[master].elements.append(portal) 1504 1505 # And to the other testbed 1506 1507 tsubstrate, segment_element = \ 1508 self.new_portal_substrate(tb, master, eid, tbparams) 1509 myname = "%stunnel" % master 1510 desthost = "%stunnel" % tb 1511 1512 portal = self.new_portal_node(tb, master, tbparams, master, 1513 eid, myname, desthost, "control", tsubstrate.name) 1514 if self.fedkit: 1515 self.add_kit(portal, self.fedkit) 1516 if self.gatewaykit: 1517 self.add_kit(portal, self.gatewaykit) 1518 1519 topo[tb].substrates.append(tsubstrate) 1520 topo[tb].elements.append(segment_element) 1521 topo[tb].elements.append(portal) 1522 1523 1524 # Connect the portal nodes into the topologies and clear out 1400 1525 # substrates that are not in the topologies 1401 1526 for tb in tbparams.keys():
Note: See TracChangeset
for help on using the changeset viewer.