From 0d06a8f546f3c249522511e9d81efd83d8cb9948 Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Sat, 28 Oct 2023 21:59:54 +0200 Subject: [PATCH] Add set/noset bootstrap command (#648) Closes osism/issues#616 Signed-off-by: Christian Berendt --- osism/commands/noset.py | 28 +++++++++++++++++++ osism/commands/set.py | 28 +++++++++++++++++++ ...d-set-noset-boostrap-8ae8277a4ce31186.yaml | 5 ++++ setup.cfg | 2 ++ 4 files changed, 63 insertions(+) create mode 100644 releasenotes/notes/command-set-noset-boostrap-8ae8277a4ce31186.yaml diff --git a/osism/commands/noset.py b/osism/commands/noset.py index 80a30e4c..f2ab38e8 100644 --- a/osism/commands/noset.py +++ b/osism/commands/noset.py @@ -32,3 +32,31 @@ def take_action(self, parsed_args): "state-maintenance", arguments, ) + + +class NoBootstrap(Command): + def get_parser(self, prog_name): + parser = super(NoBootstrap, self).get_parser(prog_name) + parser.add_argument( + "host", + nargs=1, + type=str, + help="Host that should no longer be set to bootstrapped", + ) + return parser + + def take_action(self, parsed_args): + host = parsed_args.host[0] + + logger.info(f"Set not bootstrapped state on host {host}") + + arguments = [ + "-e status=False", + f"-l {host}", + ] + + ansible.run.delay( + "generic", + "state-bootstrap", + arguments, + ) diff --git a/osism/commands/set.py b/osism/commands/set.py index f9b78bf4..1d5819d7 100644 --- a/osism/commands/set.py +++ b/osism/commands/set.py @@ -32,3 +32,31 @@ def take_action(self, parsed_args): "state-maintenance", arguments, ) + + +class Bootstrap(Command): + def get_parser(self, prog_name): + parser = super(Bootstrap, self).get_parser(prog_name) + parser.add_argument( + "host", + nargs=1, + type=str, + help="Host to be set to bootstrapped", + ) + return parser + + def take_action(self, parsed_args): + host = parsed_args.host[0] + + logger.info(f"Set bootstraped state on host {host}") + + arguments = [ + "-e status=True", + f"-l {host}", + ] + + ansible.run.delay( + "generic", + "state-bootstrap", + arguments, + ) diff --git a/releasenotes/notes/command-set-noset-boostrap-8ae8277a4ce31186.yaml b/releasenotes/notes/command-set-noset-boostrap-8ae8277a4ce31186.yaml new file mode 100644 index 00000000..01aaf35a --- /dev/null +++ b/releasenotes/notes/command-set-noset-boostrap-8ae8277a4ce31186.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + With the new commands set/noset bootstrap it is possible to set if + a node is bootstrapped or not. diff --git a/setup.cfg b/setup.cfg index a5b8da0f..f9113760 100644 --- a/setup.cfg +++ b/setup.cfg @@ -77,10 +77,12 @@ osism.commands: netbox sync = osism.commands.netbox:Sync netbox sync bifrost = osism.commands.netbox:Bifrost netbox sync ironic = osism.commands.netbox:Ironic + noset bootstrap = osism.commands.noset:NoBootstrap noset maintenance = osism.commands.noset:NoMaintenance reconciler = osism.commands.reconciler:Run reconciler sync = osism.commands.reconciler:Sync service = osism.commands.service:Run + set bootstrap = osism.commands.set:Bootstrap set maintenance = osism.commands.set:Maintenance status = osism.commands.status:Run task list = osism.commands.get:Tasks