Thursday, December 27, 2012

Introduction: Scripting your Brocade Fibre Channel switches

HOW-TO collect data from multiple brocade switches

Got tired as a SAN administrator after logging into all your Fibre Channel switches to perform just one configuration change? Well, I did and I decided to find a way to perform basic configuration tasks by script.
We all know how to remotely manage a Brocade fibre channel switch. If you have lots of time, you are using the WebTools. If you have only minutes left during a working day, you know almost all FabOS commands by heart, connecting to the switches using ssh.
On the top of my wishlist was the possibility to schedule an upload of the switch configuration. That’s why I started with this little project. At least the start was very easy. After spending several hours using ssh to connect to the switches the command to save the config was rapidly written down:
configupload -all -ftp 10.0.0.1,configupload,fcswitch01-today.txt
(For testing purposes the account configupload is configured without a password.)

That’s the beginning. Let’s now connect to the switch to execute this command. I choose to use Expect as a programming language. With this language it is very easy to respond on interactive commands, like snmpconfig. The idea is to build a framework, that can be used for all kinds of commands you can execute on a fibre channel switch. In Expect, you can connect to a Brocade switch using ssh with the command
spawn ssh -l admin fcswitch01
The nice part of Expect is in my opinion, you can describe what you will see. So what will happen, when setting up a ssh connection to fcswitch01 using the account admin? You will be asked to enter your password. So you can describe that as follows.
expect "*password: "
Now you can send your password within the script.
send "password\r"
The \r represents a hard return. If the password of the admin account is really “password”, you now will be logged on into the switch.
Again, you have to describe what the output of the ssh terminal, would be if you logged on by yourself. Afterwards, you can issue the command you want to execute. Finally you have to exit the session in a decent manner. This would be scripted as follows.
expect "*admin> "
send "configupload -all -ftp 10.0.0.1,configupload,fcswitch01-today.txt\r"
expect "*admin> "
send "exit\r"

At this point we have written a script that allows us to upload a switch configuration of a particular switch. Unfortunately a fibre channel SAN mostly consists of multiple switches. We don’t want to have one script per switch. We need to use some variables in the script and make the script more general. Besides that, I don’t think the presence of the account and the password in the script is a safe way.
To enhance the script, I usually use three text files. One is containing all the switches in the fabrics and the file is called switches.txt. For naming purposes I make sure name resolution is working for the switches. If customers don’t want to add them to DNS, I always edit the hosts file of the management server. A second file user.txt only contains the account used for login. In the third file password.txt the associated password is written.
The three files are opened read-only at the first three lines of the script:
set file [open ~/tools/switches.txt r]
set pass [open ~/tools/pass/password.txt r]
set account [open ~/tools/pass/user.txt r]

The user and password are put into a variable, so we can use that variable in the script. We use the command gets for it. gets reads one line of the text file.
gets $pass admpw
gets $account admin

Next to do, is to go to the file switches.txt and read one line after another and perform some actions to the switch. That is done in the following way.

while 1 {
if {[gets $file fcsw] == -1} break
commands
}
At the end I usually declare another variable in which the current date is set. I will use this date in the filename for the switch config.
set date [timestamp -format %Y%m%d]
When we combine al this programming, we will get the following script. I normally use this script every night to have a daily backup of all switch configurations.
set file [open ~/tools/switches.txt r]
set pass [open ~/tools/pass/password.txt r]
set account [open ~/tools/pass/user.txt r]
set date [timestamp -format %Y%m%d]
#--
gets $pass admpw
gets $account admin
#--
while 1 {
if {[gets $file fcsw] == -1} break
#--
spawn ssh -l $admin $fcsw
expect "*password: "
send "$admpw\r"
expect "*$admin> "
send "configupload -all -ftp 10.0.0.1,configupload,$fcsw-$date.txt\r"
expect "*$admin> "
send "exit\r"
}

The beauty of this script is maybe not the programming, but the reusability of it. Replace the command of the configupload with any other command you need to execute. This is a very fast way to make sure you have consistent configurations of all your switches. I will attach a script in which snmp settings are configured. You can also see how you can deal with interactive commands also with Expect.

Tuesday, December 11, 2012

HOW-TO: Qualcomm Gobi 2000 under linux


yum -y install gcc
cd /tmp
wget http://www.codon.org.uk/~mjg59/gobi_loader/download/gobi_loader-0.7.tar.gz
tar xvzf gobi_loader-0.7.tar.gz && cd gobi_loader-0.7
make && sudo make install
cp /lib/udev/rules.d/60-gobi.rules  /etc/udev/rules.d
/

Now you have to get the firmware images from the Lenovo website. This is a windows executable- get the latest and greatest directly from the Lenovo support page or here. You will have to extract the contents - either you have a Windows(R) machine running somewhere, or use wine for it...  yeah, I know...

The installer will extract the firmware files into %Program Files%\QUALCOMM\Images\Lenovo\.

Now you will see several directories named 0-12, and UMTS. According to the information found on this thinkwiki page, they break down as follows:

Dir Image Dir Image
0 Vodafone Image 1 Verizon Image
2 ATT Image 3 Sprint Image
4 T-Mobile Image 6 Generic UMTS Image
7 Telefonica Image 8 Telecom Italia Image
9 Orange Image 12 DoCoMo Image
UMTS Default Firmware

Now, use your imagination to get the best out of your WWAN - for me the UMTS ran fine on 5 not listed (south-, centralamerican and asian) operators, too - but that may vary. Obviously, should your operator be listed, choose the according directory and then substitute below's with your favourite directory "id" (e.g. 2 or 12 or UMTS or...):

http://www.thinkwiki.org/wiki/Qualcomm_Gobi_2000

how to activate GSM modem:

/lib/udev/gobi_loader -2000 /dev/ttyUSB0 /lib/firmware/gobi
 

How to use DiskSpd to simulate Veeam Backup & Replication disk actions

This HOW-TO contains information on how to use Microsoft© DiskSpd to simulate Veeam Backup & Replication disk actions to measure disk pe...