From 42aee200dcfcfe162de79073cc70ca242ff96538 Mon Sep 17 00:00:00 2001 From: XuWei Date: Wed, 4 Jan 2017 01:55:20 -0500 Subject: [PATCH] Fix issue 1567, check attribute switch & switch port --- xCAT-probe/subcmds/discovery | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/xCAT-probe/subcmds/discovery b/xCAT-probe/subcmds/discovery index bd57ead93..a84ecccee 100755 --- a/xCAT-probe/subcmds/discovery +++ b/xCAT-probe/subcmds/discovery @@ -315,10 +315,20 @@ sub check_pre_defined_node { my $keystring; foreach my $node (keys %nodecheckrst) { { + last if ($nodecheckrst{$node}{"nodetype"} eq "switch"); + + my @error_attribute = (); $keystring = ""; - if (!(exists($nodecheckrst{$node}{"switch"}) && exists($nodecheckrst{$node}{"switchport"}))) { - last if ($nodecheckrst{$node}{"nodetype"} eq "switch"); - $keystring = "Atrribute 'switch' or 'switchport' isn't defined for '$discovery_type' type discovery"; + + if (!(exists($nodecheckrst{$node}{"switch"})) or $nodecheckrst{$node}{"switch"} !~ /^\w/) { + push @error_attribute, "switch"; + } + if (!(exists($nodecheckrst{$node}{"switchport"})) or $nodecheckrst{$node}{"switchport"} !~ /^\w/) { + push @error_attribute, "switchport"; + } + + if (@error_attribute) { + $keystring = "Attribute " . join(", ", @error_attribute) . " Invalid"; last; } else { my $switchport = "$nodecheckrst{$node}{\"switch\"}*$nodecheckrst{$node}{\"switchport\"}";