Changeset b709861 for fedd/federation/emulab_segment.py
- Timestamp:
- Nov 30, 2011 4:45:15 PM (12 years ago)
- Branches:
- compt_changes, info-ops, master
- Children:
- 1ae1aa2
- Parents:
- 22a1a77
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/emulab_segment.py
r22a1a77 rb709861 14 14 from federation.util import fedd_ssl_context 15 15 from federation import service_error 16 from federation.operation_status import operation_status 16 17 17 18 class emulab_segment: … … 32 33 self.debug = getattr(self, 'debug', False) 33 34 self.node = { } 35 self.status = [ ] 34 36 35 37 def emulab_call(self, method, params): … … 103 105 if self.debug: 104 106 if self.log: 105 self.log.debug("[make_null_experiment]: (debug) Creating experiment") 107 self.log.debug("[make_null_experiment]: " + \ 108 "(debug) Creating experiment") 106 109 return True 107 110 else: … … 243 246 "Cannot get node mapping of segment:%s/%s" % (pid, eid)) 244 247 248 def do_operation(self, op, lnode, pnode, params): 249 """ 250 Carry out operation on node in the given experiment. 251 """ 252 def get_param(params, name): 253 if params is None: 254 return None 255 for d in params: 256 if 'attribute' in d and d['attribute'] == name: 257 return d.get('value', None) 258 else: 259 return None 260 261 op = op.lower() 262 263 if op == 'restore': 264 state = get_param(params, 'state') 265 if state is None: 266 self.status.append(operation_status(lnode, 267 operation_status.bad_param, 'No state to restore')) 268 return False 269 elif state == 'initial': 270 self.status.append(operation_status(lnode, 271 operation_status.unsupp, 'Image load unsupported')) 272 return False 273 elif state == 'boot': 274 p = {'nodes': pnode, 'wait': False} 275 code, result = self.emulab_call('node.reboot', p) 276 if code == 0: 277 self.status.append(operation_status(lnode, 278 operation_status.success, 'rebooting')) 279 return True 280 else: 281 self.status.append(operation_status(lnode, 282 operation_status.federant, 'Error code: %d' % code)) 283 return False 284 else: 285 self.status.append(operation_status(lnode, 286 operation_status.bad_param, 287 "Unsupported state %s" % state)) 288 return False 289 else: 290 self.status.append(operation_status(lnode, operation_status.unsupp)) 291 return False 292
Note: See TracChangeset
for help on using the changeset viewer.