Skip to content
This repository has been archived by the owner on Jul 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #196 from upgrades-migrations/remove_component_fro…
Browse files Browse the repository at this point in the history
…m_log

remove 'component' from generated modules and tests
  • Loading branch information
bocekm authored Jan 17, 2017
2 parents 9b1cb87 + 62e3992 commit 5afe41d
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 23 deletions.
6 changes: 3 additions & 3 deletions man/preupgrade-assistant-api.1
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Your script should also tell the administrator how risky it is to upgrade your c

\fBneeds_action\fP - The test failed with the exit_fail return code but the module developer added the log_high_risk before exit_fail.

\fBfail\fP - The test failed. The in-place upgrade is not recommended and marked as an EXTERME risk.
\fBfail\fP - The test failed. The in-place upgrade is not recommended and marked as an EXTERME risk.

.SH RISK ASSESSMENT LEVELS
The available risk assessment levels are:
Expand All @@ -110,11 +110,11 @@ The levels None, Slight and Medium change return code exit_fail to exit_needs_in

There are several functions which do logging:

\fBlog_{debug,info,warning,error} <component> <message>\fP
\fBlog_{debug,info,warning,error} <message>\fP

The function creates logs in the format:

<SEVERITIES> <component> <TIMESTAMP> <MESSAGE>
<SEVERITIES> <TIMESTAMP> <MESSAGE>

.SH INI FILE EXAMPLE

Expand Down
5 changes: 2 additions & 3 deletions preupg/ui/report/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ def bulk_create_logs(self, testlogs, result):
create hostruns for list of hosts specified as Query in variable hosts
"""
testlog_list = []
keys = ['component', 'date', 'level', 'message']
keys = ['date', 'level', 'message']

for testlog in testlogs:
testlog_dict = dict((key, testlog[key]) for key in keys if key in testlog)
Expand All @@ -630,14 +630,13 @@ def get_query_set(self):
class TestLog(models.Model):
message = models.TextField()
level = models.CharField(max_length=32)
component = models.CharField(max_length=255, null=True, blank=True)
date = models.DateTimeField(null=True, blank=True)
result = models.ForeignKey(TestResult)

objects = TestLogManager()

def __unicode__(self):
return u"%s %s %s %s" % (self.level, self.component, self.date, self.message)
return u"%s %s %s" % (self.level, self.date, self.message)


class RiskMixin(object):
Expand Down
4 changes: 2 additions & 2 deletions preupg/ui/report/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ def parse_test_result_logs(self, text):
"""
parse test's logs; result is list of dicts:
[
{'level': '', 'date': '', 'component': '', 'message': ''}
{'level': '', 'date': '', 'message': ''}
]
"""
if not text:
return None, None
text = text.strip()
lines = text.split('\n')

log_regex = "preupg\.log\.(?P<level>(ERROR|WARNING|INFO|DEBUG)): (?P<component>\S+): (?P<date_str>\S+) (?P<time>\S+) (?P<message>.+)"
log_regex = "preupg\.log\.(?P<level>(ERROR|WARNING|INFO|DEBUG)): (?P<date_str>\S+) (?P<time>\S+) (?P<message>.+)"
risk_regex = "preupg\.risk\.(?P<level>\w+): (?P<message>.+)"
date_format = '%Y-%m-%d %H:%M'
logs = []
Expand Down
2 changes: 0 additions & 2 deletions preupg/ui/report/south_migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ def forwards(self, orm):
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('message', self.gf('django.db.models.fields.TextField')()),
('level', self.gf('django.db.models.fields.CharField')(max_length=32)),
('component', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True)),
('date', self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True)),
('result', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['report.TestResult'])),
))
Expand Down Expand Up @@ -273,7 +272,6 @@ def backwards(self, orm):
},
u'report.testlog': {
'Meta': {'object_name': 'TestLog'},
'component': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
'date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'level': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
Expand Down
4 changes: 0 additions & 4 deletions preupg/ui/templates/report/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ <h2>Solution</h2>
<th>
Level
</th>
<th>
Component
</th>
<th>
Message
</th>
Expand All @@ -60,7 +57,6 @@ <h2>Solution</h2>
<tr class="log">
<td>{{ log.date }}</td>
<td>{{ log.level }}</td>
<td>{{ log.component }}</td>
<td>{{ log.message }}</td>
</tr>
{% endfor %}
Expand Down
8 changes: 0 additions & 8 deletions preupg/xmlgen/script_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,6 @@ def update_check_script(self, updates, author=None):
new_line = '\n'.join(generated_section)
new_line = new_line.replace('<empty_line>', '').replace('<new_line>', '')
output_text += new_line+'\n'
if 'check_applies' in updates:
component = updates['check_applies']
else:
component = "distribution"
if script_type == "sh":
output_text += 'COMPONENT="'+component+'"\n'
else:
output_text += 'set_component("'+component+'")\n'
output_text += line
FileHelper.write_to_file(self.full_path_name, "wb", output_text)

Expand Down
1 change: 0 additions & 1 deletion tests/FOOBAR6_7/dummy/failed/dummy_failed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ echo "Dummy failed test"


. /usr/share/preupgrade/common.sh
COMPONENT="distribution"
#END GENERATED SECTION

exit $XCCDF_RESULT_FAIL

0 comments on commit 5afe41d

Please sign in to comment.