Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature rework install log processing #240

Merged
merged 81 commits into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
a0af68a
Write some tests for Install log regex.
sheagcraig Apr 20, 2018
7981f81
Remove code saving install log file into machine record. Twice.
sheagcraig Apr 20, 2018
0109b12
Rewrite process_update_item and install log submission functions.
sheagcraig Apr 20, 2018
ca0992c
Fix syntax error.
sheagcraig Apr 20, 2018
c55026f
Fix renaming error.
sheagcraig Apr 20, 2018
9ad712b
Pick off remaining typos and bugs.
sheagcraig Apr 20, 2018
593f476
Remove machine install log field.
sheagcraig Apr 20, 2018
c33663e
Write some tests for Install log regex.
sheagcraig Apr 20, 2018
f7f74b4
Remove code saving install log file into machine record. Twice.
sheagcraig Apr 20, 2018
9051470
Rewrite process_update_item and install log submission functions.
sheagcraig Apr 20, 2018
6d52c16
Fix syntax error.
sheagcraig Apr 20, 2018
5711cf5
Fix renaming error.
sheagcraig Apr 20, 2018
2a12fa0
Pick off remaining typos and bugs.
sheagcraig Apr 20, 2018
85907d9
Remove machine install log field.
sheagcraig Apr 20, 2018
f5cdf88
Merge branch 'feature_rework_checkin' of github.com:salopensource/sal…
sheagcraig Apr 23, 2018
c3e1d34
Start merging base64/bz2 decode/encode methods.
sheagcraig Apr 23, 2018
8f2e148
Add UTC to puppet run datetime.
sheagcraig Apr 23, 2018
3cc78e3
Reuse the pending UpdateHistoryItem query as much as possible.
sheagcraig Apr 23, 2018
66b7a72
Add some timezone information to things so we don't get django mad.
sheagcraig Apr 23, 2018
63ed358
Line length.
sheagcraig Apr 23, 2018
6275fa9
WS.
sheagcraig Apr 23, 2018
57d2cfb
Fix up Machine.get_report to handle always returning a plist.
sheagcraig Apr 25, 2018
bd988f6
Rewrite update processing during checkin.
sheagcraig Apr 25, 2018
c5d0b42
Remove `Machine.install_log_hash` and references.
sheagcraig Apr 25, 2018
8e5bb8c
Remove `Machine.pending_recorded`.
sheagcraig Apr 25, 2018
c7a9bd5
Remove unused regex, add deprecation todos.
sheagcraig Apr 25, 2018
3b6c56d
Write some tests for Install log regex.
sheagcraig Apr 20, 2018
cffb6fb
Remove code saving install log file into machine record. Twice.
sheagcraig Apr 20, 2018
1ae7513
Rewrite process_update_item and install log submission functions.
sheagcraig Apr 20, 2018
a4f7021
Fix syntax error.
sheagcraig Apr 20, 2018
f65ec9c
Fix renaming error.
sheagcraig Apr 20, 2018
837c45d
Pick off remaining typos and bugs.
sheagcraig Apr 20, 2018
fbb596f
Remove machine install log field.
sheagcraig Apr 20, 2018
7e8680f
Start merging base64/bz2 decode/encode methods.
sheagcraig Apr 23, 2018
a329d7d
Add UTC to puppet run datetime.
sheagcraig Apr 23, 2018
a846856
Reuse the pending UpdateHistoryItem query as much as possible.
sheagcraig Apr 23, 2018
476fd0f
Add some timezone information to things so we don't get django mad.
sheagcraig Apr 23, 2018
5c653e8
Line length.
sheagcraig Apr 23, 2018
80fd977
WS.
sheagcraig Apr 23, 2018
f394276
Fix up Machine.get_report to handle always returning a plist.
sheagcraig Apr 25, 2018
c59fe74
Rewrite update processing during checkin.
sheagcraig Apr 25, 2018
88cd38b
Remove `Machine.install_log_hash` and references.
sheagcraig Apr 25, 2018
9fdd1d7
Remove `Machine.pending_recorded`.
sheagcraig Apr 25, 2018
8b10556
Remove unused regex, add deprecation todos.
sheagcraig Apr 25, 2018
9aa39c4
Merge branch 'feature_rework_checkin' of github.com:salopensource/sal…
sheagcraig May 2, 2018
efa7a8d
Rewrite pending updates plugins and cleanup one template.
sheagcraig Apr 27, 2018
462e6d5
Cleanup special handling for the uptime plugin in views and templates.
sheagcraig Apr 27, 2018
7cd2ea1
Replace request method checks with builtin decorator.
sheagcraig Apr 27, 2018
38f9028
Use best-practice settings import here.
sheagcraig Apr 27, 2018
072c12b
Add utility for getting django settings.
sheagcraig Apr 27, 2018
fa99d63
Start refactoring checkin.
sheagcraig Apr 27, 2018
de915a6
Fix typo.
sheagcraig Apr 27, 2018
99b6168
Fix typo
sheagcraig Apr 27, 2018
eaa9b84
Fix some logic errors in Machine.update_report.
sheagcraig Apr 27, 2018
c5ad853
Remove extra console user check.
sheagcraig Apr 27, 2018
1fd55c6
Refactor some basic machine field setting operations. Move compress test
sheagcraig Apr 27, 2018
51bfe77
Move last_puppet_run and puppet_errors code up, away from hwinfo.
sheagcraig Apr 27, 2018
55a0e16
Rewrite memory calculations in checkin, move os_family check up.
sheagcraig Apr 27, 2018
d3ec0f8
Move os_family even further up, to group with similar.
sheagcraig Apr 27, 2018
ff12cdc
Clean up plugin script processing logic.
sheagcraig Apr 27, 2018
c61df22
Remove duplicate time delta calculations.
sheagcraig Apr 27, 2018
bed7bce
Use raw delete for speed for UpdateHistoryItems too.
sheagcraig Apr 27, 2018
1e4c48b
Fix a couple bugs.
sheagcraig Apr 27, 2018
55c3596
Refactor fact and condition processing.
sheagcraig Apr 27, 2018
46fa2c5
Move `models.Machine.update_report` to checkin view.
sheagcraig Apr 30, 2018
29eec70
Add a little plugin sanity check.
sheagcraig Apr 30, 2018
8baae4c
Make `Machine.activity` a boolean and update all consumers.
sheagcraig Apr 30, 2018
12eeb1a
Remove activity from api exclusions and update its use.
sheagcraig Apr 30, 2018
a8c423a
Fix up tests.
sheagcraig Apr 30, 2018
e3ca6ac
Remove `Machine.report_format` as it's not really used.
sheagcraig Apr 30, 2018
a8b6b5e
Remove overridden `Machine.save` since its tasks are handled elsewhere.
sheagcraig Apr 30, 2018
06b6761
Fix test.
sheagcraig Apr 30, 2018
04c025b
Add another emergency plugin test.
sheagcraig Apr 30, 2018
c49e684
Remove unused `Machine` methods.
sheagcraig Apr 30, 2018
d10815c
Revert pending updates plugins.
sheagcraig May 2, 2018
47116cd
Revert use of [Installed|Pending][Apple]Updates, factor out into funcs.
sheagcraig May 2, 2018
84058b0
Make flake happy.
sheagcraig May 2, 2018
c619f70
Factor together UpdateHistory, Pending, and InstalledUpdate processing.
sheagcraig May 2, 2018
b8fb49a
Add a UTC timezone to parsable pluginscript date strings that lack a tz.
sheagcraig May 2, 2018
b0d0cda
Remove out-of-date UpdateHistory and their items.
sheagcraig May 2, 2018
f1ef7bc
Implement the existing code's handling of duplicate ManagedInstalls.
sheagcraig May 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions api/fixtures/machine_fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@
"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": "",
"activity": false,
"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 @@ -61,16 +58,13 @@
"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": "",
"activity": false,
"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": "hostname",
"search_field": "serial",
"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', 'install_log', 'install_log_hash')
exclude = ('report', )
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', 'report_format')
'hd_percent', 'cpu_type', 'broken_client', 'activity')

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


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', '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'}
'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'}


