-
Notifications
You must be signed in to change notification settings - Fork 0
/
aruba_ap_config
executable file
·131 lines (107 loc) · 3.46 KB
/
aruba_ap_config
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env python3
import sys
import time
import json
import argparse
import concurrent.futures
from netmiko import ConnectHandler
from constants import *
from aruba_query import *
requests.packages.urllib3.disable_warnings()
def print_ssid_config(current_config):
for ssid in current_config:
print(ssid + ":")
if "essid" in current_config[ssid].keys():
print(" ESSID: " + current_config[ssid]["essid"])
if "wpa-passphrase" in current_config[ssid].keys():
print(" PSK: " + current_config[ssid]["wpa-passphrase"])
def main():
# CLI parser for the command
parser = argparse.ArgumentParser(description="Aruba AP Config.")
parser.add_argument(
"--ap",
default="NONE",
help="AP to Modify, case sensitive",
)
parser.add_argument(
"--ap-ssid-add",
default="NONE",
help="SSID to add to AP, use vap",
)
parser.add_argument(
"--ap-ssid-remove",
default="NONE",
help="SSID to remove from AP, use vap",
)
parser.add_argument(
"--ap-current",
action="store_true",
default=False,
help="Unique SSIDs configured on AP",
)
parser.add_argument(
"--ssid",
default="NONE",
help="Add SSID Specific Config, use SSID profile",
)
parser.add_argument(
"--ssid-essid",
default="NONE",
help="Set ESSID for SSID Profile",
)
parser.add_argument(
"--ssid-psk",
default="NONE",
help="PSK for SSID Profile",
)
parser.add_argument(
"--ssid-current",
action="store_true",
default=False,
help="Current Config for SSID Profile",
)
parser.add_argument(
"--ssid-list",
action="store_true",
default=False,
help="SSID Profile and ESSID List",
)
parser.add_argument(
"--raw-config",
action="store_true",
default=False,
help="USE WITH CARE Input Raw config to push out to MCs",
)
# parse the arguments and print help if there are none
if len(sys.argv) == 1:
parser.print_help(sys.stderr)
sys.exit(1)
# read CLI into args
args = parser.parse_args()
query = ArubaQuery()
inventory = ArubaInventory()
arubapost = ArubaPost()
if args.raw_config:
print("Paste in the config and press ctrl-D to end input")
raw_config = sys.stdin.readlines()
confirm = input("Are you sure you want to deploy this to? (N/y) ")
if confirm.lower().startswith("y"):
print("Pushing config....")
with concurrent.futures.ThreadPoolExecutor() as executor:
for mc in MOBILITY_CONDUCTORS:
executor.submit(arubapost.aruba_set_raw_config, mc, PASSWORD, raw_config)
sys.exit()
else:
print("Quiting...")
sys.exit()
# make sure at least one of the options below is given
if args.ap or args.ssid or args.ssid_list:
config_class = ArubaConfig()
with concurrent.futures.ThreadPoolExecutor() as executor:
for mc in MOBILITY_CONDUCTORS:
executor.submit(query.get_aruba_api_token, mc, PASSWORD, inventory)
with concurrent.futures.ThreadPoolExecutor() as executor:
for mc in MOBILITY_CONDUCTORS:
executor.submit(arubapost.set_ap_config, mc, inventory, args, query, config_class)
if __name__ == "__main__":
main()