diff --git a/bin/curtin-journald-forwarder b/bin/curtin-journald-forwarder deleted file mode 100755 index b5d0fe24..00000000 --- a/bin/curtin-journald-forwarder +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/python3 - -from http import server -import json -import socket -import socketserver -from systemd import journal - - -class Handler(server.BaseHTTPRequestHandler): - address_family = socket.AF_INET6 - - def log_request(self, code, size=None): - pass - - def do_GET(self): - self.send_response(200) - self.end_headers() - self.wfile.write(b"OK") - - def do_POST(self): - length = int(self.headers['Content-Length']) - post_data = json.loads(self.rfile.read(length).decode('utf-8')) - self.forward_event(post_data) - self.do_GET() - - def forward_event(self, event): - level = str(getattr(journal, "LOG_" + event.get("level", "DEBUG"), journal.LOG_DEBUG)) - journal.send( - event['description'], - PRIORITY=level, - CURTIN_EVENT_TYPE=event["event_type"], - CURTIN_NAME=event["name"], - SYSLOG_IDENTIFIER="curtin_event", - ) - - -class HTTPServerV6(socketserver.TCPServer): - address_family = socket.AF_INET6 - - -def main(): - """Return URL to pass to curtin.""" - httpd = HTTPServerV6(("::", 0), Handler) - port = httpd.server_address[1] - print("http://[::1]:{}/".format(port), flush=True) - httpd.serve_forever() - - -if __name__ == '__main__': - main() diff --git a/scripts/replay-curtin-log.py b/scripts/replay-curtin-log.py index 6f1b0570..cc956520 100644 --- a/scripts/replay-curtin-log.py +++ b/scripts/replay-curtin-log.py @@ -2,28 +2,32 @@ import json import logging -import random import sys import time from curtin import reporter from curtin.reporter import events -url = sys.argv[1] - logger = logging.getLogger('') logger.setLevel('DEBUG') handler = logging.StreamHandler(sys.stdout) handler.setFormatter(logging.Formatter("%(asctime)s %(name)s:%(lineno)d %(message)s")) logger.addHandler(handler) -json_file = sys.argv[2] +json_file = sys.argv[1] -c = {'subiquity': {'type': 'webhook', 'endpoint': url}, 'print': {'type': 'print'}} +c = {'subiquity': {'type': 'journald'}, 'print': {'type': 'print'}} reporter.update_configuration(c) -ev_dict = {"origin": "curtin", "event_type": "start", "level": "DEBUG", "timestamp": 1505187478.3402257, "name": "cmd-install", "description": "curtin command install"} +## ev_dict = { +## "origin": "curtin", +## "event_type": "start", +## "level": "DEBUG", +## "timestamp": 1505187478.3402257, +## "name": "cmd-install", +## "description": "curtin command install" +## } class FakeEvent: def __init__(self, ev_dict): diff --git a/subiquity/controllers/installprogress.py b/subiquity/controllers/installprogress.py index 7758bde7..f152ba82 100644 --- a/subiquity/controllers/installprogress.py +++ b/subiquity/controllers/installprogress.py @@ -59,7 +59,6 @@ class InstallProgressController(BaseController): self.progress_view = None self.install_state = InstallState.NOT_STARTED self.tail_proc = None - self.journald_forwarder_proc = None self.curtin_event_stack = [] self._identity_config_done = False @@ -133,8 +132,7 @@ class InstallProgressController(BaseController): log.debug("Installprogress: this is a dry-run") config_location = os.path.join('.subiquity/', config_file_name) curtin_cmd = [ - "python3", "scripts/replay-curtin-log.py", - self.reporting_url, "examples/curtin-events.json", + "python3", "scripts/replay-curtin-log.py", "examples/curtin-events.json", ] else: log.debug("Installprogress: this is the *REAL* thing") @@ -143,14 +141,13 @@ class InstallProgressController(BaseController): self._write_config( config_location, - self.base_model.render(target=TARGET, reporting_url=self.reporting_url)) + self.base_model.render(target=TARGET)) return curtin_cmd def curtin_start_install(self): log.debug('Curtin Install: starting curtin') self.install_state = InstallState.RUNNING - self.start_journald_forwarder() self.start_journald_listener("curtin_event", self.curtin_event) curtin_cmd = self._get_curtin_command() @@ -201,16 +198,6 @@ class InstallProgressController(BaseController): tail = self.tail_proc.stdout.read().decode('utf-8', 'replace') self.progress_view.add_log_tail(tail) - def start_journald_forwarder(self): - log.debug("starting curtin journald forwarder") - if "SNAP" in os.environ and sys.executable.startswith(os.environ["SNAP"]): - script = os.path.join(os.environ["SNAP"], 'usr/bin/curtin-journald-forwarder') - else: - script = './bin/curtin-journald-forwarder' - self.journald_forwarder_proc = utils.run_command_start([script]) - self.reporting_url = self.journald_forwarder_proc.stdout.readline().decode('utf-8').strip() - log.debug("curtin journald forwarder listening on %s", self.reporting_url) - def start_tail_proc(self): self.progress_view.clear_log_tail() tail_cmd = ['tail', '-n', '1000', '-F', CURTIN_INSTALL_LOG] diff --git a/subiquity/models/subiquity.py b/subiquity/models/subiquity.py index 1e2ca969..f813ff24 100644 --- a/subiquity/models/subiquity.py +++ b/subiquity/models/subiquity.py @@ -82,7 +82,7 @@ class SubiquityModel: with open(path, 'w') as fp: fp.write(content) - def render(self, target, reporting_url=None): + def render(self, target): config = { 'install': { 'target': target,