cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
19111
Views
6
Helpful
9
Replies

Cisco Switch Configuration Generator

aoyawale
Level 1
Level 1

Good day,

 

I'm trying to create a scripts to create configuration files for 500 switches consisting of C2960, C3850 & C3560 models. I have created 3 templates text files with for each model and an excel spreadsheet or MS Access DB containing specific information such as Switch model, hostnames, IP addresses, native vlans, etc for all the switches.

 

I'm trying create a script in VB or Powershell that would generate the configuration files for all 500 switches using the relevant template based on switch model and corresponding data from the Excel spreadsheet/Access Database?

 

I'm not good at programming and would appreciate any suggestion from the forum.

 

Thanks in advance.

2 Accepted Solutions

Accepted Solutions

Ben Walters
Level 3
Level 3

Do you have the beginnings of a script yet? I could help further if necessary but I will give you some general pointers first. I prefer powershell scripting so my logic below is based on how I like to create scripts using powershell.

 

I would start by scrubbing each of the 3 config files to replace any variable with a unique identifier so for example the hostname would be *HOSTNAME* IP address would be *IPADDRESS* and so on until you have 3 generic configs for your devices, which it sounds like you already have.

 

From there I would use an excel spreadsheet for each of your devices(1 device per row not column) and convert it to a csv when all the information is filled out in it. Then you should be able to easily parse the data and replace those variables in the generic config file for each switch and spit the data back out as a separate text file.

 

 

Here is a high level of how I would get this done.

 

Read the device information document and convert to a variable

 

For each line in the information document split using the comma as a delimiter (from csv file) to be able to grab each part of the config information and convert to a variable

 

Check variables to find out which model of switch is being configured and read/convert the corresponding generic config to a variable

 

Replace the variables in the corresponding config template with the correct values from the device information file

 

Output to a txt file using the hostname as the file name

 

If you have some scripting experience this should at least get you started.

View solution in original post

Leo Laohoo
Hall of Fame
Hall of Fame

You're re-inventing the wheel. 

There is a feature called Zero-Touch SmartInstall which can do all what you've describe.  

View solution in original post

9 Replies 9

Ben Walters
Level 3
Level 3

Do you have the beginnings of a script yet? I could help further if necessary but I will give you some general pointers first. I prefer powershell scripting so my logic below is based on how I like to create scripts using powershell.

 

I would start by scrubbing each of the 3 config files to replace any variable with a unique identifier so for example the hostname would be *HOSTNAME* IP address would be *IPADDRESS* and so on until you have 3 generic configs for your devices, which it sounds like you already have.

 

From there I would use an excel spreadsheet for each of your devices(1 device per row not column) and convert it to a csv when all the information is filled out in it. Then you should be able to easily parse the data and replace those variables in the generic config file for each switch and spit the data back out as a separate text file.

 

 

Here is a high level of how I would get this done.

 

Read the device information document and convert to a variable

 

For each line in the information document split using the comma as a delimiter (from csv file) to be able to grab each part of the config information and convert to a variable

 

Check variables to find out which model of switch is being configured and read/convert the corresponding generic config to a variable

 

Replace the variables in the corresponding config template with the correct values from the device information file

 

Output to a txt file using the hostname as the file name

 

If you have some scripting experience this should at least get you started.

Hi Ben,

Thank you for taking the time to reply and offer suggestions. This is exactly I'm trying to achieve but I have very limited scripting experience. Although I'd try out the Zero-Touch SmartInstall suggested Leo Laohoo, I would also spend sometime to learn scripting to close an obvious knowledge gap that might come in handy in future.

Thanks again for your help.

Leo Laohoo
Hall of Fame
Hall of Fame

You're re-inventing the wheel. 

There is a feature called Zero-Touch SmartInstall which can do all what you've describe.  

Hi Leo,

Thanks for your suggestion, I would give the Zero-Touch SmartInstall a try as well.

Appreciate your time and assistance.

alagu.raja
Level 1
Level 1

Hi,

I had the same issue. So i have created one Excel based file. Attached.

Instructions: (based on Cisco 2960 Layer-2 switch)

1. Before start doing,Please keep a copy of the original file since the macros are involved.

2. It has three sections

Value: This is where all your variables going in like hostname, ip address etc

Template: This is your base config file along with variables configured.

3. This very first tab- you will have to fill it manually. If you want to 10 switch configuration then you will have to fill 10 rows with information.

4. Once you filled the information in "Generate Config" Tab, click the "Generate" and then all the config will created in seperate excel sheet within the same workbook.

5. The "Export function" is currently not working correctly- But you can export from the excel sheet itself to PDF or text file.

6. The "clear" button Clears - the Contents on that "Generate Configs" Tab

7. The "list Header" will list load the variables from the "value" tab.

8. You can add more variables in the "Value" tab.

 

This we can use for any model switch. All we need is a Base Template for that model.

This needs lot of improvements. But i think deploying switches like 2960 or any layer-2 switch in a large amount - This is pretty easy tool without any cost!

Please let me know your comments!

Raja, this is great!! it will save me a tons of time. Thanks!
Is there a way to to scale this up a bit and be able to call on different variables and template so I can generate configuration for different device type in same workbook? for example be able to generate the switch config and then go to another tab (or a button) and call on different variable and template for a router or a different type of switch?

Alagu.

 

How can I modify the template so that i can can extend the length of the hostname [HOSTNAME] variable to more than 31 characters?  Where are the limits set to the length of each variable?  Thanks!

Hi, 

 

Please read my original post. In the templete you can modify it in the hostname portion. 

Alagu.

 

I did read your post and am using your template.  What I am saying is that there is a limit to the length data contained within each variable.  I am trying to generate a configuration with a hostname variable that is longer than 31 characters.  When executing the generate macro, it errors out unless the length of data in the [HOSTNAME] defined variable is 31 or less characters.  It may be a limit on the variable length within your VB script.  Please advise.  Thank you so much in advance.