Skip to content

Commit

Permalink
Revert "Feature rework install log processing (#240)"
Browse files Browse the repository at this point in the history
This reverts commit 77a2e36.
  • Loading branch information
grahamgilbert authored Jun 21, 2018
1 parent 62608c8 commit 7e2c663
Show file tree
Hide file tree
Showing 30 changed files with 891 additions and 478 deletions.
10 changes: 8 additions & 2 deletions api/fixtures/machine_fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@
"last_checkin": "2016-10-06T19:29:38.376Z",
"first_checkin": "2016-10-06T15:51:21.145Z",
"report": "",
"report_format": "base64bz2",
"errors": 4,
"warnings": 7,
"activity": false,
"activity": "",
"puppet_version": "4.7.0",
"sal_version": "1.0.6",
"last_puppet_run": "2016-10-06T19:06:21Z",
"puppet_errors": 0,
"install_log_hash": "ed168dbcf43e8c89ec3bc1a5708a7210cfeeedf0fc4e8cbbda2e0b50af782e72",
"install_log": "",
"deployed": true,
"broken_client": false
}
Expand Down Expand Up @@ -58,13 +61,16 @@
"last_checkin": "2017-05-16T19:04:51.336Z",
"first_checkin": "2017-05-16T19:04:51.728Z",
"report": "",
"report_format": "base64bz2",
"errors": 0,
"warnings": 3,
"activity": false,
"activity": "",
"puppet_version": "4.10.1",
"sal_version": "2.0.3",
"last_puppet_run": "2017-05-16T18:54:56Z",
"puppet_errors": 0,
"install_log_hash": null,
"install_log": null,
"deployed": true,
"broken_client": false
}
Expand Down
2 changes: 1 addition & 1 deletion api/fixtures/search_fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"fields": {
"search_group": 3,
"search_models": "Machine",
"search_field": "serial",
"search_field": "hostname",
"and_or": "AND",
"operator": "=",
"search_term": "C0DEADBEEF",
Expand Down
2 changes: 1 addition & 1 deletion api/v1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ class MachineSerializer(serializers.ModelSerializer):

class Meta:
model = Machine
exclude = ('report', )
exclude = ('report', 'install_log', 'install_log_hash')
2 changes: 1 addition & 1 deletion api/v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class MachineSerializer(QueryFieldsMixin, serializers.ModelSerializer):
'machine_model_friendly', 'memory', 'memory_kb', 'warnings',
'first_checkin', 'last_checkin', 'hd_total', 'os_family', 'deployed',
'operating_system', 'machine_group', 'sal_version', 'manifest',
'hd_percent', 'cpu_type', 'broken_client', 'activity')
'hd_percent', 'cpu_type', 'broken_client', 'report_format')

class Meta:
model = Machine
Expand Down
22 changes: 13 additions & 9 deletions api/v2/tests/test_machines.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@


ALL_MACHINE_COLUMNS = {
'console_user', 'munki_version', 'hd_space', 'machine_model', 'cpu_speed', 'serial', 'id',
'last_puppet_run', 'errors', 'puppet_version', 'hostname', 'puppet_errors',
'machine_model_friendly', 'memory', 'memory_kb', 'warnings', 'first_checkin', 'last_checkin',
'broken_client', 'hd_total', 'os_family', 'report', 'deployed', 'operating_system',
'machine_group', 'sal_version', 'manifest', 'hd_percent', 'cpu_type',
'activity'}
REMOVED_MACHINE_COLUMNS = {'report'}
'console_user', 'munki_version', 'hd_space', 'machine_model', 'cpu_speed',
'serial', 'id', 'last_puppet_run', 'errors', 'puppet_version', 'hostname',
'puppet_errors', 'machine_model_friendly', 'memory', 'memory_kb',
'warnings', 'install_log', 'first_checkin', 'last_checkin',
'broken_client', 'hd_total', 'os_family', 'report', 'deployed',
'operating_system', 'report_format', 'machine_group', 'sal_version',
'manifest', 'hd_percent', 'cpu_type', 'activity', 'install_log_hash'}
REMOVED_MACHINE_COLUMNS = {
'activity', 'report', 'install_log', 'install_log_hash'}


