Fibre Channel (SAN)

Reply
Contributor
Posts: 39
Registered: ‎12-08-2011

scripting creation of aliases, zone, add zone to config, cfgsave

what is the best way to script the creation of new aliases, zone, and add the zone to a config and cfgsave?

 

I have tried the ssh way where I uploaded the ssh keys to both fabic switches but the cfgsave part keeps my bash script hanging waiting on the "yes" confirmation.

 

Could it be done with another way?

Contributor
Posts: 36
Registered: ‎05-12-2013

Re: scripting creation of aliases, zone, add zone to config, cfgsave

echo yes | cfgsave

Contributor
Posts: 39
Registered: ‎12-08-2011

Re: scripting creation of aliases, zone, add zone to config, cfgsave

it did not work

 

Do you want to save Defined zoning configuration only?  (yes, y, no, n): [no] Nothing changed: nothing to save, returning ...

 

 

#!/bin/bash
ssh admin@10.60.1.100 "alicreate "UCSTEST1_vHBA0","20:00:00:25:B5:11:0A:9E""
ssh admin@10.60.1.100 "zonecreate "zUCSTEST1_vHBA0", "UCSTEST1_vHBA0; CX380SPA1; CX380SPA3; CX380SPB0; CX380SPB2""

ssh admin@10.60.1.100 "echo yes | cfgsave"

External Moderator
Posts: 5,072
Registered: ‎02-23-2004

Re: scripting creation of aliases, zone, add zone to config, cfgsave

in order to save the config, "cfgsave" command, you have to do:

 

in example as below,

 

cfgcreate "config_name" \ "zone_name_1, zone_name_2, and_so_on_if_you_have_more_zone"

 

i've created in all the years a million of config with a stupid TXT editor.

 

finally you must set the config to active with "cfgenable" command.

 

 

TechHelp24
Contributor
Posts: 39
Registered: ‎12-08-2011

Re: scripting creation of aliases, zone, add zone to config, cfgsave

I already have a config.

 

I am just trying to 

 

1. create an alias with a connected wwn

2. create a zone and add the SPs and new alias to the new zone

3. add the new zone to an existing config

4. cfgsave

4. cfgenable

 

how do i do this?

Contributor
Posts: 39
Registered: ‎12-08-2011

Re: scripting creation of aliases, zone, add zone to config, cfgsave

any help here?/

Occasional Contributor
Posts: 8
Registered: ‎04-08-2008

Re: scripting creation of aliases, zone, add zone to config, cfgsave

Hi Tony,

 

I think your problem comes from multiple ssh sessions, you are disconnecting and reconnecting between each FOS commands, which means you are loosing alias and zoning just created before enabling.

 

You must perform all your commands within a single ssh session.

 

Here is an example made from a linux shell :

# echo "version;chassisname;echo y|cfgsave" | ssh your_switch_name -l admin

 

Pseudo-terminal will not be allocated because stdin is not a terminal.

Kernel: 2.6.14.2 

Fabric OS: v6.3.2d
Made on: Thu Jun 30 19:13:51 2011
Flash: Wed May 30 10:42:30 2012
BootProm: 4.6.6
SilkWorm48000
You are about to save the Defined zoning configuration. This
action will only save the changes on Defined configuration.
Any changes made on the Effective configuration will not
take effect until it is re-enabled.
Do you want to save Defined zoning configuration only? (yes, y, no, n): [no] Nothing changed: nothing to save, returning ...

 

or maybe more convenient to use within a shell script :

# cat << _END_ | ssh your_switch_name -l admin

version
chassisname
echo y|cfgsave
_END_

 

Pseudo-terminal will not be allocated because stdin is not a terminal.
Kernel: 2.6.14.2
Fabric OS: v6.3.2d
Made on: Thu Jun 30 19:13:51 2011
Flash: Wed May 30 10:42:30 2012
BootProm: 4.6.6
SilkWorm48000
You are about to save the Defined zoning configuration. This
action will only save the changes on Defined configuration.
Any changes made on the Effective configuration will not
take effect until it is re-enabled.
Do you want to save Defined zoning configuration only? (yes, y, no, n): [no] Nothing changed: nothing to save, returning ...

 

Contributor
Posts: 22
Registered: ‎02-24-2014

Re: scripting creation of aliases, zone, add zone to config, cfgsave

[ Edited ]

I was this close to writing a perl script that would do this... thank you.

 

edit: ok, I tried this and it doesn't really work.

 

$ cat << _END_ | ssh admin@myswitch
> setcontext 2
> portname
> _END_
Pseudo-terminal will not be allocated because stdin is not a terminal.
-rbash: setcontext: command not found

 edit 2:

 

cat << _END_ | ssh -tt admin@switch

That's what was needed. It works!

Occasional Visitor
Posts: 1
Registered: ‎12-04-2017

Re: scripting creation of aliases, zone, add zone to config, cfgsave

In a previous world I wrote a bash script that created all of the commands necessary to enable ports, create aliases, create zones, add members to zones, and activate zones. When I ran the script I had it display all of the commands on the console so that I could copy/paste them into a Change Control. Once approved my colleagues or myself would copy them from the Change Control directly into an ssh session on the switch. By not directly sending each command to the switch you at least have the opportunity for review before you break something.
Broadcom Moderator
Posts: 457
Registered: ‎03-29-2011

Re: scripting creation of aliases, zone, add zone to config, cfgsave

Hi,

 

with newer version, 7.4.1e, cfgsave, cfgenable, and cfgdisable  have "-f" option to not prompt for confirmation.

For those not on 7.4.1e and missing the "echo y|cfgsave" you can instead use on the switch

 

printf "y" | cfgsave

 

For some discussion see the following forum discussions

 

https://community.brocade.com/t5/Fibre-Channel-SAN/echo-command-no-longer-working/m-p/88842/highlight/true#M24563

 

 




If this provided you with a solution to this issue, please mark it with the button at the bottom "Accept as solution".


Any and all information provided by me is not reviewed, approved or endorsed by Brocade and is provided solely as a convenience for Brocade customers. All systems and all networks are different and unique. If you have a service affecting network problem, please open a TAC service request for service through Brocade, or through your OEM equipment provider. If this provided you with a solution to this issue, please mark it with the button at the bottom "Accept as solution"

Join the Community

Get quick and easy access to valuable resource designed to help you manage your Brocade Network.