10-11-2015 12:18 PM
I need to to get information out of the logical switches by way of a perl script, I am using the module "Perl::SSH2" and I am able to login to the switch but a setcontext command is not working. I there anybody that can help me with this? Thank you very much in advance.
10-11-2015 02:20 PM
Without your script I don't know why it's failing, but could you workaround the usage of setcontext by catching the required information via fosexec?
10-11-2015 10:30 PM
Thanks for the fast awnser Sebastian,
I tried the fosexec command like fosexec --fid 3 -cmd "portstatsshow 1/17" but this commands works only if you are logged into the logical switch.
With the Perl script (ssh2) I am able to log into the default switch, but I am not able to do a setcontext to an other logical switch. So I am open for ideas.
10-12-2015 02:41 AM
Finaly I noticed what was wrong on the command: There is a space to much between portstatsshow and the blade/port number and for the fosexec command that is a problem, directly on the logical switch the extra space is not a problem.
So we can use the fosexec command to run all kind of commands on the logical switches, but I am still open for ideas on the Perl/ssh2 script with the setcontext command.
01-05-2016 12:59 AM
thank you very much for the command hint. i was almost searching for a way to had stdin to use setcontext in my plink script until i noticed this option fosexec --fid 119 -cmd "porterrshow"
02-25-2016 07:51 AM - edited 02-25-2016 08:05 AM
I have the same issue with setcontext and Net:: SSH2, my perl script is as follows:
my $ssh2 = Net::SSH2->new(); # setup new connection.
my $channel = $ssh2->channel(); # create a ssh channel
my $sshrc = $channel->exec($cmd); # run command on the box
$channel->read($buf1, BUFLEN); # read the output and put it in $buf1
print "The output from the command: $cmd\n";
print "\$sshrc=$sshrc (1=OK 0=NOK)\n";
$channel->close(); # close the channel
$ssh2->disconnect(); # Close the connection
==> if I do this:
my $cmd = "\"setcontext 8\";switchname";
The output from the command: "setcontext 8";switchname
$sshrc=1 (1=OK 0=NOK)
==> So it gives me the name of the physical switch (FID 128), but NOT the name of mylogicalswitch8 (FID 8)
which I expected after the setcontext 8 command
==> and if I do this:
my $cmd = "fosexec --fid 8 -cmd \"echo y|cfgenable MyFabricX0\"";
The output from the command: fosexec --fid 8 -cmd "echo y|cfgenable MyFabricX0"
$sshrc=1 (1=OK 0=NOK)
"echo" on FID 8:
Failed to execute the command on logical switch with FID 8
==> So the fosexec doesn't work because the echo is not recognised.
How can I issue a cfgenable (including the required ‘yes’) against a logical switch in a Virtual Fabric ? because setcontext does not seem to arrive at the logical switch and fosexec does not accept the echo command.
Any help would be appreciated.