Skip to content

Commit 598290a

Browse files
texasaggie97amstewart
authored andcommitted
Change dry_run pattern to match other config modules. Do not bail early.
Signed-off-by: Mark Silva <mark.silva@emerson.com>
1 parent 01129e8 commit 598290a

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

nilrt_snac/_configs/_console_config.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ def __init__(self):
1414
def configure(self, args: argparse.Namespace) -> None:
1515
print("Deconfiguring console access...")
1616

17-
if args.dry_run:
18-
return
17+
if not args.dry_run:
18+
logger.debug("Disabling console access...")
19+
subprocess.run(
20+
["nirtcfg", "--set", "section=systemsettings,token=consoleout.enabled,value=False"],
21+
check=True,
22+
)
1923

20-
subprocess.run(
21-
["nirtcfg", "--set", "section=systemsettings,token=consoleout.enabled,value=False"],
22-
check=True,
23-
)
2424
opkg.remove("sysconfig-settings-console", force_depends=True)
2525

2626
def verify(self, args: argparse.Namespace) -> bool:

nilrt_snac/_configs/_graphical_config.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@
88

99

1010
class _GraphicalConfig(_BaseConfig):
11-
"""The graphical configuration for SNAC is to deconfigure the X11, embedded UI, and other components that are only useful when using the graphical UI.
12-
"""
11+
"""The graphical configuration for SNAC is to deconfigure the X11, embedded UI, and other components that are only useful when using the graphical UI."""
1312

1413
def configure(self, args: Namespace) -> None:
1514
print("Deconfiguring the graphical UI...")
16-
if args.dry_run:
17-
return
15+
if not args.dry_run:
16+
logger.debug("Disabling the embedded UI...")
17+
run(
18+
["nirtcfg", "--set", "section=systemsettings,token=ui.enabled,value=False"],
19+
check=True,
20+
)
1821

19-
run(["nirtcfg", "--set", "section=systemsettings,token=ui.enabled,value=False"], check=True)
2022
opkg.remove("packagegroup-ni-graphical", autoremove=True)
2123
opkg.remove("packagegroup-core-x11", autoremove=True)
2224

nilrt_snac/_configs/_syslog_ng_config.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,28 @@
99
class _SyslogConfig(_BaseConfig):
1010
def __init__(self):
1111
self._opkg_helper = opkg_helper
12-
self.syslog_conf_path = '/etc/syslog-ng/syslog-ng.conf'
12+
self.syslog_conf_path = "/etc/syslog-ng/syslog-ng.conf"
1313

1414
def configure(self, args: argparse.Namespace) -> None:
1515
print("Configuring syslog-ng...")
1616
dry_run: bool = args.dry_run
17-
if dry_run:
18-
return
1917

2018
# Check if syslog-ng is already installed
2119
if not self._opkg_helper.is_installed("syslog-ng"):
2220
self._opkg_helper.install("syslog-ng")
2321

24-
# Enable persistent storage
25-
_cmd('nirtcfg', '--set', 'section=SystemSettings,token=PersistentLogs.enabled,value="True"')
26-
27-
# Restart syslog-ng service
28-
_cmd('/etc/init.d/syslog', 'restart')
29-
22+
if not dry_run:
23+
# Enable persistent storage
24+
logger.debug("Enabling persistent log storage...")
25+
_cmd(
26+
"nirtcfg",
27+
"--set",
28+
'section=SystemSettings,token=PersistentLogs.enabled,value="True"',
29+
)
30+
31+
# Restart syslog-ng service
32+
logger.debug("Restarting syslog-ng service...")
33+
_cmd("/etc/init.d/syslog", "restart")
3034

3135
def verify(self, args: argparse.Namespace) -> bool:
3236
print("Verifying syslog-ng configuration...")

0 commit comments

Comments
 (0)