Changeset 2097


Ignore:
Timestamp:
Feb 5, 2009, 3:24:56 AM (15 years ago)
Author:
broder
Message:

For now, revert r2093-2095, which were committed by accident; I'm not
comfortable with them sitting on HEAD when I don't have time to test
them.

Location:
trunk/packages
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/invirt-base/debian/changelog

    r2095 r2097  
    1 invirt-base (0.0.21) unstable; urgency=low
    2 
    3   * Get rid of confusing err=True option to invirt.remctl.remctl
    4 
    5  -- Evan Broder <broder@mit.edu>  Fri, 30 Jan 2009 19:49:46 -0500
    6 
    71invirt-base (0.0.20) unstable; urgency=low
    82
  • trunk/packages/invirt-base/python/invirt/common.py

    r2095 r2097  
    7676class CodeError(Exception):
    7777    """Exception for internal errors or bad faith input."""
    78     def __init__(self, message, code=None):
    79         Exception.__init__(self, message)
    80         self.code = code
     78    pass
    8179
    8280#
  • trunk/packages/invirt-base/python/invirt/remctl.py

    r2095 r2097  
    3737                         stderr=subprocess.PIPE)
    3838    v = p.wait()
     39    if kws.get('err'):
     40        return p.stdout.read(), p.stderr.read()
    3941    if v:
    40         raise CodeError('ERROR on remctl %s:\n%s' % (args, p.stderr.read()), v)
     42        print >> sys.stderr, 'Error', v, 'on remctl', args, ':'
     43        print >> sys.stderr, p.stderr.read()
     44        raise CodeError('ERROR on remctl')
    4145    return p.stdout.read()
  • trunk/packages/invirt-remote/debian/changelog

    r2094 r2097  
    1 invirt-remote (0.3.2) unstable; urgency=low
    2 
    3   * Don't pass untrusted arguments to xm info.
    4   * Exit with a non-0 error code on the host if there's an error.
    5   * Always exec instead of fork&exec on the remctl server so that return
    6     codes get passed on.
    7 
    8  -- Evan Broder <broder@mit.edu>  Sat, 31 Jan 2009 03:51:54 -0500
    9 
    101invirt-remote (0.3.1) unstable; urgency=low
    112
  • trunk/packages/invirt-remote/host/usr/sbin/invirt-remote

    r2093 r2097  
    2222                ;;
    2323            info)
    24                 exec /usr/sbin/xm info
     24                COMMAND=/usr/sbin/xm
    2525                ;;
    2626            vnccert)
     
    3939esac
    4040
    41 exec "$COMMAND" "$SERVICE" "$@"
     41$COMMAND "$SERVICE" "$@"
  • trunk/packages/invirt-remote/host/usr/sbin/invirt-vmcontrol

    r2093 r2097  
    1212ACTION="$2"
    1313MACHINE="d_$ORIGMACHINE"
    14 
    15 xm () {
    16     command xm "$@" || exit 35
    17 }
    1814
    1915case "$ACTION" in
  • trunk/packages/invirt-remote/server/usr/sbin/invirt-remote-proxy

    r2094 r2097  
    1414case "$TYPE/$SERVICE" in
    1515    web/listvms )
    16         exec invirt-remote-listvms "$@" ;;
     16        invirt-remote-listvms "$@" ;;
    1717    web/vnccert )
    18         exec invirt-remote-vnccert "$@" ;;
     18        invirt-remote-vnccert "$@" ;;
    1919    control/help )
    20         exec invirt-remctl-help ;;
     20        invirt-remctl-help ;;
    2121    control/create|control/install )
    22         exec invirt-remote-create "$SERVICE" "$MACHINE" "$@" ;;
     22        invirt-remote-create "$SERVICE" "$MACHINE" "$@" ;;
    2323    control/listhost|control/list-host )
    24         exec invirt-remote-listhost "$MACHINE" "$@" ;;
     24        invirt-remote-listhost "$MACHINE" "$@" ;;
    2525    control/* )
    2626        # Everything but create must go where the VM is already running.
    27         exec invirt-remote-control "$MACHINE" "$SERVICE" "$@" ;;
     27        invirt-remote-control "$MACHINE" "$SERVICE" "$@" ;;
    2828    * )
    29         exec remctl "$(invirt-getconf hosts.0.hostname)" remote "$TYPE" "$SERVICE" "$@" ;;
     29        remctl "$(invirt-getconf hosts.0.hostname)" remote "$TYPE" "$SERVICE" "$@" ;;
    3030esac
  • trunk/packages/invirt-web/code/controls.py

    r2095 r2097  
    6565    id of the CD (e.g. 'gutsy_i386')
    6666    """
    67     try:
    68         if cdtype is not None:
    69             out = remctl('control', machine.name, 'create',
    70                               cdtype)
    71         else:
    72             out = remctl('control', machine.name, 'create')
    73     except CodeError, e:
    74         if 'already running' in e.message:
    75             raise InvalidInput('action', 'create',
    76                                'VM %s is already on' % machine.name)
    77         else:
     67    if cdtype is not None:
     68        out, err = remctl('control', machine.name, 'create',
     69                          cdtype, err=True)
     70    else:
     71        out, err = remctl('control', machine.name, 'create',
     72                          err=True)
     73    if 'already running' in err:
     74        raise InvalidInput('action', 'create',
     75                           'VM %s is already on' % machine.name)
     76    elif err:
    7877        raise CodeError('"%s" on "control %s create %s'
    7978                        % (err, machine.name, cdtype))
     
    158157    Gets and parses xm list --long
    159158    """
    160     try:
    161         value_string = remctl('control', machine.name, 'list-long')
    162     except CodeError, e:
    163         if 'is not on' in e.message:
    164             return None
    165         else:
    166             raise
     159    value_string, err_string = remctl('control', machine.name, 'list-long',
     160                                      err=True)
     161    if 'Unknown command' in err_string:
     162        raise CodeError("ERROR in remctl list-long %s is not registered" %
     163                        (machine.name,))
     164    elif 'is not on' in err_string:
     165        return None
     166    elif err_string:
     167        raise CodeError("ERROR in remctl list-long %s:  %s" %
     168                        (machine.name, err_string))
    167169    status = parseStatus(value_string)
    168170    return status
     
    170172def listHost(machine):
    171173    """Return the host a machine is running on"""
    172     try:
    173         out = remctl('control', machine.name, 'listhost')
    174     except CodeError, e:
     174    out, err = remctl('control', machine.name, 'listhost', err=True)
     175    if err:
    175176        return None
    176177    return out.strip()
     
    178179def vnctoken(machine):
    179180    """Return a time-stamped VNC token"""
    180     try:
    181         out = remctl('control', machine.name, 'vnctoken')
    182     except CodeError, e:
     181    out, err = remctl('control', machine.name, 'vnctoken', err=True)
     182    if err:
    183183        return None
    184184    return out.strip()
     
    186186def deleteVM(machine):
    187187    """Delete a VM."""
    188     try:
    189         remctl('control', machine.name, 'destroy')
    190     except CodeError:
    191         pass
     188    remctl('control', machine.name, 'destroy', err=True)
    192189    session.begin()
    193190    delete_disk_pairs = [(machine.name, d.guest_device_name)
     
    219216        raise CodeError("Invalid action '%s'" % action)
    220217    if action == 'Reboot':
    221         try:
    222             if cdrom is not None:
    223                 out = remctl('control', machine.name, 'reboot', cdrom)
    224             else:
    225                 out = remctl('control', machine.name, 'reboot')
    226         except CodeError, e:
    227             if re.match("machine '.*' is not on", e.message):
     218        if cdrom is not None:
     219            out, err = remctl('control', machine.name, 'reboot', cdrom,
     220                              err=True)
     221        else:
     222            out, err = remctl('control', machine.name, 'reboot',
     223                              err=True)
     224        if err:
     225            if re.match("machine '.*' is not on", err):
    228226                raise InvalidInput("action", "reboot",
    229227                                   "Machine is not on")
    230228            else:
    231                 raise
     229                print >> sys.stderr, 'Error on reboot:'
     230                print >> sys.stderr, err
     231                raise CodeError('ERROR on remctl')
    232232               
    233233    elif action == 'Power on':
     
    238238        bootMachine(machine, cdrom)
    239239    elif action == 'Power off':
    240         try:
    241             out = remctl('control', machine.name, 'destroy')
    242         except CodeError, e:
    243             if re.match("machine '.*' is not on", e.message):
     240        out, err = remctl('control', machine.name, 'destroy', err=True)
     241        if err:
     242            if re.match("machine '.*' is not on", err):
    244243                raise InvalidInput("action", "Power off",
    245244                                   "Machine is not on.")
    246245            else:
    247                 raise
     246                print >> sys.stderr, 'Error on power off:'
     247                print >> sys.stderr, err
     248                raise CodeError('ERROR on remctl')
    248249    elif action == 'Shutdown':
    249         try:
    250             out = remctl('control', machine.name, 'shutdown')
    251         except CodeError, e:
    252             if re.match("machine '.*' is not on", e.message):
     250        out, err = remctl('control', machine.name, 'shutdown', err=True)
     251        if err:
     252            if re.match("machine '.*' is not on", err):
    253253                raise InvalidInput("action", "Shutdown",
    254254                                   "Machine is not on.")
    255255            else:
    256                 raise
     256                print >> sys.stderr, 'Error on Shutdown:'
     257                print >> sys.stderr, err
     258                raise CodeError('ERROR on remctl')
    257259    elif action == 'Delete VM':
    258260        deleteVM(machine)
Note: See TracChangeset for help on using the changeset viewer.