2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-06-24 15:05:36 +00:00

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

This commit is contained in:
chudegao
2015-01-22 09:55:12 +08:00
11 changed files with 227 additions and 70 deletions

View File

@ -895,18 +895,21 @@ sub check_profile_consistent{
return 0, "Provisioning network not defined for network profile."
}
# Remove check mechanism about arch and netboot attribute
# Attribute 'neboot' will be generated based on arch, management method, os
# Profile consistent keys, arch=>netboot, mgt=>nictype
my $ppc_netboot = 'yaboot';
if( $os =~ /rhels7/ ){
$ppc_netboot = 'grub2';
}
my %profile_dict = ('x86' => 'xnba','x86_64' => 'xnba', 'ppc64' => $ppc_netboot,
'ppc64el' => $ppc_netboot,
'fsp' => 'FSP', 'ipmi' => 'BMC');
#my $ppc_netboot = 'yaboot';
#if( $os =~ /rhels7/ ){
# $ppc_netboot = 'grub2';
#}
#my %profile_dict = ('x86' => 'xnba','x86_64' => 'xnba', 'ppc64' => $ppc_netboot,
# 'ppc64el' => $ppc_netboot,
# 'fsp' => 'FSP', 'ipmi' => 'BMC');
# Check if imageprofile is consistent with networkprofile
if ($profile_dict{$arch} ne $netboot) {
return 0, "Imageprofile's arch is not consistent with networkprofile's netboot."
}
#if ($profile_dict{$arch} ne $netboot) {
# return 0, "Imageprofile's arch is not consistent with networkprofile's netboot."
#}
# Check if networkprofile is consistent with hardwareprofile
if (not $hardwareprofile) { # Not define hardwareprofile
@ -916,27 +919,27 @@ sub check_profile_consistent{
return 0, "$nictype networkprofile must use with hardwareprofile.";
}
}
if ($mgt eq 'vm')
{
return 1, "";
}
my %mgt_dict = ('fsp' => 'FSP', 'ipmi' => 'BMC', 'kvm' => '');
# For nodetype is lpar node, not need to check the nictype as it is not required for lpar node
if (not $nictype and $mgt and $nodetype ne 'lpar' ) {
# define hardwareprofile, not define fsp or bmc networkprofile, and the node type is not lpar
return 0, "$profile_dict{$mgt} hardwareprofile must use with $profile_dict{$mgt} networkprofile.";
if ($mgt eq 'vm') {
return 1, "";
}
if ($profile_dict{$mgt} ne $nictype and $nodetype ne 'lpar') {
# Networkprofile's nictype is not consistent with hadrwareprofile's mgt, and the node type is not lpar
return 0, "Networkprofile's nictype is not consistent with hardwareprofile's mgt.";
if ($nodetype eq 'lpar') {
if ($nictype) {
# Can not associate FSP/BMC network if the node type is lpar
return 0, "The node with hardware type $nodetype can not use with $nictype networkprofile.";
}
return 1, ""
}
if ($nodetype eq 'lpar' and $nictype eq 'FSP')
{
# can not associate FSP network if the node type is lpar
return 0, "The node with hardware type $nodetype can not use with $nictype networkprofile.";
if ($mgt and $mgt_dict{$mgt} ne $nictype) {
my $errmsg = "$mgt hardwareprofile must use with $mgt_dict{$mgt} networkprofile.";
if ( $mgt eq 'kvm' ) {
$errmsg = "$mgt hardwareprofile must use with non-BMC and non-FSP networkprofile."
}
return 0, $errmsg;
}
return 1, "";
@ -1267,3 +1270,32 @@ sub gen_chain_for_profiles{
}
return (0, $final_chain);
}
#-------------------------------------------------------------------------------
=head3 get_all_vmhosts
Description : Get all vm hosts/hypervisor from DB.
Arguments : N/A
Returns : ref for vm hosts/hypervisor hash.
Example :
my $hashref = xCAT::ProfiledNodeUtils->get_all_vmhosts();
=cut
#-------------------------------------------------------------------------------
sub get_all_vmhosts
{
my %vmhostshash;
my $nodelisttab = xCAT::Table->new('nodelist');
# groups like '__Hypervisor_pkvm' means this node is Power KVM hypervisor
my @vmhosts = $nodelisttab->getAllAttribsWhere("groups like '%__Hypervisor_kvm%'", 'node');
foreach (@vmhosts) {
if($_->{'node'}) {
$vmhostshash{$_->{'node'}} = 1;
}
}
$nodelisttab->close();
# Return the ref accordingly
return \%vmhostshash;
}

View File

@ -185,6 +185,13 @@ sub isServiceReq
if (!exists($servicehash->{'tftpserver'})) {
$servicehash->{'tftpserver'} = 1;
}
# On Ubuntu management node, we disabled the isc-dhcp-server in upstart,
# through file /etc/init/isc-dhcp-server.override, see bug 4399
# however, this causes a new problem, bug 4515
# the fix is to start dhcp server when starting xcatd
if (!exists($servicehash->{'dhcpserver'}) && xCAT::Utils->osver() =~ /ubuntu.*/i) {
$servicehash->{'dhcpserver'} = 1;
}
}
$servicenodetab->close;

View File

@ -134,12 +134,22 @@ To import nodes using a profile, follow the following steps:
cec=mycec
lparid=2
# Node information file ends.
Example of a node information file that specifies a PowerKVM Guest node that uses KVM management:
# Node information file begins
# This entry defines a PowerKVM Guest node.
# Make sure the node 'vm01' is already created on Hypervisor
vm01:
mac=b8:ef:3f:28:31:15
vmhost=pkvm1
# Node information file ends.
The node information file includes the following items:
B<__hostname__:> This is a mandatory item.
Description: The name of the node, where __hostname__ is automatically generated by the node name format. You can also input a fixed node name, for example compute-node.
Description: The name of the node, where __hostname__ is automatically generated by the node name format. You can also input a fixed node name, for example "compute-node".
B<mac=<mac-address>> This is a mandatory item.
@ -185,6 +195,10 @@ B<unit=<rack-server-unit-location>> This is an optional item.
Description: node location info, for rack server only. Specify the node's start unit number in rack, in U. this item must be specified together with rack and height.
B<vmhost=<PowerKVM Hypervisior Host Name>> This is a mandatory option for defining PowerKVM Guest nodes.
Description: Specifies the vmhost of a Power KVM Guest node, where <vmhost> is the host name of PowerKVM Hypervisior.
3. Import the nodes, by using the following commands. Note: If we want to import PureFlex X/P nodes, hardware profile must be set to a PureFlex hardware type.
nodeimport file=/root/hostinfo.txt networkprofile=default_cn imageprofile=rhels6.3_packaged hostnameformat=compute-#NNN

View File

@ -544,9 +544,13 @@ sub setup_DHCP
if (xCAT::Utils->isMN()) { # on the MN
#my @output = xCAT::Utils->runcmd("service dhcpd status", -1);
#if ($::RUNCMD_RC != 0) { # not running
my $retcode= xCAT::Utils->checkservicestatus("dhcpd");
my $dhcpservice = "dhcpd";
if (-e "/etc/init.d/isc-dhcp-server") { #Ubuntu
$dhcpservice = "isc-dhcp-server";
}
my $retcode= xCAT::Utils->checkservicestatus($dhcpservice);
if($retcode!=0){
$rc = xCAT::Utils->startservice("dhcpd");
$rc = xCAT::Utils->startservice($dhcpservice);
if ($rc != 0)
{
return 1;

View File

@ -221,8 +221,8 @@ sub copycd
return;
}
if ( $copypath || $noosimage || $nonoverwrite ){
$callback->({info=> ["copycd on debian/ubuntu doesn't support -p, -o, -w options!"]});
if ( $copypath || $nonoverwrite ){
$callback->({info=> ["copycd on debian/ubuntu doesn't support -p, -w options!"]});
return;
}
@ -419,17 +419,19 @@ sub copycd
}
$callback->({data => "Media copy operation successful"});
my @ret=xCAT::SvrUtils->update_tables_with_templates($distname, $arch, $temppath, $osdistroname);
if ($ret[0] != 0) {
$callback->({data => "Error when updating the osimage tables: " . $ret[1]});
}
my @ret=xCAT::SvrUtils->update_tables_with_diskless_image($distname, $arch, undef, "netboot", $temppath, $osdistroname);
if ($ret[0] != 0) {
$callback->({data => "Error when updating the osimage tables for stateless: " . $ret[1]});
}
my @ret=xCAT::SvrUtils->update_tables_with_diskless_image($distname, $arch, undef, "statelite", $temppath, $osdistroname);
if ($ret[0] != 0) {
$callback->({data => "Error when updating the osimage tables for statelite: " . $ret[1]});
unless($noosimage) {
my @ret=xCAT::SvrUtils->update_tables_with_templates($distname, $arch, $temppath, $osdistroname);
if ($ret[0] != 0) {
$callback->({data => "Error when updating the osimage tables: " . $ret[1]});
}
my @ret=xCAT::SvrUtils->update_tables_with_diskless_image($distname, $arch, undef, "netboot", $temppath, $osdistroname);
if ($ret[0] != 0) {
$callback->({data => "Error when updating the osimage tables for stateless: " . $ret[1]});
}
my @ret=xCAT::SvrUtils->update_tables_with_diskless_image($distname, $arch, undef, "statelite", $temppath, $osdistroname);
if ($ret[0] != 0) {
$callback->({data => "Error when updating the osimage tables for statelite: " . $ret[1]});
}
}
}
}

View File

@ -42,6 +42,7 @@ my %allracks;
my %allchassis;
my %allswitches;
my %all_switchports;
my %allvmhosts;
my @switch_records;
@ -430,6 +431,10 @@ Usage:
# Get all LPAR ids
$recordsref = xCAT::ProfiledNodeUtils->get_all_lparids(\%allcecs);
%alllparids = %$recordsref;
# Get all vm hosts/hypervisiors
$recordsref = xCAT::ProfiledNodeUtils->get_all_vmhosts();
%allvmhosts = %$recordsref;
#TODO: can not use getallnode to get rack infos.
$recordsref = xCAT::ProfiledNodeUtils->get_all_rack(1);
@ -2103,6 +2108,12 @@ sub gen_new_hostinfo_dict{
$hostinfo_dict{$item}{"mgt"} = "fsp";
}
# Generate VM host nodes' attribute
# Update netboot attribute if this is powerKVM node
if (exists $hostinfo_dict{$item}{"vmhost"}){
$hostinfo_dict{$item}{"netboot"} = 'grub2';
}
# get the chain attribute from hardwareprofile and insert it to node.
my $chaintab = xCAT::Table->new('chain');
my $hardwareprofile = $args_dict{'hardwareprofile'};
@ -2538,6 +2549,12 @@ sub validate_node_entry{
}
}
}
}elsif ($_ eq "vmhost") {
# Support PowerKVM vms
my $vm_host= $node_entry{"vmhost"};
if (! exists $allvmhosts{$node_entry{$_}}){
$errmsg .= "The VM host name $node_entry{$_} that is specified in the node information file is not defined in the system.\n";
}
}else{
$errmsg .= "Invalid attribute $_ specified\n";
}

