- Timestamp:
- Feb 20, 2010 12:07:17 PM (15 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
- Children:
- 39ee3cc
- Parents:
- 2fdf4b3
- Location:
- fedd/federation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/experiment_control.py
r2fdf4b3 r5b74b63 923 923 try: 924 924 self.log.debug("Calling StartSegment at %s " % uri) 925 print req 925 926 r = self.caller(uri, req, self.cert_file, self.cert_pwd, 926 927 self.trusted_certs) … … 1324 1325 1325 1326 def new_portal_node(self, st, dt, tbparams, master, eid, myname, desthost, 1326 portal_type, iface_desc=() ):1327 portal_type, iface_desc=(), conn_type="ssh", conn_attrs=[]): 1327 1328 """ 1328 1329 Return a new internet portal node and a dict with the connectionInfo to … … 1344 1345 for sub, attrs in iface_desc: 1345 1346 inf = topdl.Interface( 1347 name="inf%03d" % len(ifaces), 1346 1348 substrate=sub, 1347 1349 attribute=[ … … 1354 1356 ifaces.append(inf) 1355 1357 info = { 1356 "type" : "ssh",1358 "type" : conn_type, 1357 1359 "portal": myname, 1358 'peer': "%s.%s.%s%s" % (desthost.lower(), eid.lower(), 1359 dproject.lower(), ddomain.lower()), 1360 'peer': desthost, 1360 1361 'fedAttr': [ 1361 1362 { 'attribute': 'masterdomain', 'value': mdomain}, … … 1368 1369 ], 1369 1370 } 1371 1372 if conn_type == 'transit': 1373 info['member'] = [ { 'element': myname, 'interface': 'inf000'} ] 1374 if conn_attrs: 1375 info['fedAttr'].extend(con_attrs) 1376 1370 1377 return (topdl.Computer( 1371 1378 name=myname, … … 1447 1454 ) 1448 1455 1449 def create_dragon_substrate(self, sub, topo, tbs, tbparams, master, eid): 1456 def create_dragon_substrate(self, sub, topo, tbs, tbparams, master, eid, 1457 connInfo): 1450 1458 """ 1451 1459 Add attribiutes to the various elements indicating that they are to be 1452 dragon connected and create a dragon segment in top sto be1460 dragon connected and create a dragon segment in topo to be 1453 1461 instantiated. 1454 1462 """ … … 1459 1467 else: return None 1460 1468 1469 # dn is the number of previously created dragon nets. This routine 1470 # creates a net numbered by dn 1461 1471 dn = len([x for x in topo.keys() if x.startswith('dragon')]) 1462 elements = [ i.element for i in sub.interfaces ] 1472 # Count the number of interfaces on this substrate in each testbed from 1473 # the global topology 1463 1474 count = { } 1464 for e in elements:1475 for e in [ i.element for i in sub.interfaces ]: 1465 1476 tb = e.get_attribute('testbed') 1466 1477 count[tb] = count.get(tb, 0) + 1 1467 1478 1479 # Set the attributes in the copies that will allow setup of dragon 1480 # connections. 1468 1481 for tb in tbs.keys(): 1469 1482 s = get_substrate_from_topo(sub.name, topo[tb]) 1470 1483 if s: 1471 for i in s.interfaces: 1472 i.set_attribute('dragon_vlan', 'unassigned%d' % dn) 1473 if count[tb] > 1: i.set_attribute('dragon_type', 'lan') 1474 else: i.set_attribute('dragon_type', 'link') 1484 if not connInfo.has_key(tb): 1485 connInfo[tb] = [ ] 1486 info = { 1487 'type': 'transit', 1488 'member': [ { 1489 'element': i.element.name[0], 1490 'interface': i.name 1491 } for i in s.interfaces ], 1492 'fedAttr': [ { 1493 'attribute': 'vlan_id', 1494 'value': 'unassigned%d' % dn 1495 } ] 1496 } 1497 connInfo[tb].append(info) 1475 1498 else: 1476 1499 raise service_error(service_error.internal, … … 1530 1553 portal_type = "experiment" 1531 1554 myname = "%stunnel%d" % (dt, len(portals[st][dt])) 1532 desthost = "%stunnel%d" % (st, len(portals[st][dt])) 1555 desthost = "%stunnel%d.%s.%s%s" % (st, 1556 len(portals[st][dt]), eid.lower(), 1557 dproject.lower(), ddomain.lower()) 1533 1558 else: 1534 1559 new_i = topdl.Interface( … … 1547 1572 portals[st][dt] = [ ] 1548 1573 myname = "%stunnel%d" % (dt, len(portals[st][dt])) 1549 desthost = "%stunnel%d" % (st, len(portals[st][dt])) 1574 desthost = "%stunnel%d.%s.%s%s" % (st.lower(), 1575 len(portals[st][dt]), eid.lower(), 1576 dproject.lower(), ddomain.lower()) 1550 1577 1551 1578 if dt == master or st == master: portal_type = "both" … … 1599 1626 desthost = "%s" % ip_addr(dip) 1600 1627 1601 portal = self.new_portal_node(st, dt, tbparams, master,1628 portal, info = self.new_portal_node(st, dt, tbparams, master, 1602 1629 eid, myname, desthost, "control", 1603 1630 ((substrate.name,( 1604 1631 ('portal','true'), 1605 ('ip4_address', "%s" % ip_addr(myip)), 1606 ('dragon_vlan', 'unassigned%d' % idx), 1607 ('dragon_type', 'link'),)),)) 1632 ('ip4_address', "%s" % ip_addr(myip)),)),), 1633 conn_type="transit", 1634 conn_attrs = [ { 1635 'attribute': 'vlan_id', 'value': 'unassigned%d' % idx 1636 }]) 1608 1637 if self.fedkit: 1609 1638 self.add_kit(portal, self.fedkit) … … 1611 1640 self.add_kit(portal, self.gatewaykit) 1612 1641 1613 return portal 1642 return portal, info 1614 1643 1615 1644 def add_portals(self, top, topo, eid, master, tbparams, ip_allocator, … … 1640 1669 all([tbparams[x].has_key('dragon') for x in tbs]): 1641 1670 self.create_dragon_substrate(s, topo, tbs, tbparams, 1642 master, eid )1671 master, eid, connInfo) 1643 1672 else: 1644 1673 self.insert_internet_portals(s, topo, tbs, tbparams, master, … … 1692 1721 ], 1693 1722 ) 1723 portal, info = self.new_dragon_portal(tb, master, 1724 master, eid, dip, mip, idx, csub, tbparams) 1694 1725 topo[tb].substrates.append(csub) 1695 topo[tb].elements.append( 1696 self.new_dragon_portal(tb, master, master, eid, 1697 dip, mip, idx, csub, tbparams)) 1726 topo[tb].elements.append(portal) 1698 1727 topo[tb].elements.append(seg) 1728 if not connInfo.has_key(tb): 1729 connInfo[tb] = [info] 1730 else: 1731 connInfo[tb].append(info) 1699 1732 1700 1733 mcsub = csub.clone() … … 1719 1752 ], 1720 1753 ) 1754 portal, info = self.new_dragon_portal(master, tb, master, 1755 eid, mip, dip, idx, mcsub, tbparams) 1721 1756 topo[master].substrates.append(mcsub) 1722 topo[master].elements.append( 1723 self.new_dragon_portal(master, tb, master, eid, 1724 mip, dip, idx, mcsub, tbparams)) 1757 topo[master].elements.append(portal) 1725 1758 topo[master].elements.append(seg) 1759 if not connInfo.has_key(master): 1760 connInfo[master] = [info] 1761 else: 1762 connInfo[master].append(info) 1726 1763 1727 1764 self.create_dragon_substrate(csub, topo, -
fedd/federation/topdl.py
r2fdf4b3 r5b74b63 55 55 56 56 class ConsistencyError(RuntimeError): pass 57 class NamespaceError(RuntimeError): pass 57 58 58 59 class Attribute(base): … … 199 200 200 201 class Interface(base): 201 def __init__(self, substrate, capacity=None, latency=None, attribute=[], 202 element=None): 202 def __init__(self, substrate, name=None, capacity=None, latency=None, 203 attribute=[], element=None): 204 self.name = name 203 205 self.substrate = self.make_list(substrate) 204 206 self.capacity = self.init_class(Capacity, capacity) … … 216 218 else: l = None 217 219 218 return Interface(substrate=self.substrate, 220 return Interface(substrate=self.substrate, name=self.name, 219 221 capacity=c, latency=l, 220 222 attribute = [ a.clone() for a in self.attribute]) 221 223 222 224 def to_dict(self): 223 rv = { 'substrate': self.substrate }225 rv = { 'substrate': self.substrate, 'name': self.name } 224 226 if self.capacity: 225 227 rv['capacity'] = self.capacity.to_dict() … … 403 405 self.incorporate_elements() 404 406 407 @staticmethod 408 def name_element_interfaces(e): 409 names = set([i.name for i in e.interface if i.name]) 410 inum = 0 411 for i in [ i for i in e.interface if not i.name]: 412 while inum < 1000: 413 n = "inf%03d" % inum 414 inum += 1 415 if n not in names: 416 i.name = n 417 break 418 else: 419 raise NamespaceError("Cannot make new interface name") 420 421 422 423 def name_interfaces(self): 424 """ 425 For any interface without a name attribute, assign a unique one within 426 its element. 427 """ 428 429 for e in self.elements: 430 self.name_element_interfaces(e) 431 432 405 433 def incorporate_elements(self): 406 434 … … 416 444 417 445 for e in self.elements: 446 self.name_element_interfaces(e) 418 447 for i in e.interface: 419 448 i.element = e … … 781 810 out += '\t\t<node_type type_name="%s" slots="%s"/>\n' % (hw, slots) 782 811 for i, ii in enumerate(e.interface): 783 iname = "if%03d" % i 784 out += '\t\t<interface virtual_id="%s"/>\n' % iname 785 ifname[ii] = iname 812 out += '\t\t<interface virtual_id="%s"/>\n' % ii.name 786 813 ifnode[ii] = name 787 814 for f in filters: … … 797 824 for ii in s.interfaces: 798 825 out += ('\t\t<interface_ref virtual_node_id="%s"' + \ 799 'virtual_interface_id="%s"/>\n') % (ifnode[ii], i fname[ii])826 'virtual_interface_id="%s"/>\n') % (ifnode[ii], ii.name) 800 827 for f in filters: 801 828 out += f(s)
Note: See TracChangeset
for help on using the changeset viewer.