diff --git a/xCAT-server/lib/perl/xCAT/SvrUtils.pm b/xCAT-server/lib/perl/xCAT/SvrUtils.pm index e66b64d3b..f4ae3c2cb 100644 --- a/xCAT-server/lib/perl/xCAT/SvrUtils.pm +++ b/xCAT-server/lib/perl/xCAT/SvrUtils.pm @@ -1116,8 +1116,59 @@ sub setupStatemnt { } -#------------------------------------------------------------------------------- +#------------------------------------------------------------------------------------------- +# Common method to send info back to the client +# The last two args are optional, though $allerrornodes will unlikely be there without $node +# TODO: investigate possibly removing this and using MsgUtils instead +# +#-------------------------------------------------------------------------------------------- +sub sendmsg { + my $text = shift; + my $callback = shift; + my $node = shift; + my %allerrornodes = shift; + my $descr; + my $rc; + if (ref $text eq 'HASH') { + die "not right now"; + } elsif (ref $text eq 'ARRAY') { + $rc = $text->[0]; + $text = $text->[1]; + } + if ($text =~ /:/) { + ($descr,$text) = split /:/,$text,2; + } + $text =~ s/^ *//; + $text =~ s/ *$//; + my $msg; + my $curptr; + if ($node) { + $msg->{node}=[{name => [$node]}]; + $curptr=$msg->{node}->[0]; + } else { + $msg = {}; + $curptr = $msg; + } + if ($rc) { + $curptr->{errorcode}=[$rc]; + $curptr->{error}=[$text]; + $curptr=$curptr->{error}->[0]; + if (defined $node && %allerrornodes) { + $allerrornodes{$node}=1; + } + } else { + $curptr->{data}=[{contents=>[$text]}]; + $curptr=$curptr->{data}->[0]; + if ($descr) { $curptr->{desc}=[$descr]; } + } +# print $outfd freeze([$msg]); +# print $outfd "\nENDOFFREEZE6sK4ci\n"; +# yield; +# waitforack($outfd); + $callback->($msg); +} +#------------------------------------------------------------------------------- =head3 build_deps Look up the "deps" table to generate the dependencies for the nodes Arguments: @@ -1336,4 +1387,5 @@ sub handle_deps() return $nodeseq; } +>>>>>>> .r6990 1; diff --git a/xCAT-server/lib/xcat/plugins/activedirectory.pm b/xCAT-server/lib/xcat/plugins/activedirectory.pm index 6c16f7733..cbbf5a655 100644 --- a/xCAT-server/lib/xcat/plugins/activedirectory.pm +++ b/xCAT-server/lib/xcat/plugins/activedirectory.pm @@ -9,6 +9,7 @@ use lib "$::XCATROOT/lib/perl"; use Getopt::Long; use xCAT::ADUtils; use Net::DNS; +use xCAT::SvrUtils; use strict; sub handled_commands { @@ -50,7 +51,7 @@ sub process_request { my $passtab = xCAT::Table->new('passwd'); my $adpent = $passtab->getAttribs({key=>'activedirectory'},[qw/username password/]); unless ($adpent and $adpent->{username} and $adpent->{password}) { - sendmsg([1,"activedirectory entry missing from passwd table"]); + xCAT::SvrUtils::sendmsg([1,"activedirectory entry missing from passwd table"], $callback); return 1; } if ($server and $server->{value}) { @@ -64,7 +65,7 @@ sub process_request { } } unless ($server) { - sendmsg([1,"Unable to determine a directory server to communicate with, try site.directoryserver"]); + xCAT::SvrUtils::sendmsg([1,"Unable to determine a directory server to communicate with, try site.directoryserver"], $callback); return; } } @@ -81,12 +82,12 @@ sub process_request { } } unless ($domain and $realm) { - sendmsg([1,"Unable to determine domain from arguments or site table"]); + xCAT::SvrUtils::sendmsg([1,"Unable to determine domain from arguments or site table"], $callback); return undef; } my $err = xCAT::ADUtils::krb_login(username=>$adpent->{username},password=>$adpent->{password},realm=>$realm); if ($err) { - sendmsg([1,"Error authenticating to Active Directory"]); + xCAT::SvrUtils::sendmsg([1,"Error authenticating to Active Directory"], $callback); return 1; } my $accounts = xCAT::ADUtils::list_user_accounts( @@ -101,22 +102,22 @@ sub process_request { $textout .= $accounts->{$account}->{$_}.":"; } $textout =~ s/:$//; - sendmsg($textout); + xCAT::SvrUtils::sendmsg($textout, $callback); } } else { my $account; foreach $account (keys %$accounts) { - sendmsg($account); + xCAT::SvrUtils::sendmsg($account, $callback); } } } elsif ($command =~ /hostaccountlist/) { unless ($domain and $realm) { - sendmsg([1,"Unable to determine domain from arguments or site table"]); + xCAT::SvrUtils::sendmsg([1,"Unable to determine domain from arguments or site table"], $callback); return undef; } my $err = xCAT::ADUtils::krb_login(username=>$adpent->{username},password=>$adpent->{password},realm=>$realm); if ($err) { - sendmsg([1,"Error authenticating to Active Directory"]); + xCAT::SvrUtils::sendmsg([1,"Error authenticating to Active Directory"], $callback); return 1; } my $accounts = xCAT::ADUtils::list_host_accounts( @@ -125,7 +126,7 @@ sub process_request { ); my $account; foreach $account (keys %$accounts) { - sendmsg($account); + xCAT::SvrUtils::sendmsg($account, $callback); } } elsif ($command =~ /hostaccountdel/) { my $accountname; @@ -139,7 +140,7 @@ sub process_request { $domain = lc($domain); } unless ($domain) { - sendmsg([1,"Unable to determine domain from arguments or site table"]); + xCAT::SvrUtils::sendmsg([1,"Unable to determine domain from arguments or site table"], $callback); return undef; } #my $domainstab = xCAT::Table->new('domains'); @@ -152,7 +153,7 @@ sub process_request { unless ($loggedrealms{$realm}) { my $err = xCAT::ADUtils::krb_login(username=>$adpent->{username},password=>$adpent->{password},realm=>$realm); if ($err) { - sendmsg([1,"Error authenticating to Active Directory"],$accountname); + xCAT::SvrUtils::sendmsg([1,"Error authenticating to Active Directory"], $callback,$accountname); next; } $loggedrealms{$realm}=1; @@ -177,7 +178,7 @@ sub process_request { $domain = lc($domain); } unless ($domain) { - sendmsg([1,"Unable to determine domain from arguments or site table"]); + xCAT::SvrUtils::sendmsg([1,"Unable to determine domain from arguments or site table"], $callback); return undef; } @@ -191,7 +192,7 @@ sub process_request { my $err = xCAT::ADUtils::krb_login(username=>$adpent->{username},password=>$adpent->{password},realm=>$realm); if ($err) { - sendmsg([1,"Error authenticating to Active Directory"]); + xCAT::SvrUtils::sendmsg([1,"Error authenticating to Active Directory"], $callback); return 1; } my %args = ( @@ -228,7 +229,7 @@ sub process_request { $domain = lc($domain); } unless ($domain) { - sendmsg([1,"Unable to determine domain from arguments or site table"]); + xCAT::SvrUtils::sendmsg([1,"Unable to determine domain from arguments or site table"], $callback); return undef; } @@ -241,7 +242,7 @@ sub process_request { my $err = xCAT::ADUtils::krb_login(username=>$adpent->{username},password=>$adpent->{password},realm=>$realm); if ($err) { - sendmsg([1,"Error authenticating to Active Directory"]); + xCAT::SvrUtils::sendmsg([1,"Error authenticating to Active Directory"], $callback); return 1; } my %args = ( @@ -262,7 +263,7 @@ sub process_request { if (defined $homedir) { $args{homedir} = $homedir }; my $ret = xCAT::ADUtils::add_user_account(%args); if (ref $ret and $ret->{error}) { - sendmsg([1,$ret->{error}]); + xCAT::SvrUtils::sendmsg([1,$ret->{error}], $callback); } } elsif ($command =~ /hostaccountadd$/) { #user management command, adding my $ou; @@ -284,7 +285,7 @@ sub process_request { $domain = lc($domain); } unless ($domain) { - sendmsg([1,"Unable to determine domain from arguments or site table"]); + xCAT::SvrUtils::sendmsg([1,"Unable to determine domain from arguments or site table"], $callback); return undef; } @@ -297,7 +298,7 @@ sub process_request { unless ($loggedrealms{$realm}) { my $err = xCAT::ADUtils::krb_login(username=>$adpent->{username},password=>$adpent->{password},realm=>$realm); if ($err) { - sendmsg([1,"Error authenticating to Active Directory"],$nodename); + xCAT::SvrUtils::sendmsg([1,"Error authenticating to Active Directory"], $callback,$nodename); next; } $loggedrealms{$realm}=1; @@ -315,52 +316,12 @@ sub process_request { } my $ret = xCAT::ADUtils::add_host_account(%args); if (ref $ret and $ret->{error}) { - sendmsg([1,$ret->{error}]); + xCAT::SvrUtils::sendmsg([1,$ret->{error}], $callback); } elsif (ref $ret) { - sendmsg($ret->{password},$nodename); + xCAT::SvrUtils::sendmsg($ret->{password}, $callback,$nodename); } } } } -sub sendmsg { - my $text = shift; - my $node = shift; - my $descr; - my $rc; - if (ref $text eq 'HASH') { - die "not right now"; - } elsif (ref $text eq 'ARRAY') { - $rc = $text->[0]; - $text = $text->[1]; - } - if ($text =~ /:/) { - ($descr,$text) = split /:/,$text,2; - } - $text =~ s/^ *//; - $text =~ s/ *$//; - my $msg; - my $curptr; - if ($node) { - $msg->{node}=[{name => [$node]}]; - $curptr=$msg->{node}->[0]; - } else { - $msg = {}; - $curptr = $msg; - } - if ($rc) { - $curptr->{errorcode}=[$rc]; - $curptr->{error}=[$text]; - $curptr=$curptr->{error}->[0]; - } else { - $curptr->{data}=[{contents=>[$text]}]; - $curptr=$curptr->{data}->[0]; - if ($descr) { $curptr->{desc}=[$descr]; } - } -# print $outfd freeze([$msg]); -# print $outfd "\nENDOFFREEZE6sK4ci\n"; -# yield; -# waitforack($outfd); - $callback->($msg); -} 1; diff --git a/xCAT-server/lib/xcat/plugins/ddns.pm b/xCAT-server/lib/xcat/plugins/ddns.pm index 0af619386..473d1bb03 100644 --- a/xCAT-server/lib/xcat/plugins/ddns.pm +++ b/xCAT-server/lib/xcat/plugins/ddns.pm @@ -5,6 +5,7 @@ use Net::DNS; use xCAT::Table; use Sys::Hostname; use MIME::Base64; +use xCAT::SvrUtils; use Socket; use Fcntl qw/:flock/; #This is a rewrite of DNS management using nsupdate rather than direct zone mangling @@ -123,7 +124,7 @@ sub process_request { 'a|all' => \$allnodes, 'n|new' => \$zapfiles, )) { - sendmsg([1,"TODO: makedns Usage message"]); + xCAT::SvrUtils::sendmsg([1,"TODO: makedns Usage message"], $callback); return; } } @@ -131,7 +132,7 @@ sub process_request { my $sitetab = xCAT::Table->new('site'); my $stab = $sitetab->getAttribs({key=>'domain'},['value']); unless ($stab and $stab->{value}) { - sendmsg([1,"domain not defined in site table"]); + xCAT::SvrUtils::sendmsg([1,"domain not defined in site table"], $callback); return; } $ctx->{domain} = $stab->{value}; @@ -163,11 +164,11 @@ sub process_request { next unless ($_); #skip empty lines ($addr,$names) = split /[ \t]+/,$_,2; if ($addr !~ /^\d+\.\d+\.\d+\.\d+$/) { - sendmsg(":Ignoring line $_ in /etc/hosts, only IPv4 format entries are supported currently"); + xCAT::SvrUtils::sendmsg(":Ignoring line $_ in /etc/hosts, only IPv4 format entries are supported currently", $callback); next; } unless ($names =~ /^[a-z0-9\. \t\n-]+$/i) { - sendmsg(":Ignoring line $_ in /etc/hosts, names $names contain invalid characters (valid characters include a through z, numbers and the '-', but not '_'"); + xCAT::SvrUtils::sendmsg(":Ignoring line $_ in /etc/hosts, names $names contain invalid characters (valid characters include a through z, numbers and the '-', but not '_'", $callback); next; } ($canonical,$aliasstr) = split /[ \t]+/,$names,2; @@ -204,7 +205,7 @@ sub process_request { } $ctx->{nodes} = \@nodes; my $networkstab = xCAT::Table->new('networks',-create=>0); - unless ($networkstab) { sendmsg([1,'Unable to enumerate networks, try to run makenetworks']); } + unless ($networkstab) { xCAT::SvrUtils::sendmsg([1,'Unable to enumerate networks, try to run makenetworks'], $callback); } my @networks = $networkstab->getAllAttribs('net','mask'); foreach (@networks) { my $maskn = unpack("N",inet_aton($_->{mask})); @@ -270,14 +271,14 @@ sub process_request { update_namedconf($ctx); update_zones($ctx); if ($ctx->{restartneeded}) { - sendmsg("Restarting named"); + xCAT::SvrUtils::sendmsg("Restarting named", $callback); system("/sbin/service named start"); system("/sbin/service named reload"); - sendmsg("Restarting named complete"); + xCAT::SvrUtils::sendmsg("Restarting named complete", $callback); } } else { unless ($ctx->{privkey}) { - sendmsg([1,"Unable to update DNS due to lack of credentials in passwd to communicate with remote server"]); + xCAT::SvrUtils::sendmsg([1,"Unable to update DNS due to lack of credentials in passwd to communicate with remote server"], $callback); } } #now we stick to Net::DNS style updates, with TSIG if possible. TODO: kerberized (i.e. Windows) DNS server support, maybe needing to use nsupdate -g.... @@ -331,13 +332,13 @@ sub update_zones { if ($ctx->{hoststab} and $ctx->{hoststab}->{$node} and $ctx->{hoststab}->{$node}->[0]->{ip}) { $ip = $ctx->{hoststab}->{$node}->[0]->{ip}; unless (isvalidip($ip)) { - sendmsg([1,"The hosts table entry for $node indicates $ip as an ip address, which is not a valid address"]); + xCAT::SvrUtils::sendmsg([1,"The hosts table entry for $node indicates $ip as an ip address, which is not a valid address"], $callback); next; } } else { unless ($ip = inet_aton($ip)) { print "Unable to find an IP for $node in hosts table or via system lookup (i.e. /etc/hosts"; - sendmsg([1,"Unable to find an IP for $node in hosts table or via system lookup (i.e. /etc/hosts"]); + xCAT::SvrUtils::sendmsg([1,"Unable to find an IP for $node in hosts table or via system lookup (i.e. /etc/hosts"], $callback); next; } $ip = inet_ntoa($ip); @@ -571,7 +572,7 @@ sub add_records { if ($pent and $pent->{password}) { $ctx->{privkey} = $pent->{password}; } else { - sendmsg([1,"Unable to find omapi key in passwd table"]); + xCAT::SvrUtils::sendmsg([1,"Unable to find omapi key in passwd table"], $callback); } } my $node; @@ -590,7 +591,7 @@ sub add_records { $ip = $ctx->{hoststab}->{$node}->[0]->{ip}; } else { unless ($ip = inet_aton($ip)) { - sendmsg([1,"Unable to find an IP for $node in hosts table or via system lookup (i.e. /etc/hosts"]); + xCAT::SvrUtils::sendmsg([1,"Unable to find an IP for $node in hosts table or via system lookup (i.e. /etc/hosts"], $callback); next; } $ip = inet_ntoa($ip); @@ -621,7 +622,7 @@ sub add_records { $numreqs=300; my $reply = $resolver->send($update); if ($reply->header->rcode ne 'NOERROR') { - sendmsg([1,"Failure encountered updating $zone, error was ".$reply->header->rcode]); + xCAT::SvrUtils::sendmsg([1,"Failure encountered updating $zone, error was ".$reply->header->rcode], $callback); } $update = Net::DNS::Update->new($zone); #new empty request } @@ -673,59 +674,18 @@ sub find_nameserver_for_dns { last; } else { #we have it defined, but zero, means search higher domains. Possible to shortcut further by pointing to the right domain, maybe later if ($zone !~ /\./) { - sendmsg([1,"Unable to find reverse zone to hold $node"],$node); + xCAT::SvrUtils::sendmsg([1,"Unable to find reverse zone to hold $node"], $callback,$node); last; } $zone =~ s/^[^\.]*\.//; #strip all up to and including first dot unless ($zone) { - sendmsg([1,"Unable to find zone to hold $node"],$node); + xCAT::SvrUtils::sendmsg([1,"Unable to find zone to hold $node"], $callback,$node); last; } } } } -sub sendmsg { -# my $callback = $output_handler; - my $text = shift; - my $node = shift; - my $descr; - my $rc; - if (ref $text eq 'HASH') { - die "not right now"; - } elsif (ref $text eq 'ARRAY') { - $rc = $text->[0]; - $text = $text->[1]; - } - if ($text =~ /:/) { - ($descr,$text) = split /:/,$text,2; - } - $text =~ s/^ *//; - $text =~ s/ *$//; - my $msg; - my $curptr; - if ($node) { - $msg->{node}=[{name => [$node]}]; - $curptr=$msg->{node}->[0]; - } else { - $msg = {}; - $curptr = $msg; - } - if ($rc) { - $curptr->{errorcode}=[$rc]; - $curptr->{error}=[$text]; - $curptr=$curptr->{error}->[0]; - } else { - $curptr->{data}=[{contents=>[$text]}]; - $curptr=$curptr->{data}->[0]; - if ($descr) { $curptr->{desc}=[$descr]; } - } -# print $outfd freeze([$msg]); -# print $outfd "\nENDOFFREEZE6sK4ci\n"; -# yield; -# waitforack($outfd); - $callback->($msg); -} sub genpassword { diff --git a/xCAT-server/lib/xcat/plugins/esx.pm b/xCAT-server/lib/xcat/plugins/esx.pm index 2b8101d34..ffa40f088 100644 --- a/xCAT-server/lib/xcat/plugins/esx.pm +++ b/xCAT-server/lib/xcat/plugins/esx.pm @@ -251,7 +251,7 @@ sub process_request { }; } unless ($vmwaresdkdetect) { - sendmsg([1,"VMWare SDK required for operation, but not installed"]); + xCAT::SvrUtils::sendmsg([1,"VMWare SDK required for operation, but not installed"], $output_handler); return; } @@ -347,7 +347,7 @@ sub process_request { }; if ($@) { $vcenterhash{$vcenter}->{conn} = undef; - sendmsg([1,"Unable to reach $vcenter vCenter server to manage $hyp: $@"]); + xCAT::SvrUtils::sendmsg([1,"Unable to reach $vcenter vCenter server to manage $hyp: $@"], $output_handler); next; } } @@ -366,7 +366,7 @@ sub process_request { }; if ($@) { $hyphash{$hyp}->{conn} = undef; - sendmsg([1,"Unable to reach $hyp to perform operation"]); + xCAT::SvrUtils::sendmsg([1,"Unable to reach $hyp to perform operation"], $output_handler); $hypready{$hyp} = -1; next; } @@ -387,13 +387,13 @@ sub process_request { push @badhypes,$_; my @relevant_nodes = sort (keys %{$hyphash{$_}->{nodes}}); foreach (@relevant_nodes) { - sendmsg([1,": hypervisor unreachable"],$_); + xCAT::SvrUtils::sendmsg([1,": hypervisor unreachable"], $output_handler,$_); } delete $hyphash{$_}; } } if (@badhypes) { - sendmsg([1,": The following hypervisors failed to become ready for the operation: ".join(',',@badhypes)]); + xCAT::SvrUtils::sendmsg([1,": The following hypervisors failed to become ready for the operation: ".join(',',@badhypes)], $output_handler); } } do_cmd($command,@exargs); @@ -463,17 +463,17 @@ sub inv { if (not defined $args{vmview}) { #attempt one refresh $args{vmview} = $hyphash{$hyp}->{conn}->find_entity_view(view_type => 'VirtualMachine',properties=>['config.name','runtime.powerState'],filter=>{name=>$node}); if (not defined $args{vmview}) { - sendmsg([1,"VM does not appear to exist"],$node); + xCAT::SvrUtils::sendmsg([1,"VM does not appear to exist"], $output_handler,$node); return; } } my $vmview = $args{vmview}; my $uuid = $vmview->config->uuid; - sendmsg("UUID/GUID: $uuid",$node); + xCAT::SvrUtils::sendmsg("UUID/GUID: $uuid", $output_handler,$node); my $cpuCount = $vmview->config->hardware->numCPU; - sendmsg("CPUs: $cpuCount",$node); + xCAT::SvrUtils::sendmsg("CPUs: $cpuCount", $output_handler,$node); my $memory = $vmview->config->hardware->memoryMB; - sendmsg("Memory: $memory MB",$node); + xCAT::SvrUtils::sendmsg("Memory: $memory MB", $output_handler,$node); my $devices = $vmview->config->hardware->device; my $label; my $size; @@ -486,9 +486,9 @@ sub inv { $label .= " (d".$device->unitNumber.")"; $size = $device->capacityInKB / 1024; $fileName = $device->backing->fileName; - sendmsg("$label: $size MB @ $fileName",$node); + xCAT::SvrUtils::sendmsg("$label: $size MB @ $fileName", $output_handler,$node); } elsif ($label =~ /Network/) { - sendmsg("$label: ".$device->macAddress,$node); + xCAT::SvrUtils::sendmsg("$label: ".$device->macAddress, $output_handler,$node); } } } @@ -505,7 +505,7 @@ sub chvm { properties=>['config.name','runtime.powerState'], filter=>{name=>$node}); if (not defined $args{vmview}) { - sendmsg([1,"VM does not appear to exist"],$node); + xCAT::SvrUtils::sendmsg([1,"VM does not appear to exist"], $output_handler,$node); return; } } @@ -520,7 +520,7 @@ sub chvm { require Getopt::Long; $SIG{__WARN__} = sub { - sendmsg([1,"Could not parse options, ".shift()]); + xCAT::SvrUtils::sendmsg([1,"Could not parse options, ".shift()], $output_handler); }; my $rc = GetOptions( "d=s" => \@deregister, @@ -533,7 +533,7 @@ sub chvm { $SIG{__WARN__} = 'DEFAULT'; if(@ARGV) { - sendmsg("Invalid arguments: @ARGV"); + xCAT::SvrUtils::sendmsg("Invalid arguments: @ARGV", $output_handler); return; } @@ -542,12 +542,12 @@ sub chvm { } #use Data::Dumper; - #sendmsg("dereg = ".Dumper(\@deregister)); - #sendmsg("purge = ".Dumper(\@purge)); - #sendmsg("add = ".Dumper(\@add)); - #sendmsg("resize = ".Dumper(\%resize)); - #sendmsg("cpus = $cpuCount"); - #sendmsg("mem = ".getUnits($memory,"K",1024)); + #xCAT::SvrUtils::sendmsg("dereg = ".Dumper(\@deregister)); + #xCAT::SvrUtils::sendmsg("purge = ".Dumper(\@purge)); + #xCAT::SvrUtils::sendmsg("add = ".Dumper(\@add)); + #xCAT::SvrUtils::sendmsg("resize = ".Dumper(\%resize)); + #xCAT::SvrUtils::sendmsg("cpus = $cpuCount"); + #xCAT::SvrUtils::sendmsg("mem = ".getUnits($memory,"K",1024)); my %conargs; @@ -582,10 +582,10 @@ sub chvm { for $disk (@deregister) { $device = getDiskByLabel($disk, $devices); unless($device) { - sendmsg([1,"Disk: $disk does not exist"],$node); + xCAT::SvrUtils::sendmsg([1,"Disk: $disk does not exist"], $output_handler,$node); return; } - #sendmsg(Dumper($device)); + #xCAT::SvrUtils::sendmsg(Dumper($device)); push @devChanges, VirtualDeviceConfigSpec->new( device => $device, operation => VirtualDeviceConfigSpecOperation->new('remove')); @@ -597,10 +597,10 @@ sub chvm { for $disk (@purge) { $device = getDiskByLabel($disk, $devices); unless($device) { - sendmsg([1,"Disk: $disk does not exist"],$node); + xCAT::SvrUtils::sendmsg([1,"Disk: $disk does not exist"], $output_handler,$node); return; } - #sendmsg(Dumper($device)); + #xCAT::SvrUtils::sendmsg(Dumper($device)); push @devChanges, VirtualDeviceConfigSpec->new( device => $device, operation => VirtualDeviceConfigSpecOperation->new('remove'), @@ -643,7 +643,7 @@ sub chvm { my $disk = $device; $device = getDiskByLabel($disk, $devices); unless($device) { - sendmsg([1,"Disk: $disk does not exist"],$node); + xCAT::SvrUtils::sendmsg([1,"Disk: $disk does not exist"], $output_handler,$node); return; } if ($value =~ /^\+(.+)/) { @@ -671,7 +671,7 @@ sub chvm { my $reconfigspec = VirtualMachineConfigSpec->new(%conargs); - #sendmsg("reconfigspec = ".Dumper($reconfigspec)); + #xCAT::SvrUtils::sendmsg("reconfigspec = ".Dumper($reconfigspec)); my $task = $vmview->ReconfigVM_Task(spec=>$reconfigspec); $running_tasks{$task}->{task} = $task; $running_tasks{$task}->{callback} = \&generic_task_callback; @@ -820,7 +820,7 @@ sub connecthost_callback { $error.=$_->message; } } - sendmsg([1,$error]); #,$node); + xCAT::SvrUtils::sendmsg([1,$error], $output_handler); #,$node); $hypready{$args->{hypname}} = -1; #Impossible for this hypervisor to ever be ready $vcenterhash{$args->{vcenter}}->{$args->{hypname}} = 'bad'; } @@ -906,7 +906,7 @@ sub enable_vmotion { $nicmgr->SelectVnicForNicType(nicType=>"vmotion",device=>$qnc->candidateVnic->[0]->device); return 1; } else { - sendmsg([1,"TODO: use configuration to pick the nic ".$args{hypname}]); + xCAT::SvrUtils::sendmsg([1,"TODO: use configuration to pick the nic ".$args{hypname}], $output_handler); } return 0; } @@ -918,7 +918,7 @@ sub mkvm_callback { my $hyp = $args->{hyp}; if ($task->info->state->val eq 'error') { my $error = $task->info->error->localizedMessage; - sendmsg([1,$error],$node); + xCAT::SvrUtils::sendmsg([1,$error], $output_handler,$node); } } @@ -934,10 +934,10 @@ sub relay_vmware_err { } if (@nodes) { foreach (@nodes) { - sendmsg([1,$extratext.$error],$_); + xCAT::SvrUtils::sendmsg([1,$extratext.$error], $output_handler,$_); } }else { - sendmsg([1,$extratext.$error]); + xCAT::SvrUtils::sendmsg([1,$extratext.$error], $output_handler); } } @@ -955,7 +955,7 @@ sub relocate_callback { $target.="=$model"; } $vmtab->setNodeAttribs($parms->{node},{storage=>$target}); - sendmsg(":relocated to to ".$parms->{target},$parms->{node}); + xCAT::SvrUtils::sendmsg(":relocated to to ".$parms->{target}, $output_handler,$parms->{node}); } else { relay_vmware_err($task,"Relocating to ".$parms->{target}." ",$parms->{node}); } @@ -964,7 +964,7 @@ sub migrate_ok { #look like a successful migrate, callback for registering a vm my %args = @_; my $vmtab = xCAT::Table->new('vm'); $vmtab->setNodeAttribs($args{nodes}->[0],{host=>$args{target}}); - sendmsg("migrated to ".$args{target},$args{nodes}->[0]); + xCAT::SvrUtils::sendmsg("migrated to ".$args{target}, $output_handler,$args{nodes}->[0]); } sub migrate_callback { my $task = shift; @@ -973,7 +973,7 @@ sub migrate_callback { if (not $parms->{skiptodeadsource} and $state eq 'success') { my $vmtab = xCAT::Table->new('vm'); $vmtab->setNodeAttribs($parms->{node},{host=>$parms->{target}}); - sendmsg("migrated to ".$parms->{target},$parms->{node}); + xCAT::SvrUtils::sendmsg("migrated to ".$parms->{target}, $output_handler,$parms->{node}); } elsif($parms->{offline}) { #try a forceful RegisterVM instead my $target = $parms->{target}; my $hostview = $hyphash{$target}->{conn}->find_entity_view(view_type=>'VirtualMachine',properties=>['config.name'],filter=>{name=>$parms->{node}}); @@ -1003,7 +1003,7 @@ sub poweron_task_callback { my $node = $parms->{node}; my $intent = $parms->{successtext}; if ($state eq 'success') { - sendmsg($intent,$node); + xCAT::SvrUtils::sendmsg($intent, $output_handler,$node); } elsif ($state eq 'error') { relay_vmware_err($task,"",$node); } elsif ($q and $q->text =~ /^msg.uuid.altered:/ and ($q->choice->choiceInfo->[0]->summary eq 'Cancel' and ($q->choice->choiceInfo->[0]->key eq '0'))) { #make sure it is what is what we have seen it to be @@ -1011,13 +1011,13 @@ sub poweron_task_callback { $vm->AnswerVM(questionId=>$q->id,answerChoice=>'1'); } else { $vm->AnswerVM(questionId=>$q->id,answerChoice=>'0'); - sendmsg([1,"Failure powering on VM, it mismatched against the hypervisor. If positive VM is not running on another hypervisor, use -f to force VM on"],$node); + xCAT::SvrUtils::sendmsg([1,"Failure powering on VM, it mismatched against the hypervisor. If positive VM is not running on another hypervisor, use -f to force VM on"], $output_handler,$node); } } elsif ($q) { if ($q->choice->choiceInfo->[0]->summary eq 'Cancel') { - sendmsg([1,":Cancelling due to unexpected question executing task: ".$q->text],$node); + xCAT::SvrUtils::sendmsg([1,":Cancelling due to unexpected question executing task: ".$q->text], $output_handler,$node); } else { - sendmsg([1,":Task hang due to unexpected question executing task, need to use VMware tools to clean up the mess for now: ".$q->text],$node); + xCAT::SvrUtils::sendmsg([1,":Task hang due to unexpected question executing task, need to use VMware tools to clean up the mess for now: ".$q->text], $output_handler,$node); } } @@ -1029,51 +1029,12 @@ sub generic_task_callback { my $node = $parms->{node}; my $intent = $parms->{successtext}; if ($state eq 'success') { - sendmsg($intent,$node); + xCAT::SvrUtils::sendmsg($intent, $output_handler,$node); } elsif ($state eq 'error') { relay_vmware_err($task,"",$node); } } -sub sendmsg { - my $callback = $output_handler; - my $text = shift; - my $node = shift; - my $descr; - my $rc; - if (ref $text eq 'HASH') { - return $callback->($text); - } elsif (ref $text eq 'ARRAY') { - $rc = $text->[0]; - $text = $text->[1]; - } - if ($text =~ /:/) { - ($descr,$text) = split /:/,$text,2; - } - $text =~ s/^ *//; - $text =~ s/ *$//; - my $msg; - my $curptr; - if ($node) { - $msg->{node}=[{name => [$node]}]; - $curptr=$msg->{node}->[0]; - } else { - $msg = {}; - $curptr = $msg; - } - if ($rc) { - $curptr->{errorcode}=[$rc]; - $curptr->{error}=[$text]; - $curptr=$curptr->{error}->[0]; - } else { - $curptr->{data}=[{contents=>[$text]}]; - $curptr=$curptr->{data}->[0]; - if ($descr) { $curptr->{desc}=[$descr]; } - } - $callback->($msg); -} - - sub migrate { my %args = @_; my @nodes = @{$args{nodes}}; @@ -1086,22 +1047,22 @@ sub migrate { 's=s' => \$datastoredest, 'f' => \$offline, )) { - sendmsg([1,"Error parsing arguments"]); + xCAT::SvrUtils::sendmsg([1,"Error parsing arguments"], $output_handler); return; } my $target=$hyp; #case for storage migration if ($datastoredest and scalar @ARGV) { - sendmsg([1,"Unable to mix storage migration and processing of arguments ".join(' ',@ARGV)]); + xCAT::SvrUtils::sendmsg([1,"Unable to mix storage migration and processing of arguments ".join(' ',@ARGV)], $output_handler); return; } elsif (@ARGV) { $target=shift @ARGV; if (@ARGV) { - sendmsg([1,"Unrecognized arguments ".join(' ',@ARGV)]); + xCAT::SvrUtils::sendmsg([1,"Unrecognized arguments ".join(' ',@ARGV)], $output_handler); return; } } elsif ($datastoredest) { #storage migration only unless (validate_datastore_prereqs([],$hyp,{$datastoredest=>\@nodes})) { - sendmsg([1,"Unable to find/mount target datastore $datastoredest"]); + xCAT::SvrUtils::sendmsg([1,"Unable to find/mount target datastore $datastoredest"], $output_handler); return; } foreach (@nodes) { @@ -1119,16 +1080,16 @@ sub migrate { return; } if ((not $offline and $vcenterhash{$vcenter}->{$hyp} eq 'bad') or $vcenterhash{$vcenter}->{$target} eq 'bad') { - sendmsg([1,"Unable to migrate ".join(',',@nodes)." to $target due to inability to validate vCenter connectivity"]); + xCAT::SvrUtils::sendmsg([1,"Unable to migrate ".join(',',@nodes)." to $target due to inability to validate vCenter connectivity"], $output_handler); return; } if (($offline or $vcenterhash{$vcenter}->{$hyp} eq 'good') and $vcenterhash{$vcenter}->{$target} eq 'good') { unless (validate_datastore_prereqs(\@nodes,$target)) { - sendmsg([1,"Unable to verify storage state on target system"]); + xCAT::SvrUtils::sendmsg([1,"Unable to verify storage state on target system"], $output_handler); return; } unless (validate_network_prereqs(\@nodes,$target)) { - sendmsg([1,"Unable to verify target network state"]); + xCAT::SvrUtils::sendmsg([1,"Unable to verify target network state"], $output_handler); return; } my $dstview = get_hostview(conn=>$hyphash{$target}->{conn},hypname=>$target,properties=>['name','parent']); @@ -1145,7 +1106,7 @@ sub migrate { $srcview = $hyphash{$hyp}->{conn}->find_entity_view(view_type=>'VirtualMachine',properties=>['config.name'],filter=>{name=>$_}); } unless ($srcview) { - sendmsg([1,"Unable to locate node in vCenter"],$_); + xCAT::SvrUtils::sendmsg([1,"Unable to locate node in vCenter"], $output_handler,$_); next; } @@ -1159,7 +1120,7 @@ sub migrate { $running_tasks{$task}->{data} = { node => $_, src=>$hyp, target=>$target, offline => $offline }; } } else { - #sendmsg("Waiting for BOTH to be 'good'"); + #xCAT::SvrUtils::sendmsg("Waiting for BOTH to be 'good'"); return; #One of them is still 'pending' } } @@ -1204,7 +1165,7 @@ sub rmvm { if (not defined $args{vmview}) { #attempt one refresh $args{vmview} = $hyphash{$hyp}->{conn}->find_entity_view(view_type => 'VirtualMachine',properties=>['config.name','runtime.powerState'],filter=>{name=>$node}); if (not defined $args{vmview}) { - sendmsg([1,"VM does not appear to exist"],$node); + xCAT::SvrUtils::sendmsg([1,"VM does not appear to exist"], $output_handler,$node); return; } } @@ -1226,7 +1187,7 @@ sub rmvm { $running_tasks{$task}->{data} = { node => $node, args=>\%args }; return; } else { - sendmsg([1,"Cannot rmvm active guest (use -f argument to force)"],$node); + xCAT::SvrUtils::sendmsg([1,"Cannot rmvm active guest (use -f argument to force)"], $output_handler,$node); return; } } @@ -1287,7 +1248,7 @@ sub power { if (not defined $args{vmview}) { #attempt one refresh $args{vmview} = $hyphash{$hyp}->{conn}->find_entity_view(view_type => 'VirtualMachine',properties=>['config.name','config','runtime.powerState'],filter=>{name=>$node}); if (not defined $args{vmview}) { - sendmsg([1,"VM does not appear to exist"],$node); + xCAT::SvrUtils::sendmsg([1,"VM does not appear to exist"], $output_handler,$node); return; } } @@ -1308,7 +1269,7 @@ sub power { my $reconfigspec; if ($reconfigspec = getreconfigspec(node=>$node,view=>$args{vmview})) { if ($currstat eq 'poweredOff') { - #sendmsg("Correcting guestId because $currid and $rightid are not the same...");#DEBUG + #xCAT::SvrUtils::sendmsg("Correcting guestId because $currid and $rightid are not the same...");#DEBUG my $task = $args{vmview}->ReconfigVM_Task(spec=>$reconfigspec); $running_tasks{$task}->{task} = $task; $running_tasks{$task}->{callback} = \&reconfig_callback; @@ -1316,7 +1277,7 @@ sub power { $running_tasks{$task}->{data} = { node => $node, reconfig_fun=>\&power, reconfig_args=>\%args }; return; } elsif (grep /$subcmd/,qw/reset boot/) { #going to have to do a 'cycle' and present it up normally.. - #sendmsg("DEBUG: forcing a cycle"); + #xCAT::SvrUtils::sendmsg("DEBUG: forcing a cycle"); $task = $args{vmview}->PowerOffVM_Task(); $running_tasks{$task}->{task} = $task; $running_tasks{$task}->{callback} = \&repower; @@ -1325,7 +1286,7 @@ sub power { return; #we have to wait } #TODO: fixit - #sendmsg("I see vm has $currid and I want it to be $rightid"); + #xCAT::SvrUtils::sendmsg("I see vm has $currid and I want it to be $rightid"); } } } else { @@ -1339,7 +1300,7 @@ sub power { $currstat = 'suspend'; } if ($subcmd =~ /^stat/) { - sendmsg($currstat,$node); + xCAT::SvrUtils::sendmsg($currstat, $output_handler,$node); return; } if ($subcmd =~ /boot/) { @@ -1362,7 +1323,7 @@ sub power { $task = $args{vmview}->PowerOnVM_Task(host=>$hyphash{$hyp}->{hostview}); }; if ($@) { - sendmsg([1,":".$@],$node); + xCAT::SvrUtils::sendmsg([1,":".$@], $output_handler,$node); return; } $running_tasks{$task}->{task} = $task; @@ -1370,7 +1331,7 @@ sub power { $running_tasks{$task}->{hyp} = $args{hyp}; #$hyp_conns->{$hyp}; $running_tasks{$task}->{data} = { node => $node, successtext => $intent.'on', forceon=>$forceon }; } else { - sendmsg($currstat,$node); + xCAT::SvrUtils::sendmsg($currstat, $output_handler,$node); } } elsif ($subcmd =~ /off/) { if ($currstat eq 'on') { @@ -1380,7 +1341,7 @@ sub power { $running_tasks{$task}->{hyp} = $args{hyp}; $running_tasks{$task}->{data} = { node => $node, successtext => 'off' }; } else { - sendmsg($currstat,$node); + xCAT::SvrUtils::sendmsg($currstat, $output_handler,$node); } } elsif ($subcmd =~ /suspend/) { if ($currstat eq 'on') { @@ -1390,7 +1351,7 @@ sub power { $running_tasks{$task}->{hyp} = $args{hyp}; $running_tasks{$task}->{data} = { node => $node, successtext => 'suspend' }; } else { - sendmsg("off",$node); + xCAT::SvrUtils::sendmsg("off", $output_handler,$node); } } elsif ($subcmd =~ /reset/) { if ($currstat eq 'on') { @@ -1404,7 +1365,7 @@ sub power { $task = $args{vmview}->PowerOnVM_Task(host=>$hyphash{$hyp}->{hostview}); }; if ($@) { - sendmsg([1,":".$@],$node); + xCAT::SvrUtils::sendmsg([1,":".$@], $output_handler,$node); return; } $running_tasks{$task}->{task} = $task; @@ -1412,7 +1373,7 @@ sub power { $running_tasks{$task}->{hyp} = $args{hyp}; $running_tasks{$task}->{data} = { node => $node, successtext => $intent.'reset' }; } else { - sendmsg($currstat,$node); + xCAT::SvrUtils::sendmsg($currstat, $output_handler,$node); } } } @@ -1571,7 +1532,7 @@ sub lsvm { } foreach (@$vms) { my $vmv = $hyphash{$hyp}->{conn}->get_view(mo_ref=>$_); - sendmsg($vmv->name,$hyp); + xCAT::SvrUtils::sendmsg($vmv->name, $output_handler,$hyp); } return; } @@ -1611,7 +1572,7 @@ sub mkvms { foreach $node (@$nodes) { process_tasks; #check for tasks needing followup actions before the task is forgotten (VMWare's memory is fairly short at times if ($hyphash{$hyp}->{conn}->find_entity_view(view_type=>"VirtualMachine",filter=>{name=>$node})) { - sendmsg([1,"Virtual Machine already exists"],$node); + xCAT::SvrUtils::sendmsg([1,"Virtual Machine already exists"], $output_handler,$node); next; } else { register_vm($hyp,$node,$disksize); @@ -1632,7 +1593,7 @@ sub setboot { if (not defined $args{vmview}) { #attempt one refresh $args{vmview} = $hyphash{$hyp}->{conn}->find_entity_view(view_type => 'VirtualMachine',properties=>['config.name'],filter=>{name=>$node}); if (not defined $args{vmview}) { - sendmsg([1,"VM does not appear to exist"],$node); + xCAT::SvrUtils::sendmsg([1,"VM does not appear to exist"], $output_handler,$node); return; } } @@ -1647,7 +1608,7 @@ sub setboot { my $reconfigspec; if ($bootorder =~ /setup/) { unless ($bootorder eq 'setup') { - sendmsg([1,"rsetboot parameter may not contain 'setup' with other items, assuming vm.bootorder is just 'setup'"],$node); + xCAT::SvrUtils::sendmsg([1,"rsetboot parameter may not contain 'setup' with other items, assuming vm.bootorder is just 'setup'"], $output_handler,$node); } $reconfigspec = VirtualMachineConfigSpec->new( bootOptions=>VirtualMachineBootOptions->new(enterBIOSSetup=>1), @@ -1725,7 +1686,7 @@ sub register_vm_callback { } elsif ($args->{errregister}) { relay_vmware_err($task,"",$args->{node}); } else { - sendmsg([1,"mkvm must be called before use of this function"],$args->{node}); + xCAT::SvrUtils::sendmsg([1,"mkvm must be called before use of this function"], $output_handler,$args->{node}); } } elsif (defined $args->{blockedfun}) { #If there is a blocked function, call it here) $args->{blockedfun}->(%{$args->{blockedargs}}); @@ -1744,7 +1705,7 @@ sub getURI { $server =~ s/:$//; #tolerate habitual colons my $servern = inet_aton($server); unless ($servern) { - sendmsg([1,"could not resolve '$server' to an address from vm.storage/vm.cfgstore"]); + xCAT::SvrUtils::sendmsg([1,"could not resolve '$server' to an address from vm.storage/vm.cfgstore"], $output_handler); } $server = inet_ntoa($servern); $uri = "nfs://$server/$path"; @@ -1753,7 +1714,7 @@ sub getURI { $name =~ s/:$//; #remove a : if someone put it in for some reason. $uri = "vmfs://$name"; }else{ - sendmsg([1,"Unsupported VMware Storage Method: $method. Please use 'vmfs or nfs'"]); + xCAT::SvrUtils::sendmsg([1,"Unsupported VMware Storage Method: $method. Please use 'vmfs or nfs'"], $output_handler); } return $uri; @@ -1994,7 +1955,7 @@ sub create_storage_devs { #$server =~ s/:$//; #tolerate habitual colons #my $servern = inet_aton($server); #unless ($servern) { - # sendmsg([1,"could not resolve '$server' to an address from vm.storage"]); + # xCAT::SvrUtils::sendmsg([1,"could not resolve '$server' to an address from vm.storage"]); # return; #} #$server = inet_ntoa($servern); @@ -2075,7 +2036,7 @@ sub validate_vcenter_prereqs { #Communicate with vCenter and ensure this host is } } unless ($hyphash{$hyp}->{vcenter}->{conn}) { - sendmsg([1,": Unable to reach vCenter server managing $hyp"]); + xCAT::SvrUtils::sendmsg([1,": Unable to reach vCenter server managing $hyp"], $output_handler); return undef; } @@ -2145,7 +2106,7 @@ sub validate_vcenter_prereqs { #Communicate with vCenter and ensure this host is $hyphash{$hyp}->{conn}->login(user_name=>$hyphash{$hyp}->{username},password=>$hyphash{$hyp}->{password}); }; if ($@) { - sendmsg([1,": Failed to communicate with $hyp"]); + xCAT::SvrUtils::sendmsg([1,": Failed to communicate with $hyp"], $output_handler); $hyphash{$hyp}->{conn} = undef; return "failed"; } @@ -2186,7 +2147,7 @@ sub addhosttovcenter { if ($tablecfg{hypervisor}->{$hyp}->[0]->{cluster}) { my $cluster = get_clusterview(clustname=>$tablecfg{hypervisor}->{$hyp}->[0]->{cluster},conn=>$hyphash{$hyp}->{vcenter}->{conn}); unless ($cluster) { - sendmsg([1,$tablecfg{hypervisor}->{$hyp}->[0]->{cluster}. " is not a known cluster to the vCenter server."]); + xCAT::SvrUtils::sendmsg([1,$tablecfg{hypervisor}->{$hyp}->[0]->{cluster}. " is not a known cluster to the vCenter server."], $output_handler); $hypready{$hyp}=-1; #Declare impossiblility to be ready return; } @@ -2268,7 +2229,7 @@ sub get_switchname_for_portdesc { $description = 'vsw'.$portdesc; } unless ($description) { - sendmsg([1,": Invalid format for hypervisor.netmap detected for $hyp"]); + xCAT::SvrUtils::sendmsg([1,": Invalid format for hypervisor.netmap detected for $hyp"], $output_handler); return undef; } my %requiredports; @@ -2289,7 +2250,7 @@ sub get_switchname_for_portdesc { } } if (keys %requiredports) { - sendmsg([1,":Unable to locate the following nics on $hyp: ".join(',',keys %requiredports)]); + xCAT::SvrUtils::sendmsg([1,":Unable to locate the following nics on $hyp: ".join(',',keys %requiredports)], $output_handler); return undef; } my $foundmatchswitch; @@ -2310,7 +2271,7 @@ sub get_switchname_for_portdesc { } if ($foundmatchswitch) { if ($cfgmismatch) { - sendmsg([1,": Aggregation mismatch detected, request nic is aggregated with a nic not requested"]); + xCAT::SvrUtils::sendmsg([1,": Aggregation mismatch detected, request nic is aggregated with a nic not requested"], $output_handler); return undef; } unless (keys %portkeys) { @@ -2446,7 +2407,7 @@ sub validate_datastore_prereqs { $mnthost = inet_ntoa($mnthost); } else { $mnthost = $dsv->info->nas->remoteHost; - sendmsg([1,"Unable to resolve VMware specified host '".$dsv->info->nas->remoteHost."' to an address, problems may occur"]); + xCAT::SvrUtils::sendmsg([1,"Unable to resolve VMware specified host '".$dsv->info->nas->remoteHost."' to an address, problems may occur"], $output_handler); } $hyphash{$hyp}->{datastoremap}->{"nfs://".$mnthost.$dsv->info->nas->remotePath}=$dsv->info->name; $hyphash{$hyp}->{datastorerefmap}->{"nfs://".$mnthost.$dsv->info->nas->remotePath}=$_; @@ -2479,7 +2440,7 @@ sub validate_datastore_prereqs { $server =~ s/:$//; #remove a : if someone put it in out of nfs mount habit my $servern = inet_aton($server); unless ($servern) { - sendmsg([1,": Unable to resolve '$server' to an address, check vm.cfgstore/vm.storage"]); + xCAT::SvrUtils::sendmsg([1,": Unable to resolve '$server' to an address, check vm.cfgstore/vm.storage"], $output_handler); return 0; } $server = inet_ntoa($servern); @@ -2497,11 +2458,11 @@ sub validate_datastore_prereqs { ($hyphash{$hyp}->{datastoremap}->{$uri},$hyphash{$hyp}->{datastorerefmap}->{$uri})=create_vmfs_datastore($hostview,$name); } }else{ - sendmsg([1,": $method is unsupported at this time (nfs would be)"],$node); + xCAT::SvrUtils::sendmsg([1,": $method is unsupported at this time (nfs would be)"], $output_handler,$node); return 0; } } else { - sendmsg([1,": $_ not supported storage specification for ESX plugin,\n\t'nfs:///'\n\t\tor\n\t'vmfs://'\n only currently supported vm.storage supported for ESX at the moment"],$node); + xCAT::SvrUtils::sendmsg([1,": $_ not supported storage specification for ESX plugin,\n\t'nfs:///'\n\t\tor\n\t'vmfs://'\n only currently supported vm.storage supported for ESX at the moment"], $output_handler,$node); return 0; } #TODO: raw device mapping, VMFS via iSCSI, VMFS via FC? } @@ -2517,14 +2478,14 @@ sub validate_datastore_prereqs { $server =~ s/:$//; #remove a : if someone put it in out of nfs mount habit my $servern = inet_aton($server); unless ($servern) { - sendmsg([1,": Unable to resolve '$server' to an address, check vm.cfgstore/vm.storage"]); + xCAT::SvrUtils::sendmsg([1,": Unable to resolve '$server' to an address, check vm.cfgstore/vm.storage"], $output_handler); return 0; } $server = inet_ntoa($servern); my $uri = "nfs://$server/$path"; unless ($method =~ /nfs/) { foreach (@{$newdatastores->{$_}}) { - sendmsg([1,": $method is unsupported at this time (nfs would be)"],$_); + xCAT::SvrUtils::sendmsg([1,": $method is unsupported at this time (nfs would be)"], $output_handler,$_); } return 0; } @@ -2534,7 +2495,7 @@ sub validate_datastore_prereqs { } } else { foreach (@{$newdatastores->{$_}}) { - sendmsg([1,": $_ not supported storage specification for ESX plugin, 'nfs:///' only currently supported vm.storage supported for ESX at the moment"],$_); + xCAT::SvrUtils::sendmsg([1,": $_ not supported storage specification for ESX plugin, 'nfs:///' only currently supported vm.storage supported for ESX at the moment"], $output_handler,$_); } return 0; } #TODO: raw device mapping, VMFS via iSCSI, VMFS via FC? @@ -2552,7 +2513,7 @@ sub validate_datastore_prereqs { $mnthost = inet_ntoa($mnthost); } else { $mnthost = $dsv->info->nas->remoteHost; - sendmsg([1,"Unable to resolve VMware specified host '".$dsv->info->nas->remoteHost."' to an address, problems may occur"]); + xCAT::SvrUtils::sendmsg([1,"Unable to resolve VMware specified host '".$dsv->info->nas->remoteHost."' to an address, problems may occur"], $output_handler); } $hyphash{$hyp}->{datastoremap}->{"nfs://".$mnthost.$dsv->info->nas->remotePath}=$dsv->info->name; $hyphash{$hyp}->{datastorerefmap}->{"nfs://".$mnthost.$dsv->info->nas->remotePath}=$_; @@ -2757,7 +2718,7 @@ sub copycd { } $found = 1; if( $arch and $arch ne $darch){ - sendmsg([1, "Requested distribution architecture $arch, but media is $darch"]); + xCAT::SvrUtils::sendmsg([1, "Requested distribution architecture $arch, but media is $darch"], $output_handler); return; } $arch = $darch; @@ -2766,7 +2727,7 @@ sub copycd { } close(LINE); unless($found){ - sendmsg([1,"I don't recognize this VMware ESX DVD"]); + xCAT::SvrUtils::sendmsg([1,"I don't recognize this VMware ESX DVD"], $output_handler); return; # doesn't seem to be a valid DVD or CD } } elsif (-r $path . "/vmkernel.gz" and -r $path . "/isolinux.cfg"){ @@ -2784,7 +2745,7 @@ sub copycd { } unless ($found) { return; } #not our media - sendmsg("Copying media to $installroot/$distname/$arch/"); + xCAT::SvrUtils::sendmsg("Copying media to $installroot/$distname/$arch/", $output_handler); my $omask = umask 0022; mkpath("$installroot/$distname/$arch"); umask $omask; @@ -2805,7 +2766,7 @@ sub copycd { my $child = open($KID, "|-"); unless (defined $child) { - sendmsg([1,"Media copy operation fork failure"]); + xCAT::SvrUtils::sendmsg([1,"Media copy operation fork failure"], $output_handler); return; } if ($child) @@ -2824,7 +2785,7 @@ sub copycd { nice 10; my $c = "nice -n 20 cpio -vdump $installroot/$distname/$arch"; my $k2 = open(PIPE, "$c 2>&1 |") || - sendmsg([1,"Media copy operation fork failure"]); + xCAT::SvrUtils::sendmsg([1,"Media copy operation fork failure"], $output_handler); push @cpiopid, $k2; my $copied = 0; my ($percent, $fout); @@ -2841,12 +2802,12 @@ sub copycd { #chdir "/tmp"; chmod 0755, "$installroot/$distname/$arch"; if ($rc != 0){ - sendmsg([1,"Media copy operation failed, status $rc"]); + xCAT::SvrUtils::sendmsg([1,"Media copy operation failed, status $rc"], $output_handler); }else{ - sendmsg("Media copy operation successful"); + xCAT::SvrUtils::sendmsg("Media copy operation successful", $output_handler); my @ret=xCAT::SvrUtils->update_tables_with_templates($distname, $arch); if ($ret[0] != 0) { - sendmsg("Error when updating the osimage tables: " . $ret[1]); + xCAT::SvrUtils::sendmsg("Error when updating the osimage tables: " . $ret[1], $output_handler); } @@ -2944,7 +2905,7 @@ sub mknetboot { my $profile = $ent->{'profile'}; my $osver = $ent->{'os'}; #if($arch ne 'x86'){ - # sendmsg([1,"VMware ESX hypervisors are x86, please change the nodetype.arch value to x86 instead of $arch for $node before proceeding: + # xCAT::SvrUtils::sendmsg([1,"VMware ESX hypervisors are x86, please change the nodetype.arch value to x86 instead of $arch for $node before proceeding: #e.g: nodech $node nodetype.arch=x86\n"]); # return; #} @@ -2957,7 +2918,7 @@ sub mknetboot { -r "$custprofpath/vmkboot.gz" or -r "$installroot/$osver/$arch/mboot.c32" or -r "$installroot/$osver/$arch/install.tgz" ){ - sendmsg([1,"Please run copycds first for $osver or create custom image in $custprofpath/"]); + xCAT::SvrUtils::sendmsg([1,"Please run copycds first for $osver or create custom image in $custprofpath/"], $output_handler); } mkpath("$tftpdir/xcat/netboot/$osver/$arch/"); @@ -2988,7 +2949,7 @@ sub mknetboot { my $bail=0; foreach (@reqmods) { unless (-r "$tftpdir/$tp/$_") { - sendmsg([1,"$_ is missing from the target destination, ensure that either copycds has been run or that $custprofpath contains this file"]); + xCAT::SvrUtils::sendmsg([1,"$_ is missing from the target destination, ensure that either copycds has been run or that $custprofpath contains this file"], $output_handler); $bail=1; #only flag to bail, present as many messages as possible to user } } @@ -3058,17 +3019,17 @@ sub cpNetbootImages { if (-r "$srcDir/image.tgz") { #it still may work without image.tgz if profile customization has everything replaced mkdir($tmpDir); chdir($tmpDir); - sendmsg("extracting netboot files from OS image. This may take about a minute or two...hopefully you have ~1GB free in your /tmp dir\n"); + xCAT::SvrUtils::sendmsg("extracting netboot files from OS image. This may take about a minute or two...hopefully you have ~1GB free in your /tmp dir\n", $output_handler); my $cmd = "tar zxvf $srcDir/image.tgz"; print "\n$cmd\n"; if(system("tar zxf $srcDir/image.tgz")){ - sendmsg([1,"Unable to extract $srcDir/image.tgz\n"]); + xCAT::SvrUtils::sendmsg([1,"Unable to extract $srcDir/image.tgz\n"], $output_handler); } # this has the big image and may take a while. # this should now create: # /tmp/xcat.1234/usr/lib/vmware/installer/VMware-VMvisor-big-164009-x86_64.dd.bz2 or some other version. We need to extract partition 5 from it. system("bunzip2 $tmpDir/usr/lib/vmware/installer/*bz2"); - sendmsg("finished extracting, now copying files...\n"); + xCAT::SvrUtils::sendmsg("finished extracting, now copying files...\n", $output_handler); # now we need to get partition 5 which has the installation goods in it. my $scmd = "fdisk -lu $tmpDir/usr/lib/vmware/installer/*dd 2>&1 | grep dd5 | awk '{print \$2}'"; @@ -3080,7 +3041,7 @@ sub cpNetbootImages { my $mntcmd = "mount $tmpDir/usr/lib/vmware/installer/*dd /mnt/xcat -o loop,offset=$offset"; print "$mntcmd\n"; if(system($mntcmd)){ - sendmsg([1,"unable to mount partition 5 of the ESX netboot image to /mnt/xcat"]); + xCAT::SvrUtils::sendmsg([1,"unable to mount partition 5 of the ESX netboot image to /mnt/xcat"], $output_handler); return; } @@ -3089,7 +3050,7 @@ sub cpNetbootImages { } if(system("cp /mnt/xcat/* $destDir/")){ - sendmsg([1,"Could not copy netboot contents to $destDir"]); + xCAT::SvrUtils::sendmsg([1,"Could not copy netboot contents to $destDir"], $output_handler); system("umount /mnt/xcat"); return; } @@ -3106,9 +3067,9 @@ sub cpNetbootImages { foreach ("$srcDir/cim.vgz","$srcDir/vmkernel.gz","$srcDir/vmkboot.gz","$srcDir/sys.vgz","$srcDir/sys.vgz") { my $mod = scalar fileparse($_); if ($mod =~ /vmkernel.gz/) { - copy($_,"$destDir/vmk.gz") or sendmsg([1,"Could not copy netboot contents from $_ to $destDir/$mod"]); + copy($_,"$destDir/vmk.gz") or xCAT::SvrUtils::sendmsg([1,"Could not copy netboot contents from $_ to $destDir/$mod"], $output_handler); } else { - copy($_,"$destDir/$mod") or sendmsg([1,"Could not copy netboot contents from $_ to $destDir/$mod"]); + copy($_,"$destDir/$mod") or xCAT::SvrUtils::sendmsg([1,"Could not copy netboot contents from $_ to $destDir/$mod"], $output_handler); } } @@ -3120,17 +3081,17 @@ sub cpNetbootImages { my $mod = scalar fileparse($_); if ($mod =~ /gz\z/ and $mod !~ /pkgdb.tgz/ and $mod !~ /vmkernel.gz/) { $modulestoadd->{$mod}=1; - copy($_,"$destDir/$mod") or sendmsg([1,"Could not copy netboot contents from $overridedir to $destDir"]); + copy($_,"$destDir/$mod") or xCAT::SvrUtils::sendmsg([1,"Could not copy netboot contents from $overridedir to $destDir"], $output_handler); } elsif ($mod =~ /vmkernel.gz/) { $modulestoadd->{"vmk.gz"}=1; - copy($_,"$destDir/vmk.gz") or sendmsg([1,"Could not copy netboot contents from $overridedir to $destDir"]); + copy($_,"$destDir/vmk.gz") or xCAT::SvrUtils::sendmsg([1,"Could not copy netboot contents from $overridedir to $destDir"], $output_handler); } } } }else{ - sendmsg([1,"VMware $osver is not supported for netboot"]); + xCAT::SvrUtils::sendmsg([1,"VMware $osver is not supported for netboot"], $output_handler); } } diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index b0692b098..c7d7693d6 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -450,7 +450,7 @@ sub on_bmc_connect { my $sessdata = shift; my $command = $sessdata->{command}; if ($status =~ /ERROR:/) { - sendmsg([1,$status],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,$status],$callback,$sessdata->{node},%allerrornodes); return; } #ok, detect some common prereqs here, notably: @@ -474,7 +474,7 @@ sub on_bmc_connect { } } if($command eq "ping") { - sendmsg("ping",$sessdata->{node}); + xCAT::SvrUtils::sendmsg("ping",$callback,$sessdata->{node},%allerrornodes); return; } if ($command eq "rpower") { @@ -598,17 +598,17 @@ sub resetedbmc { my $rsp = shift; my $sessdata = shift; if ($rsp->{error}) { - sendmsg([1,$rsp->{error}],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,$rsp->{error}],$callback,$sessdata->{node},%allerrornodes); } else { if ($rsp->{code}) { if ($codes{$rsp->{code}}) { - sendmsg([1,$codes{$rsp->{code}}],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,$codes{$rsp->{code}}],$callback,$sessdata->{node},%allerrornodes); } else { - sendmsg([1,sprintf("Unknown error %02xh",$rsp->{code})],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,sprintf("Unknown error %02xh",$rsp->{code})],$callback,$sessdata->{node},%allerrornodes); } return; } - sendmsg("BMC reset",$sessdata->{node}); + xCAT::SvrUtils::sendmsg("BMC reset",$callback,$sessdata->{node},%allerrornodes); $sessdata->{ipmisession} = undef; #throw away now unusable session } } @@ -699,14 +699,14 @@ sub netinfo_set { my $rsp = shift; my $sessdata = shift; if ($rsp->{error}) { - sendmsg([1,$rsp->{error}],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,$rsp->{error}],$callback,$sessdata->{node},%allerrornodes); return; } if ($rsp->{code}) { if ($codes{$rsp->{code}}) { - sendmsg([1,$codes{$rsp->{code}}],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,$codes{$rsp->{code}}],$callback,$sessdata->{node},%allerrornodes); } else { - sendmsg([1,sprintf("Unknown ipmi error %02xh",$rsp->{code})],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,sprintf("Unknown ipmi error %02xh",$rsp->{code})],$callback,$sessdata->{node},%allerrornodes); } return; } @@ -791,14 +791,14 @@ sub getnetinfo_response { my $subcommand = $sessdata->{subcommand}; $sessdata->{subcommand} = shift @{$sessdata->{extraargs}}; if ($rsp->{error}) { - sendmsg([1,$rsp->{error}],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,$rsp->{error}],$callback,$sessdata->{node},%allerrornodes); return; } if ($rsp->{code}) { if ($codes{$rsp->{code}}) { - sendmsg([1,$codes{$rsp->{code}}],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,$codes{$rsp->{code}}],$callback,$sessdata->{node},%allerrornodes); } else { - sendmsg([1,sprintf("Unknown ipmi error %02xh",$rsp->{code})],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,sprintf("Unknown ipmi error %02xh",$rsp->{code})],$callback,$sessdata->{node},%allerrornodes); } return; } @@ -809,50 +809,50 @@ sub getnetinfo_response { my $format = "%-25s"; if($subcommand eq "garp") { my $code = $returnd[2] / 2; - sendmsg(sprintf("$format %d","Gratuitous ARP seconds:",$code),$sessdata->{node}); + xCAT::SvrUtils::sendmsg(sprintf("$format %d","Gratuitous ARP seconds:",$code),$callback,$sessdata->{node},%allerrornodes); } elsif($subcommand eq "alert") { if ($returnd[3] & 0x8) { - sendmsg("SP Alerting: enabled",$sessdata->{node}); + xCAT::SvrUtils::sendmsg("SP Alerting: enabled",$callback,$sessdata->{node},%allerrornodes); } else { - sendmsg("SP Alerting: disabled",$sessdata->{node}); + xCAT::SvrUtils::sendmsg("SP Alerting: disabled",$callback,$sessdata->{node},%allerrornodes); } } elsif($subcommand =~ m/^snmpdest(\d+)/ ) { - sendmsg(sprintf("$format %d.%d.%d.%d", + xCAT::SvrUtils::sendmsg(sprintf("$format %d.%d.%d.%d", "SP SNMP Destination $1:", $returnd[5], $returnd[6], $returnd[7], - $returnd[8]),$sessdata->{node}); + $returnd[8]),$callback,$sessdata->{node},%allerrornodes); } elsif($subcommand eq "ip") { - sendmsg(sprintf("$format %d.%d.%d.%d", + xCAT::SvrUtils::sendmsg(sprintf("$format %d.%d.%d.%d", "BMC IP:", $returnd[2], $returnd[3], $returnd[4], - $returnd[5]),$sessdata->{node}); + $returnd[5]),$callback,$sessdata->{node},%allerrornodes); } elsif($subcommand eq "netmask") { - sendmsg(sprintf("$format %d.%d.%d.%d", + xCAT::SvrUtils::sendmsg(sprintf("$format %d.%d.%d.%d", "BMC Netmask:", $returnd[2], $returnd[3], $returnd[4], - $returnd[5]),$sessdata->{node}); + $returnd[5]),$callback,$sessdata->{node},%allerrornodes); } elsif($subcommand eq "gateway") { - sendmsg(sprintf("$format %d.%d.%d.%d", + xCAT::SvrUtils::sendmsg(sprintf("$format %d.%d.%d.%d", "BMC Gateway:", $returnd[2], $returnd[3], $returnd[4], - $returnd[5]),$sessdata->{node}); + $returnd[5]),$callback,$sessdata->{node},%allerrornodes); } elsif($subcommand eq "backupgateway") { - sendmsg(sprintf("$format %d.%d.%d.%d", + xCAT::SvrUtils::sendmsg(sprintf("$format %d.%d.%d.%d", "BMC Backup Gateway:", $returnd[2], $returnd[3], $returnd[4], - $returnd[5]),$sessdata->{node}); + $returnd[5]),$callback,$sessdata->{node},%allerrornodes); } elsif ($subcommand eq "community") { my $text = sprintf("$format ","SP SNMP Community:"); my $l = 2; @@ -864,7 +864,7 @@ sub getnetinfo_response { $text = $text . sprintf("%c",$returnd[$i]); $i = $i + 1; } - sendmsg($text,$sessdata->{node}); + xCAT::SvrUtils::sendmsg($text,$callback,$sessdata->{node},%allerrornodes); } if ($sessdata->{subcommand}) { if ($sessdata->{subcommand} =~ /=/) { @@ -885,17 +885,17 @@ sub setboot_timerdisabled { my $rsp = shift; my $sessdata = shift; if ($rsp->{error}) { - sendmsg([1,$rsp->{error}],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,$rsp->{error}],$callback,$sessdata->{node},%allerrornodes); return; } if ($rsp->{code}) { if ($codes{$rsp->{code}}) { - sendmsg([1,$codes{$rsp->{code}}],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,$codes{$rsp->{code}}],$callback,$sessdata->{node},%allerrornodes); return; } elsif ($rsp->{code} == 0x80) { - sendmsg("Unable to disable countdown timer, boot device may revert in 60 seconds",$sessdata->{node}); + xCAT::SvrUtils::sendmsg("Unable to disable countdown timer, boot device may revert in 60 seconds",$callback,$sessdata->{node},%allerrornodes); } else { - sendmsg([1,sprintf("Unknown ipmi error %02xh",$rsp->{code})],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,sprintf("Unknown ipmi error %02xh",$rsp->{code})],$callback,$sessdata->{node},%allerrornodes); return; } } @@ -908,7 +908,7 @@ sub setboot_timerdisabled { 'p' => \$persistent, 'u' => \$uefi, )) { - sendmsg([1,"Error parsing arguments"],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,"Error parsing arguments"],$callback,$sessdata->{node},%allerrornodes); return; } my $subcommand=shift @ARGV; @@ -938,7 +938,7 @@ sub setboot_timerdisabled { return; } else { - sendmsg([1,"unsupported command setboot $subcommand"],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,"unsupported command setboot $subcommand"],$callback,$sessdata->{node},%allerrornodes); } $sessdata->{ipmisession}->subcmd(netfn=>0,command=>8,data=>\@cmd,callback=>\&setboot_stat,callback_args=>$sessdata); } @@ -946,12 +946,12 @@ sub setboot_stat { my $rsp = shift; my $sessdata = shift; if (ref $rsp) { - if ($rsp->{error}) { sendmsg([1,$rsp->{error}],$sessdata->{node}); } + if ($rsp->{error}) { xCAT::SvrUtils::sendmsg([1,$rsp->{error}],$callback,$sessdata->{node},%allerrornodes); } elsif ($rsp->{code}) { if ($codes{$rsp->{code}}) { - sendmsg([1,$codes{$rsp->{code}}],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,$codes{$rsp->{code}}],$callback,$sessdata->{node},%allerrornodes); } else { - sendmsg([1,sprintf("Unknown ipmi error %02xh",$rsp->{code})],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,sprintf("Unknown ipmi error %02xh",$rsp->{code})],$callback,$sessdata->{node},%allerrornodes); } return; } @@ -961,12 +961,12 @@ sub setboot_stat { sub setboot_gotstat { my $rsp = shift; my $sessdata = shift; - if ($rsp->{error}) { sendmsg([1,$rsp->{error}],$sessdata->{node}); } + if ($rsp->{error}) { xCAT::SvrUtils::sendmsg([1,$rsp->{error}],$callback,$sessdata->{node},%allerrornodes); } elsif ($rsp->{code}) { if ($codes{$rsp->{code}}) { - sendmsg([1,$codes{$rsp->{code}}],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,$codes{$rsp->{code}}],$callback,$sessdata->{node},%allerrornodes); } else { - sendmsg([1,sprintf("Unknown ipmi error %02xh",$rsp->{code})],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,sprintf("Unknown ipmi error %02xh",$rsp->{code})],$callback,$sessdata->{node},%allerrornodes); } return; } @@ -980,11 +980,11 @@ sub setboot_gotstat { ); my @returnd = ($rsp->{code},@{$rsp->{data}}); unless ($returnd[3] & 0x80) { - sendmsg("boot override inactive",$sessdata->{node}); + xCAT::SvrUtils::sendmsg("boot override inactive",$callback,$sessdata->{node},%allerrornodes); return; } my $boot=($returnd[4] & 0x3C) >> 2; - sendmsg($bootchoices{$boot},$sessdata->{node}); + xCAT::SvrUtils::sendmsg($bootchoices{$boot},$callback,$sessdata->{node},%allerrornodes); return; } @@ -1027,12 +1027,12 @@ sub getrvidparms { } $response = $browser->request(GET $baseurl."/Java/jviewer.jnlp?ext_ip=".$sessdata->{ipmisession}->{bmc}); $response = $response->content; - sendmsg("method:imm",$sessdata->{node}); - sendmsg("jnlp:$response",$sessdata->{node}); + xCAT::SvrUtils::sendmsg("method:imm",$callback,$sessdata->{node},%allerrornodes); + xCAT::SvrUtils::sendmsg("jnlp:$response",$callback,$sessdata->{node},%allerrornodes); return; } unless ($sessdata->{mfg_id} == 2) { #Only implemented for IBM servers - sendmsg([1,"Remote video is not supported on this system"],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,"Remote video is not supported on this system"],$callback,$sessdata->{node},%allerrornodes); return; } #TODO: use get bmc capabilities to see if rvid is actually supported before bothering the client java app @@ -1042,14 +1042,14 @@ sub check_rsp_errors { #TODO: pass in command-specfic error code translation tab my $rsp = shift; my $sessdata = shift; if($rsp->{error}) { #non ipmi error - sendmsg([1,$rsp->{error}],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,$rsp->{error}],$callback,$sessdata->{node},%allerrornodes); return 1; } if ($rsp->{code}) { #ipmi error if ($codes{$rsp->{code}}) { - sendmsg([1,$codes{$rsp->{code}}]); + xCAT::SvrUtils::sendmsg([1,$codes{$rsp->{code}}],$callback); } else { - sendmsg([1,sprintf("Unknown error code %02xh",$rsp->{code})],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,sprintf("Unknown error code %02xh",$rsp->{code})],$callback,$sessdata->{node},%allerrornodes); } return 1; } @@ -1063,7 +1063,7 @@ sub getrvidparms_with_buildid { my $sessdata = shift; my @build_id = (0,@{$rsp->{data}}); unless ($build_id[1]==0x59 and $build_id[2]==0x55 and $build_id[3]==0x4f and $build_id[4]==0x4f) { #Only know how to cope with yuoo builds - sendmsg([1,"Remote video is not supported on this system"],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,"Remote video is not supported on this system"],$callback,$sessdata->{node},%allerrornodes); return; } #wvid should be a possiblity, time to do the http... @@ -1073,7 +1073,7 @@ sub getrvidparms_with_buildid { my $baseurl = "http://".$sessdata->{ipmisession}->{bmc}."/"; my $response = $browser->request(POST $baseurl."/session/create",'Content-Type'=>"text/xml",Content=>$message); unless ($response->content eq "ok") { - sendmsg ([1,"Server returned unexpected data"],$sessdata->{node}); + sendmsg ([1,"Server returned unexpected data"],$callback,$sessdata->{node},%allerrornodes); return; } @@ -1081,16 +1081,16 @@ sub getrvidparms_with_buildid { $response = $browser->request(GET $baseurl."/kvm/kvm/jnlp"); my $jnlp = $response->content; if ($jnlp =~ /This advanced option requires the purchase and installation/) { - sendmsg ([1,"Node does not have feature key for remote video"],$sessdata->{node}); + sendmsg ([1,"Node does not have feature key for remote video"],$sessdata->{node},%allerrornodes); } my $currnode = $sessdata->{node}; $jnlp =~ s!argument>title=.*Video Viewer!argument>title=$currnode wvid!; - sendmsg("method:imm",$sessdata->{node}); - sendmsg("jnlp:$jnlp",$sessdata->{node}); + xCAT::SvrUtils::sendmsg("method:imm",$callback,$sessdata->{node},%allerrornodes); + xCAT::SvrUtils::sendmsg("jnlp:$jnlp",$callback,$sessdata->{node},%allerrornodes); my @cmdargv = @{$sessdata->{extraargs}}; if (grep /-m/,@cmdargv) { $response = $browser->request(GET $baseurl."/kvm/vm/jnlp"); - sendmsg("mediajnlp:".$response->content,$sessdata->{node});; + xCAT::SvrUtils::sendmsg("mediajnlp:".$response->content,$callback,$sessdata->{node},%allerrornodes);; } return; } @@ -1113,21 +1113,21 @@ sub power_with_context { my $sessdata = shift; my $text=""; if ($rsp->{error}) { - sendmsg([1,$rsp->{error}],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,$rsp->{error}],$callback,$sessdata->{node},%allerrornodes); return; } if ($rsp->{code} != 0) { $text = $codes{$rsp->{code}}; unless ($text) { $text = sprintf("Unknown error code %02xh",$rsp->{code}); } - sendmsg([1,$text],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,$text],$callback,$sessdata->{node},%allerrornodes); return; } $sessdata->{powerstatus} = ($rsp->{data}->[0] & 1 ? "on" : "off"); if ($sessdata->{subcommand} eq "stat" or $sessdata->{subcommand} eq "state" or $sessdata->{subcommand} eq "status") { if ($sessdata->{powerstatprefix}) { - sendmsg($sessdata->{powerstatprefix}.$sessdata->{powerstatus},$sessdata->{node}); + xCAT::SvrUtils::sendmsg($sessdata->{powerstatprefix}.$sessdata->{powerstatus},$callback,$sessdata->{node},%allerrornodes); } else { - sendmsg($sessdata->{powerstatus},$sessdata->{node}); + xCAT::SvrUtils::sendmsg($sessdata->{powerstatus},$callback,$sessdata->{node},%allerrornodes); } if ($sessdata->{sensorstoread} and scalar @{$sessdata->{sensorstoread}}) { #if we are in an rvitals path, hook back into good graces $sessdata->{currsdr} = shift @{$sessdata->{sensorstoread}}; @@ -1150,18 +1150,18 @@ sub power_with_context { ); if($subcommand eq "on") { if ($sessdata->{powerstatus} eq "on") { - sendmsg("on",$sessdata->{node}); + xCAT::SvrUtils::sendmsg("on",$callback,$sessdata->{node},%allerrornodes); $allerrornodes{$sessdata->{node}}=1; return; # don't bother sending command } } elsif ($subcommand eq "softoff" or $subcommand eq "off" or $subcommand eq "reset") { if ($sessdata->{powerstatus} eq "off") { - sendmsg("off",$sessdata->{node}); + xCAT::SvrUtils::sendmsg("off",$callback,$sessdata->{node},%allerrornodes); $allerrornodes{$sessdata->{node}}=1; return; } } elsif (not $argmap{$subcommand}) { - sendmsg([1,"unsupported command power $subcommand"]); + xCAT::SvrUtils::sendmsg([1,"unsupported command power $subcommand"],$callback); return; } @@ -1171,16 +1171,16 @@ sub power_response { my $rsp = shift; my $sessdata = shift; if($rsp->{error}) { - sendmsg([1,$rsp->{error}],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,$rsp->{error}],$callback,$sessdata->{node},%allerrornodes); return; } my @returnd = ($rsp->{code},@{$rsp->{data}}); if ($rsp->{code}) { my $text = $codes{$rsp->{code}}; unless ($text) { $text = sprintf("Unknown response %02xh",$rsp->{code}); } - sendmsg([1,$text],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,$text],$callback,$sessdata->{node},%allerrornodes); } - sendmsg($sessdata->{subcommand},$sessdata->{node}); + xCAT::SvrUtils::sendmsg($sessdata->{subcommand},$callback,$sessdata->{node},%allerrornodes); } sub generic { @@ -1253,7 +1253,7 @@ sub beacon { $ipmiv2 = 1; } if($subcommand ne "on" and $subcommand ne "off"){ - sendmsg([1,"please specify on or off for ipmi nodes (stat impossible)"],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,"please specify on or off for ipmi nodes (stat impossible)"],$callback,$sessdata->{node},%allerrornodes); } #if stuck with 1.5, say light for 255 seconds. In 2.0, specify to turn it on forever @@ -1280,18 +1280,18 @@ sub beacon_answer { my $sessdata = shift; if($rsp->{error}) { #non ipmi error - sendmsg([1,$rsp->{error}],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,$rsp->{error}],$callback,$sessdata->{node},%allerrornodes); return; } if ($rsp->{code}) { #ipmi error if ($codes{$rsp->{code}}) { - sendmsg([1,$codes{$rsp->{code}}]); + xCAT::SvrUtils::sendmsg([1,$codes{$rsp->{code}}],$callback); } else { - sendmsg([1,sprintf("Unknown error code %02xh",$rsp->{code})],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,sprintf("Unknown error code %02xh",$rsp->{code})],$callback,$sessdata->{node},%allerrornodes); } return; } - sendmsg($sessdata->{subcommand},$sessdata->{node}); + xCAT::SvrUtils::sendmsg($sessdata->{subcommand},$callback,$sessdata->{node},%allerrornodes); } sub inv { @@ -1364,7 +1364,7 @@ sub fru_initted { my $type; foreach $type (split /,/,$fru->rec_type) { if(grep {$_ eq $type} @types) { - sendmsg(sprintf($format,$sessdata->{fru_hash}->{$key}->desc . ":",$sessdata->{fru_hash}->{$key}->value),$sessdata->{node}); + xCAT::SvrUtils::sendmsg(sprintf($format,$sessdata->{fru_hash}->{$key}->desc . ":",$sessdata->{fru_hash}->{$key}->value),$callback,$sessdata->{node},%allerrornodes); last; } } @@ -1521,7 +1521,7 @@ sub get_uefi_version_with_xid { my $sessdata = shift; my @data = @{$rsp->{data}}; if ($data[2] != 0 or $data[3] != 5 or $data[4] != 0x44) { - sendmsg([1,"Error1 retrieving UEFI build version"],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,"Error1 retrieving UEFI build version"],$callback,$sessdata->{node},%allerrornodes); return; } splice @data,0,5; @@ -1537,7 +1537,7 @@ sub waitfor_openxid { my $sessdata = shift; my @data = @{$rsp->{data}}; if ($data[2] != 0) { - sendmsg([1,"Error2 retrieving UEFI build version"],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,"Error2 retrieving UEFI build version"],$callback,$sessdata->{node},%allerrornodes); $sessdata->{ipmisession}->subcmd(netfn=>0x3a,command=>0xf0,data=>[0x4,0,0,0x05,0x44,@{$sessdata->{fmapixid}}],callback=>\&fmapi_xid_closed,callback_args=>$sessdata); return; } @@ -1555,7 +1555,7 @@ sub got_uefi_buildid { my $sessdata = shift; my @data = @{$rsp->{data}}; if ($data[2] != 0) { - sendmsg([1,"Error3 retrieving UEFI build version"],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,"Error3 retrieving UEFI build version"],$callback,$sessdata->{node},%allerrornodes); $sessdata->{ipmisession}->subcmd(netfn=>0x3a,command=>0xf0,data=>[0x4,0,0,0x05,0x44,@{$sessdata->{fmapixid}}],callback=>\&fmapi_xid_closed,callback_args=>$sessdata); return; } @@ -1572,7 +1572,7 @@ sub got_uefi_buildversion { my $sessdata = shift; my @data = @{$rsp->{data}}; if ($data[2] != 0) { - sendmsg([1,"Error4 retrieving UEFI build version"],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,"Error4 retrieving UEFI build version"],$callback,$sessdata->{node},%allerrornodes); $sessdata->{ipmisession}->subcmd(netfn=>0x3a,command=>0xf0,data=>[0x4,0,0,0x05,0x44,@{$sessdata->{fmapixid}}],callback=>\&fmapi_xid_closed,callback_args=>$sessdata); return; } @@ -1589,7 +1589,7 @@ sub got_uefi_builddate { my $sessdata = shift; my @data = @{$rsp->{data}}; if ($data[2] != 0) { - sendmsg([1,"Error5 retrieving UEFI build version"],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,"Error5 retrieving UEFI build version"],$callback,$sessdata->{node},%allerrornodes); $sessdata->{ipmisession}->subcmd(netfn=>0x3a,command=>0xf0,data=>[0x4,0,0,0x05,0x44,@{$sessdata->{fmapixid}}],callback=>\&fmapi_xid_closed,callback_args=>$sessdata); return; } @@ -2111,7 +2111,7 @@ sub add_fruhash { my $err; ($err,$fruhash) = parsefru($sessdata->{currfrudata}); if ($err) { - sendmsg([1,":Error reading fru area ".$sessdata->{currfruid}.": $err"]); + xCAT::SvrUtils::sendmsg([1,":Error reading fru area ".$sessdata->{currfruid}.": $err"],$callback); return; } } @@ -2162,7 +2162,7 @@ sub readcurrfrudevice { } my @data = @{$rsp->{data}}; if ($data[0] != $sessdata->{currfruchunk}) { - sendmsg([1,"Received incorrect data from BMC"],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,"Received incorrect data from BMC"],$callback,$sessdata->{node},%allerrornodes); return; } shift @data; @@ -2472,7 +2472,7 @@ sub extractfield { #idx is location of the type/length byte, returns something a my $language=shift; my $data; if ($idx >= scalar @$area) { - sendmsg([1,"Error parsing FRU data from BMC"]); + xCAT::SvrUtils::sendmsg([1,"Error parsing FRU data from BMC"],$callback); return 1,undef,undef; } my $size = $area->[$idx] & 0b00111111; @@ -2873,20 +2873,20 @@ sub eventlog_with_selinfo { my $sel_version = $returnd[1]; if($sel_version != 0x51) { - sendmsg(sprintf("SEL version 51h support only, version reported: %x",$sel_version),$sessdata->{node}); + xCAT::SvrUtils::sendmsg(sprintf("SEL version 51h support only, version reported: %x",$sel_version),$callback,$sessdata->{node},%allerrornodes); return; } hexdump(\@returnd); my $num_entries = ($returnd[3]<<8) + $returnd[2]; if($num_entries <= 0) { - sendmsg("no SEL entries",$sessdata->{node}); + xCAT::SvrUtils::sendmsg("no SEL entries",$callback,$sessdata->{node},%allerrornodes); return; } my $canres = $returnd[14] & 0b00000010; if(!$canres) { - sendmsg([1,"SEL reservation not supported"],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,"SEL reservation not supported"],$callback,$sessdata->{node},%allerrornodes); return; } @@ -2939,7 +2939,7 @@ sub got_sel { $text.=" With additional data:\n".$sessdata->{auxloginfo}->{$entry}; } if ($sessdata->{fullsel}) { - sendmsg($text,$sessdata->{node}); + xCAT::SvrUtils::sendmsg($text,$callback,$sessdata->{node},%allerrornodes); } else { push(@{$sessdata->{selentries}},$text); } @@ -3062,9 +3062,9 @@ sub got_sel { if ($sessdata->{auxloginfo} and $sessdata->{auxloginfo}->{$entry}) { $text.=" with additional data:"; if ($sessdata->{fullsel}) { - sendmsg($text,$sessdata->{node}); + xCAT::SvrUtils::sendmsg($text,$callback,$sessdata->{node},%allerrornodes); foreach (split /\n/,$sessdata->{auxloginfo}->{$entry}) { - sendmsg(0,$_,$sessdata->{node}); + xCAT::SvrUtils::sendmsg($_,$sessdata->{node}); } } else { push(@{$sessdata->{selentries}},$text); @@ -3073,7 +3073,7 @@ sub got_sel { } else { if ($sessdata->{fullsel}) { - sendmsg($text,$sessdata->{node}); + xCAT::SvrUtils::sendmsg($text,$callback,$sessdata->{node},%allerrornodes); } else { push(@{$sessdata->{selentries}},$text); } @@ -3122,7 +3122,7 @@ sub wait_for_selerase { my $sessdata = shift; my @returnd = (0,@{$rsp->{data}}); my $erase_status = $returnd[1] & 0b00000001; - sendmsg("SEL cleared",$sessdata->{node}); + xCAT::SvrUtils::sendmsg("SEL cleared",$callback,$sessdata->{node},%allerrornodes); } #commenting out usless 'while 0' loop. @@ -3666,7 +3666,7 @@ sub ieminitted { sub readenergy { my $sessdata = shift; unless ($iem_support) { - sendmsg([1,"IBM::EnergyManager package required for this value"],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,"IBM::EnergyManager package required for this value"],$callback,$sessdata->{node},%allerrornodes); return; } my @entries; @@ -3688,7 +3688,7 @@ sub got_ac_energy { sub got_ac_energy_with_precision { my $sessdata=shift; $sessdata->{iemtextdata} .= sprintf(" +/-%.1f%%",$sessdata->{iem}->energy_ac_precision()*0.1); #note while \x{B1} would be cool, it's non-trivial to support - sendmsg($sessdata->{iemtextdata},$sessdata->{node}); + xCAT::SvrUtils::sendmsg($sessdata->{iemtextdata},$callback,$sessdata->{node},%allerrornodes); $sessdata->{iem}->prep_get_dc_energy(); $sessdata->{iemcallback} = \&got_dc_energy; process_data_from_iem($sessdata); @@ -3696,7 +3696,7 @@ sub got_ac_energy_with_precision { sub got_dc_energy { my $sessdata = shift; $sessdata->{iemtextdata} .= sprintf(" +/-%.1f%%",$sessdata->{iem}->energy_dc_precision()*0.1); - sendmsg($sessdata->{iemtextdata},$sessdata->{node}); + xCAT::SvrUtils::sendmsg($sessdata->{iemtextdata},$callback,$sessdata->{node},%allerrornodes); if (scalar @{$sessdata->{sensorstoread}}) { $sessdata->{currsdr} = shift @{$sessdata->{sensorstoread}}; readsensor($sessdata); #next sensor @@ -3773,7 +3773,7 @@ sub checkleds { my $mfg_id=$sessdata->{mfg_id}; #TODO device id if ($mfg_id != 2) { - sendmsg("LED status not supported on this system",$sessdata->{node}); + xCAT::SvrUtils::sendmsg("LED status not supported on this system",$callback,$sessdata->{node},%allerrornodes); return; } @@ -3808,7 +3808,7 @@ sub checkleds { $sessdata->{current_led_sdr} = pop @{$sessdata->{doled}}; $sessdata->{ipmisession}->subcmd(netfn=>0x3a,command=>0xc0,data=>$sessdata->{doled},callback=>\&did_led,callback_args=>$sessdata); } else { - sendmsg("No supported LEDs found in system",$sessdata->{node}); + xCAT::SvrUtils::sendmsg("No supported LEDs found in system",$callback,$sessdata->{node},%allerrornodes); } # if ($#output==-1) { # push(@output,"No active error LEDs detected"); @@ -3843,19 +3843,19 @@ sub did_led { if ($returnd[2]) { # != 0) { #It's on... if ($returnd[6] == 4) { - sendmsg(sprintf("BIOS or admininstrator has %s lit",getsensorname($mfg_id,$prod_id,$sdr->led_id,"ibmleds")),$sessdata->{node}); + xCAT::SvrUtils::sendmsg(sprintf("BIOS or admininstrator has %s lit",getsensorname($mfg_id,$prod_id,$sdr->led_id,"ibmleds")),$callback,$sessdata->{node},%allerrornodes); $sessdata->{activeleds}=1; } elsif ($returnd[6] == 3) { - sendmsg(sprintf("A user has manually requested LED 0x%04x (%s) be active",$sdr->led_id,getsensorname($mfg_id,$prod_id,$sdr->led_id,"ibmleds")),$sessdata->{node}); + xCAT::SvrUtils::sendmsg(sprintf("A user has manually requested LED 0x%04x (%s) be active",$sdr->led_id,getsensorname($mfg_id,$prod_id,$sdr->led_id,"ibmleds")),$callback,$sessdata->{node},%allerrornodes); $sessdata->{activeleds}=1; } elsif ($returnd[6] == 1 && $sdr->led_id !=0) { - sendmsg(sprintf("LED 0x%02x%02x (%s) active to indicate LED 0x%02x%02x (%s) is active",$led_id_ms,$led_id_ls,getsensorname($mfg_id,$prod_id,$sdr->led_id,"ibmleds"),$returnd[4],$returnd[5],getsensorname($mfg_id,$prod_id,($returnd[4]<<8)+$returnd[5],"ibmleds")),$sessdata->{node}); + xCAT::SvrUtils::sendmsg(sprintf("LED 0x%02x%02x (%s) active to indicate LED 0x%02x%02x (%s) is active",$led_id_ms,$led_id_ls,getsensorname($mfg_id,$prod_id,$sdr->led_id,"ibmleds"),$returnd[4],$returnd[5],getsensorname($mfg_id,$prod_id,($returnd[4]<<8)+$returnd[5],"ibmleds")),$callback,$sessdata->{node},%allerrornodes); $sessdata->{activeleds}=1; } elsif ($sdr->led_id ==0) { - sendmsg(sprintf("LED 0x0000 (%s) active to indicate system error condition.",getsensorname($mfg_id,$prod_id,$sdr->led_id,"ibmleds")),$sessdata->{node}); + xCAT::SvrUtils::sendmsg(sprintf("LED 0x0000 (%s) active to indicate system error condition.",getsensorname($mfg_id,$prod_id,$sdr->led_id,"ibmleds")),$callback,$sessdata->{node},%allerrornodes); $sessdata->{activeleds}=1; } elsif ($returnd[6] == 2) { @@ -3873,7 +3873,7 @@ sub did_led { } } #push(@output,sprintf("Sensor 0x%02x (%s) has activated LED 0x%04x",$sensor_num,$sensor_desc,$sdr->led_id)); - sendmsg(sprintf("LED 0x%02x%02x active to indicate Sensor 0x%02x (%s) error.",$led_id_ms,$led_id_ls,$sensor_num,$sensor_desc),$sessdata->{node}); + xCAT::SvrUtils::sendmsg(sprintf("LED 0x%02x%02x active to indicate Sensor 0x%02x (%s) error.",$led_id_ms,$led_id_ls,$sensor_num,$sensor_desc),$callback,$sessdata->{node},%allerrornodes); $sessdata->{activeleds}=1; } else { #an LED is on for some other reason print "DEBUG: unknown LED reason code ".$returnd[6]."\n"; @@ -3886,7 +3886,7 @@ sub did_led { $sessdata->{current_led_sdr} = pop @{$sessdata->{doled}}; $sessdata->{ipmisession}->subcmd(netfn=>0x3a,command=>0xc0,data=>$sessdata->{doled},callback=>\&did_led,callback_args=>$sessdata); } elsif (not $sessdata->{activeleds}) { - sendmsg("No active error LEDs detected",$sessdata->{node}); + xCAT::SvrUtils::sendmsg("No active error LEDs detected",$callback,$sessdata->{node},%allerrornodes); } if (scalar @{$sessdata->{sensorstoread}}) { $sessdata->{currsdr} = shift @{$sessdata->{sensorstoread}}; @@ -3916,19 +3916,19 @@ sub renergy_withiem { my @settable_keys = qw/savingstatus cappingstatus cappingwatt cappingvalue/; my $directive = shift (@{$sessdata->{directives}}); if ($sessdata->{iemtextdata}) { - sendmsg($sessdata->{iemtextdata},$sessdata->{node}); + xCAT::SvrUtils::sendmsg($sessdata->{iemtextdata},$callback,$sessdata->{node},%allerrornodes); $sessdata->{iemtextdata}=""; } if ($sessdata->{gotcapstatus}) { $sessdata->{gotcapstatus}=0; my $capenabled = $sessdata->{iem}->capping_enabled(); - sendmsg("cappingstatus: ".($capenabled ? "on" : "off"),$sessdata->{node}); + xCAT::SvrUtils::sendmsg("cappingstatus: ".($capenabled ? "on" : "off"),$callback,$sessdata->{node},%allerrornodes); } if ($sessdata->{gothistogram}) { $sessdata->{gothistogram}=0; my @histdata = $sessdata->{iem}->extract_relative_histogram; foreach (sort { $a <=> $b } keys %{$histdata[0]}) { - sendmsg("$_: ".$histdata[0]->{$_},$sessdata->{node}); + xCAT::SvrUtils::sendmsg("$_: ".$histdata[0]->{$_},$callback,$sessdata->{node},%allerrornodes); } } @@ -4037,7 +4037,7 @@ sub vitals { $sensor_filters{leds}=1; } unless (keys %sensor_filters) { - sendmsg([1,"Unrecognized rvitals arguments ".join(" ",@{$sessdata->{extraargs}})],$sessdata->{node});; + xCAT::SvrUtils::sendmsg([1,"Unrecognized rvitals arguments ".join(" ",@{$sessdata->{extraargs}})],$callback,$sessdata->{node},%allerrornodes);; } $sessdata->{sensorstoread} = []; @@ -4070,7 +4070,7 @@ sub vitals { if ($iem_support) { push @{$sessdata->{sensorstoread}},"energy"; } elsif (not $doall) { - sendmsg([1,"Energy data requires additional IBM::EnergyManager plugin in conjunction with IMM managed IBM equipment"],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,"Energy data requires additional IBM::EnergyManager plugin in conjunction with IMM managed IBM equipment"],$callback,$sessdata->{node},%allerrornodes); } #my @energies; #($rc,@energies)=readenergy(); @@ -4107,7 +4107,7 @@ sub sensorformat { if ($extext) { $text="$text ($extext)"; } - sendmsg($text,$sessdata->{node}); + xCAT::SvrUtils::sendmsg($text,$callback,$sessdata->{node},%allerrornodes); if (scalar @{$sessdata->{sensorstoread}}) { $sessdata->{currsdr} = shift @{$sessdata->{sensorstoread}}; readsensor($sessdata); #next @@ -4129,7 +4129,7 @@ sub readsensor { readenergy($sessdata); return; } else { - sendmsg([1,"TODO: make ".$sessdata->{currsdr}." work again"],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,"TODO: make ".$sessdata->{currsdr}." work again"],$callback,$sessdata->{node},%allerrornodes); } return; } @@ -4141,7 +4141,7 @@ sub sensor_was_read { my $rsp = shift; my $sessdata = shift; if ($rsp->{error}) { - sendmsg([1,$rsp->{error}],$sessdata->{node}); + xCAT::SvrUtils::sendmsg([1,$rsp->{error}],$callback,$sessdata->{node},%allerrornodes); } if ($rsp->{code}) { my $text = $codes{$rsp->{code}}; @@ -5476,7 +5476,7 @@ sub donode { subcommand => $exargs[0], }; if ($sessiondata{$node}->{ipmisession}->{error}) { - sendmsg([1,$sessiondata{$node}->{ipmisession}->{error}],$node); + xCAT::SvrUtils::sendmsg([1,$sessiondata{$node}->{ipmisession}->{error}],$callback,$node,%allerrornodes); } else { my ($rc,@output) = ipmicmd($sessiondata{$node}); sendoutput($rc,@output); @@ -5487,50 +5487,6 @@ sub donode { # print $outfd $msgtoparent; } -sub sendmsg { -# my $callback = $output_handler; - my $text = shift; - my $node = shift; - my $descr; - my $rc; - if (ref $text eq 'HASH') { - die "not right now"; - } elsif (ref $text eq 'ARRAY') { - $rc = $text->[0]; - $text = $text->[1]; - } - if ($text =~ /:/) { - ($descr,$text) = split /:/,$text,2; - } - $text =~ s/^ *//; - $text =~ s/ *$//; - my $msg; - my $curptr; - if ($node) { - $msg->{node}=[{name => [$node]}]; - $curptr=$msg->{node}->[0]; - } else { - $msg = {}; - $curptr = $msg; - } - if ($rc) { - $curptr->{errorcode}=[$rc]; - $curptr->{error}=[$text]; - $curptr=$curptr->{error}->[0]; - if (defined $node) { - $allerrornodes{$node}=1; - } - } else { - $curptr->{data}=[{contents=>[$text]}]; - $curptr=$curptr->{data}->[0]; - if ($descr) { $curptr->{desc}=[$descr]; } - } -# print $outfd freeze([$msg]); -# print $outfd "\nENDOFFREEZE6sK4ci\n"; -# yield; -# waitforack($outfd); - $callback->($msg); -} sub sendoutput { my $rc=shift; foreach (@_) { diff --git a/xCAT-server/lib/xcat/plugins/ontap.pm b/xCAT-server/lib/xcat/plugins/ontap.pm index e23aadcd6..76f6d9fe0 100644 --- a/xCAT-server/lib/xcat/plugins/ontap.pm +++ b/xCAT-server/lib/xcat/plugins/ontap.pm @@ -19,6 +19,7 @@ BEGIN use lib "$::XCATROOT/lib/perl"; use warnings "all"; use xCAT::Table; +use xCAT::SvrUtils; my $output_handler; my $newiqns; my $domain; @@ -45,49 +46,12 @@ sub handled_commands { } my %iscsicfg; -sub sendmsg { #TODO: common code - my $callback = $output_handler; - my $text = shift; - my $node = shift; - my $descr; - my $rc; - if (ref $text eq 'HASH') { - return $callback->($text); - } elsif (ref $text eq 'ARRAY') { - $rc = $text->[0]; - $text = $text->[1]; - } - if ($text =~ /:/) { - ($descr,$text) = split /:/,$text,2; - } - $text =~ s/^ *//; - $text =~ s/ *$//; - my $msg; - my $curptr; - if ($node) { - $msg->{node}=[{name => [$node]}]; - $curptr=$msg->{node}->[0]; - } else { - $msg = {}; - $curptr = $msg; - } - if ($rc) { - $curptr->{errorcode}=[$rc]; - $curptr->{error}=[$text]; - $curptr=$curptr->{error}->[0]; - } else { - $curptr->{data}=[{contents=>[$text]}]; - $curptr=$curptr->{data}->[0]; - if ($descr) { $curptr->{desc}=[$descr]; } - } - $callback->($msg); -} sub process_request { my $request = shift; $output_handler = shift; $iscsitab = xCAT::Table->new('iscsi'); unless ($iscsitab) { - sendmsg([1,"iSCSI configuration lacking from the iscsi table"]); + xCAT::SvrUtils::sendmsg([1,"iSCSI configuration lacking from the iscsi table"], $output_handler); return; } my @nodes = @{$request->{node}}; @@ -97,12 +61,12 @@ sub process_request { $domain = $dent->{value}; $domain = join(".",reverse(split(/\./,$domain))); } else { - sendmsg([1,"Cannot determine domain name for iqn generation from site table"]); + xCAT::SvrUtils::sendmsg([1,"Cannot determine domain name for iqn generation from site table"], $output_handler); return; } my $nodetype =xCAT::Table->new('nodetype',-create=>0); unless ($nodetype) { - sendmsg([1,"ONTAP plugin requires nodetype table to be populated"]); + xCAT::SvrUtils::sendmsg([1,"ONTAP plugin requires nodetype table to be populated"], $output_handler); return; } $nodetypeinfo = $nodetype->getNodesAttribs(\@nodes,['os']); @@ -246,7 +210,7 @@ sub create_new_lun { imagex => 'windows' ); unless ($nodetypeinfo->{$gname}->[0]->{os}) { - sendmsg([1,"nodetype.os must be set for ONTAP plugin to create a lun"]); + xCAT::SvrUtils::sendmsg([1,"nodetype.os must be set for ONTAP plugin to create a lun"], $output_handler); } my $ltype; my $ost=$nodetypeinfo->{$gname}->[0]->{os}; @@ -265,7 +229,7 @@ sub create_new_lun { my $output; unless (($lunsize or $mspec) and $ltype and $file and $gtype) { #TODO etc - sendmsg([1,"Insufficient data"]); + xCAT::SvrUtils::sendmsg([1,"Insufficient data"], $output_handler); } if ($lunsize) { my $size = getUnits($lunsize,'g',1048576);