diff --git a/perl-xCAT/xCAT/PPCvm.pm b/perl-xCAT/xCAT/PPCvm.pm index 0e8a02138..cf23758f5 100644 --- a/perl-xCAT/xCAT/PPCvm.pm +++ b/perl-xCAT/xCAT/PPCvm.pm @@ -262,39 +262,39 @@ sub mkvm_parse_args { ################################################ if ( (exists($opt{full})) && (scalar (@{$opt{target}}) > 1) ) { - my $lparparent; + my $lparparent; - my $ppctab = xCAT::Table->new('ppc'); + my $ppctab = xCAT::Table->new('ppc'); - foreach my $vnode (@{$opt{target}}) { - my $vcon = $ppctab->getAttribs({node => $vnode}, ('node','parent')); - if ($vcon and $vcon->{"node"} and $vcon->{"parent"}) { - my $lparent = $vcon->{"parent"}; - $lparparent->{$lparent}->{$vnode} = $vnode; - } + foreach my $vnode (@{$opt{target}}) { + my $vcon = $ppctab->getAttribs({node => $vnode}, ('node','parent')); + if ($vcon and $vcon->{"node"} and $vcon->{"parent"}) { + my $lparent = $vcon->{"parent"}; + $lparparent->{$lparent}->{$vnode} = $vnode; + } } - $ppctab->close; + $ppctab->close; - my $cbmsg = "mkvm: multiple LPAR nodes which belong to the same CEC have been defined.\n"; - my $sameflag = 0; + my $cbmsg = "mkvm: multiple LPAR nodes which belong to the same CEC have been defined.\n"; + my $sameflag = 0; - foreach my $iparent (keys %$lparparent) { - if (scalar (keys %{$lparparent->{$iparent}}) > 1) { - $sameflag = 1; - $cbmsg = $cbmsg . $iparent . ":" . "\t"; - foreach my $inode (keys %{$lparparent->{$iparent}}) { - $cbmsg = $cbmsg . $inode . ","; - } - } - - $cbmsg =~ s/,$/ /; - $cbmsg = $cbmsg . "\n"; - } + foreach my $iparent (keys %$lparparent) { + if (scalar (keys %{$lparparent->{$iparent}}) > 1) { + $sameflag = 1; + $cbmsg = $cbmsg . $iparent . ":" . "\t"; + foreach my $inode (keys %{$lparparent->{$iparent}}) { + $cbmsg = $cbmsg . $inode . ","; + } + } + + $cbmsg =~ s/,$/ /; + $cbmsg = $cbmsg . "\n"; + } - if ($sameflag) { - return(usage( $cbmsg )); - } + if ($sameflag) { + return(usage( $cbmsg )); + } } #################################### @@ -668,38 +668,38 @@ sub remove { # Remove the LPARs #################################### foreach ( @lpars ) { - my $lparinfo = shift(@lpars); + my $lparinfo = shift(@lpars); my ($name,$id) = split /,/, $lparinfo; my $mtms = @$d[2]; - if ($opt->{service}) { - ############################################### - # begin to retrieve the CEC's service lpar id - ############################################### - my $service_lparid = xCAT::PPCcli::lssyscfg( - $exp, - "fsp", - $mtms, - "service_lpar_id" ); - my $Rc = shift(@$service_lparid); + if ($opt->{service}) { + ############################################### + # begin to retrieve the CEC's service lpar id + ############################################### + my $service_lparid = xCAT::PPCcli::lssyscfg( + $exp, + "fsp", + $mtms, + "service_lpar_id" ); + my $Rc = shift(@$service_lparid); - ##################################################### - # Change the CEC's state to standby and set it's service lpar id to none - ##################################################### - if ( $Rc == SUCCESS ) { - my $cfgdata = @$service_lparid[0]; - if ( ($id == $cfgdata) && ($cfgdata !~ /none/) ) { - $cfgdata = "service_lpar_id=none"; - my $result = xCAT::PPCcli::chsyscfg( $exp, "fsp", $d, $cfgdata ); - $Rc = shift(@$result); - if ( $Rc != SUCCESS ) { - return( [[$lpar, @$service_lparid[0], $Rc]] ); - } - } - } - } + ##################################################### + # Change the CEC's state to standby and set it's service lpar id to none + ##################################################### + if ( $Rc == SUCCESS ) { + my $cfgdata = @$service_lparid[0]; + if ( ($id == $cfgdata) && ($cfgdata !~ /none/) ) { + $cfgdata = "service_lpar_id=none"; + my $result = xCAT::PPCcli::chsyscfg( $exp, "fsp", $d, $cfgdata ); + $Rc = shift(@$result); + if ( $Rc != SUCCESS ) { + return( [[$lpar, @$service_lparid[0], $Rc]] ); + } + } + } + } - ################################ + ################################ # id profile mtms hcp type frame ################################ my @d = ( $id,0,$mtms,0,"lpar",0 ); @@ -954,10 +954,18 @@ sub subst_profile my ($attr,$value) = $av_pair =~ /^\s*(\S+?)\s*=\s*(\S+)\s*$/; if ( $cfgline =~ /^$attr=/) { - $cfgline = "$attr=$value"; + if ( $cfgline =~ /lhea_logical_ports/) + { + $cfgline = "$attr=\\\"\\\"$value\\\"\\\""; + } else + { + $cfgline = "$attr=$value"; + } + delete $attrs[$i]; last; } + } if ( $cfgline =~ /,/) { @@ -1503,7 +1511,7 @@ sub lhea_adapter { # If double-quoted, has comma- # seperated list of adapters ##################################### - my $delim = ( $1 =~ /^\"/ ) ? "\\\\\"" : ","; + #my $delim = ( $1 =~ /^\"/ ) ? "\\\\\"" : ","; #$cfgdata =~ /lhea_logical_ports=([^$delim]+)|$/; $cfgdata =~ /lhea_logical_ports=(.*)lhea_capabilities/; my @lhea = split ",", $1; @@ -1804,7 +1812,7 @@ sub xCATdB { my $server = @$d[3]; my $fsp = @$d[2]; - ################################### + ################################### # Find FSP name in ppc database ################################### my $tab = xCAT::Table->new( "ppc" ); @@ -1847,7 +1855,7 @@ sub xCATdB { $lparid, $model, $serial, - "", + "", $server, $profile, $parent ); @@ -1900,82 +1908,82 @@ my $ppctab = xCAT::Table->new('ppc'); return( [[$lpar,"Node must be LPAR or CEC",RC_ERROR]] ); } - my $ppctab = xCAT::Table->new('ppc'); + my $ppctab = xCAT::Table->new('ppc'); ##################################### - # Check if a existing with requested LPAR ID has existed - ##################################### - my $value = xCAT::PPCcli::lssyscfg( - $exp, - "profs", - $mtms, - "all_resources", - "lpar_ids=$lparid" ); - my $Rc = shift(@$value); - ####################################### - # make how to handle according to the result of lssyscfg - ####################################### - if ( $Rc == SUCCESS ) { - # close the DB handler of the ppc table - $ppctab->close; - # change the lpar's attribute before removing it. - my $all_res_flag = @$value[0]; - if ( $all_res_flag != 1 ) { - return( [[$lpar,"The LPAR ID has been occupied",RC_ERROR]] ); - } - else { - return( [[$lpar,"This full LPAR has been created",RC_ERROR]] ); - } - } - - ################################# - # Create the new full LPAR's configure data - ################################# - my ($lpar_id, $profname); - my $vcon = $ppctab->getAttribs({node => $name}, ('id','pprofile')); - if ($vcon) { - if ($vcon->{"id"}) { - $lpar_id = $vcon->{"id"}; - } else { - $lpar_id = 1; - } + # Check if a existing with requested LPAR ID has existed + ##################################### + my $value = xCAT::PPCcli::lssyscfg( + $exp, + "profs", + $mtms, + "all_resources", + "lpar_ids=$lparid" ); + my $Rc = shift(@$value); + ####################################### + # make how to handle according to the result of lssyscfg + ####################################### + if ( $Rc == SUCCESS ) { + # close the DB handler of the ppc table + $ppctab->close; + # change the lpar's attribute before removing it. + my $all_res_flag = @$value[0]; + if ( $all_res_flag != 1 ) { + return( [[$lpar,"The LPAR ID has been occupied",RC_ERROR]] ); + } + else { + return( [[$lpar,"This full LPAR has been created",RC_ERROR]] ); + } + } + + ################################# + # Create the new full LPAR's configure data + ################################# + my ($lpar_id, $profname); + my $vcon = $ppctab->getAttribs({node => $name}, ('id','pprofile')); + if ($vcon) { + if ($vcon->{"id"}) { + $lpar_id = $vcon->{"id"}; + } else { + $lpar_id = 1; + } - if ($vcon->{"pprofile"}) { - $profname = $vcon->{"pprofile"}; - } else { - $profname = $name; - } - } else { - $lpar_id = 1; - $profname = $name; - } - - my $cfgdata = "name=$name,profile_name=$profname,lpar_id=$lpar_id,lpar_env=aixlinux,all_resources=1,boot_mode=norm,conn_monitoring=0"; - + if ($vcon->{"pprofile"}) { + $profname = $vcon->{"pprofile"}; + } else { + $profname = $name; + } + } else { + $lpar_id = 1; + $profname = $name; + } + + my $cfgdata = "name=$name,profile_name=$profname,lpar_id=$lpar_id,lpar_env=aixlinux,all_resources=1,boot_mode=norm,conn_monitoring=0"; + ################################# # Create a new full LPAR ################################# $result = xCAT::PPCcli::mksyscfg( $exp, "lpar", $d, $cfgdata ); - $Rc = shift(@$result); + $Rc = shift(@$result); ########################################### # Set the CEC's service_lpar_id to the lpar_id of the full LPAR ########################################### - if ( $Rc == SUCCESS) { - $cfgdata = "service_lpar_id=$lpar_id"; - $result = xCAT::PPCcli::chsyscfg( $exp, "fsp", $d, $cfgdata ); - $Rc = shift(@$result); + if ( $Rc == SUCCESS) { + $cfgdata = "service_lpar_id=$lpar_id"; + $result = xCAT::PPCcli::chsyscfg( $exp, "fsp", $d, $cfgdata ); + $Rc = shift(@$result); if ( $Rc != SUCCESS ) { - $ppctab->close; - return( [[$lpar, @$result[0], $Rc]] ); + $ppctab->close; + return( [[$lpar, @$result[0], $Rc]] ); } - } - + } + ################################# # Add a new full LPAR to database ################################# if ( $Rc == SUCCESS ) { - $profile = $profname; - my $id = $lpar_id; + $profile = $profname; + my $id = $lpar_id; my $err = xCATdB( "mkvm", $name, $profile, $id, $d, $hwtype, $lpar); if ( defined( $err )) { push @values, [$name,$err,RC_ERROR]; @@ -2006,7 +2014,7 @@ sub mkvm { else { # if no, it will execute the original function. return( create(@_) ); - } + } } ##########################################################################