mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-06-13 18:00:38 +00:00
fix #1157, enhance rinstall command
This commit is contained in:
@ -19,7 +19,11 @@ Name
|
||||
****************
|
||||
|
||||
|
||||
\ **rinstall**\ [\ **-O | -**\ **-osimage**\ ] [\ **-c | -**\ **-console**\ ] [\ *noderange*\ ]
|
||||
\ **rinstall**\ \ *noderange*\ \ **boot**\ | \ **shell**\ | \ **runcmd=bmcsetup**\ [\ **-c | -**\ **-console**\ ] [\ **-V | -**\ **-verbose**\ ]
|
||||
|
||||
\ **rinstall**\ \ *noderange*\ \ **osimage**\ =\ *imagename*\ | [\ **-O**\ ] \ *imagename*\ [\ **-**\ **-ignorekernelchk**\ ] [\ **-c | -**\ **-console**\ ] [\ **-u | -**\ **-uefimode**\ ] [\ **-V | -**\ **-verbose**\ ]
|
||||
|
||||
\ **rinstall**\ [\ **-h | -**\ **-help | -v | -**\ **-version**\ ]
|
||||
|
||||
|
||||
*******************
|
||||
@ -27,9 +31,9 @@ Name
|
||||
*******************
|
||||
|
||||
|
||||
\ **rinstall**\ is a convenience command that will change tables as requested for operating system version, profile, and architecture, call \ **nodeset**\ to modify the network boot configuration, call \ **rsetboot**\ net to set the next boot over network (only support nodes with "nodetype.mgt=ipmi", for other nodes, make sure the correct boot order has been set before \ **rinstall**\ ), and \ **rpower**\ to begin a boot cycle.
|
||||
\ **rinstall**\ is a convenience command to begin OS provision on a noderange(support nodes with "nodetype.mgt=ipmi,blade,hmc,ivm,fsp,kvm,esx,rhevm").
|
||||
|
||||
If [\ **-O | -**\ **-osimage**\ ] is specified or nodetype.provmethod=\ **osimage**\ is set, provision the noderange with the osimage specified/configured, ignore the table change options if specified.
|
||||
If \ **osimage**\ =\ *imagename*\ | \ **-O**\ \ *imagename*\ is specified or nodetype.provmethod=\ **osimage**\ is set, provision the noderange with the osimage specified/configured.
|
||||
|
||||
If -c is specified, it will then run rcons on the node. This is allowed only if one node in the noderange. If need consoles on multiple nodes , see winstall(8)|winstall.8.
|
||||
|
||||
@ -40,6 +44,44 @@ If -c is specified, it will then run rcons on the node. This is allowed only if
|
||||
|
||||
|
||||
|
||||
\ **boot**\
|
||||
|
||||
Instruct network boot loader to be skipped, generally meaning boot to hard disk
|
||||
|
||||
|
||||
|
||||
\ **osimage | osimage=**\ \ *imagename*\ |\ **-O**\ \ *imagename*\
|
||||
|
||||
Prepare server for installing a node using the specified os image. The os image is defined in the \ *osimage*\ table and \ *linuximage*\ table. If the <imagename> is omitted, the os image name will be obtained from \ *nodetype.provmethod*\ for the node.
|
||||
|
||||
|
||||
|
||||
\ **-**\ **-ignorekernelchk**\
|
||||
|
||||
Skip the kernel version checking when injecting drivers from osimage.driverupdatesrc. That means all drivers from osimage.driverupdatesrc will be injected to initrd for the specific target kernel.
|
||||
|
||||
|
||||
|
||||
\ **runimage**\ =\ *task*\
|
||||
|
||||
If you would like to run a task after deployment, you can define that task with this attribute.
|
||||
|
||||
|
||||
|
||||
\ **runcmd=bmcsetup**\
|
||||
|
||||
This instructs the node to boot to the xCAT nbfs environment and proceed to configure BMC
|
||||
for basic remote access. This causes the IP, netmask, gateway, username, and password to be programmed according to the configuration table.
|
||||
|
||||
|
||||
|
||||
\ **shell**\
|
||||
|
||||
This instructs tho node to boot to the xCAT genesis environment, and present a shell prompt on console.
|
||||
The node will also be able to be sshed into and have utilities such as wget, tftp, scp, nfs, and cifs. It will have storage drivers available for many common systems.
|
||||
|
||||
|
||||
|
||||
\ **-h | -**\ **-help**\
|
||||
|
||||
Display usage message.
|
||||
@ -52,15 +94,21 @@ If -c is specified, it will then run rcons on the node. This is allowed only if
|
||||
|
||||
|
||||
|
||||
\ **-O | -**\ **-osimage**\
|
||||
\ **-u | -**\ **-uefimode**\
|
||||
|
||||
Specifies the osimage to provision.
|
||||
For BMC-based servers, to specify the next boot mode to be "UEFI Mode".
|
||||
|
||||
|
||||
|
||||
\ **-V | -**\ **-Verbose**\
|
||||
|
||||
Verbose output.
|
||||
|
||||
|
||||
|
||||
\ **-c | -**\ **-console**\
|
||||
|
||||
Requests that rinstall runs rcons once the provision starts. This will only work if there is only one node in the noderange. See winstall(8)|winstall.8 for starting nsoles on multiple nodes.
|
||||
Requests that rinstall runs rcons once the provision starts. This will only work if there is only one node in the noderange. See winstall(8)|winstall.8 for starting consoles on multiple nodes.
|
||||
|
||||
|
||||
|
||||
@ -86,7 +134,7 @@ If -c is specified, it will then run rcons on the node. This is allowed only if
|
||||
|
||||
.. code-block:: perl
|
||||
|
||||
rinstall node1-node20 -O rhels6.4-ppc64-netboot-compute
|
||||
rinstall node1-node20 osimage=rhels6.4-ppc64-netboot-compute
|
||||
|
||||
|
||||
|
||||
|
@ -19,9 +19,11 @@ Name
|
||||
****************
|
||||
|
||||
|
||||
\ **winstall**\ [\ **-o | -**\ **-osver**\ ] [\ **-p | -**\ **-profile**\ ] [\ **-a | -**\ **-arch**\ ] [\ *noderange*\ ]
|
||||
\ **rinstall**\ \ *noderange*\ \ **boot**\ | \ **shell**\ | \ **runcmd=bmcsetup**\ [\ **-c | -**\ **-console**\ ] [\ **-V | -**\ **-verbose**\ ]
|
||||
|
||||
\ **winstall**\ [\ **-O | -**\ **-osimage**\ ] [\ *noderange*\ ]
|
||||
\ **rinstall**\ \ *noderange*\ \ **osimage**\ =\ *imagename*\ | [\ **-O**\ ] \ *imagename*\ [\ **-**\ **-ignorekernelchk**\ ] [\ **-c | -**\ **-console**\ ] [\ **-u | -**\ **-uefimode**\ ] [\ **-V | -**\ **-verbose**\ ]
|
||||
|
||||
\ **rinstall**\ [\ **-h | -**\ **-help | -v | -**\ **-version**\ ]
|
||||
|
||||
|
||||
*******************
|
||||
@ -29,10 +31,9 @@ Name
|
||||
*******************
|
||||
|
||||
|
||||
\ **winstall**\ is a convenience tool that will change attributes as requested for operating system version, profile, and architecture, call \ **nodeset**\ to modify the network boot configuration, call \ **rsetboot**\ net to set the next boot over network (only support nodes
|
||||
with "nodetype.mgt=ipmi", for other nodes, make sure the correct boot order has been set before \ **winstall**\ ), and \ **rpower**\ to begin a boot cycle.
|
||||
\ **winstall**\ is a convenience command to begin OS provision on a noderange(support nodes with "nodetype.mgt=ipmi,blade,hmc,ivm,fsp,kvm,esx,rhevm").
|
||||
|
||||
If [\ **-O | -**\ **-osimage**\ ] is specified or nodetype.provmethod=\ *osimage*\ is set, provision the noderange with the osimage specified/configured, ignore the table change options if specified.
|
||||
If \ **osimage**\ =\ *imagename*\ | \ **-O**\ \ *imagename*\ is specified or nodetype.provmethod=\ **osimage**\ is set, provision the noderange with the osimage specified/configured.
|
||||
|
||||
It will then run wcons on the nodes.
|
||||
|
||||
@ -43,6 +44,44 @@ It will then run wcons on the nodes.
|
||||
|
||||
|
||||
|
||||
\ **boot**\
|
||||
|
||||
Instruct network boot loader to be skipped, generally meaning boot to hard disk
|
||||
|
||||
|
||||
|
||||
\ **osimage | osimage=**\ \ *imagename*\ |\ **-O**\ \ *imagename*\
|
||||
|
||||
Prepare server for installing a node using the specified os image. The os image is defined in the \ *osimage*\ table and \ *linuximage*\ table. If the <imagename> is omitted, the os image name will be obtained from \ *nodetype.provmethod*\ for the node.
|
||||
|
||||
|
||||
|
||||
\ **-**\ **-ignorekernelchk**\
|
||||
|
||||
Skip the kernel version checking when injecting drivers from osimage.driverupdatesrc. That means all drivers from osimage.driverupdatesrc will be injected to initrd for the specific target kernel.
|
||||
|
||||
|
||||
|
||||
\ **runimage**\ =\ *task*\
|
||||
|
||||
If you would like to run a task after deployment, you can define that task with this attribute.
|
||||
|
||||
|
||||
|
||||
\ **runcmd=bmcsetup**\
|
||||
|
||||
This instructs the node to boot to the xCAT nbfs environment and proceed to configure BMC
|
||||
for basic remote access. This causes the IP, netmask, gateway, username, and password to be programmed according to the configuration table.
|
||||
|
||||
|
||||
|
||||
\ **shell**\
|
||||
|
||||
This instructs tho node to boot to the xCAT genesis environment, and present a shell prompt on console.
|
||||
The node will also be able to be sshed into and have utilities such as wget, tftp, scp, nfs, and cifs. It will have storage drivers available for many common systems.
|
||||
|
||||
|
||||
|
||||
\ **-h | -**\ **-help**\
|
||||
|
||||
Display usage message.
|
||||
@ -55,27 +94,21 @@ It will then run wcons on the nodes.
|
||||
|
||||
|
||||
|
||||
\ **-o | -**\ **-osver**\
|
||||
\ **-u | -**\ **-uefimode**\
|
||||
|
||||
Specifies which os version to provision. If unspecified, the current node os setting is used. Will be ignored if [\ *-O*\ | \ *--osimage*\ ] is specified or nodetype.provmethod=\ *osimage*\ .
|
||||
For BMC-based servers, to specify the next boot mode to be "UEFI Mode".
|
||||
|
||||
|
||||
|
||||
\ **-p | -**\ **-profile**\
|
||||
\ **-V | -**\ **-Verbose**\
|
||||
|
||||
Specifies what profile should be used of the operating system. If not specified the current node profile setting is used. Will be ignored if [\ **-O | -**\ **-osimage**\ ] is specified or nodetype.provmethod=\ *osimage*\ .
|
||||
Verbose output.
|
||||
|
||||
|
||||
|
||||
\ **-a | -**\ **-arch**\
|
||||
\ **-c | -**\ **-console**\
|
||||
|
||||
Specifies what architecture of the OS to provision. Typically this is unneeded, but if provisioning between x86_64 and x86 frequently, this may be a useful flag. Will be ignored if [\ **-O | -**\ **-osimage**\ ] is specified or nodetype.provmethod=\ *osimage*\ .
|
||||
|
||||
|
||||
|
||||
\ **-O | -**\ **-osimage**\
|
||||
|
||||
Specifies the osimage to provision.
|
||||
Requests that rinstall runs rcons once the provision starts. This will only work if there is only one node in the noderange. See winstall(8)|winstall.8 for starting consoles on multiple nodes.
|
||||
|
||||
|
||||
|
||||
@ -96,17 +129,7 @@ It will then run wcons on the nodes.
|
||||
|
||||
|
||||
|
||||
2. Provision nodes 1 through 20, forcing rhels5.1 and compute profile.
|
||||
|
||||
|
||||
.. code-block:: perl
|
||||
|
||||
winstall node1-node20 -o rhels5.1 -p compute
|
||||
|
||||
|
||||
|
||||
|
||||
3. Provision nodes 1 through 20 with the osimage rhels6.4-ppc64-netboot-compute.
|
||||
2. Provision nodes 1 through 20 with the osimage rhels6.4-ppc64-netboot-compute.
|
||||
|
||||
|
||||
.. code-block:: perl
|
||||
|
@ -4,13 +4,17 @@ B<rinstall> - Begin OS provision on a noderange
|
||||
|
||||
=head1 B<Synopsis>
|
||||
|
||||
B<rinstall> [B<-O>|B<--osimage>] [B<-c>|B<--console>] [I<noderange>]
|
||||
B<rinstall> I<noderange> B<boot> | B<shell> | B<runcmd=bmcsetup> [B<-c>|B<--console>] [B<-V>|B<--verbose>]
|
||||
|
||||
B<rinstall> I<noderange> B<osimage>=I<imagename> | [B<-O>] I<imagename> [B<--ignorekernelchk>] [B<-c>|B<--console>] [B<-u>|B<--uefimode>] [B<-V>|B<--verbose>]
|
||||
|
||||
B<rinstall> [B<-h>|B<--help>|B<-v>|B<--version>]
|
||||
|
||||
=head1 B<Description>
|
||||
|
||||
B<rinstall> is a convenience command that will change tables as requested for operating system version, profile, and architecture, call B<nodeset> to modify the network boot configuration, call B<rsetboot> net to set the next boot over network (only support nodes with "nodetype.mgt=ipmi", for other nodes, make sure the correct boot order has been set before B<rinstall>), and B<rpower> to begin a boot cycle.
|
||||
B<rinstall> is a convenience command to begin OS provision on a noderange(support nodes with "nodetype.mgt=ipmi,blade,hmc,ivm,fsp,kvm,esx,rhevm").
|
||||
|
||||
If [B<-O>|B<--osimage>] is specified or nodetype.provmethod=B<osimage> is set, provision the noderange with the osimage specified/configured, ignore the table change options if specified.
|
||||
If B<osimage>=I<imagename> | B<-O> I<imagename> is specified or nodetype.provmethod=B<osimage> is set, provision the noderange with the osimage specified/configured.
|
||||
|
||||
If -c is specified, it will then run rcons on the node. This is allowed only if one node in the noderange. If need consoles on multiple nodes , see L<winstall(8)|winstall.8>.
|
||||
|
||||
@ -18,6 +22,32 @@ If -c is specified, it will then run rcons on the node. This is allowed only if
|
||||
|
||||
=over 7
|
||||
|
||||
=item B<boot>
|
||||
|
||||
Instruct network boot loader to be skipped, generally meaning boot to hard disk
|
||||
|
||||
=item B<osimage>|B<osimage=>I<imagename>|B<-O>I<imagename>
|
||||
|
||||
Prepare server for installing a node using the specified os image. The os image is defined in the I<osimage> table and I<linuximage> table. If the <imagename> is omitted, the os image name will be obtained from I<nodetype.provmethod> for the node.
|
||||
|
||||
=item B<--ignorekernelchk>
|
||||
|
||||
Skip the kernel version checking when injecting drivers from osimage.driverupdatesrc. That means all drivers from osimage.driverupdatesrc will be injected to initrd for the specific target kernel.
|
||||
|
||||
=item B<runimage>=I<task>
|
||||
|
||||
If you would like to run a task after deployment, you can define that task with this attribute.
|
||||
|
||||
=item B<runcmd=bmcsetup>
|
||||
|
||||
This instructs the node to boot to the xCAT nbfs environment and proceed to configure BMC
|
||||
for basic remote access. This causes the IP, netmask, gateway, username, and password to be programmed according to the configuration table.
|
||||
|
||||
=item B<shell>
|
||||
|
||||
This instructs tho node to boot to the xCAT genesis environment, and present a shell prompt on console.
|
||||
The node will also be able to be sshed into and have utilities such as wget, tftp, scp, nfs, and cifs. It will have storage drivers available for many common systems.
|
||||
|
||||
=item B<-h>|B<--help>
|
||||
|
||||
Display usage message.
|
||||
@ -26,13 +56,17 @@ Display usage message.
|
||||
|
||||
Display version.
|
||||
|
||||
=item B<-O>|B<--osimage>
|
||||
=item B<-u>|B<--uefimode>
|
||||
|
||||
Specifies the osimage to provision.
|
||||
For BMC-based servers, to specify the next boot mode to be "UEFI Mode".
|
||||
|
||||
=item B<-V>|B<--Verbose>
|
||||
|
||||
Verbose output.
|
||||
|
||||
=item B<-c>|B<--console>
|
||||
|
||||
Requests that rinstall runs rcons once the provision starts. This will only work if there is only one node in the noderange. See L<winstall(8)|winstall.8> for starting nsoles on multiple nodes.
|
||||
Requests that rinstall runs rcons once the provision starts. This will only work if there is only one node in the noderange. See L<winstall(8)|winstall.8> for starting consoles on multiple nodes.
|
||||
|
||||
=back
|
||||
|
||||
@ -49,7 +83,7 @@ Provision nodes 1 through 20, using their current configuration.
|
||||
=item 2.
|
||||
Provision nodes 1 through 20 with the osimage rhels6.4-ppc64-netboot-compute.
|
||||
|
||||
rinstall node1-node20 -O rhels6.4-ppc64-netboot-compute
|
||||
rinstall node1-node20 osimage=rhels6.4-ppc64-netboot-compute
|
||||
|
||||
=item 3.
|
||||
Provision node1 and start a console to monitor the process.
|
||||
|
@ -4,16 +4,17 @@ B<winstall> - Begin OS provision on a noderange
|
||||
|
||||
=head1 B<Synopsis>
|
||||
|
||||
B<winstall> [B<-o>|B<--osver>] [B<-p>|B<--profile>] [B<-a>|B<--arch>] [I<noderange>]
|
||||
B<rinstall> I<noderange> B<boot> | B<shell> | B<runcmd=bmcsetup> [B<-c>|B<--console>] [B<-V>|B<--verbose>]
|
||||
|
||||
B<winstall> [B<-O>|B<--osimage>] [I<noderange>]
|
||||
B<rinstall> I<noderange> B<osimage>=I<imagename> | [B<-O>] I<imagename> [B<--ignorekernelchk>] [B<-c>|B<--console>] [B<-u>|B<--uefimode>] [B<-V>|B<--verbose>]
|
||||
|
||||
B<rinstall> [B<-h>|B<--help>|B<-v>|B<--version>]
|
||||
|
||||
=head1 B<Description>
|
||||
|
||||
B<winstall> is a convenience tool that will change attributes as requested for operating system version, profile, and architecture, call B<nodeset> to modify the network boot configuration, call B<rsetboot> net to set the next boot over network (only support nodes
|
||||
with "nodetype.mgt=ipmi", for other nodes, make sure the correct boot order has been set before B<winstall>), and B<rpower> to begin a boot cycle.
|
||||
B<winstall> is a convenience command to begin OS provision on a noderange(support nodes with "nodetype.mgt=ipmi,blade,hmc,ivm,fsp,kvm,esx,rhevm").
|
||||
|
||||
If [B<-O>|B<--osimage>] is specified or nodetype.provmethod=I<osimage> is set, provision the noderange with the osimage specified/configured, ignore the table change options if specified.
|
||||
If B<osimage>=I<imagename> | B<-O> I<imagename> is specified or nodetype.provmethod=B<osimage> is set, provision the noderange with the osimage specified/configured.
|
||||
|
||||
It will then run wcons on the nodes.
|
||||
|
||||
@ -21,6 +22,32 @@ It will then run wcons on the nodes.
|
||||
|
||||
=over 7
|
||||
|
||||
=item B<boot>
|
||||
|
||||
Instruct network boot loader to be skipped, generally meaning boot to hard disk
|
||||
|
||||
=item B<osimage>|B<osimage=>I<imagename>|B<-O>I<imagename>
|
||||
|
||||
Prepare server for installing a node using the specified os image. The os image is defined in the I<osimage> table and I<linuximage> table. If the <imagename> is omitted, the os image name will be obtained from I<nodetype.provmethod> for the node.
|
||||
|
||||
=item B<--ignorekernelchk>
|
||||
|
||||
Skip the kernel version checking when injecting drivers from osimage.driverupdatesrc. That means all drivers from osimage.driverupdatesrc will be injected to initrd for the specific target kernel.
|
||||
|
||||
=item B<runimage>=I<task>
|
||||
|
||||
If you would like to run a task after deployment, you can define that task with this attribute.
|
||||
|
||||
=item B<runcmd=bmcsetup>
|
||||
|
||||
This instructs the node to boot to the xCAT nbfs environment and proceed to configure BMC
|
||||
for basic remote access. This causes the IP, netmask, gateway, username, and password to be programmed according to the configuration table.
|
||||
|
||||
=item B<shell>
|
||||
|
||||
This instructs tho node to boot to the xCAT genesis environment, and present a shell prompt on console.
|
||||
The node will also be able to be sshed into and have utilities such as wget, tftp, scp, nfs, and cifs. It will have storage drivers available for many common systems.
|
||||
|
||||
=item B<-h>|B<--help>
|
||||
|
||||
Display usage message.
|
||||
@ -29,22 +56,17 @@ Display usage message.
|
||||
|
||||
Display version.
|
||||
|
||||
=item B<-o>|B<--osver>
|
||||
=item B<-u>|B<--uefimode>
|
||||
|
||||
Specifies which os version to provision. If unspecified, the current node os setting is used. Will be ignored if [I<-O> | I<--osimage>] is specified or nodetype.provmethod=I<osimage>.
|
||||
For BMC-based servers, to specify the next boot mode to be "UEFI Mode".
|
||||
|
||||
=item B<-p>|B<--profile>
|
||||
=item B<-V>|B<--Verbose>
|
||||
|
||||
Specifies what profile should be used of the operating system. If not specified the current node profile setting is used. Will be ignored if [B<-O>|B<--osimage>] is specified or nodetype.provmethod=I<osimage>.
|
||||
Verbose output.
|
||||
|
||||
=item B<-c>|B<--console>
|
||||
|
||||
=item B<-a>|B<--arch>
|
||||
|
||||
Specifies what architecture of the OS to provision. Typically this is unneeded, but if provisioning between x86_64 and x86 frequently, this may be a useful flag. Will be ignored if [B<-O>|B<--osimage>] is specified or nodetype.provmethod=I<osimage>.
|
||||
|
||||
=item B<-O>|B<--osimage>
|
||||
|
||||
Specifies the osimage to provision.
|
||||
Requests that rinstall runs rcons once the provision starts. This will only work if there is only one node in the noderange. See L<winstall(8)|winstall.8> for starting consoles on multiple nodes.
|
||||
|
||||
=back
|
||||
|
||||
@ -58,11 +80,6 @@ Provison nodes 1 through 20, using their current configuration.
|
||||
winstall node1-node20
|
||||
|
||||
=item 2.
|
||||
Provision nodes 1 through 20, forcing rhels5.1 and compute profile.
|
||||
|
||||
winstall node1-node20 -o rhels5.1 -p compute
|
||||
|
||||
=item 3.
|
||||
Provision nodes 1 through 20 with the osimage rhels6.4-ppc64-netboot-compute.
|
||||
|
||||
winstall node1-node20 -O rhels6.4-ppc64-netboot-compute
|
||||
|
@ -2,11 +2,11 @@
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head1
|
||||
xCAT plugin package to handle rinstall and winstall
|
||||
xCAT plugin package to handle rinstall and winstall
|
||||
|
||||
Supported command:
|
||||
rinstall - runs nodeset, rsetboot,rpower commands
|
||||
winstall - also opens the console
|
||||
Supported command:
|
||||
rinstall - runs nodeset, rsetboot, rpower commands
|
||||
winstall - also opens the console
|
||||
|
||||
=cut
|
||||
|
||||
@ -26,18 +26,16 @@ use Getopt::Long;
|
||||
|
||||
=head3 handled_commands
|
||||
|
||||
Return list of commands handled by this plugin
|
||||
Return list of commands handled by this plugin
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
sub handled_commands
|
||||
{
|
||||
sub handled_commands {
|
||||
return {
|
||||
rinstall => "rinstall",
|
||||
winstall => "rinstall",
|
||||
};
|
||||
rinstall => "rinstall",
|
||||
winstall => "rinstall",
|
||||
};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
@ -47,353 +45,509 @@ sub handled_commands
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
sub process_request
|
||||
{
|
||||
|
||||
my $request = shift;
|
||||
sub process_request {
|
||||
my $request = shift;
|
||||
my $callback = shift;
|
||||
my $subreq = shift;
|
||||
my $subreq = shift;
|
||||
|
||||
rinstall($request, $callback, $subreq);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 rinstall
|
||||
|
||||
Wrapper around nodeset, rsetboot, rpower for the admin convenience
|
||||
=head3 rinstall
|
||||
|
||||
Wrapper around nodeset, rsetboot, rpower for the admin convenience
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
sub rinstall
|
||||
{
|
||||
sub rinstall {
|
||||
my ($req, $callback, $subreq) = @_;
|
||||
$::CALLBACK=$callback;
|
||||
my $OSVER;
|
||||
my $PROFILE;
|
||||
my $ARCH;
|
||||
my $CONSOLE;
|
||||
my $OSIMAGE;
|
||||
my $STATES;
|
||||
my $ignorekernelchk;
|
||||
my $VERBOSE;
|
||||
my $HELP;
|
||||
my $VERSION;
|
||||
my $command = $req->{command}->[0]; # could be rinstall on winstall
|
||||
my $args;
|
||||
if (defined($req->{arg}) ) { # there are arguments
|
||||
$args=$req->{arg}; # argument
|
||||
@ARGV = @{$args};
|
||||
}
|
||||
my $UEFIMODE;
|
||||
# Could be rinstall or winstall
|
||||
my $command = $req->{command}->[0];
|
||||
|
||||
my $nodes;
|
||||
my @nodes;
|
||||
if (defined ($req->{node})) { # there are nodes
|
||||
$nodes = $req->{node};
|
||||
@nodes=@$nodes;
|
||||
my %nodes;
|
||||
# There are nodes
|
||||
if (defined($req->{node})) {
|
||||
$nodes = $req->{node};
|
||||
@nodes = @$nodes;
|
||||
}
|
||||
# no arguments, no nodes then input wrong
|
||||
if ((scalar(@nodes) == 0) && (scalar(@ARGV) == 0)){
|
||||
&usage($command,$callback);
|
||||
return 1;
|
||||
}
|
||||
#print Dumper($req);
|
||||
Getopt::Long::Configure("bundling");
|
||||
|
||||
unless (
|
||||
GetOptions(
|
||||
'o|osver=s' => \$OSVER,
|
||||
'p|profile=s' => \$PROFILE,
|
||||
'a|arch=s' => \$ARCH,
|
||||
'O|osimage=s' => \$OSIMAGE,
|
||||
'h|help' => \$HELP,
|
||||
'v|version' => \$VERSION,
|
||||
'c|console' => \$CONSOLE
|
||||
)
|
||||
)
|
||||
{
|
||||
&usage($command,$callback);
|
||||
return 1;
|
||||
my $args;
|
||||
# There are arguments
|
||||
if (defined($req->{arg})) {
|
||||
$args = $req->{arg};
|
||||
@ARGV = @{$args};
|
||||
}
|
||||
if ($HELP)
|
||||
{
|
||||
&usage($command,$callback);
|
||||
return 0;
|
||||
|
||||
if (($command =~ /rinstall/) or ($command =~ /winstall/)) {
|
||||
my $state = $ARGV[0];
|
||||
my $reststates;
|
||||
($state, $reststates) = split (/,/, $state, 2);
|
||||
chomp($state);
|
||||
if ($state eq "image" or $state eq "winshell" or $state =~ /^osimage/) {
|
||||
my $target;
|
||||
my $action;
|
||||
if ($state =~ /=/) {
|
||||
($state,$target) = split '=',$state,2;
|
||||
if ($target =~ /:/) {
|
||||
($target, $action) = split ':',$target,2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($state =~ /:/) {
|
||||
($state, $action) = split ':',$state,2;
|
||||
}
|
||||
}
|
||||
if ($state eq 'osimage') {
|
||||
$OSIMAGE = $target;
|
||||
}
|
||||
}
|
||||
else {
|
||||
unless ($state =~ /-/) {
|
||||
$STATES = $state;
|
||||
}
|
||||
}
|
||||
|
||||
Getopt::Long::Configure("bundling");
|
||||
Getopt::Long::Configure("no_pass_through");
|
||||
unless (
|
||||
GetOptions ('O|osimage=s' => \$OSIMAGE,
|
||||
'ignorekernelchk' => \$ignorekernelchk,
|
||||
'V|verbose' => \$VERBOSE,
|
||||
'h|help' => \$HELP,
|
||||
'v|version' => \$VERSION,
|
||||
'u|uefimode' => \$UEFIMODE,
|
||||
'c|console' => \$CONSOLE)
|
||||
) {
|
||||
&usage($command,$callback);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if ($VERSION)
|
||||
{
|
||||
if ($HELP) {
|
||||
&usage($command,$callback);
|
||||
return 0;
|
||||
}
|
||||
if ($VERSION) {
|
||||
my $version = xCAT::Utils->Version();
|
||||
my $rsp = {};
|
||||
$rsp->{data}->[0] = "$version";
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (scalar @$nodes eq 0)
|
||||
{
|
||||
my $rsp = {};
|
||||
$rsp->{error}->[0] ="noderange not supplied";
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
if (scalar(@nodes) == 0) {
|
||||
&usage($command,$callback);
|
||||
return 1;
|
||||
}
|
||||
|
||||
my $rc = 0;
|
||||
my %pnhash;
|
||||
my $rc = 0;
|
||||
my @parameter;
|
||||
|
||||
|
||||
if ($OSIMAGE)
|
||||
{
|
||||
my $nodehmtable = xCAT::Table->new("nodehm");
|
||||
my $nodehmcache = $nodehmtable->getNodesAttribs(\@nodes, ['mgt']);
|
||||
$nodehmtable->close();
|
||||
|
||||
# -O|--osimage is specified, ignore any -a,-p,-o options,
|
||||
if ($OSIMAGE) {
|
||||
|
||||
# if -O|--osimage or osimage=<imagename> is specified,
|
||||
# call "nodeset ... osimage= ..." to set the boot state of the noderange to the specified osimage,
|
||||
# "nodeset" will handle the updating of node attributes such as os,arch,profile,provmethod
|
||||
# verify input
|
||||
&checkoption("[-O|--osimage] $OSIMAGE",$OSVER,$PROFILE,$ARCH,$callback);
|
||||
# "nodeset" will handle the updating of node attributes such as os,arch,profile,provmethod.
|
||||
|
||||
# run nodeset $noderange osimage=$OSIMAGE
|
||||
my @osimageargs;
|
||||
push @osimageargs,"osimage=$OSIMAGE" ;
|
||||
my $res =
|
||||
xCAT::Utils->runxcmd(
|
||||
{
|
||||
command => ["nodeset"],
|
||||
node => \@nodes,
|
||||
arg => \@osimageargs
|
||||
},
|
||||
$subreq, -1, 1);
|
||||
$rc=$::RUNCMD_RC;
|
||||
my $rsp = {};
|
||||
foreach my $line (@$res) {
|
||||
$rsp->{data} ->[0] = $line;
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
my $noderestable = xCAT::Table->new("noderes");
|
||||
my $noderescache = $noderestable->getNodesAttribs(\@nodes, ['netboot']);
|
||||
$noderestable->close();
|
||||
my $nodetypetable = xCAT::Table->new("nodetype");
|
||||
my $nodetypecache = $nodetypetable->getNodesAttribs(\@nodes, ['arch']);
|
||||
$nodetypetable->close();
|
||||
my $osimagetable = xCAT::Table->new("osimage");
|
||||
(my $ref) = $osimagetable->getAttribs({imagename => $OSIMAGE}, 'osvers', 'osarch','imagetype');
|
||||
$osimagetable->close();
|
||||
unless (defined($ref->{osarch})) {
|
||||
my $rsp = {};
|
||||
$rsp->{error}->[0] = "$OSIMAGE 'osarch' attribute not defined in 'osimage' table.";
|
||||
$rsp->{errorcode}->[0] = 1;
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
return 1;
|
||||
}
|
||||
my $osimagearch = $ref->{osarch};
|
||||
my $netbootval = xCAT::Utils->lookupNetboot($ref->{osvers},$ref->{osarch},$ref->{imagetype});
|
||||
my @validnodes;
|
||||
foreach my $node (@nodes) {
|
||||
unless ($noderescache) { next; }
|
||||
unless ($nodetypecache) { next; }
|
||||
unless ($nodehmcache) { next; }
|
||||
my $noderesattribs = $noderescache->{$node}->[0];
|
||||
my $nodetypeattribs = $nodetypecache->{$node}->[0];
|
||||
my $nodehmattribs = $nodehmcache->{$node}->[0];
|
||||
unless (defined($noderesattribs) and defined($noderesattribs->{'netboot'})) {
|
||||
my $rsp = {};
|
||||
$rsp->{error}->[0] = "$node: Missing the 'netboot' attribute.";
|
||||
$rsp->{errorcode}->[0] = 1;
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
next;
|
||||
}
|
||||
else {
|
||||
unless($netbootval =~ /$noderesattribs->{'netboot'}/i){
|
||||
$callback->({warning=> [$node.": $noderesattribs->{'netboot'} might be invalid when provisioning $OSIMAGE,valid options: \"$netbootval\". For more details see the 'netboot' description in the output of \"tabdump -d noderes\"."]});
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
unless (defined($nodetypeattribs) and defined($nodetypeattribs->{'arch'})) {
|
||||
my $rsp = {};
|
||||
$rsp->{error}->[0] = "$node: 'arch' attribute not defined in 'nodetype' table.";
|
||||
$rsp->{errorcode}->[0] = 1;
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
next;
|
||||
}
|
||||
my $nodetypearch = $nodetypeattribs->{'arch'};
|
||||
if ($nodetypearch ne $osimagearch) {
|
||||
unless ((($nodetypearch =~ /ppc64le/) or ($nodetypearch =~ /ppc64el/)) and (($osimagearch =~ /ppc64le/) or ($osimagearch =~ /ppc64el/))) {
|
||||
my $rsp = {};
|
||||
$rsp->{error}->[0] = "$node: The value of 'arch' attribute is not same as the 'osarch' attribute for osimage.";
|
||||
$rsp->{errorcode}->[0] = 1;
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
unless (defined($nodehmattribs) and defined($nodehmattribs->{'mgt'})) {
|
||||
my $rsp = {};
|
||||
$rsp->{error}->[0] = "$node: 'mgt' attribute not defined in 'nodehm' table.";
|
||||
$rsp->{errorcode}->[0] = 1;
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
next;
|
||||
}
|
||||
push @validnodes, $node;
|
||||
}
|
||||
#only provision the normal nodes
|
||||
@nodes = @validnodes;
|
||||
|
||||
push @parameter,"osimage=$OSIMAGE";
|
||||
if ($ignorekernelchk) {
|
||||
push @parameter," --ignorekernelchk";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
elsif ($STATES) {
|
||||
push @parameter,"$STATES";
|
||||
}
|
||||
else {
|
||||
|
||||
# no osimage specified, update the node attributes specified by -a,-p,-o options thru "nodech",
|
||||
# then set the boot state of each node based on the nodetype.provmethod:
|
||||
# 1) if nodetype.provmethod = <osimage>, ignore any -p,-o,-a option,
|
||||
# No osimage specified, set the boot state of each node based on the nodetype.provmethod:
|
||||
# 1) if nodetype.provmethod = [install/netboot/statelite],
|
||||
# then output error message.
|
||||
# 2) if nodetype.provmethod = <osimage>,
|
||||
# then call "nodeset ... osimage"
|
||||
# 2) if nodetype.provmethod = [install/netboot/statelite],
|
||||
# update the node attributes specified by -a,-p,-o options thru "nodech",
|
||||
# call "nodeset ... [install/netboot/statelite]"
|
||||
# 3) if nodetype.provmethod is not set, use 'install' as the default value
|
||||
|
||||
# group the nodes according to the nodetype.provmethod
|
||||
|
||||
foreach (@$nodes)
|
||||
{
|
||||
my $tab = xCAT::Table->new("nodetype");
|
||||
my $nthash = $tab->getNodeAttribs($_, ['provmethod']);
|
||||
$tab->close();
|
||||
if (defined($nthash) and defined($nthash->{'provmethod'}))
|
||||
{
|
||||
push(@{$pnhash{$nthash->{'provmethod'}}}, $_);
|
||||
# Group the nodes according to the nodetype.provmethod
|
||||
my %tphash;
|
||||
my $nodetypetable = xCAT::Table->new("nodetype");
|
||||
my $nodetypecache = $nodetypetable->getNodesAttribs(\@nodes, ['provmethod']);
|
||||
$nodetypetable->close();
|
||||
foreach my $node (@nodes) {
|
||||
unless ($nodetypecache) { next; }
|
||||
my $nodetypeattribs = $nodetypecache->{$node}->[0];
|
||||
unless (defined($nodetypeattribs) and defined($nodetypeattribs->{'provmethod'})) {
|
||||
my $rsp = {};
|
||||
$rsp->{error}->[0] = "$node: 'provmethod' attribute not defined in 'nodetype' table.";
|
||||
$rsp->{errorcode}->[0] = 1;
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
next;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
#if nodetype.provmethod is not specified,
|
||||
push(@{$pnhash{'install'}}, $_);
|
||||
else {
|
||||
push(@{$tphash{$nodetypeattribs->{'provmethod'}}}, $node);
|
||||
}
|
||||
}
|
||||
# Now for each group based on provmethod
|
||||
foreach my $key (keys %pnhash)
|
||||
{
|
||||
$::RUNCMD_RC =0;
|
||||
my $nodes = join(',', @{$pnhash{$key}});
|
||||
if ($key =~ /^(install|netboot|statelite)$/)
|
||||
{
|
||||
|
||||
# nodetype.provmethod = [install|netboot|statelite]
|
||||
my @nodechline;
|
||||
if ($OSVER)
|
||||
{
|
||||
push @nodechline, "nodetype.os=$OSVER";
|
||||
}
|
||||
if ($PROFILE)
|
||||
{
|
||||
push @nodechline, "nodetype.profile=$PROFILE";
|
||||
}
|
||||
if ($ARCH)
|
||||
{
|
||||
push @nodechline, "nodetype.arch=$ARCH";
|
||||
}
|
||||
if (@nodechline)
|
||||
{
|
||||
# run nodech $nodes $nodechline
|
||||
my $res =
|
||||
xCAT::Utils->runxcmd(
|
||||
{
|
||||
command => ["nodech"],
|
||||
node => \@nodes,
|
||||
arg => \@nodechline
|
||||
},
|
||||
$subreq, -1, 1);
|
||||
|
||||
my $rsp = {};
|
||||
$rc=$::RUNCMD_RC;
|
||||
if ($rc == 0 ) {
|
||||
foreach my $line (@$res) {
|
||||
$rsp->{data} ->[0] = $line;
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
} else { # error
|
||||
$rsp->{error} ->[0] = "nodech error";
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
foreach my $line (@$res) {
|
||||
$rsp->{error} ->[0] = $line;
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
}
|
||||
}
|
||||
} # end nodechline
|
||||
|
||||
if ($rc == 0) # if no error from nodech then run nodeset
|
||||
{
|
||||
# run nodeset $nodes $key ( where key is install/netboot/statelite)
|
||||
my @nodesetarg;
|
||||
push @nodesetarg, "$key";
|
||||
my $res =
|
||||
xCAT::Utils->runxcmd(
|
||||
{
|
||||
command => ["nodeset"],
|
||||
node => \@nodes,
|
||||
arg => \@nodesetarg
|
||||
},
|
||||
$subreq, -1, 1);
|
||||
|
||||
$rc = $::RUNCMD_RC;
|
||||
my $rsp = {};
|
||||
foreach my $line (@$res) {
|
||||
$rsp->{data} ->[0] = $line;
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
}
|
||||
# Now for each group based on provmethod
|
||||
my @validnodes;
|
||||
foreach my $key (keys %tphash) {
|
||||
$::RUNCMD_RC = 0;
|
||||
my @pnnodes = @{$tphash{$key}};
|
||||
# If nodetype.provmethod = [install|netboot|statelite]
|
||||
if ($key =~ /^(install|netboot|statelite)$/) {
|
||||
my $rsp = {};
|
||||
$rsp->{error}->[0] = "@pnnodes: The options 'install', 'netboot', and 'statelite' have been deprecated, use 'nodeset <noderange> osimage=<imagename>' instead.";
|
||||
$rsp->{errorcode}->[0] = 1;
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
next;
|
||||
}
|
||||
else # if not install/netboot/statelite
|
||||
{
|
||||
|
||||
# nodetype.provmethod = <osimage>
|
||||
&checkoption("nodetype.provmethod=$key",$OSVER,$PROFILE,$ARCH,$callback);
|
||||
# run nodeset $nodes osimage
|
||||
my @nodesetarg;
|
||||
push @nodesetarg, "osimage";
|
||||
my $res =
|
||||
xCAT::Utils->runxcmd(
|
||||
{
|
||||
command => ["nodeset"],
|
||||
node => \@nodes,
|
||||
arg => \@nodesetarg
|
||||
},
|
||||
$subreq, -1, 1);
|
||||
|
||||
$rc = $::RUNCMD_RC;
|
||||
my $rsp = {};
|
||||
foreach my $line (@$res) {
|
||||
$rsp->{data} ->[0] = $line;
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
# If nodetype.provmethod != [install|netboot|statelite]
|
||||
else {
|
||||
push @validnodes, @pnnodes;
|
||||
}
|
||||
|
||||
}
|
||||
} # end nodech/nodeset for each group
|
||||
#only provision the normal nodes
|
||||
@nodes = @validnodes;
|
||||
|
||||
if ($rc != 0) # we got an error with the nodeset
|
||||
{
|
||||
my $rsp = {};
|
||||
$rsp->{error}->[0] = "nodeset failed on certain nodes.";
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
push @parameter, "osimage";
|
||||
}
|
||||
|
||||
# call "rsetboot" to set the boot order of the nodehm.mgt=ipmi nodes,for others,
|
||||
# assume user has set the correct boot order before "rinstall"
|
||||
if (scalar(@nodes) == 0) {
|
||||
my $rsp = {};
|
||||
$rsp->{error}->[0] = "No available nodes for provision.";
|
||||
$rsp->{errorcode}->[0] = 1;
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
my $rsp = {};
|
||||
$rsp->{data} ->[0] = "Provision node(s): @nodes";
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
%nodes = map { $_, 1 } @nodes;
|
||||
|
||||
# run rsetboot $noderange net
|
||||
|
||||
my @rsetbootarg;
|
||||
push @rsetbootarg, "net";
|
||||
push @rsetbootarg, "-u";
|
||||
my $res =
|
||||
xCAT::Utils->runxcmd(
|
||||
{
|
||||
command => ["rsetboot"],
|
||||
node => \@nodes,
|
||||
arg => \@rsetbootarg
|
||||
},
|
||||
$subreq, -1, 1);
|
||||
# Run nodeset $noderange $parameter
|
||||
my $res =
|
||||
xCAT::Utils->runxcmd(
|
||||
{
|
||||
command => ["nodeset"],
|
||||
node => \@nodes,
|
||||
arg => \@parameter
|
||||
},
|
||||
$subreq, -1, 1);
|
||||
|
||||
$rc = $::RUNCMD_RC;
|
||||
# fix output it is a hash and you must get error out of the hash.
|
||||
my $rsp = {};
|
||||
foreach my $line (@$res) {
|
||||
$rsp->{data} ->[0] = $line;
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
|
||||
if ($rc != 0) # we got an error with the rsetboot
|
||||
{
|
||||
my $rsp = {};
|
||||
$rsp->{error}->[0] = "rsetboot failed on certain nodes.";
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
}
|
||||
|
||||
|
||||
# call "rpower" to start the node provision process
|
||||
|
||||
#run rpower $noderange boot
|
||||
my @rpowerarg;
|
||||
push @rpowerarg, "boot";
|
||||
my $res =
|
||||
xCAT::Utils->runxcmd(
|
||||
{
|
||||
command => ["rpower"],
|
||||
node => \@nodes,
|
||||
arg => \@rpowerarg
|
||||
},
|
||||
$subreq, -1, 1);
|
||||
|
||||
$rc = $::RUNCMD_RC;
|
||||
my $rsp = {};
|
||||
foreach my $line (@$res) {
|
||||
$rsp->{data} ->[0] = $line;
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
|
||||
if ($rc != 0) # we got an error with the rsetboot
|
||||
{
|
||||
my $rsp = {};
|
||||
$rsp->{error}->[0] = "rpower failed on certain nodes.";
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
}
|
||||
|
||||
|
||||
# Check if they asked to bring up a console ( -c) from rinstall always for winstall
|
||||
$req->{startconsole}->[0] =0;
|
||||
if ($command =~ /rinstall/)
|
||||
{
|
||||
|
||||
# for rinstall, the -c|--console option can provide the remote console for only 1 node
|
||||
if ($CONSOLE)
|
||||
{
|
||||
if (scalar @$nodes ne 1)
|
||||
{
|
||||
my $rsp = {};
|
||||
$rsp->{error}->[0] = "rinstall -c only accepts one node in the noderange. See winstall for support for support of consoles on multiple nodes.";
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
return 1;
|
||||
} else { # tell rinstall client ok to start rcons
|
||||
$req->{startconsole}->[0] =1;
|
||||
}
|
||||
|
||||
if ($rc == 0) {
|
||||
if ($VERBOSE) {
|
||||
my @cmd = "Run command: nodeset @nodes @parameter";
|
||||
push @{$rsp->{data}}, @cmd;
|
||||
push @{$rsp->{data}}, @$res;
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
}
|
||||
elsif ($command =~ /winstall/)
|
||||
{
|
||||
|
||||
# winstall can start a wcons command to multiple nodes for monitoring the provision cycle
|
||||
$req->{startconsole}->[0] =1;
|
||||
|
||||
else {
|
||||
# We got an error with the nodeset
|
||||
my @successnodes;
|
||||
my @failurenodes;
|
||||
foreach my $line (@$res) {
|
||||
$rsp->{data} ->[0] = $line;
|
||||
if (($line =~ /: install/) or ($line =~ /: netboot/)) {
|
||||
my $successnode;
|
||||
my $restline;
|
||||
($successnode, $restline) = split (/:/, $line, 2);
|
||||
$nodes{$successnode} = 0;
|
||||
push @successnodes, $successnode;
|
||||
}
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
foreach my $node (@nodes) {
|
||||
if ($nodes{$node} = 1) {
|
||||
push @failurenodes, $node;
|
||||
}
|
||||
}
|
||||
my $rsp = {};
|
||||
$rsp->{error}->[0] = "failed to run 'nodeset' against the following nodes: @failurenodes";
|
||||
$rsp->{errorcode}->[0] = 1;
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
@nodes = @successnodes;
|
||||
}
|
||||
|
||||
# Group the nodes according to the nodehm.mgt
|
||||
my %hmhash;
|
||||
foreach my $node (@nodes) {
|
||||
unless ($nodehmcache) { next; }
|
||||
my $nodehmattribs = $nodehmcache->{$node}->[0];
|
||||
push(@{$hmhash{$nodehmattribs->{'mgt'}}}, $node);
|
||||
}
|
||||
|
||||
# Now for each group based on mgt
|
||||
foreach my $hmkey (keys %hmhash) {
|
||||
$::RUNCMD_RC = 0;
|
||||
my @nodes = @{$hmhash{$hmkey}};
|
||||
unless (($hmkey =~ /^ipmi$/) or ($hmkey =~ /^blade$/) or ($hmkey =~ /^hmc$/) or ($hmkey =~ /^ivm$/) or ($hmkey =~ /^fsp$/) or ($hmkey =~ /^kvm$/) or ($hmkey =~ /^esx$/) or ($hmkey =~ /^rhevm$/)) {
|
||||
my $rsp = {};
|
||||
$rsp->{error}->[0] = "@nodes: rinstall only support nodehm.mgt type 'ipmi', 'blade', 'hmc', 'ivm', 'fsp', 'kvm', 'esx', 'rhevm'.";
|
||||
$rsp->{errorcode}->[0] = 1;
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
next;
|
||||
}
|
||||
if (($hmkey =~ /^ivm$/) or ($hmkey =~ /^fsp$/) or ($hmkey =~ /^hmc$/)) {
|
||||
%nodes = map { $_, 1 } @nodes;
|
||||
# Run rnetboot $noderange
|
||||
my $res =
|
||||
xCAT::Utils->runxcmd(
|
||||
{
|
||||
command => ["rnetboot"],
|
||||
node => \@nodes
|
||||
},
|
||||
$subreq, -1, 1);
|
||||
|
||||
$rc = $::RUNCMD_RC;
|
||||
my $rsp = {};
|
||||
if ($rc == 0) {
|
||||
if ($VERBOSE) {
|
||||
my @cmd = "Run command: rnetboot @nodes";
|
||||
push @{$rsp->{data}}, @cmd;
|
||||
push @{$rsp->{data}}, @$res;
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
}
|
||||
else {
|
||||
# We got an error with the rnetboot
|
||||
my @failurenodes;
|
||||
foreach my $line (@$res) {
|
||||
$rsp->{data} ->[0] = $line;
|
||||
if ($line =~ /: Success/) {
|
||||
my $successnode;
|
||||
my $restline;
|
||||
($successnode, $restline) = split (/:/, $line, 2);
|
||||
$nodes{$successnode} = 0;
|
||||
}
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
foreach my $node (@nodes) {
|
||||
if ($nodes{$node} = 1) {
|
||||
push @failurenodes, $node;
|
||||
}
|
||||
}
|
||||
my $rsp = {};
|
||||
$rsp->{error}->[0] = "failed to run 'rnetboot' against the following nodes: @failurenodes";
|
||||
$rsp->{errorcode}->[0] = 1;
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
}
|
||||
}
|
||||
else {
|
||||
# Call "rsetboot" to set the boot order of the nodehm.mgt=ipmi nodes
|
||||
if ($hmkey =~ /^ipmi$/) {
|
||||
%nodes = map { $_, 1 } @nodes;
|
||||
# Run rsetboot $noderange net
|
||||
my @rsetbootarg;
|
||||
push @rsetbootarg, "net";
|
||||
if ($UEFIMODE) {
|
||||
push @rsetbootarg, "-u";
|
||||
}
|
||||
my $res =
|
||||
xCAT::Utils->runxcmd(
|
||||
{
|
||||
command => ["rsetboot"],
|
||||
node => \@nodes,
|
||||
arg => \@rsetbootarg
|
||||
},
|
||||
$subreq, -1, 1);
|
||||
|
||||
$rc = $::RUNCMD_RC;
|
||||
my $rsp = {};
|
||||
if ($rc == 0) {
|
||||
if ($VERBOSE) {
|
||||
my @cmd = "Run command: rsetboot @nodes @rsetbootarg";
|
||||
push @{$rsp->{data}}, @cmd;
|
||||
push @{$rsp->{data}}, @$res;
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
}
|
||||
else {
|
||||
# We got an error with the rsetboot
|
||||
my @successnodes;
|
||||
my @failurenodes;
|
||||
foreach my $line (@$res) {
|
||||
$rsp->{data} ->[0] = $line;
|
||||
if ($line =~ /: Network/) {
|
||||
my $successnode;
|
||||
my $restline;
|
||||
($successnode, $restline) = split (/:/, $line, 2);
|
||||
$nodes{$successnode} = 0;
|
||||
push @successnodes, $successnode;
|
||||
}
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
foreach my $node (@nodes) {
|
||||
if ($nodes{$node} = 1) {
|
||||
push @failurenodes, $node;
|
||||
}
|
||||
}
|
||||
my $rsp = {};
|
||||
$rsp->{error}->[0] = "failed to run 'rsetboot' against the following nodes: @failurenodes";
|
||||
$rsp->{errorcode}->[0] = 1;
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
@nodes = @successnodes;
|
||||
}
|
||||
}
|
||||
# Call "rpower" to start the node provision process
|
||||
%nodes = map { $_, 1 } @nodes;
|
||||
# Run rpower $noderange boot
|
||||
my @rpowerarg;
|
||||
push @rpowerarg, "boot";
|
||||
my $res =
|
||||
xCAT::Utils->runxcmd(
|
||||
{
|
||||
command => ["rpower"],
|
||||
node => \@nodes,
|
||||
arg => \@rpowerarg
|
||||
},
|
||||
$subreq, -1, 1);
|
||||
|
||||
$rc = $::RUNCMD_RC;
|
||||
my $rsp = {};
|
||||
if ($rc == 0) {
|
||||
if ($VERBOSE) {
|
||||
my @cmd = "Run command: rpower @nodes @rpowerarg";
|
||||
push @{$rsp->{data}}, @cmd;
|
||||
push @{$rsp->{data}}, @$res;
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
}
|
||||
else {
|
||||
# We got an error with the rpower
|
||||
my @failurenodes;
|
||||
foreach my $line (@$res) {
|
||||
$rsp->{data} ->[0] = $line;
|
||||
if (($line =~ /: on reset/) or ($line =~ /: off on/)) {
|
||||
my $successnode;
|
||||
my $restline;
|
||||
($successnode, $restline) = split (/:/, $line, 2);
|
||||
$nodes{$successnode} = 0;
|
||||
}
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
foreach my $node (@nodes) {
|
||||
if ($nodes{$node} = 1) {
|
||||
push @failurenodes, $node;
|
||||
}
|
||||
}
|
||||
my $rsp = {};
|
||||
$rsp->{error}->[0] = "failed to run 'rpower' against the following nodes: @failurenodes";
|
||||
$rsp->{errorcode}->[0] = 1;
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Check if they asked to bring up a console (-c) from rinstall always for winstall
|
||||
$req->{startconsole}->[0] = 0;
|
||||
if ($command =~ /rinstall/) {
|
||||
# For rinstall, the -c|--console option can provide the remote console for only 1 node
|
||||
if ($CONSOLE) {
|
||||
if (scalar @nodes != 1) {
|
||||
my $rsp = {};
|
||||
$rsp->{error}->[0] = "rinstall -c only accepts one node in the noderange. See winstall for support of consoles on multiple nodes.";
|
||||
$rsp->{errorcode}->[0] = 1;
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
# Tell rinstall client ok to start rcons
|
||||
$req->{startconsole}->[0] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif ($command =~ /winstall/) {
|
||||
# Command winstall can start a wcons command to multiple nodes for monitoring the provision cycle
|
||||
$req->{startconsole}->[0] = 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -405,47 +559,17 @@ sub rinstall
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
sub usage
|
||||
{
|
||||
sub usage {
|
||||
my $command = shift;
|
||||
my $callback = shift;
|
||||
my $rsp = {};
|
||||
$rsp->{data}->[0] = "$command usage:";
|
||||
if ($command =~ /rinstall/) {
|
||||
$rsp->{data}->[1] = " [-O|--osimage] [-c|--console] <noderange>";
|
||||
} else { # wininstall
|
||||
$rsp->{data}->[1] = " [-O|--osimage] <noderange>";
|
||||
}
|
||||
|
||||
$rsp->{data}->[2] = " [-h|--help]";
|
||||
$rsp->{data}->[3] = " [-v|--version]";
|
||||
$rsp->{data}->[0] = "Usage:";
|
||||
$rsp->{data}->[1] = " $command <noderange> boot | shell | runcmd=bmcsetup [-c|--console] [-u|--uefimode] [-V|--verbose]";
|
||||
$rsp->{data}->[2] = " $command <noderange> osimage=<imagename> | -O <imagename> [--ignorekernelchk] [-c|--console] [-u|--uefimode] [-V|--verbose]";
|
||||
$rsp->{data}->[3] = " $command [-h|--help|-v|--version]";
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
|
||||
# check and complain about the invalid combination of the options,
|
||||
# ignore -o,-p and -a options and prompt a warning message when provmethod=osimagename
|
||||
sub checkoption{
|
||||
my $optstring=shift;
|
||||
my $OSVER=shift;
|
||||
my $PROFILE=shift;
|
||||
my $ARCH=shift;
|
||||
my $callback=shift;
|
||||
my $rsp = {};
|
||||
if($OSVER) {
|
||||
$rsp->{data}->[0] = "-o option not valid with $optstring. It is ignored.";
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
if($PROFILE) {
|
||||
$rsp->{data}->[0] = "-p option not valid with $optstring. It is ignored.";
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
if($ARCH) {
|
||||
$rsp->{data}->[0] = "-a option not valid with $optstring. It is ignored.";
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
Reference in New Issue
Block a user