-
Notifications
You must be signed in to change notification settings - Fork 0
/
add.py
43 lines (34 loc) · 1.21 KB
/
add.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
"""
Add Command: Used to add --discovered-devices or a --single-device to Netbox
Usage:
python main.py add --help
python main.py add --discovered-devices
python main.py add --single-device chi-leaf-04
python main.py add -d
python main.py add -s chi-leaf-04
"""
from typer import Option, Typer, echo
app = Typer(short_help="add --discovered-devices or a --single-device")
@app.callback("add", invoke_without_command=True)
def add_options(
discovered_devices: bool = Option(
False,
"--discovered-devices",
"-d",
help="Discovered Devices into netbox",
),
single_device: str = Option(
None, "--single-device", "-s", help='Choose a scope: "subnet" OR "devices"'
),
) -> None:
"""Add Discovered Devices to Netbox or add a static device"""
if discovered_devices and single_device:
echo(f'All Discovered devices and: "{single_device}" will be added to Netbox')
exit()
if discovered_devices:
echo("All Discovered devices will be added to Netbox")
if single_device:
echo(f'The device: "{single_device}" will be added to Netbox')
if __name__ == "__main__":
app()