Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^4: issue with code to save config on brocade swicth

by janasec (Sexton)
on Jul 28, 2015 at 12:37 UTC ( [id://1136602]=note: print w/replies, xml ) Need Help??


in reply to Re^3: issue with code to save config on brocade swicth
in thread issue with code to save config on brocade switch

it didnt work ....any other way i could try.

  • Comment on Re^4: issue with code to save config on brocade swicth

Replies are listed 'Best First'.
Re^5: issue with code to save config on brocade swicth
by Corion (Patriarch) on Jul 28, 2015 at 12:45 UTC

    You could help us help you better by providing the following information:

    1. Your current code, as relevant to the problem
    2. The input data you have
    3. The output data you get
    4. The errors that get shown

    This makes it much easier for us to help you than the description of "it didn't work" without the additional information.

      adding the exact script below

      #!/usr/bin/perl use strict; use warnings; use List::Util qw( first ); use Net::OpenSSH; use Log::Log4perl qw(:easy); Log::Log4perl->easy_init($INFO); use Expect; use 5.010; my $logger = get_logger(); my $username = 'admin'; my $password = 'password'; my $ip = '10.227.0.216'; $logger->info("performing ssh to the swicth"); my $ssh = Net::OpenSSH->new($ip,user=>"$username",password=>"$password +",master_opts=>[-o =>"StrictHostKeyChecking=no"]); $logger->info("listing zone on the switch $ip using zoneshow"); my($out,$err) = $ssh->capture2("zoneshow"); print "$out\n"; $logger->info("zoneshow successful"); $logger->info("listing zone on the switch $ip using nsshow"); ($out,$err) = $ssh->capture2("nsshow"); print "$out\n"; $logger->info("nsshow successful"); sleep 3; $logger->info("create zone on the switch $ip using zonecreate"); ($out,$err) = $ssh->capture2("zonecreate \"test5\", \" 20:01:00:11:0d: +34:57:00\" "); $ssh->error and die "remote find command failed: $!" . $ssh->error; print "$out\n"; $logger->info("zonecreate successful"); ##now add the zone to the config and save it ($out,$err) = $ssh->capture2("cfgadd \"FC_DVT\", \"test5\""); ($out,$err) = $ssh->capture2({stdin_data => 'yes'},"cfgsave"); ($out,$err) = $ssh->capture2({stdin_data => 'yes'},"cfgenable \"FC_DVT +\"");

      the output is below,it does not throw any error thats the problem,but it doest not perform the required stpes as well

      the output when script is run is below

      [root@localhost jana]# vi switchconfig.pl [root@localhost jana]# ./switchconfig.pl 2015/07/29 04:53:48 performing ssh to the swicth 2015/07/29 04:53:49 listing zone on the switch 10.227.0.216 using zone +show Defined configuration: cfg: FC_DVT MEZZI; MEZZI1; test1 zone: MEZZI mezzi1; mezzi2; sanblaze zone: MEZZI1 mezzi3; mezzi4; sanblaze zone: test1 20:00:00:11:0d:34:56:00 zone: vikash_enfield 10:00:00:00:c9:a1:95:aa; 10:00:00:00:c9:a1:95:ab; 20:00:00:11:0d:34:56:00 alias: mezzi1 10:00:00:00:c9:cd:cc:6c alias: mezzi2 10:00:00:00:c9:cd:cc:6d alias: mezzi3 10:00:00:90:fa:2e:dd:9f alias: mezzi4 10:00:00:90:fa:2e:dd:a0 alias: sanblaze 20:01:00:11:0d:34:57:00 Effective configuration: cfg: FC_DVT zone: MEZZI 10:00:00:00:c9:cd:cc:6c 10:00:00:00:c9:cd:cc:6d 20:01:00:11:0d:34:57:00 zone: MEZZI1 10:00:00:90:fa:2e:dd:9f 10:00:00:90:fa:2e:dd:a0 20:01:00:11:0d:34:57:00 zone: test1 20:00:00:11:0d:34:56:00 2015/07/29 04:53:50 zoneshow successful 2015/07/29 04:53:50 listing zone on the switch 10.227.0.216 using nssh +ow { Type Pid COS PortName NodeName +TTL(sec) N 010700; 3;50:0a:09:84:88:ed:66:d4;50:0a:09:80:88:ed:66:d4; +na FC4s: FCP [NETAPP LUN 7360] Fabric Port Name: 20:07:00:05:33:d4:06:4d Permanent Port Name: 50:0a:09:84:88:ed:66:d4 Port Index: 7 Share Area: No Device Shared in Other AD: No Redirect: No Partial: No LSAN: No N 010a00; 3;10:00:00:90:fa:2e:dd:9f;20:00:00:90:fa:2e:dd:9f; +na FC4s: IPFC FCP PortSymb: [34] "Emulex PPN-10:00:00:90:fa:2e:dd:9f" NodeSymb: [37] "Emulex 7101684 FV10.6.168.0 DV3.0.02 " Fabric Port Name: 20:0a:00:05:33:d4:06:4d Permanent Port Name: 10:00:00:90:fa:2e:dd:9f Port Index: 10 Share Area: No Device Shared in Other AD: No Redirect: No Partial: No LSAN: No N 010b00; 2,3;20:00:00:11:0d:34:56:00;20:00:00:11:0d:34:56:00; +na FC4s: FCP PortSymb: [22] "SANBlaze FC Port Targ0" Fabric Port Name: 20:0b:00:05:33:d4:06:4d Permanent Port Name: 20:00:00:11:0d:34:56:00 Port Index: 11 Share Area: No Device Shared in Other AD: No Redirect: No Partial: No LSAN: No N 010e00; 2,3;20:01:00:11:0d:34:57:00;20:01:00:11:0d:34:57:00; +na FC4s: FCP PortSymb: [22] "SANBlaze FC Port Targ0" Fabric Port Name: 20:0e:00:05:33:d4:06:4d Permanent Port Name: 20:01:00:11:0d:34:57:00 Port Index: 14 Share Area: No Device Shared in Other AD: No Redirect: No Partial: No LSAN: No The Local Name Server has 4 entries } 2015/07/29 04:53:51 nsshow successful 2015/07/29 04:53:54 create zone on the switch 10.227.0.216 using zonec +reate 2015/07/29 04:53:55 zonecreate successful

      when i do the cfgsave and cfgenable i also need to press 'y' or 'yes' for them to save on the switch,the problem is here i think

        When sending your stdin_data, you never send the carriage return.

        Also, you only ever print/check $out for content and not $err.

        I would look through the options that Net::OpenSSH offers for debugging and enable them so you can see the actual data that gets sent/received and determine from that where your script differs from the manual interaction.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1136602]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-26 03:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found