How to loop through excel form to create VLANS python

SOLVED
NetworkStuffGuy
Conversationalist

How to loop through excel form to create VLANS python

Hey peeps,

 

Im fairly new to scripting. I am working on a Python script to create VLANs based on the data in a excel form. 

I am not completely sure how to go about this. How would I go about pulling site names and then uploading the row of data relevant to that site name? 

You can see this is a broken script. "Net name" is referencing a range of cells in colum A which contain "Site name". This actually gives a tupel error. 

 

Create VLAN: Name, ID etc. Reference a single cell currently. (this was my test). But now i need it to reference the data in the row next to "site name" 

 

Id appreciate any direction here. Anything i should study or thought process etc. Still new, sorry for the painfully basic question. 

import meraki
import openpyxl
from openpyxl import Workbook, load_workbook

API_KEY = *****
wb = load_workbook('test-excel.xlsx')
ws = wb.active
dashboard = meraki.DashboardAPI(API_KEY)

myOrgs = dashboard.organizations.getOrganizations()
net_name = ws['A2':'A4']

for row in net_name:
net_name = row + 1

#gets and defines the ORG ID
for theOrg in myOrgs:
if theOrg['name'] == "ORG NAME":
my_org = int(theOrg['id'])


#Gets network ID from ORG and saves as variable named network_id
my_networks = dashboard.organizations.getOrganizationNetworks(my_org, total_pages='all')

for net in my_networks:
if net["name"] == net_name:
network_id = net["id"]

#Create a new VLAN from your input network

vlan = dashboard.appliance.createNetworkApplianceVlan(
network_id,
id=ws['B2'].value,
name=ws['C2'].value,
applianceIp=ws['D2'].value,
subnet=ws['E2'].value)

print("Done")

 

 

 

1 ACCEPTED SOLUTION
alemabrahao
Kind of a big deal
Kind of a big deal

Hi

 

Check this link https://github.com/CiscoDevNet/meraki-network-vlan-provision

I am not a Cisco Meraki employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.

View solution in original post

2 REPLIES 2
alemabrahao
Kind of a big deal
Kind of a big deal

Hi

 

Check this link https://github.com/CiscoDevNet/meraki-network-vlan-provision

I am not a Cisco Meraki employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.

certainly helps, thank you!

Get notified when there are additional replies to this discussion.