~andreserl/maas/1.8b8

« back to all changes in this revision

Viewing changes to debian/maas-region-controller-min.apport

[r=andreserl,mpontillo,ubuntudotcom1][bug=1452276][author=allenap] Launch 4 maas-regiond workers using systemd template units.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
the full text of the license.
13
13
'''
14
14
 
 
15
import os.path
 
16
import subprocess
 
17
import tempfile
 
18
 
15
19
from apport.hookutils import (
16
20
    attach_conffiles,
 
21
    attach_file,
17
22
    attach_file_if_exists,
18
23
    attach_related_packages,
19
24
)
20
25
 
21
26
 
 
27
def attach_journal_logs(report, key, *units):
 
28
    """Capture logs from systemd's journal."""
 
29
    if os.path.exists("/bin/journalctl"):
 
30
        cmd = ['/bin/journalctl', '--utc', '--since=-24hours']
 
31
        cmd.extend("--unit=%s" % unit for unit in units)
 
32
        with tempfile.NamedTemporaryFile() as logfile:
 
33
            subprocess.call(cmd, stdout=logfile, stderr=logfile)
 
34
            attach_file(report, logfile.name, key)
 
35
 
 
36
 
22
37
def add_info(report, ui):
23
38
    response = ui.yesno(
24
39
        "The contents of your /etc/maas/maas_local_settings.py, "
31
46
    elif response is True:
32
47
        attach_conffiles(report, 'maas')
33
48
 
34
 
    # Attaching log files
 
49
    # Attaching log files (Upstart).
35
50
    attach_file_if_exists(
36
51
        report, '/var/log/maas/regiond.log', 'MAASRegionLog')
37
52
    attach_file_if_exists(
38
53
        report, '/var/log/maas/clusterd.log', 'MAASClusterLog')
39
54
 
 
55
    # Attaching log files (systemd). These will overwrite the logs above on a
 
56
    # system where systemd is available.
 
57
    attach_journal_logs(
 
58
        report, "MAASRegionLog", "maas-regiond", "maas-regiond-worker@*")
 
59
    attach_journal_logs(
 
60
        report, "MAASClusterLog", "maas-clusterd")
 
61
 
40
62
    # Attaching related packages info
41
63
    attach_related_packages(report, ['python-django-maas', 'apparmor'])