コード例 #1
0
ファイル: scanjob_signal.py プロジェクト: AllenBW/quipucords
def handle_scan(sender, instance, **kwargs):
    """Handle incoming scan.

    :param sender: Class that was saved
    :param instance: ScanJob that was triggered
    :param kwargs: Other args
    :returns: None
    """
    scanner = ScanJobRunner(instance)
    if not SCAN_MANAGER.is_alive():
        SCAN_MANAGER.start()
        # Don't add the scan as it will be picked up
        # by the manager startup, looking for pending/running scans.
    else:
        SCAN_MANAGER.put(scanner)
コード例 #2
0
def scan_restart(sender, instance, fact_endpoint, **kwargs):
    """Restart a scan.

    :param sender: Class that was saved
    :param instance: ScanJob that was saved
    :param kwargs: Other args
    :returns: None
    """
    scanner = ScanJobRunner(instance, fact_endpoint)

    if not SCAN_MANAGER.is_alive():
        SCAN_MANAGER.start()
        # Don't add the scan as it will be picked up
        # by the manager startup, looking for pending/running scans.
    else:
        SCAN_MANAGER.put(scanner)
コード例 #3
0
    def restart_incomplete_scansjobs(self):
        """Look for incomplete scans and restart."""
        logger.debug('Scan manager searching for incomplete scans')

        incomplete_scans = ScanJob.objects.filter(
            Q(status=ScanTask.RUNNING) | Q(status=ScanTask.PENDING)
            | Q(status=ScanTask.CREATED)).order_by('-status')
        restarted_scan_count = 0
        for scanjob in incomplete_scans:
            scanner = ScanJobRunner(scanjob)
            logger.debug('Adding ScanJob(id=%d, status=%s, scan_type=%s)',
                         scanjob.id, scanjob.status, scanjob.scan_type)
            self.put(scanner)
            restarted_scan_count += 1

        if restarted_scan_count == 0:
            logger.debug('No running or pending scan jobs to start')
コード例 #4
0
def scan_restart(sender, instance, **kwargs):
    """Restart a scan.

    :param sender: Class that was saved
    :param instance: ScanJob that was saved
    :param kwargs: Other args
    :returns: None
    """
    instance.log_message(_(messages.SIGNAL_STATE_CHANGE) % ('RESTART'))
    scanner = ScanJobRunner(instance)

    if not SCAN_MANAGER.is_alive():
        SCAN_MANAGER.start()
        # Don't add the scan as it will be picked up
        # by the manager startup, looking for pending/running scans.
    else:
        SCAN_MANAGER.put(scanner)