Merge branch '2.8' of ssh://git.code.sf.net/p/xcat/xcat-core into 2.8

This commit is contained in:
lissav 2013-09-12 08:15:13 -04:00
commit ffc621cf29
3 changed files with 225 additions and 12 deletions

View File

@ -56,6 +56,7 @@ sub handled_commands {
rspreset => 'nodehm:mgt', #done
rvitals => 'nodehm:mgt', #done
rinv => 'nodehm:mgt', #done
rflash => 'nodehm:mgt', #done
rsetboot => 'nodehm:mgt', #done
rbeacon => 'nodehm:mgt', #done
reventlog => 'nodehm:mgt',
@ -466,12 +467,16 @@ sub on_bmc_connect {
}
#ok, detect some common prereqs here, notably:
#getdevid
if ($command eq "getrvidparms") {
if ($command eq "getrvidparms" or $command eq "rflash") {
unless (defined $sessdata->{device_id}) {
$sessdata->{ipmisession}->subcmd(netfn=>6,command=>1,data=>[],callback=>\&gotdevid,callback_args=>$sessdata);
return;
}
getrvidparms($sessdata);
if ($command eq "getrvidparms") {
getrvidparms($sessdata);
} else {
rflash($sessdata);
}
}
#initsdr
if ($command eq "rinv" or $command eq "reventlog" or $command eq "rvitals") {
@ -1209,6 +1214,121 @@ sub ripmi_callback {
xCAT::SvrUtils::sendmsg($output,$callback,$sessdata->{node},%allerrornodes);
}
sub isfpc {
my $sessdata = shift;
return 1
}
sub rflash {
my $sessdata = shift;
if (isfpc($sessdata)) {
#first, start a fpc firmware transaction
$sessdata->{firmpath} = $sessdata->{subcommand};
$sessdata->{firmctx} = "init";
$sessdata->{ipmisession}->subcmd(netfn=>0x8, command=>0x17,
data=>[0,0,1,0,0,0,0],
callback=>\&fpc_firmup_config,
callback_args=>$sessdata);
} else {
die "Unimplemented";
}
}
sub fpc_firmup_config {
if (check_rsp_errors(@_)) {
abort_fpc_update($_[1]);
return;
}
my $rsp = shift;
my $sessdata = shift;
unless ($sessdata->{firmupxid}) {
$sessdata->{firmupxid} = $rsp->{data}->[0];
}
my $data;
if ($sessdata->{firmctx} eq 'init') {
$data =[0, $sessdata->{firmupxid}, 1, 0, 1, 0, 0, 0,
length($sessdata->{firmpath}),
unpack("C*",$sessdata->{firmpath})];
$sessdata->{firmctx} = 'p1';
} elsif ($sessdata->{firmctx} eq 'p1') {
$data = [0, $sessdata->{firmupxid}, 3, 0, 5];
$sessdata->{firmctx} = 'p2';
} elsif ($sessdata->{firmctx} eq 'p2') {
$data = [0, $sessdata->{firmupxid}, 4, 0, 0xa];
$sessdata->{firmctx} = 'p3';
} elsif ($sessdata->{firmctx} eq 'p3') {
$data = [0, $sessdata->{firmupxid}, 5, 0, 3];
$sessdata->{firmctx} = 'p4';
} elsif ($sessdata->{firmctx} eq 'p4') {
$data = [0, $sessdata->{firmupxid}, 6, 0, 1];
$sessdata->{firmctx} = 'xfer';
xCAT::SvrUtils::sendmsg("Transferring firmware",$callback,$sessdata->{node},%allerrornodes);
$sessdata->{ipmisession}->subcmd(netfn=>0x8, command=>0x19,
data=>[0, $sessdata->{firmupxid}],
callback=>\&fpc_firmxfer_watch,
callback_args=>$sessdata);
return;
}
$sessdata->{ipmisession}->subcmd(netfn=>0x8, command=>0x18,
data=>$data,
callback=>\&fpc_firmup_config,
callback_args=>$sessdata);
}
sub abort_fpc_update {
my $sessdata = shift;
$sessdata->{ipmisession}->subcmd(netfn=>0x8, command=>0x15, data=>[], callback=>\&fpc_update_aborted, callback_args=>$sessdata);
}
sub fpc_update_aborted {
check_rsp_errors(@_);
return;
}
sub fpc_firmxfer_watch {
if ($_[0]->{code} == 0x89) {
xCAT::SvrUtils::sendmsg([1,"Transfer failed (wrong url?)"],$callback,$_[1]->{node},%allerrornodes);
abort_fpc_update($_[1]);
return;
}
if (check_rsp_errors(@_)) {
abort_fpc_update($_[1]);
return;
}
my $rsp = shift;
my $sessdata = shift;
my $delay=1;
my $watch=2;
if ($sessdata->{firmctx} eq 'apply') { $delay = 15; $watch = 1;}
if (check_rsp_errors(@_)) {
return;
}
my $percent = 0;
if ($rsp->{data} and (length(@{$rsp->{data}}) > 0)) {
$percent = $rsp->{data}->[0];
}
#$callback->({sinfo=>"$percent%"});
if ($percent == 100) {
if ($sessdata->{firmctx} eq 'xfer') {
xCAT::SvrUtils::sendmsg("Applying firmware",$callback,$sessdata->{node},%allerrornodes);
$sessdata->{firmctx} = "apply";
$sessdata->{ipmisession}->subcmd(netfn=>0x8, command=>0x20,
data=>[0, $sessdata->{firmupxid}],
callback=>\&fpc_firmxfer_watch,
callback_args=>$sessdata);
return;
} else {
xCAT::SvrUtils::sendmsg("Resetting FPC",$callback,$sessdata->{node},%allerrornodes);
resetbmc($sessdata);
}
} else {
$sessdata->{ipmisession}->subcmd(netfn=>0x8, command=>0x12,
data=>[$watch],
delayxmit=>$delay,
callback=>\&fpc_firmxfer_watch,
callback_args=>$sessdata);
}
}
sub reseat_node {
my $sessdata = shift;
if (1) { # TODO: FPC path checked for

View File

@ -106,16 +106,10 @@ function configipv4(){
if [ $num_v4num -eq 0 ];then
echo "DEVICE=${str_if_name}" > $str_conf_file
echo "BOOTPROTO=static" >> $str_conf_file
echo "BROADCAST=" >> $str_conf_file
echo "ETHTOOL_OPTIONS=" >> $str_conf_file
echo "IPADDR=${str_v4ip}" >> $str_conf_file
echo "MTU=" >> $str_conf_file
echo "NAME=" >> $str_conf_file
echo "NETMASK=${str_v4mask}" >> $str_conf_file
echo "NETWORK=${str_v4net}" >> $str_conf_file
echo "REMOTE_IPADDR=" >> $str_conf_file
echo "STARTMODE=onboot" >> $str_conf_file
echo "UNIQUE=" >> $str_conf_file
echo "USERCONTROL=no" >> $str_conf_file
echo "_nm_name=static-0" >> $str_conf_file
else
@ -148,7 +142,7 @@ function configipv4(){
echo "DEVICE=${str_if_name}:${num_v4num}" > $str_conf_file
fi
echo "BOOTPROTO=none" >> $str_conf_file
echo "BOOTPROTO=static" >> $str_conf_file
echo "NM_CONTROLLED=no" >> $str_conf_file
echo "IPADDR=${str_v4ip}" >> $str_conf_file
echo "NETMASK=${str_v4mask}" >> $str_conf_file
@ -211,7 +205,7 @@ configipv6(){
str_conf_file="/etc/sysconfig/network-scripts/ifcfg-${str_if_name}"
if [ $num_v4num -eq 0 -a $num_v6num -eq 0 ];then
echo "DEVICE=$str_if_name" > $str_conf_file
echo "BOOTPROTO=none" >> $str_conf_file
echo "BOOTPROTO=static" >> $str_conf_file
echo "NM_CONTROLLED=no" >> $str_conf_file
echo "ONBOOT=yes" >> $str_conf_file
fi
@ -378,6 +372,102 @@ if [ "$1" = "-r" ];then
delete_nic_config_files $str_nic_name
fi
exit 0
elif [ "$1" = "-s" ];then
if [ $# -lt 2 ];then
logger -t xcat -p local4.err "configeth: config install nic, but the nic name is missed"
echo "configeth on $NODE: config install nic, but the nic name is missed"
exit 1
fi
str_inst_nic=$2
str_inst_ip=''
str_inst_mask=''
str_inst_gateway=''
if [ "$str_os_type" = "aix" ];then
logger -t xcat -p local4.err "configeth: aix does not support -s flag"
echo "configeth on $NODE: aix does not support -s flag"
exit 0
elif [ -f "/etc/debian_version" ];then
str_lease_file="/var/lib/dhcp/dhclient."$str_inst_nic".leases"
if [ -e $str_lease_file ];then
str_inst_ip=`grep fixed-address $str_lease_file | tail -n 1 | awk '{print $2}' | sed 's/;$//'`
str_inst_mask=`grep subnet-mask $str_lease_file | tail -n 1 | awk '{print $3}' | sed 's/;$//'`
str_inst_gateway=`grep routers $str_lease_file | tail -n 1 | awk '{print $3}' | sed 's/;$//'`
fi
elif [ -f "/etc/SuSE-release" ];then
str_lease_file="/var/lib/dhcpcd/dhcpcd-"$str_inst_nic".info"
if [ -e $str_lease_file ];then
str_inst_ip=`grep IPADDR $str_lease_file | tail -n 1 | awk -F'=' '{print $2}' | sed "s/'//g"`
str_inst_mask=`grep NETMASK $str_lease_file | tail -n 1 | awk -F'=' '{print $2}' | sed "s/'//g"`
str_inst_gateway=`grep GATEWAYS $str_lease_file | tail -n 1 | awk -F'=' '{print $2}' | sed "s/'//g"`
fi
else
str_lease_file=`ls /var/lib/dhclient/*$str_inst_nic*`
if [ -e $str_lease_file ];then
str_inst_ip=`grep fixed-address $str_lease_file | tail -n 1 | awk '{print $2}' | sed 's/;$//'`
str_inst_mask=`grep subnet-mask $str_lease_file | tail -n 1 | awk '{print $3}' | sed 's/;$//'`
str_inst_gateway=`grep routers $str_lease_file | tail -n 1 | awk '{print $3}' | sed 's/;$//'`
fi
fi
if [ -z "$str_inst_ip" -o -z "$str_inst_mask" ];then
logger -t xcat -p local4.err "configeth: config install nic, can not find the information from lease file, return."
echo "configeth on $NODE: config install nic, can not find information from dhcp lease file, return."
exit 0
fi
if [ -f "/etc/debian_version" ];then
str_conf_file="/etc/sysconfig/network/ifcfg-${str_inst_nic}"
echo "auto ${str_inst_nic}" > $str_conf_file
echo "iface ${str_inst_nic} inet static" >> $str_conf_file
echo " address ${str_inst_ip}" >> $str_conf_file
echo " netmask ${str_inst_mask}" >> $str_conf_file
if [ -n "$str_inst_gateway" ];then
echo " gateway $str_inst_gateway" >> $str_conf_file
fi
hostname $NODE
echo $NODE > /etc/hostname
elif [ -f "/etc/SuSE-release" ];then
str_conf_file="/etc/network/interfaces.d/${str_inst_nic}"
echo "DEVICE=${str_inst_nic}" > $str_conf_file
echo "BOOTPROTO=static" >> $str_conf_file
echo "IPADDR=${str_inst_ip}" >> $str_conf_file
echo "NETMASK=${str_inst_mask}" >> $str_conf_file
echo "STARTMODE=onboot" >> $str_conf_file
if [ -n "$str_inst_gateway" ];then
grep -i "default" /etc/sysconfig/network/routes
if [ $? -eq 0 ];then
sed -i "s/.*default.*/default ${str_inst_gateway} - -/i" /etc/sysconfig/network/routes
else
echo "default ${str_inst_gateway} - -" >> /etc/sysconfig/network/routes
fi
fi
hostname $NODE
echo $NODE > /etc/HOSTNAME
else
str_conf_file="/etc/sysconfig/network-scripts/ifcfg-${str_inst_nic}"
echo "DEVICE=${str_inst_nic}" > $str_conf_file
echo "IPADDR=${str_inst_ip}" >> $str_conf_file
echo "NETMASK=${str_inst_mask}" >> $str_conf_file
echo "BOOTPROTO=static" >> $str_conf_file
echo "ONBOOT=yes" >> $str_conf_file
if [ -n "$str_inst_gateway" ];then
grep -i "GATEWAY" /etc/sysconfig/network
if [ $? -eq 0 ];then
sed -i "s/.*GATEWAY.*/GATEWAY=${str_inst_gateway}/i" /etc/sysconfig/network
else
echo "GATEWAY=${str_inst_gateway}" >> /etc/sysconfig/network
fi
fi
hostname $NODE
grep -i "HOSTNAME" /etc/sysconfig/network
if [ $? -eq 0 ];then
sed -i "s/.*HOSTNAME.*/HOSTNAME=${NODE}/i" /etc/sysconfig/network
else
echo "HOSTNAME=${NODE}" >> /etc/sysconfig/network
fi
fi
exit 0
fi
#main prcess

View File

@ -91,6 +91,9 @@ elif [ `echo $str_temp | grep -E "e(n|th)[0-9]+"` ];then
str_inst_nic=$str_temp
fi
if [ $bool_cfg_inst_nic -eq 1 ];then
configeth -s $str_inst_nic
fi
bool_exit_flag=0
#check the required attributes
@ -162,7 +165,7 @@ if [ $bool_remove -eq 1 ];then
continue
fi
if [ "$str_temp_nic" = "$str_inst_nic" -a $bool_cfg_inst_nic -eq 0 ];then
if [ "$str_temp_nic" = "$str_inst_nic" ];then
continue
fi
@ -187,7 +190,7 @@ do
key=`echo $key | sed 's/^ \+//' | sed 's/ \+$//'`
str_nic_type=
str_value=$(hashget hash_defined_nics $key)
if [ "$key" = "$str_inst_nic" -a $bool_cfg_inst_nic -eq 0 ];then
if [ "$key" = "$str_inst_nic" ];then
continue
fi
old_ifs=$IFS