View File

@ -278,6 +278,10 @@ sub daemonize {
}
my %cmd_handlers;
my $rescanreadpipe;
my $rescanwritepipe;
my $rescanrselect;
my $rescanrequest = "rescanplugins";
sub do_installm_service {
unless ($sport) { return; }
#This function servers as a handler for messages from installing nodes
@ -341,6 +345,19 @@ sleep 0.05; #up to 50 ms outage possible
my $conn;
next unless $conn = $socket->accept;
# check if a rescanplugins request has come in
my @rescans;
if (@rescans = $rescanrselect->can_read(0)) {
foreach my $rrequest (@rescans) {
my $rescan_request = fd_retrieve($rrequest);
if ($$rescan_request =~ /rescanplugins/) {
scan_plugins('','1');
} else {
print "ignoring unrecognized pipe request received by install monitor from ssl listener: $rescan_request \n";
}
}
}
my $client_name;
my $client_aliases;
my @clients;
@ -991,6 +1008,14 @@ unless ($pid_UDP) {
xexit(0);
}
close($sslctl);
# Set up communication pipe to have ssl listener tell install monitor to
# rescanplugins
if ( !(socketpair($rescanreadpipe, $rescanwritepipe,AF_UNIX,SOCK_STREAM,PF_UNSPEC)) ) {
xCAT::MsgUtils->message("S", "socketpair failed: $!");
}
$rescanrselect = new IO::Select;
$rescanrselect->add($rescanreadpipe);
$pid_MON = xCAT::Utils->xfork;
if (! defined $pid_MON) {
xCAT::MsgUtils->message("S", "Unable to fork installmonitor");
@ -1509,6 +1534,9 @@ sub plugin_command {
# rescanplugins request gets handled directly here in xcatd
if ($req->{command}->[0] eq 'rescanplugins') {
scan_plugins($chwritepipe,'1');
if ($rescanwritepipe) {
store_fd(\$rescanrequest,$rescanwritepipe);
}
} else {
${"xCAT_plugin::".$modname."::"}{process_request}->($req,$callback,\&do_request);
}
@ -1602,6 +1630,9 @@ sub plugin_command {
# rescanplugins request gets handled directly here in xcatd
if ($req->{command}->[0] eq 'rescanplugins') {
scan_plugins($chwritepipe,'1');
if ($rescanwritepipe) {
store_fd(\$rescanrequest,$rescanwritepipe);
}
} else {
${"xCAT_plugin::".$modname."::"}{process_request}->($req,$callback,\&do_request);
}
@ -1836,6 +1867,9 @@ sub dispatch_request {
# rescanplugins request gets handled directly here in xcatd
if ($_->{command}->[0] eq 'rescanplugins') {
scan_plugins($chwritepipe,'1');
if ($rescanwritepipe) {
store_fd(\$rescanrequest,$rescanwritepipe);
}
} else {
${"xCAT_plugin::".$modname."::"}{process_request}->($_,$dispatch_cb,\&do_request);
}
@ -1925,6 +1959,9 @@ sub dispatch_request {
# rescanplugins request gets handled directly here in xcatd
if ($_->{command}->[0] eq 'rescanplugins') {
scan_plugins($chwritepipe,'1');
if ($rescanwritepipe) {
store_fd(\$rescanrequest,$rescanwritepipe);
}
} else {
${"xCAT_plugin::".$modname."::"}{process_request}->($_,\&dispatch_callback,\&do_request);
}

View File

@ -272,6 +272,8 @@ if [ -d "$NEWROOT/etc/sysconfig" -a ! -e "$NEWROOT/etc/sysconfig/selinux" ]; the
echo "SELINUX=disabled" >> "$NEWROOT/etc/sysconfig/selinux"
fi
echo `hostname` > $NEWROOT/etc/hostname
# inject new exit_if_exists
echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/initqueue/xcat.sh
# force udevsettle to break

View File

@ -273,9 +273,13 @@ unless ($onlyinitrd) {
#if(-e "$rootimg_dir/etc/zypp/repos.d/${osver}sdk.repo") {
# system("rm -rf $rootimg_dir/etc/zypp/repos.d/${osver}sdk.repo");
#}
my $srcdir_sdk = "$installroot/$osver/$arch/sdk1";
if ( -e "$srcdir_sdk") {
system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir_sdk ${osver}sdk");
my $index=1;
while (1) {
my $srcdir_sdk = "$installroot/$osver/$arch/sdk$index";
if ( -e "$srcdir_sdk") {
system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir_sdk ${osver}sdk$index");
$index++;
} else { last; }
}
}else {
@ -855,7 +859,19 @@ if (@new_order) {
}
# add drivers for local disk support
push @ndrivers, ("ext3.ko", "ext4.ko", "virtio_pci.ko", "virtio_blk.ko", "ata_piix.ko", "libata.ko", "scsi_mod.ko", "scsi_dh.ko", "ahci.ko", "ibmvscsi.ko", "ibmvscsic.ko", "megaraid_sas.ko", "pcieport.ko", "sd_mod.ko");
push @ndrivers, ("ext3.ko", "ext4.ko", "virtio_pci.ko", "virtio_blk.ko", "libata.ko", "scsi_mod.ko", "scsi_dh.ko", "ahci.ko", "megaraid_sas.ko", "sd_mod.ko");
if ($osver_host >= 12) {
push @ndrivers, ("ibmvscsi.ko");
} else { # for sles11 or lower
push @ndrivers, ("ibmvscsic.ko", "ata_piix.ko", "pcieport.ko");
}
if (-f "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/net/ethernet/mellanox/mlx4/mlx4_en.ko") {
for (@ndrivers) {
s/mlx_en/mlx4_en/;
}
}
open($moddeps,"<","$rootimg_dir/lib/modules/$kernelver/modules.dep");
my @moddeps = <$moddeps>;
@ -1957,18 +1973,42 @@ sub generic_post { # This function is meant to leave the image in a state approx
copy("$installroot/postscripts/xcatpostinit", "$rootimg_dir/etc/init.d/xcatpostinit");
chmod(0755, "$rootimg_dir/etc/init.d/xcatpostinit");
#insserv with -f option to ignore the dependency on sles10.4
system("chroot $rootimg_dir insserv -f network sshd gettyset xcatpostinit");
my $rc = system("grep sshd $rootimg_dir/etc/init.d/.depend.start | grep TARGETS");
if ($rc) {
system("sed -i '".'s/^\(TARGETS = .*\)$/\1 sshd/'."' $rootimg_dir/etc/init.d/.depend.start");
system("ln -s ../sshd $rootimg_dir/etc/init.d/rc3.d/S20sshd");
#
# set certain system services to start on boot, if the file exists in /etc/init.d as a script,
# use insserv to start it. If not, assume that the service is controlled by systemctl
#
# note: insserv is passed the -f option to ignore the dependency on sles10.4
#
print "[genimage] setting services to start at boot time...\n";
my @services;
push @services, qw/sshd network gettyset xcatpostinit/;
foreach my $service (@services) {
my $cmd = "chroot $rootimg_dir ";
if (-r "$rootimg_dir/etc/init.d/$service" ) {
$cmd = $cmd . "insserv -f $service";
system("$cmd");
}
else {
print "[genimage] Not starting service $service, verify if started by systemctl\n";
}
}
my $rc = system("grep gettyset $rootimg_dir/etc/init.d/.depend.start | grep TARGETS");
if ($rc) {
system("sed -i '".'s/^\(TARGETS = .*\)$/\1 gettyset/'."' $rootimg_dir/etc/init.d/.depend.start");
system("ln -s ../gettyset $rootimg_dir/etc/init.d/rc3.d/S60gettyset");
#
# Check if .depend.start file exists. For SLES12 and later OS, this does not apply
#
if (-r '$rootimg_dir/etc/init.d/.depend.start') {
my $rc = system("grep sshd $rootimg_dir/etc/init.d/.depend.start | grep TARGETS");
if ($rc) {
system("sed -i '".'s/^\(TARGETS = .*\)$/\1 sshd/'."' $rootimg_dir/etc/init.d/.depend.start");
system("ln -s ../sshd $rootimg_dir/etc/init.d/rc3.d/S20sshd");
}
my $rc = system("grep gettyset $rootimg_dir/etc/init.d/.depend.start | grep TARGETS");
if ($rc) {
system("sed -i '".'s/^\(TARGETS = .*\)$/\1 gettyset/'."' $rootimg_dir/etc/init.d/.depend.start");
system("ln -s ../gettyset $rootimg_dir/etc/init.d/rc3.d/S60gettyset");
}
}
}

View File

@ -628,10 +628,10 @@ while [ $op_index -le $OTHERPKGS_INDEX ]; do
fn=`basename $x`
path=`dirname $x`
whole_path=$OTHERPKGDIR
if [[ ! $OSVER =~ ^ubuntu|^debian ]]; then
echo "rhel package path"
if [[ ! $OSVER =~ ^debian ]]; then
# echo "rhel package path"
whole_path=$OTHERPKGDIR/$path
whole_path=${whole_path%.}
fi
#find out if this path has already handled
@ -689,7 +689,7 @@ while [ $op_index -le $OTHERPKGS_INDEX ]; do
fi
echo "deb $type://$whole_path ./" > $REPOFILE
fi
if [ -n "$OTHERPKGDIR_INTERNET" ];then
if [ -n "$OTHERPKGDIR_INTERNET" ] && [ $index -eq 0 ] ;then
OLDIFS=$IFS
IFS=$','
urlarray=($OTHERPKGDIR_INTERNET)
@ -903,9 +903,9 @@ EOF`
elif [ $hasapt -eq 1 ]; then
apt_get_update_if_repos_changed $REPOFILE
if [ $VERBOSE ]; then
echo "$envlist DEBIAN_FRONTEND=noninteractive apt-get -q -y --force-yes install $repo_pkgs"
echo "$envlist DEBIAN_FRONTEND=noninteractive apt-get -q -y --force-yes -o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef' install $repo_pkgs"
fi
result=`eval $envlist DEBIAN_FRONTEND=noninteractive apt-get -q -y --force-yes install $repo_pkgs 2>&1`
result=`eval $envlist DEBIAN_FRONTEND=noninteractive apt-get -q -y --force-yes -o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef' install $repo_pkgs 2>&1`
R=$?
if [ $R -ne 0 ]; then
RETURNVAL=$R

View File

@ -205,13 +205,15 @@ fi
# We only update the /etc/rsyslog.d/remote.conf file to point to the xcatmaster.
# Do not even touch rsyslog.conf
# There is no /etc/sysconfig/rsyslog file, so we use rsyslogd -v to get the version
SYSLOGPROD=`rsyslogd -v | grep rsyslogd |awk {'print $1'}`
SYSLOGVER=`rsyslogd -v | grep rsyslogd |awk {'print $2'}`
if ( pmatch $SYSLOGPROD "*rsyslogd*" ) && ( pmatch $SYSLOGVER "8*" ); then
config_rsyslog_V8
#keep a record
logger -t xCAT -p local4.info "Install: rsyslog version 8 setup"
exit 0
if [ -e "/sbin/rsyslogd" -o -e "/usr/sbin/rsyslogd" ]; then
SYSLOGPROD=`rsyslogd -v | grep rsyslogd |awk {'print $1'}`
SYSLOGVER=`rsyslogd -v | grep rsyslogd |awk {'print $2'}`
if ( pmatch $SYSLOGPROD "*rsyslogd*" ) && ( pmatch $SYSLOGVER "8*" ); then
config_rsyslog_V8
#keep a record
logger -t xCAT -p local4.info "Install: rsyslog version 8 setup"
exit 0
fi
fi
if [ "$(uname -s)" = "Linux" ]; then