Changeset 6527d60 for fedd/federation
- Timestamp:
- Mar 4, 2012 8:20:31 PM (13 years ago)
- Branches:
- compt_changes, master
- Children:
- 9e5e251
- Parents:
- 8cab4c2
- Location:
- fedd/federation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/emulab_access.py
r8cab4c2 r6527d60 771 771 (info.node[e.name].pname, self.domain),), 772 772 e.localname) 773 add_new(("%s%s" % 774 (info.node[e.name].lname, self.domain),), 775 e.localname) 773 776 e.status = info.node[e.name].status 774 777 os = info.node[e.name].getOS() … … 780 783 add_new(('testop1', 'testop2'), e.operation) 781 784 i += 1 785 786 for s in t.substrates: 787 if s.name in info.subs: 788 sub = info.subs[s.name] 789 if sub.cap is not None: 790 s.capacity = topdl.Capacity(sub.cap, 'max') 791 if sub.delay is not None: 792 s.delay = topdl.Latency(sub.delay, 'max') 793 # XXX interfaces 782 794 783 795 -
fedd/federation/xmlrpc_emulab_segment.py
r8cab4c2 r6527d60 19 19 class xmlrpc_emulab_segment: 20 20 class node_info: 21 def __init__(self, name, pname, status=None, osname=None,21 def __init__(self, name, pname, lname=None, status=None, osname=None, 22 22 osversion=None, image=None): 23 23 self.name = name 24 24 self.pname = pname 25 self.lname = lname 25 26 self.status = status 26 27 self.osname = osname … … 36 37 return rv 37 38 39 class lan_info: 40 def __init__(self, name, cap=None, delay=None): 41 self.name = name 42 self.cap = cap 43 self.delay = delay 44 def __repr__(self): 45 return "%s %s %s" % (self.name, self.cap, self.delay) 46 47 class interface_info: 48 def __init__(self, name, node, sub, cap=None, delay=None): 49 self.name = name 50 self.node = node 51 self.sub = sub 52 self.cap = cap 53 self.delay = delay 54 def __repr__(self): 55 return "%s %s %s %s %s" % (self.name, self.node, self.sub, 56 self.cap, self.delay) 57 58 38 59 def __init__(self, boss, ops, cert): 39 60 self.ctxt = fedd_ssl_context(my_cert=cert) … … 53 74 self.debug = getattr(self, 'debug', False) 54 75 self.node = { } 76 self.subs = { } 77 self.interfaces = { } 55 78 self.status = [ ] 56 79 self.node_info = xmlrpc_emulab_segment.node_info 80 self.lan_info = xmlrpc_emulab_segment.lan_info 81 self.interface_info = xmlrpc_emulab_segment.interface_info 57 82 58 83 def emulab_call(self, method, params): … … 236 261 return oses 237 262 238 def get_mapping(self, pid, eid): 239 """ 240 Get the physical to virtual mapping from the expinfo command and save 241 it in the self.map member. 242 """ 263 def get_links(self, pid, eid): 264 params = { 265 'proj': pid, 266 'exp': eid, 267 'aspect': 'links' 268 } 269 code, links = self.emulab_call('experiment.info', params) 270 if code ==0: 271 lans = { } 272 # Links contains per-interface information about all the LANs in 273 # the emulab experiment. First construct the LANs, then look for 274 # overrides. 275 for i in links.values(): 276 if i['name'] not in lans: 277 lans[i['name']] = { 'cap': None, 'delay': None }; 278 cap = max(i['bandwidth'], i['r_bandwidth']) 279 delay = max(i['delay'], i['r_delay']) 280 if delay == 0.0: delay = None 281 if lans[i['name']]['cap'] is None or \ 282 cap > lans[i['name']]['cap']: 283 lans[i['name']]['cap'] = cap 284 285 if (lans[i['name']]['delay'] is None and delay is not None) or \ 286 delay > lans[i['name']]['delay']: 287 lans[i['name']]['delay'] = delay 288 289 for s, info in lans.items(): 290 self.subs[s] = self.lan_info(s, info['cap'], info['delay']) 291 292 # XXX: should deal better with r_delay != delay, etc 293 for i in links.values(): 294 li = self.subs[i['name']] 295 cap = max(i['bandwidth'], i['r_bandwidth']) 296 delay = max(i['delay'], i['r_delay']) 297 if delay == 0.0: delay = None 298 if cap != li.cap or delay != li.delay: 299 node, dummy = i['member'].split(':', 1) 300 self.interfaces[i['member']] = \ 301 self.interface_info(i['member'], node, i['name'], 302 cap, delay) 303 304 if self.log: 305 self.log.info("Link mapping complete") 306 return True 307 else: 308 raise service_error(service_error.internal, 309 "Cannot get link mapping of segment:%s/%s" % (pid, eid)) 310 311 def get_nodes(self, pid, eid): 243 312 244 313 ev_active = ('ISUP', 'ALWAYSUP' ) … … 248 317 ev_terminating = ( 'SHUTDOWN' ) 249 318 250 319 osidmap = self.get_osid_map() 320 321 params = { 322 'proj': pid, 323 'exp': eid, 324 'aspect': 'mapping' 325 } 326 code, nodes = self.emulab_call('experiment.info', params) 327 if code ==0: 328 for k, v in nodes.items(): 329 if v.get('erole', False) and 'pnode' in v: 330 st = v.get('status', 'up') 331 ev = v.get('eventstatus', 'ISUP') 332 os = v.get('osid', None) 333 lname = "%s.%s.%s" % (k, eid, pid) 334 335 if st == 'up': 336 if ev in ev_active: st = 'active' 337 elif ev in ev_starting: st = 'starting' 338 elif ev in ev_terminating: st = 'terminating' 339 else: st = 'failed' 340 else: st = 'failed' 341 342 if os and os in osidmap: 343 osname = osidmap[os].get('OS', None) 344 osversion = osidmap[os].get('version', None) 345 osimage = "%s/%s" % \ 346 ( osidmap[os].get('pid', ''), 347 osidmap[os].get('imageid', '')) 348 else: 349 osname = osversion = osimage = None 350 351 self.node[k] = self.node_info(k, v['pnode'], lname, 352 st, osname, osversion, osimage) 353 if self.log: 354 self.log.info("Node mapping complete") 355 return True 356 else: 357 raise service_error(service_error.internal, 358 "Cannot get node mapping of segment:%s/%s" % (pid, eid)) 359 360 def get_mapping(self, pid, eid): 361 """ 362 Get the physical to virtual mapping from the expinfo command and save 363 it in the self.map member. 364 """ 365 251 366 if self.debug: 252 367 if self.log: … … 256 371 if self.log: 257 372 self.log.info("[get_mapping] Generating mapping") 258 259 osidmap = self.get_osid_map() 260 261 params = { 262 'proj': pid, 263 'exp': eid, 264 'aspect': 'mapping' 265 } 266 code, nodes = self.emulab_call('experiment.info', params) 267 if code ==0: 268 for k, v in nodes.items(): 269 if v.get('erole', False) and 'pnode' in v: 270 st = v.get('status', 'up') 271 ev = v.get('eventstatus', 'ISUP') 272 os = v.get('osid', None) 273 274 if st == 'up': 275 if ev in ev_active: st = 'active' 276 elif ev in ev_starting: st = 'starting' 277 elif ev in ev_terminating: st = 'terminating' 278 else: st = 'failed' 279 else: st = 'failed' 280 281 if os and os in osidmap: 282 osname = osidmap[os].get('OS', None) 283 osversion = osidmap[os].get('version', None) 284 osimage = "%s/%s" % \ 285 ( osidmap[os].get('pid', ''), 286 osidmap[os].get('imageid', '')) 287 else: 288 osname = osversion = osimage = None 289 290 self.node[k] = self.node_info(k, v['pnode'], st, 291 osname, osversion, osimage) 292 if self.log: 293 self.log.info("Mapping complete") 294 return True 295 else: 296 raise service_error(service_error.internal, 297 "Cannot get node mapping of segment:%s/%s" % (pid, eid)) 373 self.get_nodes(pid, eid) 374 self.get_links(pid, eid) 375 return True 376 298 377 def get_initial_image(self, node, top): 299 378 for e in top.elements:
Note: See TracChangeset
for help on using the changeset viewer.