-
Notifications
You must be signed in to change notification settings - Fork 15
/
site_conf_psk.py
53 lines (43 loc) · 1.34 KB
/
site_conf_psk.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
44
45
46
47
48
49
50
51
52
53
'''
Written by Thomas Munzer ([email protected])
Github repository: https://github.com/tmunzer/Mist_library/
'''
#### IMPORTS #####
import logging
import sys
MISTAPI_MIN_VERSION = "0.44.1"
try:
import mistapi
from mistapi.__logger import console
except:
print("""
Critical:
\"mistapi\" package is missing. Please use the pip command to install it.
# Linux/macOS
python3 -m pip install mistapi
# Windows
py -m pip install mistapi
""")
sys.exit(2)
#### PARAMETERS #####
PSK = {"name":'myUser', "passphrase":'myBadPassword', "ssid":'mySSID', "usage":'multi'}
LOG_FILE = "./sites_scripts.log"
ENV_FILE = "./.env"
#### LOGS ####
LOGGER = logging.getLogger(__name__)
#### FUNCTIONS #####
def start(apisession):
site_id = mistapi.cli.select_site(apisession, allow_many=False)
mistapi.api.v1.sites.psks.createSitePsk(apisession, site_id, PSK)
response = mistapi.api.v1.sites.psks.listSitePsks(apisession, site_id)
psks = mistapi.get_all(apisession, response)
mistapi.cli.pretty_print(psks)
##### ENTRY POINT ####
if __name__ == "__main__":
#### LOGS ####
logging.basicConfig(filename=LOG_FILE, filemode='w')
LOGGER.setLevel(logging.DEBUG)
### START ###
APISESSION = mistapi.APISession(env_file=ENV_FILE)
APISESSION.login()
start(APISESSION)