Changeset 617592b
- Timestamp:
- Feb 20, 2010 5:27:56 PM (15 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
- Children:
- 6af3226
- Parents:
- 0f06528
- Location:
- fedd/federation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/emulab_access.py
r0f06528 r617592b 917 917 918 918 rv = None 919 print info 919 920 for i in info: 920 if i.get('portal', "") == key: 921 if key == i.get('portal', "") or \ 922 key in [e.get('element', "") \ 923 for e in i.get('member', [])]: 921 924 rv = i.copy() 922 925 break 926 923 927 else: 924 928 return rv … … 1049 1053 1050 1054 1051 def generate_ns2(self, topo, expfn, softdir, master): 1052 def dragon_commands(e): 1053 s = "" 1054 if isinstance(e, topdl.Computer): 1055 for i in e.interface: 1056 vlan = i.get_attribute('dragon_vlan') 1057 if vlan: 1058 type = i.get_attribute('dragon_type') 1059 ip = i.get_attribute('ip4_address') 1060 if type == 'link': 1061 s = ("tb-allow-external $%s dragonportal " + \ 1062 "ip %s vlan %s\n") % \ 1063 (topdl.to_tcl_name(e.name[0]), ip, vlan) 1064 elif type == 'lan': 1065 s = ("tb-allow-external $%s dragonportal " + \ 1066 "ip %s vlan %s usurp %s\n") % \ 1067 (topdl.to_tcl_name(e.name[0]), ip, vlan, 1068 i.substrate[0]) 1069 else: 1070 raise service_error(service_error_internal, 1071 "Unknown DRAGON type %s" % type) 1072 return s 1073 1074 def not_dragon(e): 1075 return all([not i.get_attribute('dragon_vlan') \ 1076 for i in e.interface]) 1055 def generate_ns2(self, topo, expfn, softdir, master, connInfo): 1056 class dragon_commands: 1057 """ 1058 Functor to spit out approrpiate dragon commands for nodes listed in 1059 the connectivity description. The constructor makes a dict mapping 1060 dragon nodes to their parameters and the __call__ checks each 1061 element in turn for membership. 1062 """ 1063 def __init__(self, map): 1064 self.node_info = map 1065 1066 def __call__(self, e): 1067 s = "" 1068 if isinstance(e, topdl.Computer): 1069 if self.node_info.has_key(e.name[0]): 1070 i = self.node_info[e.name[0]] 1071 for ifname, vlan, type in i: 1072 print "Checking %s" % e.name[0] 1073 for i in e.interface: 1074 print "interface s %s %s" % (i.name, ifname) 1075 if i.name == ifname: 1076 addr = i.get_attribute('ip4_address') 1077 subs = i.substrate[0] 1078 break 1079 else: 1080 raise service_error(service_error.internal, 1081 "No interface %s on element %s" % \ 1082 (ifname, e.name[0])) 1083 if type =='link': 1084 s = ("tb-allow-external $%s dragonportal " + \ 1085 "ip %s vlan %s\n") % \ 1086 (e.name[0], addr, vlan) 1087 elif type =='lan': 1088 s = ("tb-allow-external $%s dragonportal " + \ 1089 "ip %s vlan %s usurp %s\n") % \ 1090 (e.name[0], addr, vlan, subs) 1091 else: 1092 raise service_error(service_error_internal, 1093 "Unknown DRAGON type %s" % type) 1094 return s 1095 1096 class not_dragon: 1097 def __init__(self, map): 1098 self.nodes = set(map.keys()) 1099 1100 def __call__(self, e): 1101 return e.name[0] not in self.nodes 1077 1102 1078 1103 t = topo.clone() 1104 1105 dragon_map = { } 1106 for i in [ i for i in connInfo if i['type'] == 'transit']: 1107 for a in i.get('fedAttr', []): 1108 if a['attribute'] == 'vlan_id': 1109 vlan = a['value'] 1110 break 1111 else: 1112 raise service_error(service_error.internal, 1113 "No vlan tag") 1114 members = i.get('member', []) 1115 if len(members) > 1: type = 'lan' 1116 else: type = 'link' 1117 1118 try: 1119 for m in members: 1120 if dragon_map.has_key(m['element']): 1121 dragon_map[m['element']].append(( m['interface'], 1122 vlan, type)) 1123 else: 1124 dragon_map[m['element']] = [( m['interface'], 1125 vlan, type),] 1126 except KeyError: 1127 raise service_error(service_error.req, 1128 "Missing connectivity info") 1079 1129 1080 1130 # The startcmds for master and slave testbeds … … 1109 1159 e.set_attribute('startup', node_cmd) 1110 1160 1161 dinf = [i[0] for i in dragon_map.get(e.name[0], []) ] 1111 1162 # Remove portal interfaces that do not connect to DRAGON 1112 1163 e.interface = [i for i in e.interface \ 1113 if not i.get_attribute('portal') or \ 1114 i.get_attribute('dragon_vlan')] 1164 if not i.get_attribute('portal') or i.name in dinf ] 1115 1165 1116 1166 t.substrates = [ s.clone() for s in t.substrates ] … … 1125 1175 1126 1176 if self.attrs.has_key('dragon'): 1127 add_filter = not_dragon 1128 filters.append(dragon_commands )1177 add_filter = not_dragon(dragon_map) 1178 filters.append(dragon_commands(dragon_map)) 1129 1179 else: 1130 1180 add_filter = None … … 1312 1362 services) 1313 1363 self.generate_ns2(topo, expfile, 1314 "/proj/%s/software/%s/" % (proj, ename), master )1364 "/proj/%s/software/%s/" % (proj, ename), master, connInfo) 1315 1365 1316 1366 starter = self.start_segment(keyfile=self.ssh_privkey_file, -
fedd/federation/experiment_control.py
r0f06528 r617592b 831 831 # Add attributes to parameter space. We don't allow attributes to 832 832 # overlay any parameters already installed. 833 for a in r ['fedAttr']:833 for a in r.get('fedAttr', []): 834 834 try: 835 835 if a['attribute'] and \ … … 923 923 try: 924 924 self.log.debug("Calling StartSegment at %s " % uri) 925 print req926 925 r = self.caller(uri, req, self.cert_file, self.cert_pwd, 927 926 self.trusted_certs) … … 1039 1038 vlan = get_vlan(ss.response) 1040 1039 if vlan is not None: 1041 for k, t in topo.items():1042 for e in t.elements:1043 for i in e.interface:1044 vl = i.get_attribute('dragon_vlan')1045 if vl is not None and vl== to_repl:1046 i.set_attribute('dragon_vlan', vlan)1040 for v in connInfo.values(): 1041 for i in v: 1042 for a in i.get('fedAttr', []): 1043 if a.get('attribute', "") == 'vlan_id' and \ 1044 a.get('value', "") == to_repl: 1045 a['value'] = vlan 1047 1046 else: 1048 1047 break … … 1355 1354 ) 1356 1355 ifaces.append(inf) 1357 info = { 1358 "type" : conn_type, 1359 "portal": myname, 1360 'peer': desthost, 1361 'fedAttr': [ 1362 { 'attribute': 'masterdomain', 'value': mdomain}, 1363 { 'attribute': 'masterexperiment', 'value': 1364 "%s/%s" % (mproject, eid)}, 1365 { 'attribute': 'active', 'value': active}, 1366 # Move to SMB service description 1367 { 'attribute': 'masteruser', 'value': muser}, 1368 { 'attribute': 'smbshare', 'value': smbshare}, 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) 1356 if conn_type == "ssh": 1357 info = { 1358 "type" : conn_type, 1359 "portal": myname, 1360 'peer': desthost, 1361 'fedAttr': [ 1362 { 'attribute': 'masterdomain', 'value': mdomain}, 1363 { 'attribute': 'masterexperiment', 'value': 1364 "%s/%s" % (mproject, eid)}, 1365 { 'attribute': 'active', 'value': active}, 1366 # Move to SMB service description 1367 { 'attribute': 'masteruser', 'value': muser}, 1368 { 'attribute': 'smbshare', 'value': smbshare}, 1369 ], 1370 } 1371 else: 1372 info = None 1376 1373 1377 1374 return (topdl.Computer( … … 1455 1452 1456 1453 def create_dragon_substrate(self, sub, topo, tbs, tbparams, master, eid, 1457 connInfo ):1454 connInfo, peer={ }): 1458 1455 """ 1459 1456 Add attribiutes to the various elements indicating that they are to be … … 1467 1464 else: return None 1468 1465 1466 mdomain = tbparams[master].get('domain', '.example.com') 1467 mproject = tbparams[master].get('project', 'project') 1469 1468 # dn is the number of previously created dragon nets. This routine 1470 1469 # creates a net numbered by dn … … 1473 1472 # the global topology 1474 1473 count = { } 1474 node = { } 1475 1475 for e in [ i.element for i in sub.interfaces ]: 1476 1476 tb = e.get_attribute('testbed') 1477 1477 count[tb] = count.get(tb, 0) + 1 1478 node[tb] = i.get_attribute('ip4_address') 1479 1478 1480 1479 1481 # Set the attributes in the copies that will allow setup of dragon … … 1484 1486 if not connInfo.has_key(tb): 1485 1487 connInfo[tb] = [ ] 1488 1489 # This may need another look, but only a service gateway will 1490 # look at the active parameter, and these are only inserted to 1491 # connect to the master. 1492 active = "%s" % ( tb == 'master') 1486 1493 info = { 1487 1494 'type': 'transit', … … 1489 1496 'element': i.element.name[0], 1490 1497 'interface': i.name 1491 } for i in s.interfaces ], 1492 'fedAttr': [ { 1493 'attribute': 'vlan_id', 1494 'value': 'unassigned%d' % dn 1495 } ] 1498 } for i in s.interfaces \ 1499 if isinstance(i.element, topdl.Computer) ], 1500 'fedAttr': [ 1501 { 'attribute': 'vlan_id', 1502 'value': 'unassigned%d' % dn }, 1503 { 'attribute': 'masterdomain', 'value': mdomain}, 1504 { 'attribute': 'masterexperiment', 'value': 1505 "%s/%s" % (mproject, eid)}, 1506 { 'attribute': 'active', 'value': active}, 1507 ], 1496 1508 } 1509 if peer.has_key(tb): 1510 info['peer'] = peer[tb] 1497 1511 connInfo[tb].append(info) 1498 1512 else: … … 1631 1645 ('portal','true'), 1632 1646 ('ip4_address', "%s" % ip_addr(myip)),)),), 1633 conn_type="transit", 1634 conn_attrs = [ { 1635 'attribute': 'vlan_id', 'value': 'unassigned%d' % idx 1636 }]) 1647 conn_type="transit") 1637 1648 if self.fedkit: 1638 1649 self.add_kit(portal, self.fedkit) … … 1640 1651 self.add_kit(portal, self.gatewaykit) 1641 1652 1642 return portal , info1653 return portal 1643 1654 1644 1655 def add_portals(self, top, topo, eid, master, tbparams, ip_allocator, … … 1721 1732 ], 1722 1733 ) 1723 portal , info= self.new_dragon_portal(tb, master,1734 portal = self.new_dragon_portal(tb, master, 1724 1735 master, eid, dip, mip, idx, csub, tbparams) 1725 1736 topo[tb].substrates.append(csub) 1726 1737 topo[tb].elements.append(portal) 1727 1738 topo[tb].elements.append(seg) 1728 if not connInfo.has_key(tb):1729 connInfo[tb] = [info]1730 else:1731 connInfo[tb].append(info)1732 1739 1733 1740 mcsub = csub.clone() … … 1752 1759 ], 1753 1760 ) 1754 portal , info= self.new_dragon_portal(master, tb, master,1761 portal = self.new_dragon_portal(master, tb, master, 1755 1762 eid, mip, dip, idx, mcsub, tbparams) 1756 1763 topo[master].substrates.append(mcsub) 1757 1764 topo[master].elements.append(portal) 1758 1765 topo[master].elements.append(seg) 1759 if not connInfo.has_key(master): 1760 connInfo[master] = [info] 1761 else: 1762 connInfo[master].append(info) 1766 for t in (master, tb): 1767 topo[t].incorporate_elements() 1763 1768 1764 1769 self.create_dragon_substrate(csub, topo, 1765 {tb: 1, master:1}, tbparams, master, eid) 1770 {tb: 1, master:1}, tbparams, master, eid, connInfo, 1771 {tb: ip_addr(mip), master: ip_addr(dip)}) 1766 1772 else: 1767 1773 self.add_control_portal(master, tb, master, eid, topo, … … 2104 2110 tb = t.get_attribute('testbed') 2105 2111 if tb: 2106 self.get_access(tb, None, user,tbparams, master,2112 self.get_access(tb, None, tbparams, master, 2107 2113 export_project, access_user, services) 2108 2114 tbparams[k] = tbparams[tb] … … 2196 2202 ] 2197 2203 2204 # transit and disconnected testbeds may not have a connInfo entry. 2205 # Fill in the blanks. 2206 for t in allocated.keys(): 2207 if not connInfo.has_key(t): 2208 connInfo[t] = { } 2209 2198 2210 # Start a thread to do the resource allocation 2199 2211 t = Thread(target=self.allocate_resources,
Note: See TracChangeset
for help on using the changeset viewer.