cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2539
Views
3
Helpful
2
Replies

How to loop through excel form to create VLANS python

NetworkStuffGuy
Community Member

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

Accepted Solutions

aleabrahao
Meraki Community All-Star
Meraki Community All-Star

Hi

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

I am not a Cisco 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

aleabrahao
Meraki Community All-Star
Meraki Community All-Star

Hi

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

I am not a Cisco 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!