summaryrefslogtreecommitdiff
path: root/ironic_python_agent/inspector.py
diff options
context:
space:
mode:
authorLucas Alvares Gomes <lucasagomes@gmail.com>2016-05-30 17:39:13 +0100
committerLucas Alvares Gomes <lucasagomes@gmail.com>2016-06-28 17:02:11 +0100
commitaf81914ce7309b23edcccc030d40f59f98fc258e (patch)
treeb7f33ad8e729119a8ed9f1dca7dc580ba1dbf28a /ironic_python_agent/inspector.py
parent0ba66c27ea84a68acfd56d50e5eef131fbfc56f6 (diff)
downloadironic-python-agent-af81914ce7309b23edcccc030d40f59f98fc258e.tar.gz
Add a log extension
The log extension is responsible for retrieving logs from the system, if journalctl is present the logs will come from it, otherwise we fallback to getting the logs from the /var/log directory + dmesg logs. In the coreos ramdisk, we need to bind mount /run/log in the container so the IPA service can have access to the journal. For the tinyIPA ramdisk, the logs from IPA are now being redirected to /var/logs/ironic-python-agent.log instead of only going to the default stdout. Inspector now shares the same method of collecting logs, extending its capabilities for non-systemd systems. Partial-Bug: #1587143 Change-Id: Ie507e2e5c58cffa255bbfb2fa5ffb95cb98ed8c4
Diffstat (limited to 'ironic_python_agent/inspector.py')
-rw-r--r--ironic_python_agent/inspector.py22
1 files changed, 3 insertions, 19 deletions
diff --git a/ironic_python_agent/inspector.py b/ironic_python_agent/inspector.py
index 3c59f9e3..766ce2ba 100644
--- a/ironic_python_agent/inspector.py
+++ b/ironic_python_agent/inspector.py
@@ -13,11 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import base64
-import io
import json
import os
-import tarfile
import time
import netaddr
@@ -319,7 +316,7 @@ def collect_default(data, failures):
def collect_logs(data, failures):
- """Collect journald logs from the ramdisk.
+ """Collect system logs from the ramdisk.
As inspection runs before any nodes details are known, it's handy to have
logs returned with data. This collector sends logs to inspector in format
@@ -334,24 +331,11 @@ def collect_logs(data, failures):
:param failures: AccumulatedFailures object
"""
try:
- out, _e = utils.execute('journalctl', '--full', '--no-pager', '-b',
- '-n', '10000', binary=True,
- log_stdout=False)
- except (processutils.ProcessExecutionError, OSError):
+ data['logs'] = utils.collect_system_logs(journald_max_lines=10000)
+ except errors.CommandExecutionError:
LOG.warning('failed to get system journal')
return
- journal = io.BytesIO(bytes(out))
- with io.BytesIO() as fp:
- with tarfile.open(fileobj=fp, mode='w:gz') as tar:
- tarinfo = tarfile.TarInfo('journal')
- tarinfo.size = len(out)
- tarinfo.mtime = time.time()
- tar.addfile(tarinfo, journal)
-
- fp.seek(0)
- data['logs'] = base64.b64encode(fp.getvalue())
-
def collect_extra_hardware(data, failures):
"""Collect detailed inventory using 'hardware-detect' utility.