Skip to content

Commit

Permalink
Add set/noset commands (#634)
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Berendt <[email protected]>
  • Loading branch information
berendt authored Oct 26, 2023
1 parent e1949c7 commit 8b1b311
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
33 changes: 33 additions & 0 deletions osism/commands/noset.py
Original file line number Diff line number Diff line change
@@ -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,
)
33 changes: 33 additions & 0 deletions osism/commands/set.py
Original file line number Diff line number Diff line change
@@ -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,
)
5 changes: 5 additions & 0 deletions releasenotes/notes/command-set-noset-6c803c26c0ed5666.yaml
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8b1b311

Please sign in to comment.