Skip to content

Commit

Permalink
Rename ConnectionResult(s) and InspectionResult(s) (#736)
Browse files Browse the repository at this point in the history
  • Loading branch information
kholdaway authored and chambridge committed Feb 14, 2018
1 parent f6d8559 commit 9be1c91
Show file tree
Hide file tree
Showing 27 changed files with 120 additions and 115 deletions.
13 changes: 9 additions & 4 deletions quipucords/api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@
"""Admin module for Django server application."""

from django.contrib import admin
from api.models import (FactCollection, SystemFingerprint, Credential,
Source, ScanJob, ConnectionResults, InspectionResults)
from api.models import (FactCollection,
SystemFingerprint,
Credential,
Source,
ScanJob,
JobConnectionResult,
JobInspectionResult)

admin.site.register(FactCollection)
admin.site.register(Credential)
admin.site.register(Source)
admin.site.register(SystemFingerprint)
admin.site.register(ScanJob)
admin.site.register(ConnectionResults)
admin.site.register(InspectionResults)
admin.site.register(JobConnectionResult)
admin.site.register(JobInspectionResult)
6 changes: 3 additions & 3 deletions quipucords/api/connresults/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Meta:
verbose_name_plural = _(messages.PLURAL_KEY_VALUES_MSG)


class ConnectionResult(models.Model):
class TaskConnectionResult(models.Model):
"""The captured connection results from a scan."""

source = models.ForeignKey(Source, on_delete=models.CASCADE)
Expand All @@ -71,10 +71,10 @@ class Meta:
verbose_name_plural = _(messages.PLURAL_RESULTS_MSG)


class ConnectionResults(models.Model):
class JobConnectionResult(models.Model):
"""The results of a connection scan."""

results = models.ManyToManyField(ConnectionResult)
results = models.ManyToManyField(TaskConnectionResult)

def __str__(self):
"""Convert to string."""
Expand Down
14 changes: 7 additions & 7 deletions quipucords/api/connresults/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""Module for serializing all model object for database storage."""

from rest_framework.serializers import CharField, ChoiceField
from api.models import (ConnectionResults, ConnectionResult,
from api.models import (JobConnectionResult, TaskConnectionResult,
SystemConnectionResult)
from api.common.serializer import NotEmptySerializer

Expand All @@ -31,23 +31,23 @@ class Meta:
qpc_allow_empty_fields = ['value']


class ConnectionResultSerializer(NotEmptySerializer):
"""Serializer for the ConnectionResult model."""
class TaskConnectionResultSerializer(NotEmptySerializer):
"""Serializer for the TaskConnectionResult model."""

class Meta:
"""Metadata for serialzer."""

model = ConnectionResult
model = TaskConnectionResult
fields = ['source', 'systems']
qpc_allow_empty_fields = ['source', 'systems']


class ConnectionResultsSerializer(NotEmptySerializer):
"""Serializer for the ConnectionResults model."""
class JobConnectionResultSerializer(NotEmptySerializer):
"""Serializer for the JobConnectionResult model."""

class Meta:
"""Metadata for serialzer."""

model = ConnectionResults
model = JobConnectionResult
fields = ['results']
qpc_allow_empty_fields = ['results']
6 changes: 3 additions & 3 deletions quipucords/api/inspectresults/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Meta:
verbose_name_plural = _(messages.PLURAL_KEY_VALUES_MSG)


class InspectionResult(models.Model):
class TaskInspectionResult(models.Model):
"""The captured connection results from a scan."""

source = models.ForeignKey(Source, on_delete=models.CASCADE)
Expand All @@ -85,10 +85,10 @@ class Meta:
verbose_name_plural = _(messages.PLURAL_RESULTS_MSG)


class InspectionResults(models.Model):
class JobInspectionResult(models.Model):
"""The results of a connection scan."""

results = models.ManyToManyField(InspectionResult)
results = models.ManyToManyField(TaskInspectionResult)

def __str__(self):
"""Convert to string."""
Expand Down
14 changes: 7 additions & 7 deletions quipucords/api/inspectresults/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""Module for serializing all model object for database storage."""

from rest_framework.serializers import CharField, ChoiceField
from api.models import (InspectionResults, InspectionResult,
from api.models import (JobInspectionResult, TaskInspectionResult,
SystemInspectionResult, RawFact)
from api.common.serializer import (NotEmptySerializer,
CustomJSONField)
Expand Down Expand Up @@ -46,23 +46,23 @@ class Meta:
qpc_allow_empty_fields = ['facts']


class InspectionResultSerializer(NotEmptySerializer):
"""Serializer for the InspectionResult model."""
class TaskInspectionResultSerializer(NotEmptySerializer):
"""Serializer for the TaskInspectionResult model."""

class Meta:
"""Metadata for serialzer."""

model = InspectionResult
model = TaskInspectionResult
fields = ['source', 'systems']
qpc_allow_empty_fields = ['source', 'systems']


class InspectionResultsSerializer(NotEmptySerializer):
"""Serializer for the InspectionResults model."""
class JobInspectionResultSerializer(NotEmptySerializer):
"""Serializer for the JobInspectionResult model."""

class Meta:
"""Metadata for serialzer."""

model = InspectionResults
model = JobInspectionResult
fields = ['results']
qpc_allow_empty_fields = ['results']
4 changes: 2 additions & 2 deletions quipucords/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from api.credential.model import Credential
from api.source.model import Source, SourceOptions
from api.scanjob.model import ScanJob, ScanOptions
from api.connresults.model import (ConnectionResults, ConnectionResult,
from api.connresults.model import (JobConnectionResult, TaskConnectionResult,
SystemConnectionResult)
from api.inspectresults.model import (InspectionResults, InspectionResult,
from api.inspectresults.model import (JobInspectionResult, TaskInspectionResult,
SystemInspectionResult, RawFact)
from api.scantasks.model import ScanTask
12 changes: 6 additions & 6 deletions quipucords/api/scanjob/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
from django.db.models import Q
from api.source.model import Source
from api.scantasks.model import ScanTask
from api.connresults.model import ConnectionResults
from api.inspectresults.model import InspectionResults
from api.connresults.model import JobConnectionResult
from api.inspectresults.model import JobInspectionResult
import api.messages as messages

# Get an instance of a logger
Expand Down Expand Up @@ -74,9 +74,9 @@ class ScanJob(models.Model):
start_time = models.DateTimeField(null=True)
end_time = models.DateTimeField(null=True)
connection_results = models.ForeignKey(
ConnectionResults, null=True, on_delete=models.CASCADE)
JobConnectionResult, null=True, on_delete=models.CASCADE)
inspection_results = models.ForeignKey(
InspectionResults, null=True, on_delete=models.CASCADE)
JobInspectionResult, null=True, on_delete=models.CASCADE)

def __str__(self):
"""Convert to string."""
Expand Down Expand Up @@ -154,13 +154,13 @@ def queue(self):
return

if self.connection_results is None:
temp_conn_results = ConnectionResults()
temp_conn_results = JobConnectionResult()
temp_conn_results.save()
self.connection_results = temp_conn_results
self.save()
if self.inspection_results is None and \
self.scan_type == ScanTask.SCAN_TYPE_INSPECT:
temp_inspect_results = InspectionResults()
temp_inspect_results = JobInspectionResult()
temp_inspect_results.save()
self.inspection_results = temp_inspect_results
self.save()
Expand Down
26 changes: 13 additions & 13 deletions quipucords/api/scanjob/tests_scanjob.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
ScanTask,
ScanOptions,
ScanJob,
ConnectionResults,
ConnectionResult,
JobConnectionResult,
TaskConnectionResult,
SystemConnectionResult,
InspectionResults,
InspectionResult,
JobInspectionResult,
TaskInspectionResult,
SystemInspectionResult,
RawFact)
from api.scanjob.view import (expand_scanjob,
Expand Down Expand Up @@ -457,11 +457,11 @@ def test_details(self, start_scan):

conn_task = scan_job.tasks.first()

conn_results = ConnectionResults()
conn_results = JobConnectionResult()
conn_results.save()
scan_job.connection_results = conn_results

conn_result = ConnectionResult(
conn_result = TaskConnectionResult(
source=conn_task.source, scan_task=conn_task)
conn_result.save()

Expand All @@ -478,11 +478,11 @@ def test_details(self, start_scan):

inspect_task = scan_job.tasks.all()[1]

inspect_results = InspectionResults()
inspect_results = JobInspectionResult()
inspect_results.save()
scan_job.inspection_results = inspect_results

inspect_result = InspectionResult(
inspect_result = TaskInspectionResult(
source=inspect_task.source, scan_task=inspect_task)
inspect_result.save()

Expand Down Expand Up @@ -727,7 +727,7 @@ def test_expand_sys_conn_result(self):

conn_task = scan_job.tasks.first()

conn_result = ConnectionResult(
conn_result = TaskConnectionResult(
source=conn_task.source, scan_task=conn_task)
conn_result.save()

Expand Down Expand Up @@ -758,12 +758,12 @@ def test_expand_conn_results(self):

conn_task = scan_job.tasks.first()

conn_results = ConnectionResults()
conn_results = JobConnectionResult()
conn_results.save()
scan_job.connection_results = conn_results
scan_job.save()

conn_result = ConnectionResult(
conn_result = TaskConnectionResult(
source=conn_task.source, scan_task=conn_task)
conn_result.save()

Expand Down Expand Up @@ -799,13 +799,13 @@ def test_expand_inspect_results(self):

inspect_task = scan_job.tasks.all()[1]

inspect_results = InspectionResults()
inspect_results = JobInspectionResult()
inspect_results.save()

scan_job.inspection_results = inspect_results
scan_job.save()

inspect_result = InspectionResult(
inspect_result = TaskInspectionResult(
source=inspect_task.source, scan_task=inspect_task)
inspect_result.save()

Expand Down
8 changes: 4 additions & 4 deletions quipucords/api/scanjob/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
from api.models import (ScanTask, ScanJob, Source)
from api.serializers import (ScanJobSerializer,
SourceSerializer,
ConnectionResultsSerializer,
JobConnectionResultSerializer,
SystemConnectionResultSerializer,
InspectionResultsSerializer,
JobInspectionResultSerializer,
SystemInspectionResultSerializer,
RawFactSerializer)
from api.signals.scanjob_signal import (start_scan, pause_scan,
Expand Down Expand Up @@ -258,14 +258,14 @@ def results(self, request, pk=None):
job_conn_result = scan_job.connection_results
job_scan_result = scan_job.inspection_results
if job_conn_result:
serializer = ConnectionResultsSerializer(job_conn_result)
serializer = JobConnectionResultSerializer(job_conn_result)
json_job_conn_result = serializer.data
expand_conn_results(job_conn_result, json_job_conn_result)
if result is None:
result = {}
result['connection_results'] = json_job_conn_result
if job_scan_result:
serializer = InspectionResultsSerializer(job_scan_result)
serializer = JobInspectionResultSerializer(job_scan_result)
json_job_scan_result = serializer.data
expand_inspect_results(job_scan_result, json_job_scan_result)
if result is None:
Expand Down
8 changes: 4 additions & 4 deletions quipucords/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
SourceSerializer)
from api.scanjob.serializer import SourceField, ScanJobSerializer
from api.scantasks.serializer import ScanTaskSerializer
from api.connresults.serializer import (ConnectionResultsSerializer,
ConnectionResultSerializer,
from api.connresults.serializer import (JobConnectionResultSerializer,
TaskConnectionResultSerializer,
SystemConnectionResultSerializer)
from api.inspectresults.serializer import(InspectionResultsSerializer,
InspectionResultSerializer,
from api.inspectresults.serializer import(JobInspectionResultSerializer,
TaskInspectionResultSerializer,
SystemInspectionResultSerializer,
RawFactSerializer)
6 changes: 3 additions & 3 deletions quipucords/scanner/network/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ansible.parsing.splitter import parse_kv
from api.serializers import SourceSerializer, CredentialSerializer
from api.models import (Credential, ScanTask,
ConnectionResult,
TaskConnectionResult,
SystemConnectionResult)
from django.db import transaction
from scanner.task import ScanTaskRunner
Expand All @@ -39,7 +39,7 @@ class ConnectResultStore(object):
"""This object knows how to record and retrieve connection results."""

def __init__(self, scan_task, conn_results):
"""Get the unique ConnectionResult object for this scan."""
"""Get the unique TaskConnectionResult object for this scan."""
self.scan_task = scan_task
self.conn_results = conn_results

Expand All @@ -49,7 +49,7 @@ def __init__(self, scan_task, conn_results):
conn_result = conn_results.results.filter(
source__id=source.id).first()
if conn_result is None:
conn_result = ConnectionResult(
conn_result = TaskConnectionResult(
scan_task=scan_task, source=source)
conn_result.save()
conn_results.results.add(conn_result)
Expand Down
4 changes: 2 additions & 2 deletions quipucords/scanner/network/inspect_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import json
from django.db import transaction
from ansible.plugins.callback import CallbackBase
from api.models import (InspectionResult,
from api.models import (TaskInspectionResult,
SystemInspectionResult,
RawFact)
from scanner.network.processing import process
Expand Down Expand Up @@ -148,7 +148,7 @@ def _get_inspect_result(self):
inspect_result = self.inspect_results.results.filter(
source__id=self.source.id).first()
if inspect_result is None:
inspect_result = InspectionResult(
inspect_result = TaskInspectionResult(
scan_task=self.scan_task, source=self.source)
inspect_result.save()

Expand Down
4 changes: 2 additions & 2 deletions quipucords/scanner/network/tests_network_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from api.connresults.model import SystemConnectionResult
from api.models import (Credential,
Source,
ConnectionResults,
JobConnectionResult,
ScanJob,
ScanOptions,
ScanTask)
Expand Down Expand Up @@ -141,7 +141,7 @@ def setUp(self):
self.scan_job.options = scan_options
self.scan_job.save()

self.conn_results = ConnectionResults()
self.conn_results = JobConnectionResult()
self.conn_results.save()
self.scan_job.connection_results = self.conn_results
self.scan_job.save()
Expand Down
Loading

0 comments on commit 9be1c91

Please sign in to comment.