UPDATED AND ADDED ENV FOR USER/PASS

This commit is contained in:
Andrew Keuhs 2024-02-16 00:39:40 +00:00
parent 5798adb14e
commit a1461e66ce
2 changed files with 15 additions and 6 deletions

1
.gitignore vendored
View File

@ -48,3 +48,4 @@ Thumbs.db
*.mov
*.wmv
.env

View File

@ -4,28 +4,35 @@
Script to sync arista vlan from a primary to secondary switches
'''
import os
import re
import paramiko
import time
# environment stuff
from dotenv import load_dotenv
from pathlib import Path # python3 only
env_path = Path('.') / '.env'
load_dotenv(dotenv_path=env_path)
# Define master switch details
MASTER_SWITCH = {
"ip": "23.169.120.2",
"username": "sbutler",
"password": "tori1806"
"username": os.getenv("SSHUSER"),
"password": os.getenv("SSHPASS")
}
# Define list of switches to sync with (with parameters)
SWITCHES = [
{
"ip": "23.169.120.3",
"username": "sbutler",
"password": "tori1806"
"username": os.getenv("SSHUSER"),
"password": os.getenv("SSHPASS")
},
{
"ip": "23.169.120.4",
"username": "sbutler",
"password": "tori1806"
"username": os.getenv("SSHUSER"),
"password": os.getenv("SSHPASS")
},
]
@ -34,6 +41,7 @@ SWITCHES = [
PROTECTED_VLANS = ("1")
def sync_vlans(master_switch, switch):
# Establish SSH connection to master switch
master_client = paramiko.SSHClient()
master_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())