validate profiles existing in database and also check hostnameformat while start node discovery

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14655 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
leiaibj 2012-12-14 07:59:17 +00:00
parent 6acf400ea9
commit 0ba9832d0e
2 changed files with 25 additions and 0 deletions

View File

@ -618,6 +618,20 @@ sub check_profile_consistent{
my $networkprofile = shift;
my $hardwareprofile = shift;
# Check the profiles are existing in DB.
my @nodegrps = xCAT::TableUtils->list_all_node_groups();
unless(grep{ $_ eq $imageprofile} @nodegrps){
return 0, "Image profile not defined in DB."
}
unless(grep{ $_ eq $networkprofile} @nodegrps){
return 0, "Network profile not defined in DB."
}
if ($hardwareprofile){
unless(grep{ $_ eq $hardwareprofile} @nodegrps){
return 0, "Hardware profile not defined in DB."
}
}
# Profile consistent keys, arch=>netboot, mgt=>nictype
my %profile_dict = ('x86' => 'xnba','x86_64' => 'xnba', 'ppc64' => 'yaboot',
'fsp' => 'FSP', 'ipmi' => 'BMC');

View File

@ -761,11 +761,22 @@ Usage:
return;
}
my ($returncode, $errmsg) = xCAT::ProfiledNodeUtils->check_profile_consistent($args_dict{'imageprofile'}, $args_dict{'networkprofile'}, $args_dict{'hardwareprofile'});
if (not $returncode) {
setrsp_errormsg($errmsg);
return;
}
# validate hostnameformat:
my $nameformattype = xCAT::ProfiledNodeUtils->get_hostname_format_type($args_dict{'hostnameformat'});
if ($nameformattype eq "unknown"){
setrsp_errormsg("Invalid node name format: $args_dict{'hostnameformat'}");
return;
}elsif($nameformattype eq 'rack'){
if ((! exists $args_dict{'rack'}) && (! exists $args_dict{'chassis'})){
setrsp_errormsg("Specify rack/chassis as node name format includes rack info.");
return;
}
}
my $recordsref = xCAT::ProfiledNodeUtils->get_all_rack(1);