forked from hfakoor222/Palo_Alto_Scripting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConnectionHandler.py
38 lines (35 loc) · 1.46 KB
/
ConnectionHandler.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
import json
import netmiko
class Connection():
def __init__(self):
pass
def MultiConnect(connection_parameters = []):
while True:
def params():
connection_parameters.clear()
conn = input("Please enter a list of lists for of connection parameters: device_type, firewall IP addresses, username, pass" + "\n example: ['paloalto_panos', '10.1.x.x', 'username', 'password']")
res = json.loads(conn)
[connection_parameters.append(i) for i in res]
print(connection_parameters)
conn = params()
res = input("is the list formatted properly: Type Y|N")
if res.lower() == "y":
break
def SingleConnect(connection_parameters = []):
while True:
connection_parameters.clear()
conn = input("Please enter a single list of parameters for a single connection instance")
if conn == "":
continue
try:
conn = json.loads(conn)
except:
print("enter a properly fomatted list")
continue
print("Here is your list: " + str(conn))
res = input("is the list formatted properly: Type Y|N")
if res.lower() == "y":
connection_parameters.append(conn)
return connection_parameters
if len(connection_parameters) > 0:
break