add 2 libs, main.py not done yet
This commit is contained in:
21
main.py
21
main.py
@ -1,5 +1,5 @@
|
||||
import argparse, requests, json, ipaddress, re
|
||||
from netmiko import ConnectHandler
|
||||
import argparse
|
||||
import switchlib, tenantosapi
|
||||
|
||||
### Define API
|
||||
|
||||
@ -9,7 +9,7 @@ ACTION_TAG:str = ""
|
||||
VRF:str = ""
|
||||
|
||||
###
|
||||
|
||||
'''
|
||||
# Header
|
||||
|
||||
header = {
|
||||
@ -67,6 +67,8 @@ def get_cidr(subnet_id:int):
|
||||
data = response.json()
|
||||
return data["result"]["cidr"]
|
||||
|
||||
'''
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
# Define arguments
|
||||
@ -75,10 +77,16 @@ if __name__ == "__main__":
|
||||
)
|
||||
parser.add_argument("--action", type=str, required=True)
|
||||
parser.add_argument("--server", type=int, required=True)
|
||||
parser.add_argument("--subnet", type=int, required=True)
|
||||
parser.add_argument("--ip", type=str, required=True)
|
||||
# parser.add_argument("--subnet", type=int, required=True)
|
||||
# parser.add_argument("--ip", type=str, required=True)
|
||||
args = parser.parse_args()
|
||||
|
||||
server_info = tenantosapi.APIClient(TENANTOS, AUTH_KEY, args.server).get_all_info()
|
||||
|
||||
if args.acttion == "add":
|
||||
|
||||
|
||||
'''
|
||||
# Process
|
||||
process = check_tag(args.server)
|
||||
if process:
|
||||
@ -132,4 +140,5 @@ if __name__ == "__main__":
|
||||
ptp = ipaddress.ip_network(f'{re.findall(r'inet6\s+([\da-f:]+)', show_output)}/127')[1]
|
||||
config_command = [ f'delete routing-instances {VRF} routing-options rib {VRF}.inet6.0 static route {ip}/{cidr} next-hop {ptp}' ]
|
||||
switch_connect.send_config_set(config_command)
|
||||
switch_connect.disconnect()
|
||||
switch_connect.disconnect()
|
||||
'''
|
||||
Reference in New Issue
Block a user