solution:215058 enable switch auto discovery for PCM

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@15999 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
qyin 2013-04-17 07:06:57 +00:00
parent a2247f0170
commit 233b2bf351
3 changed files with 73 additions and 16 deletions

View File

@ -10,7 +10,7 @@ B<nodeimport> file=<nostinfo-filename> networkprofile=<network-profile> imagepro
=head1 DESCRIPTION
The B<nodeimport> command creates nodes by importing a hostinfo file which is following stanza format. In this hostinfo file, we can define node's hostname, ip, mac, and host location infomation like rack, chassis, start unit, server height...etc
The B<nodeimport> command creates nodes by importing a hostinfo file which is following stanza format. In this hostinfo file, we can define node's hostname, ip, mac, switch name, switch port and host location infomation like rack, chassis, start unit, server height...etc
After nodes imported, the configuration files related with these nodes will be updated automatically. For example: /etc/hosts, dns configuration, dhcp configuration. And the kits node plugins will also be triggered automatically to update kit related configuration/services.
@ -116,6 +116,13 @@ To import nodes using a profile, follow the following steps:
slotid=1
# hostinfo end.
Example of a node information file, a switch auto discovery node defined:
# hostinfo begin
# This entry defines a blade.
__hostname__:
switch=myswitch
switchport=9
The node information file includes the following items:
B<__hostname__:> This is a mandatory item.
@ -126,6 +133,14 @@ B<mac=<mac-address>> This is a mandatory item.
Description: Specify the MAC address for the NIC used by the provisionging node, where <mac-address> is the NICs MAC address.
B<switch=<switch-name>> This is a mandatory item, when define a switch auto discovery node.
Description: Specify switch name that the provisionging node is connected, where <switch-name> is the switch name.
B<switchport=<switch-port>> This is a mandatory item, when define a switch auto discovery node.
Description: Specify switch port that the provisionging node is connected, where <switch-port> is the connected port.
B<slotid=<slot-id>> This is a mandatory item while define a PureFlex node.
Description: The node position in the PureFlex Chassis.

View File

