Changeset 1468 for trunk/server


Ignore:
Timestamp:
Feb 17, 2010, 11:44:13 AM (15 years ago)
Author:
gdb
Message:
Fixed the exception type problem in this code; fixed up remove-servers.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/common/oursrc/hacron/hacron

    r1467 r1468  
    2727
    2828class HacronError(Exception):
    29     def __init__(self, errno, msg='Something went wrong'):
    30         self.errno = errno
     29    def __init__(self, ocf_errno, msg='Something went wrong'):
     30        self.ocf_errno = ocf_errno
    3131        self.msg = msg
    3232        logger.error(msg)
     
    8383def _remove(dest):
    8484    if not path.exists(dest) and not path.islink(dest):
    85         logger.info('Tried to remove nonexistant path %s' % dest)
     85        logger.error('Tried to remove nonexistant path %s' % dest)
    8686        return True
    8787
     
    142142
    143143def start_cron(args, options):
    144     if not _touch(_serverfile(HOSTNAME)):
     144    serverfile = _serverfile(HOSTNAME)
     145    if not _touch(serverfile):
     146        logger.error('Could not touch %s' % serverfile)
    145147        return OCF_ERR_CONFIGURED
    146148    elif _is_master(HOSTNAME):
     
    167169    try:
    168170        _restart_crond(args, options)
    169     except OSError, e:
    170         return e.errno
     171    except HacronException, e:
     172        return e.ocf_errno
    171173    return OCF_SUCCESS
    172174
     
    184186        try:
    185187            _restart_crond(args, options)
    186         except OSError, e:
    187             return e.errno
     188        except HacronException, e:
     189            return e.ocf_errno
    188190        return OCF_SUCCESS
    189191
     
    199201    if not _touch(_serverfile(HOSTNAME)):
    200202        logger.error('Could not touch %s' % _serverfile(HOSTNAME))
    201         return OCF_GENERIC_ERR
     203        return OCF_ERR_GENERIC
    202204    elif not path.exists(CRONSPOOL_DIR):
    203         return OCF_GENERIC_ERR
     205        return OCF_ERR_GENERIC
    204206    else:
    205207        return OCF_SUCCESS
     
    216218    """Remove servers from the list of available ones."""
    217219    for server in servers:
    218         os.unlink(_serverfile(server))
     220        _remove(_serverfile(server))
     221        _remove(_crondir(server))
     222        logger.info('Removed %s from list of available ones' % server)
     223
    219224
    220225def meta_data_cron(args, options):
     
    325330        _set_globals(args, options)
    326331    except HacronError, e:
    327         return e.errno
     332        return e.ocf_errno
    328333
    329334    with lock('%s/hacron-%s.lock' % (HA_RSCTMP, OCF_RESOURCE_INSTANCE)):
Note: See TracChangeset for help on using the changeset viewer.