Skip to content

Commit 8b1b311

Browse files
authored
Add set/noset commands (#634)
Signed-off-by: Christian Berendt <[email protected]>
1 parent e1949c7 commit 8b1b311

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed

osism/commands/noset.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
from cliff.command import Command
4+
5+
from osism.tasks import ansible
6+
7+
8+
class NoMaintenance(Command):
9+
def get_parser(self, prog_name):
10+
parser = super(NoMaintenance, self).get_parser(prog_name)
11+
parser.add_argument(
12+
"host",
13+
nargs=1,
14+
type=str,
15+
help="Host that should no longer be set to maintenance",
16+
)
17+
return parser
18+
19+
def take_action(self, parsed_args):
20+
host = parsed_args.host[0]
21+
22+
arguments = [
23+
"-e status=False",
24+
"-l {host}",
25+
]
26+
27+
ansible.run.delay(
28+
"state",
29+
"maintenance",
30+
arguments,
31+
publish=False,
32+
locking=False,
33+
)

osism/commands/set.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
from cliff.command import Command
4+
5+
from osism.tasks import ansible
6+
7+
8+
class Maintenance(Command):
9+
def get_parser(self, prog_name):
10+
parser = super(Maintenance, self).get_parser(prog_name)
11+
parser.add_argument(
12+
"host",
13+
nargs=1,
14+
type=str,
15+
help="Host to be set to maintenance",
16+
)
17+
return parser
18+
19+
def take_action(self, parsed_args):
20+
host = parsed_args.host[0]
21+
22+
arguments = [
23+
"-e status=True",
24+
"-l {host}",
25+
]
26+
27+
ansible.run.delay(
28+
"state",
29+
"maintenance",
30+
arguments,
31+
publish=False,
32+
locking=False,
33+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
features:
3+
- |
4+
With the new commands set/noset it is possible to set certain properties of nodes.
5+
First of all, it will be possible to put a node into maintenance.

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ osism.commands:
7777
netbox sync = osism.commands.netbox:Sync
7878
netbox sync bifrost = osism.commands.netbox:Bifrost
7979
netbox sync ironic = osism.commands.netbox:Ironic
80+
noset maintenance = osism.commands.noset:NoMaintenance
8081
reconciler = osism.commands.reconciler:Run
8182
reconciler sync = osism.commands.reconciler:Sync
8283
service = osism.commands.service:Run
84+
set maintenance = osism.commands.set:Maintenance
8385
status = osism.commands.status:Run
8486
task list = osism.commands.get:Tasks
8587
task revoke = osism.commands.task:Revoke

0 commit comments

Comments
 (0)