-Add rvid for AMM (BPET46C tested)
-Have nodech implement explicit blank override of group level attributes git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2532 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		
							
								
								
									
										52
									
								
								xCAT-client/bin/wvid
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										52
									
								
								xCAT-client/bin/wvid
									
									
									
									
									
										Executable file
									
								
							| @@ -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; | ||||
							
								
								
									
										8
									
								
								xCAT-client/share/xcat/rvid/rvid.blade
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										8
									
								
								xCAT-client/share/xcat/rvid/rvid.blade
									
									
									
									
									
										Executable file
									
								
							| @@ -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 | ||||
| @@ -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 (/<param\s+name\s*=\s*"([^"]*)"\s+value\s*=\s*"([^"]*)"/) { | ||||
|            if ($1 eq 'ip') { | ||||
|                $destip=$2; | ||||
|            } elsif ($1 eq 'rbs') { | ||||
|                 $rbs = $2; | ||||
|            } | ||||
|         } | ||||
|     } | ||||
|     return ($destip,$rbs); | ||||
| } | ||||
|         | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| sub getbladecons { | ||||
|    my $noderange = shift; | ||||
| @@ -2594,6 +2631,41 @@ sub dompa { | ||||
|   my $node; | ||||
|   my $args = \@exargs; | ||||
|  | ||||
|   #Handle http commands on their own | ||||
|   if ($command eq "getrvidparms") { | ||||
|       my $user = $mpahash->{$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}})) { | ||||
|   | ||||
| @@ -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 =~ /,$/) | ||||
|         { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user