2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-30 09:36:41 +00:00

fix bug 3993 DFM support Powerlinux, chvm doesn't update node attributes

This commit is contained in:
zhaoertao 2014-04-10 04:07:25 -07:00
parent 207388d424
commit cea9a4e427
2 changed files with 140 additions and 26 deletions

View File

@ -16,7 +16,7 @@ use xCAT::Usage;
use xCAT::NodeRange;
use xCAT::FSPUtils;
use xCAT::VMCommon;
#use Data::Dumper;
use Data::Dumper;
use xCAT::MsgUtils qw(verbose_message);
##############################################
# Globals
@ -719,7 +719,7 @@ sub lsvm_parse_args {
$Getopt::Long::ignorecase = 0;
Getopt::Long::Configure( "bundling" );
if ( !GetOptions( \%opt, qw(V|verbose l|long p775) )) {
if ( !GetOptions( \%opt, qw(V|verbose l|long p775 updatedb) )) {
return( usage() );
}
if (exists($opt{l}) && !exists($opt{p775})) {
@ -758,6 +758,7 @@ sub modify {
return op_extra_cmds ($request, $hash) if ($request->{opt}->{lparname} || $request->{opt}->{huge_page});
return ([["Error", "Miss argument\n".$usage_string, 1]]);
}
sub do_op_extra_cmds {
my $request = shift;
my $hash = shift;
@ -1672,9 +1673,10 @@ sub parse_part_get_info {
$hash->{bus}->{$3}->{cur_lparid} = $1;
$hash->{bus}->{$3}->{bus_slot} = $2;
$hash->{bus}->{$3}->{des} = $4;
push @{$hash->{lpar_phy_bus}}, $3;
} elsif ($line =~ /Phy drc_index:(\w+), Port group: (\w+), Phy port id: (\w+)/) {
$hash->{phy_drc_group_port}->{$1}->{$2}->{$3} = '1';
} elsif ($line =~ /adapter_id=(\w+),lpar_id=([\d|-]+).*port_group=(\d+),phys_port_id=(\d+).*drc_index=(\w+),.*/) {
#} elsif ($line =~ /adapter_id=(\w+),lpar_id=([\d|-]+).*port_group=(\d+),phys_port_id=(\d+).*drc_index=(\w+),.*/) {
if (($2 == -1) && ($4 == 255)) {
$hash->{logic_drc_phydrc}->{$3}->{$5} = $1;
#$hash->{logic_drc_phydrc}->{$5}->{$1} = [$2,$3,$4];
@ -1687,12 +1689,49 @@ sub parse_part_get_info {
$hash->{lpar0_used_mem} = $2;
$hash->{phy_min_mem_req} = $3;
#print "===>lpar0_used_mem:$hash->{lpar0_used_mem}.\n";
} elsif ($line =~ /Curr Memory Req:[^\(]*\((\d+)\s*regions\)/) {
$hash->{lpar_used_regions} = $1;
} elsif ($line =~ /Curr Memory (Min|Req|Max):\s*([\d]*)[^\(]*\((\d+)\s*regions\)/) {
if ($1 eq 'Min') {
$hash->{lpar_mem_min} = $2
} elsif ($1 eq 'Max') {
$hash->{lpar_mem_max} = $2;
} else {
$hash->{lpar_mem_req} = $2;
$hash->{lpar_used_regions} = $3;
}
} elsif ($line =~ /Curr Processor (Min|Req|Max):\s*(\d+)/) {
if ($1 eq 'Min') {
$hash->{lpar_cpu_min} = $2;
} elsif ($1 eq 'Max') {
$hash->{lpar_cpu_max} = $2;
} else {
$hash->{lpar_cpu_req} = $2;
}
} elsif ($line =~ /\s*lpar_id=(\d+),type=vSCSI,slot=(\d+),attr=(\d+).*remote_lpar_id=0x(\w+),remote_slot_num=0x(\w+)/) {
if ($3 eq '0') {
my $lparid = hex($4);
my $slotid = hex($5);
push @{$hash->{lpar_vmstorage_client}}, "$lparid:$slotid";
} else {
if (exists($hash->{lpar_vmstorage_server})) {
$hash->{lpar_vmstorage_server}++;
} else {
$hash->{lpar_vmstorage_server} = 1;
}
}
} elsif ($line =~ /\s*lpar_id=(\d+),type=(vEth),slot=(\d+).*port_vlan_id=(\d+),mac_addr=(\w+)/) {
push @{$hash->{lpar_vmnics}}, "vlan$4";
} elsif ($line =~ /Available huge page memory\(in pages\):\s*(\d+)/) {
$hash->{huge_page_avail} = $1;
} elsif ($line =~ /Available BSR array:\s*(\d+)/) {
$hash->{cec_bsr_avail} = $1;
} elsif ($line =~ /^\d+\/(\d+)\/\d+$/) {
if ($1 ne 0) {
push @{$hash->{lpar_othersetting}}, "hugepage:$1";
}
} elsif ($line =~ /^(\d+)\.$/) {
if ($1 ne 0) {
push @{$hash->{lpar_othersetting}}, "bsr:$1";
}
}
}
}
@ -1703,6 +1742,7 @@ sub query_cec_info_actions {
my $td = shift;
my $usage = shift;
my $action_array = shift;
my $lpar_hash = shift;
my $lparid = @$td[0];
my $data;
my @array = ();
@ -1722,7 +1762,11 @@ sub query_cec_info_actions {
if (@$values[1] =~ /^$/) {
next;
}
if ($usage eq 0) {
if ($usage eq 1 or $usage eq 2) {
&parse_part_get_info(\%hash, @$values[1]);
}
if ($usage eq 0 or $usage eq 2) {
if ($lparid) {
if ($action eq "lpar_lhea_mac") {
my @output = split /\n/,@$values[1];
@ -1777,18 +1821,58 @@ sub query_cec_info_actions {
}
#$data .= "@$values[1]\n\n";
push @array, [$name, @$values[1], @$values[2]];
} else {
&parse_part_get_info(\%hash, @$values[1]);
}
}
}
if ($usage eq 0) {
if ($usage eq 0 or $usage eq 2) {
#return $data;
if ($usage eq 2) {
%$lpar_hash = %hash;
}
return \@array;
} else {
return \%hash;
}
}
sub update_vm_db {
my $request = shift;
my $lpar_hash = shift;
my $vm_hd = xCAT::Table->new('vm');
my %name_id_map = ();
foreach (keys (%$lpar_hash)) {
my %db_update = ();
my $node_hash = $lpar_hash->{$_};
$db_update{cpus} = "$node_hash->{lpar_cpu_min}/$node_hash->{lpar_cpu_req}/$node_hash->{lpar_cpu_max}";
$db_update{memory} = "$node_hash->{lpar_mem_min}/$node_hash->{lpar_mem_req}/$node_hash->{lpar_mem_max}";
if (exists($node_hash->{lpar_vmstorage_server})) {
$db_update{storage} = $node_hash->{lpar_vmstorage_server};
} elsif (exists($node_hash->{lpar_vmstorage_client})) {
my @tmp_array = ();
foreach (@{$node_hash->{lpar_vmstorage_client}}) {
if (/(\d+):(\d+)/) {
if (exists($name_id_map{$1})) {
push @tmp_array, "$name_id_map{$1}:$2";
} else {
my $vios_name = &find_lpar_name($request, $node_hash->{parent}, $1);
if (defined($vios_name)) {
$name_id_map{$1} = $vios_name;
push @tmp_array, "$vios_name:$2";
}
}
}
}
$db_update{storage} = join(",",@tmp_array);
}
$db_update{nics} = join(",",@{$node_hash->{lpar_vmnics}});
$db_update{physlots} = join(",",@{$node_hash->{lpar_phy_bus}});
if (exists($node_hash->{lpar_othersetting})) {
$db_update{othersettings} = join(",",@{$node_hash->{lpar_othersetting}});
}
$vm_hd->setNodeAttribs($_,\%db_update);
}
$vm_hd->commit;
}
#my @partition_query_actions = qw(part_get_partition_cap part_get_num_of_lpar_slots part_get_hyp_config_process_and_mem part_get_hyp_avail_process_and_mem part_get_service_authority_lpar_id part_get_shared_processing_resource part_get_all_vio_info lpar_lhea_mac part_get_all_io_bus_info part_get_lpar_processing part_get_lpar_memory get_huge_page get_cec_bsr);
sub query_cec_info {
my $request = shift;
@ -1796,25 +1880,36 @@ sub query_cec_info {
my $args = $request->{opt};
my @td = ();
my @result = ();
my $usage = 0;
my %lpar_hash = ();
#print Dumper($request);
#print Dumper($hash);
while (my ($mtms,$h) = each(%$hash) ) {
while (my ($name, $d) = each (%$h)) {
my %tmp_hash = ();
@td = @$d;
if (@$d[0] == 0 && @$d[4] !~ /lpar|vios/) {
last;
}
#my $rethash = query_cec_info_actions($request, $name, $d, 0, ["part_get_lpar_processing","part_get_lpar_memory","part_get_all_vio_info","lpar_lhea_mac","part_get_all_io_bus_info","get_huge_page","get_cec_bsr"]);
my $rethash = query_cec_info_actions($request, $name, $d, 0, ["part_get_lpar_processing","part_get_lpar_memory","part_get_all_io_bus_info","part_get_all_vio_info","get_huge_page","get_cec_bsr"]);
if ($args->{updatedb}) {
$usage = 2;
}
my $rethash = query_cec_info_actions($request, $name, $d, $usage, ["part_get_lpar_processing","part_get_lpar_memory","part_get_all_io_bus_info","part_get_all_vio_info","get_huge_page","get_cec_bsr"], \%tmp_hash);
#push @result, [$name, $rethash, 0];
push @result, @$rethash;
$lpar_hash{$name} = \%tmp_hash;
$lpar_hash{$name}->{parent} = @$d[3];
}
if (@td[0] == 0) {
my $rethash = query_cec_info_actions($request, @td[3],\@td, 0);
my $rethash = query_cec_info_actions($request, @td[3],\@td, $usage);
#push @result, [@td[3], $rethash, 0];
push @result, @$rethash;
}
}
if ($args->{updatedb} and %lpar_hash) {
update_vm_db($request, \%lpar_hash);
}
return \@result;
}
@ -1931,6 +2026,19 @@ sub find_lpar_id {
return undef;
}
sub find_lpar_name {
my $request = shift;
my $parent = shift;
my $id = shift;
my %mapping = %{$request->{ppc}->{$parent}->{mapping}};
foreach (keys %mapping) {
if ($mapping{$_} eq $id) {
return $_;
}
}
return undef;
}
sub create_lpar {
my $request = shift;
my $name = shift;
@ -2126,9 +2234,9 @@ sub mkspeclpar {
return([[$name, "Parameter for 'vmmemory' is invalid", 1]]);
}
my $memsize = $memhash->{mem_region_size};
$mmin = ($mmin + $memsize) / $memsize;
$mcur = ($mcur + $memsize) / $memsize;
$mmax = ($mmax + $memsize) / $memsize;
$mmin = ($mmin + $memsize - 1) / $memsize;
$mcur = ($mcur + $memsize - 1) / $memsize;
$mmax = ($mmax + $memsize - 1) / $memsize;
$tmp_ent->{memory} = "$mmin/$mcur/$mmax";
$tmp_ent->{mem_region_size} = $memsize;
} else {
@ -2178,21 +2286,27 @@ sub mkspeclpar {
$tmp_ent->{storage} = \@array;
}
} else {
if (exists($tmp_ent->{storage}) and $tmp_ent->{storage} !~ /^[\w_-]*:\d+$/) {
return ([[$name, "Parameter for 'vmstorage' is invalid", 1]]);
} elsif (exists($tmp_ent->{storage})) {
if ($tmp_ent->{storage} =~ /([\w_-]*):(\d+)/) {
my $vios = &find_lpar_id($request, @$d[3], $1);
my $r_slotid = $2;
if (!defined($vios)) {
return ([[$name, "Cannot find lparid for Server lpar:$1"]]);
if (exists($tmp_ent->{storage})) {
my @tmp_array = split ",",$tmp_ent->{storage};
my $storage_array = undef;
foreach (@tmp_array) {
if (/([\w_-]*):(\d+)/) {
my $vios = &find_lpar_id($request, @$d[3], $1);
my $r_slotid = $2;
if (defined($vios)) {
push @$storage_array, "0,$vios,$r_slotid";
} else {
return ([[$name, "Cannot find lparid for Server lpar:$1"]]);
}
} else {
return ([[$name, "Parameter for 'vmstorage' is invalid", 1]]);
}
$tmp_ent->{storage} = ["0,$vios,$r_slotid"];
}
$tmp_ent->{storage} = $storage_array;
}
}
$tmp_ent->{hyp_config_mem} = $memhash->{hyp_config_mem};
$tmp_ent->{hyp_avail_mem} = $memhash->{hyp_avail_mem};
if (exists($tmp_ent->{othersettings})) {

View File

@ -222,7 +222,7 @@ my %usage = (
lsvm <noderange> [-a|--all]
PPC (using Direct FSP Management) specific:
lsvm <noderange> [-l|--long] --p775
lsvm <noderange>
lsvm <noderange> [--updatedb]
zVM specific:
lsvm noderange
lsvm noderange --getnetworknames