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
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
def getContext(self, user='******'): s = SecurityContext() s.userid = user s.userdn = LdapUserGroupControl().searchUserDN(s.userid) return s
def getContext(self): s = SecurityContext() s.userid = self.userid s.userdn = LdapUserGroupControl().searchUserDN(self.userid) return s
def getContext(self): s = SecurityContext() s.userid = self.userid s.userdn = LdapUserGroupControl().searchUserDN(self.userid) return s
def getContext(self, user='******'): s = SecurityContext() s.userid = user s.userdn = LdapUserGroupControl().searchUserDN(s.userid) return s