Changeset 1321


Ignore:
Timestamp:
01/25/07 12:30:49 (6 years ago)
Author:
mglb1
Message:

Refactor host deletion callback.

  • Tidy up the code
  • Remove the hosts/<hostname> directory too
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ccsd/trunk/crcnetd/_utils/ccsd_cfengine.py

    r1311 r1321  
    870870    commit = 0 
    871871    if session.changeset == 0: 
    872         session.begin("Removing keys for %s" % (host["host_name"])) 
     872        session.begin("Removing configuration and keys for deleted host: %s" % 
     873                (host["host_name"])) 
    873874        commit = 1 
    874875 
    875876    try: 
     877        # Remove SSH Keys 
    876878        base = "%s/sshkeys" % session.revision.getConfigBase() 
    877         ensureDirExists("%s/%s" % (base, host["host_name"])) 
    878         session.revision._checkForModified(base) 
    879879        client.svn_client_delete(["%s/%s" % (base, host["host_name"])], True,  
    880880                session.revision.ctx, session.revision.pool) 
    881                  
    882         base = "%s/../ppkeys" % session.revision.getConfigBase() 
    883          
    884         client.svn_client_delete(["%s/root-%s.priv" % (base, host["ip_address"])], True, 
    885                 session.revision.ctx, session.revision.pool) 
    886          
    887         client.svn_client_delete(["%s/root-%s.pub" % (base, host["ip_address"])], True, 
     881         
     882        # Remove CFengine Keys 
     883        base = "%s/ppkeys" % session.revision.getWorkingDir() 
     884        client.svn_client_delete(["%s/root-%s.priv" %  
     885            (base, host["ip_address"])], True, session.revision.ctx,  
     886            session.revision.pool) 
     887        client.svn_client_delete(["%s/root-%s.pub" %  
     888            (base, host["ip_address"])], True, session.revision.ctx,  
     889            session.revision.pool) 
     890         
     891        # Remove Configuration 
     892        base = "%s/hosts" % session.revision.getConfigBase() 
     893        client.svn_client_delete(["%s/%s" % (base, host["host_name"])], True, 
    888894                session.revision.ctx, session.revision.pool) 
    889895    except: 
    890         (type, value, tb) = sys.exc_info() 
    891         log_error("Failed to remove  keys for %s! - %s" % \ 
    892                 (host["host_name"], value)) 
    893         # Rollback any changes 
    894         if commit == 1: 
    895             session.rollback() 
    896         return False 
     896        log_error("Failed to remove all configuration/keys for %s!" %  
     897                host["host_name"], sys.exc_info()) 
    897898     
    898899    # Commit changeset if necessary 
     
    901902         
    902903    return True 
    903                  
    904904 
    905905catchEvent("hostnameChanged") 
Note: See TracChangeset for help on using the changeset viewer.