Merge pull request #870 from mwhudson/reorg-syslog-ids
have the client unconditionally print whatever comes over one syslog id
This commit is contained in:
commit
25e107e522
|
@ -245,7 +245,10 @@ class SubiquityClient(TuiApplication):
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
print()
|
print()
|
||||||
self.event_syslog_id = status.event_syslog_id
|
journald_listen(
|
||||||
|
self.aio_loop,
|
||||||
|
[status.echo_syslog_id],
|
||||||
|
lambda e: print(e['MESSAGE']))
|
||||||
if status.state == ApplicationState.STARTING:
|
if status.state == ApplicationState.STARTING:
|
||||||
print("server is starting...", end='', flush=True)
|
print("server is starting...", end='', flush=True)
|
||||||
while status.state == ApplicationState.STARTING:
|
while status.state == ApplicationState.STARTING:
|
||||||
|
@ -255,13 +258,8 @@ class SubiquityClient(TuiApplication):
|
||||||
print()
|
print()
|
||||||
if status.state == ApplicationState.EARLY_COMMANDS:
|
if status.state == ApplicationState.EARLY_COMMANDS:
|
||||||
print("running early commands...")
|
print("running early commands...")
|
||||||
fd = journald_listen(
|
status = await self.client.meta.status.GET(cur=status.state)
|
||||||
self.aio_loop,
|
|
||||||
[status.early_commands_syslog_id],
|
|
||||||
lambda e: print(e['MESSAGE']))
|
|
||||||
status.state = await self.client.meta.status.GET(cur=status.state)
|
|
||||||
await asyncio.sleep(0.5)
|
await asyncio.sleep(0.5)
|
||||||
self.aio_loop.remove_reader(fd)
|
|
||||||
return status
|
return status
|
||||||
|
|
||||||
async def start(self):
|
async def start(self):
|
||||||
|
|
|
@ -36,7 +36,7 @@ class ApplicationState(enum.Enum):
|
||||||
class ApplicationStatus:
|
class ApplicationStatus:
|
||||||
state: ApplicationState
|
state: ApplicationState
|
||||||
cloud_init_ok: bool
|
cloud_init_ok: bool
|
||||||
early_commands_syslog_id: str
|
echo_syslog_id: str
|
||||||
log_syslog_id: str
|
log_syslog_id: str
|
||||||
event_syslog_id: str
|
event_syslog_id: str
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ class CmdListController(NonInteractiveController):
|
||||||
}
|
}
|
||||||
cmds = ()
|
cmds = ()
|
||||||
cmd_check = True
|
cmd_check = True
|
||||||
send_to_journal = False
|
syslog_id = None
|
||||||
|
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
super().__init__(app)
|
super().__init__(app)
|
||||||
|
@ -60,13 +60,12 @@ class CmdListController(NonInteractiveController):
|
||||||
with context.child("command_{}".format(i), desc):
|
with context.child("command_{}".format(i), desc):
|
||||||
if isinstance(cmd, str):
|
if isinstance(cmd, str):
|
||||||
cmd = ['sh', '-c', cmd]
|
cmd = ['sh', '-c', cmd]
|
||||||
if self.send_to_journal:
|
if self.syslog_id is not None:
|
||||||
journal.send(
|
journal.send(
|
||||||
" running " + desc,
|
" running " + desc, SYSLOG_IDENTIFIER=self.syslog_id)
|
||||||
SYSLOG_IDENTIFIER=self.app.early_commands_syslog_id)
|
|
||||||
cmd = [
|
cmd = [
|
||||||
'systemd-cat', '--level-prefix=false',
|
'systemd-cat', '--level-prefix=false',
|
||||||
'--identifier=' + self.app.early_commands_syslog_id,
|
'--identifier=' + self.syslog_id,
|
||||||
] + cmd
|
] + cmd
|
||||||
await arun_command(
|
await arun_command(
|
||||||
cmd, env=env,
|
cmd, env=env,
|
||||||
|
@ -78,13 +77,20 @@ class CmdListController(NonInteractiveController):
|
||||||
class EarlyController(CmdListController):
|
class EarlyController(CmdListController):
|
||||||
|
|
||||||
autoinstall_key = 'early-commands'
|
autoinstall_key = 'early-commands'
|
||||||
send_to_journal = True
|
|
||||||
|
def __init__(self, app):
|
||||||
|
super().__init__(app)
|
||||||
|
self.syslog_id = app.echo_syslog_id
|
||||||
|
|
||||||
|
|
||||||
class LateController(CmdListController):
|
class LateController(CmdListController):
|
||||||
|
|
||||||
autoinstall_key = 'late-commands'
|
autoinstall_key = 'late-commands'
|
||||||
|
|
||||||
|
def __init__(self, app):
|
||||||
|
super().__init__(app)
|
||||||
|
self.syslog_id = app.log_syslog_id
|
||||||
|
|
||||||
def env(self):
|
def env(self):
|
||||||
env = super().env()
|
env = super().env()
|
||||||
env['TARGET_MOUNT_POINT'] = self.app.base_model.target
|
env['TARGET_MOUNT_POINT'] = self.app.base_model.target
|
||||||
|
@ -104,3 +110,11 @@ class ErrorController(CmdListController):
|
||||||
|
|
||||||
autoinstall_key = 'error-commands'
|
autoinstall_key = 'error-commands'
|
||||||
cmd_check = False
|
cmd_check = False
|
||||||
|
|
||||||
|
@with_context()
|
||||||
|
async def run(self, context):
|
||||||
|
if self.app.interactive():
|
||||||
|
self.syslog_id = self.app.log_syslog_id
|
||||||
|
else:
|
||||||
|
self.syslog_id = self.app.echo_syslog_id
|
||||||
|
await super().run(context=context)
|
||||||
|
|
|
@ -75,7 +75,7 @@ class MetaController:
|
||||||
return ApplicationStatus(
|
return ApplicationStatus(
|
||||||
self.app.state,
|
self.app.state,
|
||||||
cloud_init_ok=self.app.cloud_init_ok,
|
cloud_init_ok=self.app.cloud_init_ok,
|
||||||
early_commands_syslog_id=self.app.early_commands_syslog_id,
|
echo_syslog_id=self.app.echo_syslog_id,
|
||||||
event_syslog_id=self.app.event_syslog_id,
|
event_syslog_id=self.app.event_syslog_id,
|
||||||
log_syslog_id=self.app.log_syslog_id)
|
log_syslog_id=self.app.log_syslog_id)
|
||||||
|
|
||||||
|
@ -149,8 +149,7 @@ class SubiquityServer(Application):
|
||||||
self.state_event = asyncio.Event()
|
self.state_event = asyncio.Event()
|
||||||
self.confirming_tty = ''
|
self.confirming_tty = ''
|
||||||
|
|
||||||
self.early_commands_syslog_id = 'subiquity_commands.{}'.format(
|
self.echo_syslog_id = 'subiquity_echo.{}'.format(os.getpid())
|
||||||
os.getpid())
|
|
||||||
self.event_syslog_id = 'subiquity_event.{}'.format(os.getpid())
|
self.event_syslog_id = 'subiquity_event.{}'.format(os.getpid())
|
||||||
self.log_syslog_id = 'subiquity_log.{}'.format(os.getpid())
|
self.log_syslog_id = 'subiquity_log.{}'.format(os.getpid())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue