Thanks everyone for your help! the change to the "network" from networkid as a variable definitely resolved the issue I was looking for. Thanks @BrechtSchamp for that.
To note in regards to my messy coding, 1, I am a true script-kiddie at this point in time so my coding is rough to say the least 😀 and 2, This was a total test setup so clean code was not necessarily on top of mind.
The goal of this script was to deploy a new VLAN to 27 locations, create a new SSID, setup that SSID, and add features like VLAN tagging and Layer 2 Isolation. Creating a list of networks was really helpful, especially for future scripts so I will definitely use it going forward.
I did discover though that my script change based on how the network is setup. An example would be an MX65w vs an MX with a MR positions the SSID network differently. Because of these differences, I changed my direction from list to input.
So far (its still as work in progress), I have the script ask what network ID to add, then it creates a vlan for that network. It then asks if the network has an access point. If so, it will run one script, if no, it will run another. Then it will ask if I want to do this again to a different network and the process repeats unless I say no.
Here it is:
from meraki import meraki
from pprint import pprint
import tkinter
#Organization Details
apikey = "<CustomAPIKey"
orgid = "<CustomOrgID"
#Network Details
mxip = "192.168.69.1"
name = "IoT_Network"
subnet = "192.0.0.0/24"
vlanid = "100"
ap_ssidnum = "3"
noap_ssidnum = "4"
enabled = "True"
authmode = "psk"
encryptionmode = "wpa"
psk = "<customPSK>"
#Create IoT VLAN and Add SSID Mac_IoT to unassigned 3 or 4
while True:
#Create and Update VLAN for network
NameNetwork = input('Enter Network ID:')
networkSSIDs4 = meraki.getssiddetail(apikey, NameNetwork, ap_ssidnum, suppressprint=False)
networkSSIDs5 = meraki.getssiddetail(apikey, NameNetwork, noap_ssidnum, suppressprint=False)
print({NameNetwork})
createVlan = meraki.addvlan(apikey,NameNetwork,vlanid,name,subnet,mxip,suppressprint=False)
updateVlan = meraki.updatevlan(apikey,NameNetwork,vlanid, name=None,subnet=None, mxip=None, fixedipassignments=None, reservedipranges=None, vpnnatsubnet=None, dnsnameservers="opendns", suppressprint=None,)
#If network has Access Point or Not
APQuestion = input('Does this network have an access point [y]/n:')
if APQuestion.lower() == 'y':
updateSSID = meraki.updatessid(apikey, NameNetwork, ap_ssidnum, name, enabled, authmode, encryptionmode, psk, suppressprint=False)
pprint(networkSSIDs4)
elif APQuestion.lower() == 'n':
updateSSID = meraki.updatessid(apikey, NameNetwork, noap_ssidnum, name, enabled, authmode, encryptionmode, psk, suppressprint=False)
pprint(networkSSIDs5)
restart = input("Do you want to make changes to another network [y]/n:")
if restart.lower() == 'n':
pprint('Thank you for using the network updater')
break
Let me know what you guys think and if I can do anything to make it simpler. My goal is to wrap it as an .exe as well (hence the tkinter, even though it is not in use.)
CMNO, CCNA R+S