- Timestamp:
- May 11, 2010 12:50:59 PM (15 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
- Children:
- bf3e812
- Parents:
- 7dbfaed
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/emulab_access.py
r7dbfaed re76f38a 87 87 self.federation_software = config.get("access", "federation_software") 88 88 self.portal_software = config.get("access", "portal_software") 89 self.local_seer_software = config.get("access", "local_seer_software") 90 self.local_seer_image = config.get("access", "local_seer_image") 91 self.local_seer_start = config.get("access", "local_seer_start") 89 92 self.ssh_privkey_file = config.get("access","ssh_privkey_file") 90 93 self.ssh_pubkey_file = config.get("access","ssh_pubkey_file") … … 96 99 self.federation_software = software_list(self.federation_software) 97 100 self.portal_software = software_list(self.portal_software) 101 self.local_seer_software = software_list(self.local_seer_software) 98 102 99 103 self.access_type = self.access_type.lower() … … 126 130 # XXX: Configurable 127 131 self.exports = set(('SMB', 'seer', 'tmcd', 'userconfig', 128 'project_export' ))132 'project_export', 'local_seer_control')) 129 133 self.imports = set(('SMB', 'seer', 'userconfig')) 134 135 if not self.local_seer_image or not self.local_seer_software or \ 136 not self.local_seer_start: 137 self.exports.discard('local_seer_control') 130 138 131 139 if auth: self.auth = auth … … 160 168 'ReleaseAccess': soap_handler("ReleaseAccess", self.ReleaseAccess), 161 169 'StartSegment': soap_handler("StartSegment", self.StartSegment), 162 'TerminateSegment': soap_handler("TerminateSegment", self.TerminateSegment), 170 'TerminateSegment': soap_handler("TerminateSegment", 171 self.TerminateSegment), 163 172 } 164 173 self.xmlrpc_services = {\ … … 182 191 allocate_project_remote(config, auth) 183 192 193 184 194 # If the project allocator exports services, put them in this object's 185 195 # maps so that classes that instantiate this can call the services. 186 196 self.soap_services.update(self.allocate_project.soap_services) 187 197 self.xmlrpc_services.update(self.allocate_project.xmlrpc_services) 198 199 @staticmethod 200 def add_kit(e, kit): 201 """ 202 Add a Software object created from the list of (install, location) 203 tuples passed as kit to the software attribute of an object e. We 204 do this enough to break out the code, but it's kind of a hack to 205 avoid changing the old tuple rep. 206 """ 207 208 s = [ topdl.Software(install=i, location=l) for i, l in kit] 209 210 if isinstance(e.software, list): e.software.extend(s) 211 else: e.software = s 188 212 189 213 … … 573 597 } 574 598 599 def export_local_seer(self, id, state, project, user): 600 return { 601 'id': id, 602 'name': 'local_seer_control', 603 'visibility': 'export', 604 'server': 'http://control:16606', 605 } 606 575 607 def export_tmcd(self, id, state, project, user): 576 608 return { … … 623 655 exp.append(self.export_userconfig(id, state, 624 656 project, user)) 657 elif sname == 'local_seer_control': 658 exp.append(self.export_local_seer(id, state, project, 659 user)) 625 660 return (exp, state) 626 661 … … 1067 1102 seer_out = False 1068 1103 client_out = False 1104 mproj = None 1105 mexp = None 1106 control_gw = None 1107 testbed = "" 1108 # Create configuration files for the portals 1069 1109 for e in [ e for e in topo.elements \ 1070 1110 if isinstance(e, topdl.Computer) and e.get_attribute('portal')]: 1071 1111 myname = e.name[0] 1072 1112 type = e.get_attribute('portal_type') 1073 testbed = e.get_attribute('testbed')1074 1113 1075 1114 info = conninfo_to_dict(myname, connInfo) … … 1083 1122 ssh_port = info.get('ssh_port', 22) 1084 1123 1085 mexp = info.get('masterexperiment',"") 1086 mproj, meid = mexp.split("/", 1) 1087 mdomain = info.get('masterdomain',"") 1088 muser = info.get('masteruser','root') 1089 smbshare = info.get('smbshare', 'USERS') 1124 # Collect this for the client.conf file 1125 if 'masterexperiment' in info: 1126 mproj, meid = info['masterexperiment'].split("/", 1) 1127 1128 if type in ('control', 'both'): 1129 testbed = e.get_attribute('testbed') 1130 control_gw = myname 1090 1131 1091 1132 active = info.get('active', 'False') … … 1114 1155 raise service_error(service_error.internal, 1115 1156 "Can't write protal config %s: %s" % (cfn, e)) 1116 1117 if not client_out and type in ('control', 'both'):1118 1119 1120 print >>f, "ControlGateway: %s.%s.%s%s" % \1121 (myname.lower(), leid.lower(), lproj.lower(),1122 ldomain.lower())1123 for s in services:1124 if s.get('name',"") in self.imports and \1125 s.get('visibility','') == 'import':1126 client_service_out[s['name']](f, s)1127 # Seer uses this.1128 print >>f, "ExperimentID: %s/%s" % (mproj, meid)1129 # Better way...1130 if testbed == master:1131 print >>f, "SEERBase: True"1132 f.close()1133 except IOError, e:1134 raise service_error(service_error.internal,1135 "Cannot write client.conf: %s" %s)1136 client_out = True1137 1157 1158 # Done with portals, write the client config file. 1159 try: 1160 f = open("%s/client.conf" % tmpdir, "w") 1161 if control_gw: 1162 print >>f, "ControlGateway: %s.%s.%s%s" % \ 1163 (myname.lower(), leid.lower(), lproj.lower(), 1164 ldomain.lower()) 1165 for s in services: 1166 if s.get('name',"") in self.imports and \ 1167 s.get('visibility','') == 'import': 1168 client_service_out[s['name']](f, s) 1169 # Seer uses this. 1170 if mproj and meid: 1171 print >>f, "ExperimentID: %s/%s" % (mproj, meid) 1172 # Better way... 1173 if testbed == master: 1174 print >>f, "SEERBase: True" 1175 f.close() 1176 except IOError, e: 1177 raise service_error(service_error.internal, 1178 "Cannot write client.conf: %s" %s) 1138 1179 1139 1180 def generate_ns2(self, topo, expfn, softdir, master, connInfo): … … 1184 1225 return e.name[0] not in self.nodes 1185 1226 1186 def add_kit(e, kit):1187 """1188 Add a Software object created from the list of (install, location)1189 tuples passed as kit to the software attribute of an object e. We1190 do this enough to break out the code, but it's kind of a hack to1191 avoid changing the old tuple rep.1192 """1193 1194 s = [ topdl.Software(install=i, location=l) for i, l in kit]1195 1196 if isinstance(e.software, list): e.software.extend(s)1197 else: e.software = s1198 1199 1227 1200 1228 t = topo.clone() … … 1243 1271 t.elements.remove(e) 1244 1272 if isinstance(e, topdl.Computer): 1245 add_kit(e, self.federation_software)1273 self.add_kit(e, self.federation_software) 1246 1274 if e.get_attribute('portal') and gate_cmd: 1247 1275 # Add local portal support software 1248 add_kit(e, self.portal_software)1276 self.add_kit(e, self.portal_software) 1249 1277 # Portals never have a user-specified start command 1250 1278 e.set_attribute('startup', gate_cmd) … … 1497 1525 # data. 1498 1526 for s in services: 1499 if s.get("name", "") == 'userconfig' \1500 and s.get('visibility',"") == 'import':1501 1527 s_name = s.get('name', '') 1528 s_vis = s.get('visibility','') 1529 if s_name == 'userconfig' and s_vis == 'import': 1502 1530 # Collect ther server and certificate info. 1503 1531 u = s.get('server', None) … … 1535 1563 "No certificate for retreiving userconfig") 1536 1564 break 1537 1538 1565 if s_name == 'local_seer_control' and s_vis == 'export': 1566 # Copy local seer control node software to the tempdir 1567 for l, f in self.local_seer_software: 1568 base = os.path.basename(f) 1569 copy_file(f, "%s/%s" % (softdir, base)) 1570 1571 # Add a control node to the local topology 1572 c_node = topdl.Computer( 1573 name='control', 1574 attribute=[ 1575 { 'attribute': 'image', 1576 'value': self.local_seer_image }, 1577 { 'attribute': 'startup', 1578 'value': self.local_seer_start }, 1579 ] 1580 ) 1581 self.add_kit(c_node, self.local_seer_software) 1582 topo.elements.append(c_node) 1539 1583 1540 1584 proj = None
Note: See TracChangeset
for help on using the changeset viewer.