diff --git a/perl-xCAT/xCAT/ProfiledNodeUtils.pm b/perl-xCAT/xCAT/ProfiledNodeUtils.pm index 505c5c57e..0ff2b7e6b 100644 --- a/perl-xCAT/xCAT/ProfiledNodeUtils.pm +++ b/perl-xCAT/xCAT/ProfiledNodeUtils.pm @@ -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'); diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index 4d673aa01..a24107027 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -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);