mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-29 02:15:34 +00:00 
			
		
		
		
	Merge pull request #5439 from bybai/dh
makedhcp check if mac format is valid
This commit is contained in:
		| @@ -587,6 +587,7 @@ sub addnode | ||||
|         ); | ||||
|         return; | ||||
|     } | ||||
|      | ||||
|     my @macs = split(/\|/, $ent->{mac}); | ||||
|     my $mace; | ||||
|     my $deflstaments = $lstatements; | ||||
| @@ -603,6 +604,16 @@ sub addnode | ||||
|             $hname = $node; | ||||
|         }                                #Default to hostname equal to nodename | ||||
|         unless ($mac) { next; }          #Skip corrupt format | ||||
|         if ($mac !~ /^[0-9a-fA-F]{2}(-[0-9a-fA-F]{2}){5}$|^[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}$/) | ||||
|         { | ||||
|             $callback->( | ||||
|                 { | ||||
|                     error => ["Invalid mac address $mac for $node"], | ||||
|                     errorcode => [1] | ||||
|                 } | ||||
|             ); | ||||
|             next; | ||||
|         } | ||||
|         my $ip = getipaddr($hname, OnlyV4 => 1); | ||||
|         if ($hname eq '*NOIP*') { | ||||
|             $hname = $node . "-noip" . $mac; | ||||
|   | ||||
| @@ -66,6 +66,19 @@ cmd:rmdef testnode1 | ||||
| cmd:if [ -f "/etc/dhcp/dhcpd.conf" ];then mv -f /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak ; elif [ -f "/etc/dhcpd.conf" ]; then mv -f /etc/dhcpd.conf /etc/dhcpd.conf.bak; fi | ||||
| end | ||||
|  | ||||
| start:makedhcp_a_linux_check_invalid_mac | ||||
| description:Define all nodes to the DHCP server. If mac format is invalid, makedhcp -a print error and return 1 | ||||
| os:Linux | ||||
| label:mn_only,dhcp | ||||
| cmd:lsdef -l $$CN -z > /tmp/$$CN.stanza | ||||
| cmd:chdef -t node -o $$CN mac=11:22:33 | ||||
| cmd:makedhcp $$CN | ||||
| check:rc!=0 | ||||
| check:output!~ ^11:22:33$ | ||||
| cmd:chdef -t node -o $$CN mac= | ||||
| cmd:cat /tmp/$$CN.stanza | chdef -z | ||||
| end | ||||
|  | ||||
| start:makedhcp_a_d_linux | ||||
| os:Linux | ||||
| label:mn_only,dhcp | ||||
|   | ||||
		Reference in New Issue
	
	Block a user