Changeset 1ae1aa2
- Timestamp:
- Nov 30, 2011 5:55:13 PM (13 years ago)
- Branches:
- compt_changes, info-ops, master
- Children:
- f671ef7
- Parents:
- b709861
- Location:
- fedd
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/emulab_access.py
rb709861 r1ae1aa2 1037 1037 if not self.create_debug: 1038 1038 if e.name in info.node: 1039 add_new(("%s%s" % (info.node[e.name][0], self.domain),), 1040 e.localname) 1041 e.status = info.node[e.name][1] 1039 add_new(("%s%s" % 1040 (info.node[e.name].pname, self.domain),), 1041 e.localname) 1042 e.status = info.node[e.name].status 1043 os = info.node[e.name].getOS() 1044 if os: e.os = [ os ] 1042 1045 else: 1043 1046 # Simple debugging assignment … … 1270 1273 info(self, user, proj, ename) 1271 1274 self.decorate_topology(info, topo) 1275 self.state_lock.acquire() 1276 if aid in self.allocation: 1277 self.allocation[aid]['topo'] = topo 1278 self.write_state() 1279 self.state_lock.release() 1280 1272 1281 return { 1273 1282 'allocID': req['allocID'], … … 1330 1339 debug=self.create_debug, boss=self.boss, 1331 1340 cert=self.xmlrpc_cert) 1332 ops(self, op, ptargets, params )1341 ops(self, op, ptargets, params, topo) 1333 1342 1334 1343 status.extend(ops.status) -
fedd/federation/emulab_segment.py
rb709861 r1ae1aa2 3 3 import logging 4 4 import util 5 import topdl 5 6 6 7 from M2Crypto import SSL … … 17 18 18 19 class emulab_segment: 20 class node_info: 21 def __init__(self, name, pname, status=None, osname=None, 22 osversion=None, image=None): 23 self.name = name 24 self.pname = pname 25 self.status = status 26 self.osname = osname 27 self.osversion = osversion 28 self.image = image 29 def getOS(self): 30 rv = None 31 if self.osname or self.osversion: 32 rv = topdl.OperatingSystem(name=self.osname, 33 version=self.osversion) 34 if self.image and rv: 35 rv.set_attribute('image', self.image) 36 return rv 37 19 38 def __init__(self, boss, cert): 20 39 self.ctxt = fedd_ssl_context(my_cert=cert) … … 34 53 self.node = { } 35 54 self.status = [ ] 55 self.node_info = emulab_segment.node_info 36 56 37 57 def emulab_call(self, method, params): … … 207 227 return code == 0 208 228 229 def get_osid_map(self): 230 oses = { } 231 code, osids = self.emulab_call('osid.getlist', {}) 232 for key, val in osids.items(): 233 val['imageid'] = key 234 oses[val['osid']] = val 235 return oses 209 236 210 237 def get_mapping(self, pid, eid): … … 223 250 if self.log: 224 251 self.log.info("[get_mapping] Generating mapping") 252 253 osidmap = self.get_osid_map() 225 254 226 255 params = { … … 235 264 st = v.get('status', 'up') 236 265 ev = v.get('eventstatus', 'ISUP') 266 os = v.get('osid', None) 237 267 238 268 if st == 'up' and ev in ev_ok: st = 'active' 239 269 else: st = 'failed' 240 self.node[k] = (v['pnode'], st) 270 271 if os and os in osidmap: 272 osname = osidmap[os].get('OS', None) 273 osversion = osidmap[os].get('version', None) 274 osimage = "%s/%s" % \ 275 ( osidmap[os].get('pid', ''), 276 osidmap[os].get('imageid', '')) 277 else: 278 osname = osversion = osimage = None 279 280 self.node[k] = self.node_info(k, v['pnode'], st, 281 osname, osversion, osimage) 241 282 if self.log: 242 283 self.log.info("Mapping complete") … … 245 286 raise service_error(service_error.internal, 246 287 "Cannot get node mapping of segment:%s/%s" % (pid, eid)) 247 248 def do_operation(self, op, lnode, pnode, params): 288 def get_image(self, node, top): 289 for e in top.elements: 290 if isinstance(e, topdl.Computer): 291 if node == e.name: 292 if e.os: 293 return e.os[0].get_attribute('image') 294 return None 295 296 297 def do_operation(self, op, lnode, pnode, params, top): 249 298 """ 250 299 Carry out operation on node in the given experiment. … … 268 317 return False 269 318 elif state == 'initial': 270 self.status.append(operation_status(lnode, 271 operation_status.unsupp, 'Image load unsupported')) 272 return False 319 image = self.get_image(lnode, top) 320 if image: 321 pid, iid = image.split('/') 322 p = {'nodes': pnode, 'imagename': iid, 'imageproj': pid, 323 'wait': False} 324 code, result = self.emulab_call('node.reload', p) 325 if code == 0: 326 self.status.append(operation_status(lnode, 327 operation_status.success, 'reloading')) 328 return True 329 else: 330 self.status.append(operation_status(lnode, 331 operation_status.federant, 332 'Error code: %d' % code)) 333 return False 334 else: 335 self.status.append(operation_status(lnode, 336 operation_status.federant, 337 'cannot find imageid??')) 338 return False 273 339 elif state == 'boot': 274 340 p = {'nodes': pnode, 'wait': False} -
fedd/federation/experiment_control.py
rb709861 r1ae1aa2 829 829 for e in top.elements: 830 830 if isinstance(e, topdl.Computer): 831 self.node[e.name] = \ 832 (e.localname, e.status, e.service, e.operation) 831 self.node[e.name] = e 833 832 834 833 def __call__(self, uri, aid, topo, masters, attrs=None, connInfo=None): … … 990 989 ann = s.node.get(e.name, None) 991 990 if ann is not None: 992 add_new(ann[0], e.localname) 993 e.status = ann[1] 994 add_new(ann[2], e.service) 995 add_new(ann[3], e.operation) 991 add_new(ann.localname, e.localname) 992 e.status = ann.status 993 add_new(ann.service, e.service) 994 add_new(ann.operation, e.operation) 995 if ann.os: 996 e.os = ann.os 996 997 break 997 998 -
fedd/federation/local_emulab_segment.py
rb709861 r1ae1aa2 139 139 emulab_segment.__init__(self, boss=boss, cert=cert) 140 140 141 def __call__(self, parent, op, targets, param ):141 def __call__(self, parent, op, targets, param, top): 142 142 for l, p in targets.items(): 143 143 self.log.info("[operation_segment]: Calling op on %s(%s)" % (l,p)) 144 self.do_operation(op, l, p, param )144 self.do_operation(op, l, p, param, top) 145 145 return True
Note: See TracChangeset
for help on using the changeset viewer.