diff --git a/osism/commands/noset.py b/osism/commands/noset.py new file mode 100644 index 00000000..bb9f5495 --- /dev/null +++ b/osism/commands/noset.py @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 + +from cliff.command import Command + +from osism.tasks import ansible + + +class NoMaintenance(Command): + def get_parser(self, prog_name): + parser = super(NoMaintenance, self).get_parser(prog_name) + parser.add_argument( + "host", + nargs=1, + type=str, + help="Host that should no longer be set to maintenance", + ) + return parser + + def take_action(self, parsed_args): + host = parsed_args.host[0] + + arguments = [ + "-e status=False", + "-l {host}", + ] + + ansible.run.delay( + "state", + "maintenance", + arguments, + publish=False, + locking=False, + ) diff --git a/osism/commands/set.py b/osism/commands/set.py new file mode 100644 index 00000000..2d76488a --- /dev/null +++ b/osism/commands/set.py @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 + +from cliff.command import Command + +from osism.tasks import ansible + + +class Maintenance(Command): + def get_parser(self, prog_name): + parser = super(Maintenance, self).get_parser(prog_name) + parser.add_argument( + "host", + nargs=1, + type=str, + help="Host to be set to maintenance", + ) + return parser + + def take_action(self, parsed_args): + host = parsed_args.host[0] + + arguments = [ + "-e status=True", + "-l {host}", + ] + + ansible.run.delay( + "state", + "maintenance", + arguments, + publish=False, + locking=False, + ) diff --git a/releasenotes/notes/command-set-noset-6c803c26c0ed5666.yaml b/releasenotes/notes/command-set-noset-6c803c26c0ed5666.yaml new file mode 100644 index 00000000..f72efce1 --- /dev/null +++ b/releasenotes/notes/command-set-noset-6c803c26c0ed5666.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + With the new commands set/noset it is possible to set certain properties of nodes. + First of all, it will be possible to put a node into maintenance. diff --git a/setup.cfg b/setup.cfg index 8e9d778d..a5b8da0f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -77,9 +77,11 @@ osism.commands: netbox sync = osism.commands.netbox:Sync netbox sync bifrost = osism.commands.netbox:Bifrost netbox sync ironic = osism.commands.netbox:Ironic + noset maintenance = osism.commands.noset:NoMaintenance reconciler = osism.commands.reconciler:Run reconciler sync = osism.commands.reconciler:Sync service = osism.commands.service:Run + set maintenance = osism.commands.set:Maintenance status = osism.commands.status:Run task list = osism.commands.get:Tasks task revoke = osism.commands.task:Revoke