@ -67,7 +67,11 @@ sub process_request {
my $request_command = shift;
my $command = $request->{command}->[0];
my $argsref = $request->{arg};
my $macflag = 1;
if(exists($request->{macflag}))
{
$macflag = $request->{macflag}->[0];
}
my $nodelist = $request->{node};
my $retref;
my $rsp;
@ -82,9 +86,12 @@ sub process_request {
$retref = xCAT::Utils->runxcmd({command=>["makedns"], node=>$nodelist}, $request_command, 0, 2);
log_cmd_return($retref);
setrsp_progress("Update DHCP entries");
$retref = xCAT::Utils->runxcmd({command=>["makedhcp"], node=>$nodelist}, $request_command, 0, 2);
log_cmd_return($retref);
if($macflag)
{
setrsp_progress("Update DHCP entries");
$retref = xCAT::Utils->runxcmd({command=>["makedhcp"], node=>$nodelist}, $request_command, 0, 2);
log_cmd_return($retref);
}
setrsp_progress("Update known hosts");
$retref = xCAT::Utils->runxcmd({command=>["makeknownhosts"], node=>$nodelist}, $request_command, 0, 2);
@ -96,24 +103,26 @@ sub process_request {
my $chainstr = $chainref->{'chain'};
my @chainarray = split(",", $chainstr);
if ($chainarray[0]){
setrsp_progress("Update nodes' boot settings");
$retref = xCAT::Utils->runxcmd({command=>["nodeset"], node=>$nodelist, arg=>[$chainarray[0]]}, $request_command, 0, 2);
log_cmd_return($retref);
if($macflag)
{
if ($chainarray[0]){
setrsp_progress("Update nodes' boot settings");
$retref = xCAT::Utils->runxcmd({command=>["nodeset"], node=>$nodelist, arg=>[$chainarray[0]]}, $request_command, 0, 2);
log_cmd_return($retref);
}
}
my $isfsp = xCAT::ProfiledNodeUtils->is_fsp_node([$firstnode]);
if ($isfsp) {
setrsp_progress("Updating FSP's IP address");
$retref = xCAT::Utils->runxcmd({command=>["rspconfig"], node=>$nodelist, arg=>['network=*']}, $request_command, 0, 2);
log_cmd_return($retref);
my $cmmref = xCAT::ProfiledNodeUtils->get_nodes_cmm($nodelist);
my @cmmchassis = keys %$cmmref;
setrsp_progress("Update node's some attributes through 'rscan -u'");
$retref = xCAT::Utils->runxcmd({command=>["rscan"], node=>\@cmmchassis, arg=>['-u']}, $request_command, 0, 2);
log_cmd_return($retref);
setrsp_progress("Sets up connections for nodes to FSP");
$retref = xCAT::Utils->runxcmd({command=>["mkhwconn"], node=>$nodelist, arg=>['-t']}, $request_command, 0, 2);
log_cmd_return($retref);

View File

@ -36,6 +36,8 @@ my %allinstallips;
my %allnicips;
my %allracks;
my %allchassis;
my %allswitches;
# The array of all chassis which is special CMM
my %allcmmchassis;
my %allothernics;
@ -362,6 +364,10 @@ Usage:
$recordsref = xCAT::ProfiledNodeUtils->get_allnode_singleattrib_hash('ppc', 'hcp');
my %allfspips = %$recordsref;
# Get all switches name
$recordsref = xCAT::ProfiledNodeUtils->get_allnode_singleattrib_hash('switches', 'switch');
%allswitches = %$recordsref;
# MAC records looks like: "01:02:03:04:05:0E!node5│01:02:03:05:0F!node6-eth1". We want to get the real mac addres.
foreach (keys %allmacs){
my @hostentries = split(/\|/, $_);
@ -401,6 +407,7 @@ Usage:
return;
}
my $mac_addr_mode = 0;
# Parse and validate the hostinfo string. The real hostnames will be generated here.
xCAT::MsgUtils->message('S', "Parsing hostinfo string and validate it.");
my ($hostinfo_dict_ref, $invalid_records_ref) = validate_node_entries();
@ -417,6 +424,23 @@ Usage:
return;
}
# if user specified the switch, we need to add a new item into switch table
my @nodelist = keys %hostinfo_dict;
foreach my $mynode (@nodelist)
{
if(defined($hostinfo_dict{$mynode}{'mac'}))
{
$mac_addr_mode = 1;
}
# cannot mix switch discovery with mac import
if(($mac_addr_mode ==1) && (defined($hostinfo_dict{$mynode}{'switch'})))
{
setrsp_progress("Failed to validate node information file.");
setrsp_errormsg("Cannot define mac import node in switch discovery hostinfo file.");
return;
}
}
# Create the real hostinfo string in stanza file format.
xCAT::MsgUtils->message('S', "Generating new hostinfo string.");
my ($retcode_gen, $retstr_gen) = gen_new_hostinfo_string(\%hostinfo_dict);
@ -440,9 +464,8 @@ Usage:
}
}
my @nodelist = keys %hostinfo_dict;
setrsp_progress("Configuring nodes...");
$retref = xCAT::Utils->runxcmd({command=>["kitnodeadd"], node=>\@nodelist, sequential=>[1]}, $request_command, 0, 2);
$retref = xCAT::Utils->runxcmd({command=>["kitnodeadd"], node=>\@nodelist, sequential=>[1], macflag=>[$mac_addr_mode]}, $request_command, 0, 2);
$retstrref = parse_runxcmd_ret($retref);
if ($::RUNCMD_RC != 0){
$warnstr .= "Warning: failed to run command kitnodeadd.";
@ -1879,7 +1902,7 @@ sub validate_node_entry{
}
# Must specify either MAC or switch + port.
if (exists $node_entry{"mac"} ||
exists $node_entry{"switch"} && exists $node_entry{"port"}){
exists $node_entry{"switch"} && exists $node_entry{"switchport"}){
} else{
$errmsg .= "MAC address, switch and port is not specified. You must specify the MAC address or switch and port.\n";
}
@ -1914,7 +1937,17 @@ sub validate_node_entry{
}
}elsif ($_ eq "switch"){
#TODO: xCAT switch discovery enhance: verify whether switch exists.
}elsif ($_ eq "port"){
if (! exists $allswitches{$node_entry{$_}}){
$errmsg .= "Specified switch $node_entry{$_} is not defined\n";
}
}elsif ($_ eq "switchport"){
if (! exists $node_entry{"switchport"}){
$errmsg .= "Specified switch must be used with port.\n";
}
# Not a valid number.
if (!($node_entry{$_} =~ /^\d+$/)){
$errmsg .= "Specified port $node_entry{$_} is invalid\n";
}
}elsif ($_ eq "rack"){
if (! exists $allracks{$node_entry{$_}}){
$errmsg .= "Specified rack $node_entry{$_} is not defined\n";