class MachinesTest(SalAPITestCase):
Expand Down Expand Up @@ -93,15 +91,13 @@ def test_detail_include_fields(self):
"""Test the field inclusion/exclusion params for detail."""
response = self.authed_get(
'machine-detail', args=('C0DEADBEEF',),
params={'fields': 'activity', 'fields!': 'hostname'})
self.assertIn('activity', response.data)
params={'fields!': 'hostname'})
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': 'activity', 'fields!': 'hostname'})
params={'fields!': 'hostname'})
record = response.data['results'][0]
self.assertIn('activity', record)
self.assertNotIn('hostname', record)
8 changes: 3 additions & 5 deletions api/v2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,10 @@ 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`, `install_log`,
`install_log_hash`, and `activity` fields.
The abbreviated form excludes the `report` field.

You may also use the `search` querystring to perform text searches
across the `activity`, `console_user`, `cpu_speed`, `cpu_type`,
across the `console_user`, `cpu_speed`, `cpu_type`,
`hostname`, `machine_model`, `machine_model_friendly`, `manifest`,
and `memory` fields.

Expand All @@ -104,8 +103,7 @@ 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 `activity`, `report`, `install_log`, and
`install_log_hash` fields.
The abbreviated form excludes the `report` field.
"""
queryset = Machine.objects.all()
serializer_class = MachineSerializer
Expand Down
10 changes: 3 additions & 7 deletions catalog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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 @@ -22,11 +23,9 @@


@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 @@ -58,12 +57,9 @@ 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: 2 additions & 8 deletions inventory/fixtures/machine_fixture.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@
"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": "",
"activity": false,
"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 @@ -61,16 +58,13 @@
"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": "",
"activity": false,
"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: 2 additions & 3 deletions inventory/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
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 @@ -524,11 +525,9 @@ 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: 2 additions & 3 deletions profiles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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 @@ -24,11 +25,9 @@

# 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: 1 addition & 3 deletions search/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ class SearchRowForm(forms.ModelForm):
'activity',
'errors',
'warnings',
'install_log',
'puppet_errors',
'install_log_hash'
'puppet_errors'
]
search_fields = []
for f in Machine._meta.fields:
Expand Down
4 changes: 1 addition & 3 deletions search/management/commands/search_maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ def handle(self, *args, **options):
'activity',
'errors',
'warnings',
'install_log',
'puppet_errors',
'install_log_hash'
'puppet_errors'
]

inventory_fields = [
Expand Down
12 changes: 1 addition & 11 deletions search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,8 @@ 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 @@ -582,9 +579,6 @@ 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 @@ -609,8 +603,7 @@ 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', 'activity', 'install_log',
'install_log_hash')
machines = Machine.objects.all().defer('report')

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

Expand All @@ -624,9 +617,6 @@ 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: 2 additions & 3 deletions server/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,9 @@ class MachineAdmin(admin.ModelAdmin):
('last_checkin', 'first_checkin'),
('puppet_version', 'last_puppet_run', 'puppet_errors'),
('sal_version', 'deployed', 'broken_client'),
'report', 'report_format', 'install_log_hash', 'install_log'
'report'
)
readonly_fields = (business_unit, 'first_checkin', 'last_checkin', 'last_puppet_run',
'report_format')
readonly_fields = (business_unit, 'first_checkin', 'last_checkin', 'last_puppet_run')
search_fields = ('hostname', 'console_user')


Expand Down
19 changes: 19 additions & 0 deletions server/migrations/0069_remove_machine_install_log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-04-20 17:39
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('server', '0068_auto_20180313_1440'),
]

operations = [
migrations.RemoveField(
model_name='machine',
name='install_log',
),
]
19 changes: 19 additions & 0 deletions server/migrations/0070_remove_machine_install_log_hash.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-04-25 18:29
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('server', '0069_remove_machine_install_log'),
]

operations = [
migrations.RemoveField(
model_name='machine',
name='install_log_hash',
),
]
19 changes: 19 additions & 0 deletions server/migrations/0071_remove_updatehistory_pending_recorded.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-04-25 18:36
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('server', '0070_remove_machine_install_log_hash'),
]

operations = [
migrations.RemoveField(
model_name='updatehistory',
name='pending_recorded',
),
]
Loading