Exemplo n.º 1
0
def purge_removed_computers():
    from mmc.plugins.base.computers import ComputerManager
    from mmc.plugins.base import LdapUserGroupControl

    # Get all imaging targets
    targets = ImagingDatabase().getAllRegisteredComputers()

    # Creating root context to query ComputerManager
    ctx = SecurityContext()
    ctx.userid = 'root'
    ctx.userdn = LdapUserGroupControl().searchUserDN(ctx.userid)

    # Init to_delete computer list
    to_delete = []

    for uuid in targets:
        if ComputerManager().getComputerCount(ctx, {'uuid': uuid}) == 0:
            # If the target computer is not in ComputerManager database anymore
            # we unregister it from imaging
            to_delete.append(uuid)

    # Unregistering orphan targets without backup
    if to_delete:
        logging.getLogger().info('Orphan imaging computer(s) found')
        logging.getLogger().info('Going to purge %s' % ' '.join(to_delete))
        computersUnregister(to_delete, False)

    return True
Exemplo n.º 2
0
def purge_removed_computers():
    from mmc.plugins.base.computers import ComputerManager
    from mmc.plugins.base import LdapUserGroupControl

    # Get all imaging targets
    targets = ImagingDatabase().getAllRegisteredComputers()

    # Creating root context to query ComputerManager
    ctx = SecurityContext()
    ctx.userid = 'root'
    ctx.userdn = LdapUserGroupControl().searchUserDN(ctx.userid)

    # Init to_delete computer list
    to_delete = []

    for uuid in targets:
        if ComputerManager().getComputerCount(ctx, {'uuid': uuid}) == 0:
            # If the target computer is not in ComputerManager database anymore
            # we unregister it from imaging
            to_delete.append(uuid)

    # Unregistering orphan targets without backup
    if to_delete:
        logging.getLogger().info('Orphan imaging computer(s) found')
        logging.getLogger().info('Going to purge %s' % ' '.join(to_delete))
        computersUnregister(to_delete, False)

    return True
Exemplo n.º 3
0
 def delComputer(self, ctx, uuid, backup):
     return computersUnregister([uuid], backup)