示例#1
0
    def addmembers_to_group(self, id, uuids):
        ctx = self.currentContext
        # remove all the computers that cant be added to a profile from the list
        didnt_work = []
        are_some_to_remove = False
        if self.isprofile(id):
            computers = []
            uuid2key = {}
            for c in uuids:
                computers.append(uuids[c]['uuid'])
                uuid2key[uuids[c]['uuid']] = c
            didnt_work = ComputerProfileManager().areForbiddebComputers(
                computers)

            if len(didnt_work) > 0:
                logging.getLogger().debug(
                    "Can't add the following computers in that profile %s : %s"
                    % (str(id), str(didnt_work)))
                for i in didnt_work:
                    if uuid2key[i] in uuids:
                        are_some_to_remove = True
                        uuids.pop(uuid2key[i])

        if len(uuids) != 0:
            if self.isprofile(id):
                ComputerProfileManager().addComputersToProfile(ctx, uuids, id)
            else:
                ret = DyngroupDatabase().addmembers_to_group(ctx, id, uuids)
                return [ret]
        return xmlrpcCleanup([not are_some_to_remove, didnt_work])
示例#2
0
 def delmembers_to_group(self, id, uuids):
     ctx = self.currentContext
     ret = DyngroupDatabase().delmembers_to_group(ctx, id, uuids)
     # WIP : call ComputerProfileManager to add machines
     if len(uuids) != 0 and self.isprofile(id):
         ComputerProfileManager().delComputersFromProfile(uuids, id)
     return xmlrpcCleanup(ret)
示例#3
0
 def delete_group(self, id):
     ctx = self.currentContext
     if self.isprofile(id):
         grp = DyngroupDatabase().get_group(ctx, id, True)
         profile_UUID = grp.getUUID()
         ComputerProfileManager().delProfile(profile_UUID)
     return xmlrpcCleanup(DyngroupDatabase().delete_group(ctx, id))
示例#4
0
def activate():
    """
    Read the plugin configuration, initialize it, and run some tests to ensure
    it is ready to operate.
    """
    logger = logging.getLogger()
    config = ImagingConfig("imaging")

    if config.disabled:
        logger.warning("Plugin imaging: disabled by configuration.")
        return False

    # Initialize imaging database
    if not ImagingDatabase().activate(config):
        logger.warning(
            "Plugin imaging: an error occurred during the database initialization"
        )
        return False

    # register ImagingProfile in ComputerProfileManager but only as a client
    ComputerProfileManager().register("imaging", ImagingProfile)

    ComputerImagingManager().register("imaging", ComputerImagingImaging)

    Pulse2Manager().register('imaging', ImagingPulse2Manager)

    ComputerManager().register('imaging', InventoryComputers)

    TaskManager().addTask("imaging.purge_removed_computers",
                          (purge_removed_computers, ),
                          cron_expression=config.purge_interval)

    return True
示例#5
0
def activate():
    logger = logging.getLogger()
    global config
    config = DGConfig()
    config.init("dyngroup")

    if config.disable:
        logger.warning("Plugin dyngroup: disabled by configuration.")
        return False

    DyngroupDatabase().activate(config)
    if not DyngroupDatabase().db_check():
        return False

    ComputerGroupManager().register("dyngroup", DyngroupGroup)
    ComputerProfileManager().register("dyngroup", DyngroupProfile)
    ComputerManager().register("dyngroup", DyngroupComputers)

    if config.check_db_enable:
        scheduleCheckStatus(config.check_db_interval)

    return True
示例#6
0
    def delProfile(self, profile_UUID):
        if ImagingDatabase().isTargetRegister(profile_UUID, P2IT.PROFILE):
            # TODO : put all the computers on their own menu
            computers_UUID = map(
                lambda c: c.uuid,
                ComputerProfileManager().getProfileContent(profile_UUID))
            computers = {}
            for uuid in computers_UUID:
                computers[uuid] = {'uuid': uuid}

            ret1 = len(computers) > 0 and ImagingDatabase(
            ).delComputersFromProfile(profile_UUID, computers) or True
            ret2 = len(computers) > 0 and ImagingDatabase(
            ).changeTargetsSynchroState(computers_UUID, P2IT.COMPUTER,
                                        P2ISS.TODO) or True
            # delete the profile itself
            ret3 = ImagingDatabase().delProfile(profile_UUID)
            ret4 = len(computers) > 0 and ImagingDatabase(
            ).switchMenusToDefault(computers_UUID) or True

            return ret1 and ret2 and ret3 and ret4
        return True
示例#7
0
 def getForbiddenComputersUUID(self, profile_UUID=None):
     ret = ComputerProfileManager().getForbiddenComputersUUID(profile_UUID)
     return ret