mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-31 03:12:30 +00:00 
			
		
		
		
	Reworked Genesis scripting to provide screen managed console
Have mknb correctly create elilo/xnba config files Have dhcp implement required hooks to start xnba.efi git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@10533 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -1,16 +1,3 @@ | ||||
| root=1 | ||||
| rootok=1 | ||||
| netroot=xcat | ||||
| clear | ||||
| echo '[ -e $NEWROOT/proc ]' > /initqueue-finished/xcatroot.sh | ||||
| mkdir /dev/cgroup | ||||
| mount -t cgroup -o cpu,memory,devices cgroup /dev/cgroup | ||||
| udevd --daemon | ||||
| udevadm trigger | ||||
| mkdir -p /var/lib/dhclient/ | ||||
| mkdir -p /var/log | ||||
| ip link set lo up | ||||
| echo '127.0.0.1 localhost' >> /etc/hosts | ||||
| if [ ! -z "$BOOTIF" ]; then | ||||
| 	BOOTIF=`echo $BOOTIF|sed -e s/01-// -e s/-/:/g` | ||||
| 	echo -n "Waiting for device with address $BOOTIF to appear.." | ||||
| @@ -40,14 +27,6 @@ if [ -r /sys/devices/virtual/dmi/id/product_uuid ]; then | ||||
| 	duid=$duid'";' | ||||
| 	echo $duid > /var/lib/dhclient/dhclient6.leases | ||||
| fi | ||||
| #/bin/sh | ||||
| mkdir -p /etc/ssh | ||||
| mkdir -p /var/empty/sshd | ||||
| echo root:x:0:0::/:/bin/sh >> /etc/passwd | ||||
| echo sshd:x:30:30:SSH User:/var/empty/sshd:/sbin/nologin >> /etc/passwd | ||||
| echo rpc:x:32:32:Rpcbind Daemon:/var/cache/rpcbind:/sbin/nologin >> /etc/passwd | ||||
| echo rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin >> /etc/passwd | ||||
| echo qemu:x:107:107:qemu user:/:/sbin/nologin >> /etc/passwd | ||||
| rpcbind | ||||
| rpc.statd | ||||
| ssh-keygen -q -t rsa -f /etc/ssh/ssh_host_rsa_key -C '' -N '' | ||||
| @@ -60,8 +39,10 @@ echo "[ req ] | ||||
| distinguished_name = nodedn | ||||
|  | ||||
| [ nodedn ]" > /etc/pki/tls/openssl.cnf | ||||
| openssl genrsa -out /etc/xcat/privkey.pem 1024 | ||||
| PUBKEY=`openssl rsa -in /etc/xcat/privkey.pem -pubout|grep -v "PUBLIC KEY"` | ||||
| echo -n "Generating private key..." | ||||
| openssl genrsa -out /etc/xcat/privkey.pem 1024 >& /dev/null | ||||
| echo "Done" | ||||
| PUBKEY=`openssl rsa -in /etc/xcat/privkey.pem -pubout 2> /dev/null|grep -v "PUBLIC KEY"` | ||||
| PUBKEY=`echo $PUBKEY|sed -e 's/ //g'` | ||||
| export PUBKEY | ||||
| /sbin/rsyslogd -c4 | ||||
| @@ -131,7 +112,7 @@ while :; do | ||||
| 	elif [ "$destiny" = shell ]; then | ||||
| 		echo "Dropping to debug shell, exit to check for further action" | ||||
| 		destiny='' | ||||
| 		/bin/sh | ||||
| 		/bin/bash | ||||
| 	elif [ "$destiny" = runcmd ]; then | ||||
| 		destiny=`/bin/nextdestiny $XCATMASTER:$XCATPORT` | ||||
| 		$destparameter | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
| echo $drivers | ||||
| dracut_install wget openssl tar ipmitool cpio gzip modprobe touch echo cut wc | ||||
| dracut_install grep ip hostname awk egrep grep dirname expr | ||||
| dracut_install mount.nfs sshd vi reboot lspci parted libvirtd /usr/share/libvirt/cpu_map.xml mkfs mkfs.ext4 mkfs.btrfs | ||||
| dracut_install mount.nfs sshd vi reboot lspci parted screen libvirtd /usr/share/libvirt/cpu_map.xml mkfs mkfs.ext4 mkfs.btrfs | ||||
| dracut_install mkswap df brctl vconfig ifenslave ssh-keygen /usr/bin/qemu-img /usr/libexec/qemu-kvm scp clear dhclient lldpad | ||||
| dracut_install lldptool /lib64/libnss_dns-2.12.so /lib64/libnss_dns.so.2 | ||||
| dracut_install poweroff ntpq ntpd hwclock date /usr/share/terminfo/x/xterm /etc/nsswitch.conf /etc/services | ||||
| @@ -591,6 +591,7 @@ inst "$moddir/allowcred.awk" "/bin/allowcred.awk" | ||||
| inst "$moddir/getipmi" "/bin/getipmi" | ||||
| inst "$moddir/getdestiny" "/bin/getdestiny" | ||||
| inst "$moddir/restart" "/bin/restart" | ||||
| inst "$moddir/doxcat" "/bin/doxcat" | ||||
| inst "$moddir/nextdestiny" "/bin/nextdestiny" | ||||
| inst "$moddir/getcert" "/bin/getcert" | ||||
| inst "$moddir/dhclient.conf" "/etc/dhclient.conf" | ||||
| @@ -608,6 +609,7 @@ inst "/bin/bash" "/bin/sh" | ||||
| inst "/lib64/libnss_dns-2.12.so" | ||||
| inst "/root/.ssh/id_rsa.pub" "/.ssh/authorized_keys" | ||||
| inst "/lib/terminfo/l/linux" "/lib/terminfo/l/linux" | ||||
| inst "/lib/terminfo/v/vt100" "/lib/terminfo/v/vt100" | ||||
| inst_hook cmdline 10 "$moddir/xcat-cmdline.sh"  | ||||
| dracut_install /lib64/rsyslog/lmtcpclt.so | ||||
| dracut_install /lib64/rsyslog/omtesting.so | ||||
|   | ||||
| @@ -44,6 +44,7 @@ my $nrhash; | ||||
| my $machash; | ||||
| my $vpdhash; | ||||
| my $iscsients; | ||||
| my $nodetypeents; | ||||
| my $chainents; | ||||
| my $tftpdir = xCAT::Utils->getTftpDir(); | ||||
| use Math::BigInt; | ||||
| @@ -65,6 +66,25 @@ if ( $distro =~ /ubuntu*/ ){ | ||||
| 	$dhcpconffile = '/etc/dhcp3/dhcpd.conf';	 | ||||
| } | ||||
|  | ||||
| sub check_uefi_support { | ||||
| 	my $ntent = shift; | ||||
| 	my %blacklist = ( | ||||
| 		"rhels5.*" => 1, | ||||
| 		"centos5.*" => 1, | ||||
| 		"sl5.*" => 1, | ||||
| 		"sles10.*" => 1, | ||||
| 		"esxi4.*" => 1); | ||||
| 	if ($ntent and $ntent->{os}) { | ||||
| 		 foreach (keys %blacklist) { | ||||
| 			if ($ntent->{os} =~ /$_/) { | ||||
| 				return 0; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return 1; | ||||
| } | ||||
|  | ||||
|  | ||||
| sub ipIsDynamic {  | ||||
| 	#meant to be v4/v6 agnostic.  DHCPv6 however takes some care to allow a dynamic range to overlap static reservations | ||||
|     #xCAT will for now continue to advise people to keep their nodes out of the dynamic range | ||||
| @@ -237,6 +257,7 @@ sub addnode | ||||
|     my $nrent; | ||||
|     my $chainent; | ||||
|     my $ient; | ||||
|     my $ntent; | ||||
|     my $tftpserver; | ||||
|     if ($chainents and $chainents->{$node}) { | ||||
|         $chainent = $chainents->{$node}->[0]; | ||||
| @@ -244,6 +265,9 @@ sub addnode | ||||
|     if ($iscsients and $iscsients->{$node}) { | ||||
|         $ient = $iscsients->{$node}->[0]; | ||||
|     } | ||||
|     if ($nodetypeents and $nodetypeents->{$node}) { | ||||
| 	$ntent = $nodetypeents->{$node}->[0]; | ||||
|     } | ||||
|     my $lstatements       = $statements; | ||||
|     my $guess_next_server = 0; | ||||
|     my $nxtsrv; | ||||
| @@ -361,12 +385,18 @@ sub addnode | ||||
|                 $lstatements = 'option root-path \"'.$iscsirootpath.'\";'.$lstatements; | ||||
|             } | ||||
|         } | ||||
|         my $douefi=check_uefi_support($ntent); | ||||
|         if ($nrent and $nrent->{netboot} and $nrent->{netboot} eq 'xnba' and $lstatements !~ /filename/) { | ||||
|             if (-f "$tftpdir/xcat/xnba.kpxe") { | ||||
|                 if ($doiscsi and $chainent and $chainent->{currstate} and ($chainent->{currstate} eq 'iscsiboot' or $chainent->{currstate} eq 'boot')) { | ||||
|                     $lstatements = 'if exists gpxe.bus-id { filename = \"\"; } else if exists client-architecture { filename = \"xcat/xnba.kpxe\"; } '.$lstatements; | ||||
|                     $lstatements = 'if client-architecture = 00:00 and not gpxe.bus-id { filename = \"xcat/xnba.kpxe\"; } else { filename = \"\"; } '.$lstatements; | ||||
|                 } else { | ||||
|                     $lstatements = 'if option user-class-identifier = \"xNBA\" { filename = \"http://'.$nxtsrv.'/tftpboot/xcat/xnba/nodes/'.$node.'\"; } else if exists client-architecture { filename = \"xcat/xnba.kpxe\"; } '.$lstatements; #Only PXE compliant clients should ever receive xNBA | ||||
| 			#TODO: if windows uefi, do vendor-class-identifier of "PXEClient" to bump it over to proxydhcp.c | ||||
| 		    if ($douefi) { | ||||
|                         $lstatements = 'if option user-class-identifier = \"xNBA\" and client-architecture = 00:00 { filename = \"http://'.$nxtsrv.'/tftpboot/xcat/xnba/nodes/'.$node.'\"; } else if option user-class-identifier = \"xNBA\" and client-architecture = 00:09 { filename = \"http://'.$nxtsrv.'/tftpboot/xcat/xnba/nodes/'.$node.'.uefi\"; } else if client-architecture = 00:07 { filename = \"xcat/xnba.efi\"; } else if client-architecture = 00:00 { filename = \"xcat/xnba.kpxe\"; } else { filename = \"\"; }'.$lstatements; #Only PXE compliant clients should ever receive xNBA | ||||
| 		    } else { | ||||
|                         $lstatements = 'if option user-class-identifier = \"xNBA\" and client-architecture = 00:00 { filename = \"http://'.$nxtsrv.'/tftpboot/xcat/xnba/nodes/'.$node.'\"; } else if client-architecture = 00:00 { filename = \"xcat/xnba.kpxe\"; } else { filename = \"\"; }'.$lstatements; #Only PXE compliant clients should ever receive xNBA | ||||
| 		   } | ||||
|                 }  | ||||
|             } #TODO: warn when windows | ||||
|         } elsif ($nrent and $nrent->{netboot} and $nrent->{netboot} eq 'pxe' and $lstatements !~ /filename/) { | ||||
| @@ -1293,7 +1323,12 @@ sub process_request | ||||
|             $chainents = undef; | ||||
|         } | ||||
|         $nrhash = $nrtab->getNodesAttribs($req->{node}, ['tftpserver','netboot']); | ||||
|         my $iscsitab = xCAT::Table->new('iscsi'); | ||||
|         my $nodetypetab; | ||||
| 	$nodetypetab = xCAT::Table->new('nodetype',-create=>0); | ||||
| 	if ($nodetypetab) { | ||||
|             $nodetypeents = $nodetypetab->getNodesAttribs($req->{node},[qw(os)]); | ||||
| 	} | ||||
|         my $iscsitab = xCAT::Table->new('iscsi',-create=>0); | ||||
|         if ($iscsitab) { | ||||
|             $iscsients = $iscsitab->getNodesAttribs($req->{node},[qw(server target lun iname)]); | ||||
|         } | ||||
| @@ -1820,12 +1855,20 @@ sub addnet | ||||
|         } | ||||
|  | ||||
|                        # $lstatements = 'if exists gpxe.bus-id { filename = \"\"; } else if exists client-architecture { filename = \"xcat/xnba.kpxe\"; } '.$lstatements; | ||||
|         push @netent, "    if option user-class-identifier = \"xNBA\" { #x86, xCAT Network Boot Agent\n"; | ||||
|         push @netent, "    if option user-class-identifier = \"xNBA\" and option client-architecture = 00:00 { #x86, xCAT Network Boot Agent\n"; | ||||
|         push @netent, "       filename = \"http://$tftp/tftpboot/xcat/xnba/nets/".$net."_".$maskbits."\";\n"; | ||||
|         push @netent, "    } else if option user-class-identifier = \"xNBA\" and option client-architecture = 00:09 { #x86, xCAT Network Boot Agent\n"; | ||||
|         push @netent, "       filename = \"http://$tftp/tftpboot/xcat/xnba/nets/".$net."_".$maskbits.".uefi\";\n"; | ||||
|         push @netent, "    } else if option client-architecture = 00:00  { #x86\n"; | ||||
|         push @netent, "      filename \"xcat/xnba.kpxe\";\n"; | ||||
|         push @netent, "    } else if option vendor-class-identifier = \"Etherboot-5.4\"  { #x86\n"; | ||||
|         push @netent, "      filename \"xcat/xnba.kpxe\";\n"; | ||||
|         push @netent, | ||||
|           "    } else if option client-architecture = 00:07 { #x86_64 uefi\n "; | ||||
|         push @netent, "      filename \"xcat/xnba.efi\";\n"; | ||||
|         push @netent, | ||||
|           "    } else if option client-architecture = 00:09 { #x86_64 uefi alternative id\n "; | ||||
|         push @netent, "      filename \"xcat/xnba.efi\";\n"; | ||||
|         push @netent, | ||||
|           "    } else if option client-architecture = 00:02 { #ia64\n "; | ||||
|         push @netent, "      filename \"elilo.efi\";\n"; | ||||
|   | ||||
| @@ -189,15 +189,15 @@ sub process_request { | ||||
|          close($cfg); | ||||
| 	if ($invisibletouch and $arch =~ /x86_64/) { #UEFI time | ||||
|          open($cfg,">","$tftpdir/xcat/xnba/nets/$net.elilo"); | ||||
|          print $cfg "default=xCAT Genesis\ndelay=5\n\n"; | ||||
|          print $cfg 'image=xcat/genesis.kernel.'."$arch\n"; | ||||
| 	 print $cfg "   label=xCAT Genesis\n"; | ||||
| 	 print $cfg "   initrd=xcat/genesis.fs.$arch.gz\n"; | ||||
| 	 print $cfg "   append=\"quiet xcatd=".$normnets->{$_}.":$xcatdport destiny=discover $consolecmdline\n"; | ||||
|          print $cfg "default=\"xCAT Genesis\"\ndelay=5\n\n"; | ||||
|          print $cfg 'image=/tftpboot/xcat/genesis.kernel.'."$arch\n"; | ||||
| 	 print $cfg "   label=\"xCAT Genesis\"\n"; | ||||
| 	 print $cfg "   initrd=/tftpboot/xcat/genesis.fs.$arch.gz\n"; | ||||
| 	 print $cfg "   append=\"quiet xcatd=".$normnets->{$_}.":$xcatdport destiny=discover $consolecmdline BOOTIF=%B\"\n"; | ||||
| 	 close($cfg); | ||||
|          open($cfg,">","$tftpdir/xcat/xnba/nets/$net.uefi"); | ||||
|          print $cfg "#!gpxe\n"; | ||||
| 	 print $cfg 'chain http://${next-server}/tftpboot/elilo-x64.efi'."\n"; | ||||
| 	 print $cfg 'chain http://${next-server}/tftpboot/xcat/elilo-x64.efi -C /tftpboot/xcat/xnba/nets/'."$net.elilo\n"; | ||||
| 	 close($cfg); | ||||
| 	} | ||||
| 	 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user