class MachinesTest(SalAPITestCase):
Expand Down Expand Up @@ -91,13 +93,15 @@ def test_detail_include_fields(self):
"""Test the field inclusion/exclusion params for detail."""
response = self.authed_get(
'machine-detail', args=('C0DEADBEEF',),
params={'fields!': 'hostname'})
params={'fields': 'activity', 'fields!': 'hostname'})
self.assertIn('activity', response.data)
self.assertNotIn('hostname', response.data)

def test_list_include_fields(self):
"""Test the field inclusion/exclusion params for list."""
response = self.authed_get(
'machine-list',
params={'fields!': 'hostname'})
params={'fields': 'activity', 'fields!': 'hostname'})
record = response.data['results'][0]
self.assertIn('activity', record)
self.assertNotIn('hostname', record)
8 changes: 5 additions & 3 deletions api/v2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ class MachineViewSet(QueryFieldsMixin, viewsets.ModelViewSet):
- Include Example: `/api/machines/?fields=console_user,hostname`
- Exclude Example: `/api/machines/?fields!=report`
The abbreviated form excludes the `report` field.
The abbreviated form excludes the `report`, `install_log`,
`install_log_hash`, and `activity` fields.
You may also use the `search` querystring to perform text searches
across the `console_user`, `cpu_speed`, `cpu_type`,
across the `activity`, `console_user`, `cpu_speed`, `cpu_type`,
`hostname`, `machine_model`, `machine_model_friendly`, `manifest`,
and `memory` fields.
Expand All @@ -103,7 +104,8 @@ class MachineViewSet(QueryFieldsMixin, viewsets.ModelViewSet):
- Include Example: `/api/machines/C0DEADBEEF/?fields=console_user,hostname`
- Exclude Example: `/api/machines/C0DEADBEEF/?fields!=report`
The abbreviated form excludes the `report` field.
The abbreviated form excludes the `activity`, `report`, `install_log`, and
`install_log_hash` fields.
"""
queryset = Machine.objects.all()
serializer_class = MachineSerializer
Expand Down
10 changes: 7 additions & 3 deletions catalog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from django.template import Context, RequestContext, Template
from django.template.context_processors import csrf
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST

from models import *
from sal.decorators import *
Expand All @@ -23,9 +22,11 @@


@csrf_exempt
@require_POST
@key_auth_required
def submit_catalog(request):
if request.method != 'POST':
raise Http404

submission = request.POST
key = submission.get('key')
name = submission.get('name')
Expand Down Expand Up @@ -57,9 +58,12 @@ def submit_catalog(request):


@csrf_exempt
@require_POST
@key_auth_required
def catalog_hash(request):
if request.method != 'POST':
print 'method not post'
raise Http404

output = []
submission = request.POST
key = submission.get('key')
Expand Down
10 changes: 8 additions & 2 deletions inventory/fixtures/machine_fixture.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@
"last_checkin": "2016-10-06T19:29:38.376Z",
"first_checkin": "2016-10-06T15:51:21.145Z",
"report": "",
"report_format": "base64bz2",
"errors": 4,
"warnings": 7,
"activity": false,
"activity": "",
"puppet_version": "4.7.0",
"sal_version": "1.0.6",
"last_puppet_run": "2016-10-06T19:06:21Z",
"puppet_errors": 0,
"install_log_hash": "ed168dbcf43e8c89ec3bc1a5708a7210cfeeedf0fc4e8cbbda2e0b50af782e72",
"install_log": "",
"deployed": true,
"broken_client": false
}
Expand Down Expand Up @@ -58,13 +61,16 @@
"last_checkin": "2017-05-16T19:04:51.336Z",
"first_checkin": "2017-05-16T19:04:51.728Z",
"report": "",
"report_format": "base64bz2",
"errors": 0,
"warnings": 3,
"activity": false,
"activity": "",
"puppet_version": "4.10.1",
"sal_version": "2.0.3",
"last_puppet_run": "2017-05-16T18:54:56Z",
"puppet_errors": 0,
"install_log_hash": null,
"install_log": null,
"deployed": true,
"broken_client": false
}
Expand Down
5 changes: 3 additions & 2 deletions inventory/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from django.template import RequestContext
from django.utils import timezone
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST
from django.views.generic import DetailView, View

from datatableview import Datatable
Expand Down Expand Up @@ -525,9 +524,11 @@ def get_machine_entry(self, item, queryset):


@csrf_exempt
@require_POST
@key_auth_required
def inventory_submit(request):
if request.method != 'POST':
return HttpResponseNotFound('No POST data sent')

# list of bundleids to ignore
bundleid_ignorelist = [
'com.apple.print.PrinterProxy'
Expand Down
5 changes: 3 additions & 2 deletions profiles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from django.shortcuts import get_object_or_404, render_to_response
from django.utils import dateparse
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST


# Local
Expand All @@ -25,9 +24,11 @@

# Create your views here.
@csrf_exempt
@require_POST
@key_auth_required
def submit_profiles(request):
if request.method != 'POST':
return HttpResponseNotFound('No POST data sent')

submission = request.POST
serial = submission.get('serial').upper()
machine = None
Expand Down
2 changes: 1 addition & 1 deletion sal/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
from yapsy.IPlugin import IPlugin
import yapsy.PluginManager

from django.conf import settings
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.template import loader

from sal import settings
from sal.decorators import handle_access, is_global_admin
from server.models import Machine, Plugin, MachineDetailPlugin, Report
from server.text_utils import class_to_title
Expand Down
4 changes: 3 additions & 1 deletion search/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class SearchRowForm(forms.ModelForm):
'activity',
'errors',
'warnings',
'puppet_errors'
'install_log',
'puppet_errors',
'install_log_hash'
]
search_fields = []
for f in Machine._meta.fields:
Expand Down
4 changes: 3 additions & 1 deletion search/management/commands/search_maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def handle(self, *args, **options):
'activity',
'errors',
'warnings',
'puppet_errors'
'install_log',
'puppet_errors',
'install_log_hash'
]

inventory_fields = [
Expand Down
12 changes: 11 additions & 1 deletion search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ def quick_search(machines, query_string):
'activity',
'errors',
'warnings',
'install_log',
'puppet_errors',
'install_log_hash',
'deployed',
'report_format',
'broken_client',
'hd_percent',
'memory',
Expand Down Expand Up @@ -579,6 +582,9 @@ def get_csv_row(machine, facter_headers, condition_headers, plugin_script_header
skip_fields = [
'id',
'report',
'activity',
'install_log',
'install_log_hash',
'machine_group'
]
for name, value in machine.get_fields():
Expand All @@ -603,7 +609,8 @@ def stream_csv(header_row, machines, facter_headers, condition_headers, plugin_s

@login_required
def export_csv(request, search_id):
machines = Machine.objects.all().defer('report')
machines = Machine.objects.all().defer('report', 'activity', 'install_log',
'install_log_hash')

machines = search_machines(search_id, machines, full=True)

Expand All @@ -617,6 +624,9 @@ def export_csv(request, search_id):
skip_fields = [
'id',
'report',
'activity',
'install_log',
'install_log_hash'
]
for field in fields:
if not field.is_relation and field.name not in skip_fields:
Expand Down
5 changes: 3 additions & 2 deletions server/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ class MachineAdmin(admin.ModelAdmin):
('last_checkin', 'first_checkin'),
('puppet_version', 'last_puppet_run', 'puppet_errors'),
('sal_version', 'deployed', 'broken_client'),
'report'
'report', 'report_format', 'install_log_hash', 'install_log'
)
readonly_fields = (business_unit, 'first_checkin', 'last_checkin', 'last_puppet_run')
readonly_fields = (business_unit, 'first_checkin', 'last_checkin', 'last_puppet_run',
'report_format')
search_fields = ('hostname', 'console_user')


Expand Down
19 changes: 0 additions & 19 deletions server/migrations/0069_remove_machine_install_log.py

This file was deleted.

19 changes: 0 additions & 19 deletions server/migrations/0070_remove_machine_install_log_hash.py

This file was deleted.

19 changes: 0 additions & 19 deletions server/migrations/0071_remove_updatehistory_pending_recorded.py

This file was deleted.

Loading

0 comments on commit 7e2c663

Please sign in to comment.