Automating Brocade FC Configuration (Part 2)

By | January 20, 2017

From the first article we looked at how to use the SSH Sessions Powershell module to log into a Linux server that will, via a script, log into a Brocade FC switch and get the zoning configuration.

As per the disclaimer in the first part, these articles have been assembled from my notes and memory and may not be 100% correct. I worked with FOS 6.x and so 7.x/later releases might not need this approach – I no longer have access to any Brocade FC switches to test 🙂

Getting the switch config via a function

As we’re going to need to get the config from two switches, we’ll write a powershell function that will get the config from one switch, so we have one call for each. The function is as follows:

So, let’s get the config:

Sanity Checking the Zone Configuration

Before changing the configuration we need to make sure anything we create does not already exist. Namely, we’ll be checking:

  • WWPNs of the server HBAs.
  • The name of the server zone.

So, we’ll then need to call this for each of the switch configs we got earlier. Our new script looks as follows:

Hopefully the above is quite straight forward – we get the config for the both switches and check that it is ok for the servername and for the HBA address. We store the result in a local variable, and when both checks are complete we will only be making changes to the FC switches if both configs reported good.

The final proxy script

Our final Linux proxy script will change the configuration on a single switches, and we will call it twice, once for each server. This would allow us to provide different variables for each switch, in case they have not been configured identically. The variables that we will pass, and their position for the script are below:

  1. Hostname of the filer.
  2. Username for the filer.
  3. Password for the filer.
  4. Server hostname
  5. WWPN for the HBA
  6. Name of the active configuration

Our full script will be:

cat << _END_ | sshpass -p ${1} ssh ${3} -tt -o StrictHostKeyChecking=no -l ${2}
alicreate ${4}_hba0, ${5}
zonecreate ${4}, “${4}_hba0;san_hba0;san_hba1”
cfgadd ${6}, ${4}
echo y|cfgenable ${6}
exit
_END_

This is how we would call it:

Powershell Configuration Script

When we put the above together we will aim to have some powershell that will:

  1. Get the config of each FC switch
  2. Check the config to ensure there will be no clashes or problems.
  3. Call the proxy script to update the config.

This would look like:

This uses the function “Get-BrocadeSwitchZoneConfig” at the beginning of this article, and most of the variables are configured in the script. For the sake of security you’ll want to remove these from being hardcoded and pass them in as parameters. I’ve left them as hardcoded to show what is required and where it is used.

This is available in a single file on my psscripts github repo.

Please let me know if anything is wrong or if this helped you !