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: 33
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: 4,875
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!

Join the Community

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