2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-05-05 16:49:08 +00:00

Merge pull request #7524 from VersatusHPC/fix/mkdef-empty-attrs-error

fix: show useful error when mkdef is called without attributes
This commit is contained in:
Markus Hilger
2026-04-27 13:35:36 +02:00
committed by GitHub
2 changed files with 49 additions and 0 deletions

View File

@@ -1676,6 +1676,24 @@ sub defmk
$error = 1;
}
# If no object definitions ended up in FINALATTRS, there is nothing to create
if (!$error && !%::FINALATTRS)
{
my $rsp;
my $is_node_type = (grep { $_ eq "node" } @::finalTypeList) ||
($::opt_t && $::opt_t =~ /\bnode\b/);
if ($is_node_type)
{
$rsp->{data}->[0] = "No object definitions have been created or modified: no attributes were specified. The \'groups\' attribute is required when creating node definitions.";
}
else
{
$rsp->{data}->[0] = "No object definitions have been created or modified: no attributes were specified.";
}
xCAT::MsgUtils->message("E", $rsp, $::callback);
return 1;
}
# we need a list of objects that are
# already defined for each type.
foreach my $t (@::finalTypeList)

View File

@@ -411,3 +411,34 @@ check:rc==0
cmd:rmdef -t osimage -o rhels7.3-test
check:rc==0
end
start:mkdef_node_no_attrs
description:mkdef -t node with no attributes should fail and mention groups
label:mn_only,ci_test,db
cmd:mkdef -t node -o testnode_noattr
check:rc!=0
check:output=~groups
cmd:lsdef testnode_noattr
check:rc!=0
end
start:mkdef_node_no_groups
description:mkdef -t node with attributes but no groups should fail
label:mn_only,ci_test,db
cmd:mkdef -t node -o testnode_nogrp ip=10.0.0.99
check:rc!=0
check:output=~groups
cmd:lsdef testnode_nogrp
check:rc!=0
cmd:rmdef -t node -o testnode_nogrp
end
start:mkdef_nonnode_no_attrs
description:mkdef with non-node type and no attributes should fail with generic message
label:mn_only,ci_test,db
cmd:mkdef -t network -o testnet_noattr
check:rc!=0
check:output=~no attributes were specified
cmd:rmdef -t network -o testnet_noattr
end