Ignore:
Timestamp:
Nov 30, 2011 4:45:15 PM (12 years ago)
Author:
Ted Faber <faber@…>
Branches:
compt_changes, info-ops, master
Children:
1ae1aa2
Parents:
22a1a77
Message:

Rebooting works

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/emulab_segment.py

    r22a1a77 rb709861  
    1414from federation.util import fedd_ssl_context
    1515from federation import service_error
     16from federation.operation_status import operation_status
    1617
    1718class emulab_segment:
     
    3233        self.debug = getattr(self, 'debug', False)
    3334        self.node = { }
     35        self.status = [ ]
    3436
    3537    def emulab_call(self, method, params):
     
    103105        if self.debug:
    104106            if self.log:
    105                 self.log.debug("[make_null_experiment]: (debug) Creating experiment")
     107                self.log.debug("[make_null_experiment]: " + \
     108                        "(debug) Creating experiment")
    106109            return True
    107110        else:
     
    243246                        "Cannot get node mapping of segment:%s/%s" % (pid, eid))
    244247
     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.