diff options
author | Ola Aunronning <olaa@yahooinc.com> | 2022-09-30 12:02:43 +0200 |
---|---|---|
committer | Ola Aunronning <olaa@yahooinc.com> | 2022-09-30 12:02:43 +0200 |
commit | b61811a48caf303321677c560010da9334d7054b (patch) | |
tree | 899e0c6290850fb6623ad73f93dc5c32dad0093b /node-admin | |
parent | e22ff8637d9f86cd56d9e9ff410b7d4b87bfe637 (diff) |
Get systemctl service property
Diffstat (limited to 'node-admin')
2 files changed, 12 insertions, 0 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/systemd/SystemCtl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/systemd/SystemCtl.java index 61090bbf252..da7af9c9c93 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/systemd/SystemCtl.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/systemd/SystemCtl.java @@ -88,6 +88,14 @@ public class SystemCtl { .map(CommandResult::getExitCode) == 0; } + public String getServiceProperty(TaskContext context, String unit, String property) { + return newCommandLine(context) + .add("systemctl", "show", "--property", property, "--value", unit + ".service") + .ignoreExitCode() + .execute() + .getOutput(); + } + private CommandLine newCommandLine(TaskContext context) { var commandLine = terminal.newCommandLine(context); if (useSudo) { diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/systemd/SystemCtlTester.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/systemd/SystemCtlTester.java index 9e0673a0b5b..396a4f9f51f 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/systemd/SystemCtlTester.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/systemd/SystemCtlTester.java @@ -45,6 +45,10 @@ public class SystemCtlTester extends SystemCtl { return this; } + public SystemCtlTester expectGetServiceProperty(String unit, String property, String output) { + expectCommand("systemctl show --property " + property + " --value " + unit + ".service 2>&1", 0, output); + return this; + } private void expectCommand(String command, int exitCode, String output) { terminal.expectCommand((useSudo() ? "sudo " : "") + command, exitCode, output); |