diff --git a/xCAT-client/bin/wvid b/xCAT-client/bin/wvid new file mode 100755 index 000000000..5a8d0f469 --- /dev/null +++ b/xCAT-client/bin/wvid @@ -0,0 +1,52 @@ +#!/usr/bin/env perl +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html + +BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; } +use lib "$::XCATROOT/lib/perl"; +use Cwd; +#use IO::Socket::SSL; +#use IO::Socket::INET; +my %rvidhash; +my $xcatroot = $ENV{'XCATROOT'}; +unless ($xcatroot) { + $xcatroot = "/opt/xcat" +} +use File::Basename; +#use Data::Dumper; +use xCAT::Client; +use Data::Dumper; +sub process_response { + my $resp = shift; + foreach my $rst (\@{$resp->{node}}) { + foreach my $rsp (@$rst) { + print Dumper($rsp); + $rvidhash{$rsp->{name}->[0]}->{$rsp->{data}->[0]->{desc}->[0]} = $rsp->{data}->[0]->{contents}->[0]; + } + } +} + +my $cmdref; +$cmdref->{command}->[0] = 'getrvidparms'; + +# Consider the 1st non-hyphen arg to be the noderange. All others (before and after) go on the arg list. +my $arg=shift(@ARGV); +while ($arg =~ /^-/) { + push (@{$cmdref->{arg}}, $arg); + $arg=shift(@ARGV); +} +if ($arg ne "NO_NODE_RANGE") { + $cmdref->{noderange}->[0]=$arg; +} +push (@{$cmdref->{arg}}, @ARGV); + +xCAT::Client::submit_request($cmdref,\&process_response); +print Dumper(\%rvidhash); +my %CLEANENV=%ENV; +foreach my $node (keys %rvidhash) { + %ENV=%CLEANENV; + foreach my $var (keys %{$rvidhash{$node}}) { + $ENV{"rvid_$var"}=$rvidhash{$node}->{$var}; + } + system("$xcatroot/share/xcat/rvid/rvid.".$ENV{"rvid_method"}." &"); +} +exit $xCAT::Client::EXITCODE; diff --git a/xCAT-client/share/xcat/rvid/rvid.blade b/xCAT-client/share/xcat/rvid/rvid.blade new file mode 100755 index 000000000..f7ea692e4 --- /dev/null +++ b/xCAT-client/share/xcat/rvid/rvid.blade @@ -0,0 +1,8 @@ +#!/bin/sh +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html +if [ ! -f /tmp/xcat/$rvid_server.remotekvm.jar ]; then + wget -O /tmp/xcat/$rvid_server.remotekvm.jar http://$rvid_server/private/remotekvm.jar +fi + +java -jar /tmp/remotekvm.jar -s $rvid_server -r $rvid_authtoken -b $rvid_slot >& /dev/null +rm /tmp/xcat/rvid_server.remotekvm.jar diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index 6cb699d01..aa7ddf2fc 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -16,10 +16,13 @@ use SNMP; use xCAT::GlobalDef; use xCAT_monitoring::monitorctrl; use strict; +use LWP; #use warnings; my %mm_comm_pids; +#a 'browser' for http actions +my $browser; use XML::Simple; if ($^O =~ /^linux/i) { $XML::Simple::PREFERRED_PARSER='XML::Parser'; @@ -41,6 +44,7 @@ sub handled_commands { rscan => 'nodehm:mgt', rpower => 'nodehm:power,mgt', getbladecons => 'blade', + getrvidparms => 'nodehm:mgt', rvitals => 'nodehm:mgt', rinv => 'nodehm:mgt', rbeacon => 'nodehm:mgt', @@ -1761,6 +1765,39 @@ sub build_depend { return( [\%dp,\%mpa_hash] ); } +sub httplogin { + #TODO: Checked for failed login here. + my $mpa = shift; + my $user = shift; + my $pass = shift; + my $url="http://$mpa/shared/userlogin.php"; + $browser = LWP::UserAgent->new; + $browser->cookie_jar({}); + my $response = $browser->post($url,{userid=>$user,password=>$pass,login=>"Log In"}); + $response = $browser->post("http://$mpa/shared/welcome.php",{timeout=>1,save=>""}); + $response = $browser->post("http://$mpa/shared/welcomeright.php",{timeout=>1,save=>""}); +} +sub get_kvm_params { + my $mpa = shift; + my $response = $browser->get("http://$mpa/private/vnc_only.php"); + my $html = $response->{_content}; + my $destip; + my $rbs; + foreach (split /\n/,$html) { + if (/{$mpa}->{username}; + my $pass = $mpahash->{$mpa}->{password}; + httplogin($mpa,$user,$pass); + (my $target, my $authtoken) = get_kvm_params($mpa); + #an http logoff would invalidate the KVM token, so we can't do it here + #For the instant in time, banking on the http session timeout to cleanup for us + #It may be possible to provide the session id to client so it can logoff when done, but + #that would give full AMM access to the KVM client + foreach $node (sort (keys %{$mpahash->{$mpa}->{nodes}})) { + my $slot = $mpahash->{$mpa}->{nodes}->{$node}; + my @output = (); + push(@output,"method:blade"); + push(@output,"server:$target"); + push(@output,"authtoken:$authtoken"); + push(@output,"slot:$slot"); + my %outh; + $outh{node}->[0]->{name}=[$node]; + $outh{node}->[0]->{data}=[]; + foreach (@output) { + (my $tag, my $text)=split /:/,$_,2; + push (@{$outh{node}->[0]->{data}},{desc=>[$tag],contents=>[$text]}); + print $out freeze([\%outh]); + print $out "\nENDOFFREEZE6sK4ci\n"; + yield; + waitforack($out); + %outh=(); + $outh{node}->[0]->{name}=[$node]; + $outh{node}->[0]->{data}=[]; + } + + } + return; + } # Handle telnet commands before SNMP if ($command eq "rspconfig") { foreach $node (sort (keys %{$mpahash->{$mpa}->{nodes}})) { diff --git a/xCAT-server/lib/xcat/plugins/tabutils.pm b/xCAT-server/lib/xcat/plugins/tabutils.pm index 288d7585b..91cd61e61 100644 --- a/xCAT-server/lib/xcat/plugins/tabutils.pm +++ b/xCAT-server/lib/xcat/plugins/tabutils.pm @@ -642,6 +642,9 @@ sub nodech #So before, table.column==value meant set to =value, now it would be matching value #the new way would be table.column=@=value to be unambiguous #now a value like '@hi' would be set with table.column=@@hi + if ($value eq '') { #If blank, force a null entry to override group settings + $value = '|^.*$||'; + } my $op = '='; if ($temp =~ /,$/) {