From 328f3227c4d53260fe5443935e6a90b98ea90b90 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Fri, 22 Sep 2023 13:02:23 -0700 Subject: [PATCH] Add a command to clear the service database Add a pdo-shell command to clear the service database. When building the test databases, the default values for some of the groups persisted. Signed-off-by: Mic Bowman --- client/bin/pdo-create-service-groups.psh | 3 +++ client/pdo/client/commands/service_groups.py | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/client/bin/pdo-create-service-groups.psh b/client/bin/pdo-create-service-groups.psh index 5ad5bcba..48e0592e 100755 --- a/client/bin/pdo-create-service-groups.psh +++ b/client/bin/pdo-create-service-groups.psh @@ -25,6 +25,9 @@ fi echo create groups for ${service_host} in ${group_file} +## Remove any groups previously defined +service_groups clear + ## ----------------------------------------------------------------- ## Set the default set of eservices that this file knows ## about. There may be more that have been added to the diff --git a/client/pdo/client/commands/service_groups.py b/client/pdo/client/commands/service_groups.py index 4b859107..a230ed16 100644 --- a/client/pdo/client/commands/service_groups.py +++ b/client/pdo/client/commands/service_groups.py @@ -28,6 +28,7 @@ 'script_command_load', 'script_command_save', 'script_command_list', + 'script_command_clear', 'do_service_groups', 'load_commands', ] @@ -149,13 +150,28 @@ def invoke(cls, state, bindings, **kwargs) : return True +## ----------------------------------------------------------------- +## ----------------------------------------------------------------- +class script_command_clear(pscript.script_command_base) : + name = "clear" + help = "Clear all information in the service groups database" + + @classmethod + def invoke(cls, state, bindings, **kwargs) : + state.set(['Service', 'ProvisioningServiceGroups'], {}) + state.set(['Service', 'StorageServiceGroups'], {}) + state.set(['Service', 'EnclaveServiceGroups'], {}) + + return True + ## ----------------------------------------------------------------- ## Create the generic, shell independent version of the aggregate command ## ----------------------------------------------------------------- __subcommands__ = [ script_command_load, script_command_save, - script_command_list + script_command_list, + script_command_clear, ] do_service_groups = pscript.create_shell_command('service_groups', __subcommands__)