@@ -4,8 +4,8 @@
// isdf - dhcp generator
// Author: Carsten Schoene
//
-// $LastChangedDate: 2012-09-17 21:47:13 +0200 (Mon, 17 Sep 2012) $
-// $Rev: 1850 $
+// $LastChangedDate: 2012-09-18 15:27:50 +0200 (Tue, 18 Sep 2012) $
+// $Rev: 1857 $
*/
// define our name
@@ -92,7 +92,8 @@
if ( $systeminet4->isipin($systemfirst) ) {
$revhost = $config["isdf"]["dhcp"]["system"]["hostnameprefix"] . preg_replace('/\./','-', $systemfirst);
//echo " first try on with: $revhost\n";
- while ( !($retval = $dhcpsystem->hostExists($revhost,$mac)) === false ) {
+ $reread = true;
+ while ( !($retval = $dhcpsystem->hostExists($revhost,$mac, $reread)) === false ) {
//echo "Retval: $retval\n";
if ( $retval == 2 ) {
// mac exists
@@ -103,6 +104,7 @@
//echo " another try with: $revhost\n";
$systemfirst = $systeminet4->increment($systemfirst,$systemend);
$revhost = $config["isdf"]["dhcp"]["system"]["hostnameprefix"] . preg_replace('/\./', '-', $systemfirst);
+ $reread = false;
} else {
break;
}
@@ -116,12 +118,14 @@
$pxefirst = $config["isdf"]["dhcp"]["systempxe"]["firstusable"];
if ( $pxeinet4->isipin($pxefirst) ) {
$revhost = $config["isdf"]["dhcp"]["systempxe"]["hostnameprefix"] . preg_replace('/\./','-', $pxefirst);
- while ( !($retval = $dhcpsystempxe->hostExists($revhost,$mac)) === false ) {
+ $reread = true;
+ while ( !($retval = $dhcpsystempxe->hostExists($revhost,$mac, $reread)) === false ) {
if ( $retval == 2 ) {
break 2;
} elseif ( $retval == 1 ) {
$pxefirst = $pxeinet4->increment($pxefirst,$pxeend);
$revhost = $config["isdf"]["dhcp"]["systempxe"]["hostnameprefix"] . preg_replace('/\./', '-', $pxefirst);
+ $reread = false;
} else {
break;
}
@@ -160,12 +164,14 @@
$mgmtfirst = $config["isdf"]["dhcp"]["systemmgmt"]["firstusable"];
if ( $mgmtinet4->isipin($mgmtfirst) ) {
$revhost = $config["isdf"]["dhcp"]["systemmgmt"]["hostnameprefix"] . preg_replace('/\./','-', $mgmtfirst);
- while ( !($retval = $dhcpsystemmgmt->hostExists($revhost,$mac)) === false ) {
+ $reread = true;
+ while ( !($retval = $dhcpsystemmgmt->hostExists($revhost,$mac,$reread)) === false ) {
if ( $retval == 2 ) {
break 2;
} elseif ( $retval == 1 ) {
$mgmtfirst = $mgmtinet4->increment($mgmtfirst,$mgmtend);
$revhost = $config["isdf"]["dhcp"]["systemmgmt"]["hostnameprefix"] . preg_replace('/\./', '-', $mgmtfirst);
+ $reread = false;
} else {
break;
}
|
@@ -1,6 +1,6 @@
<?php
-// $LastChangedDate: 2012-09-17 18:09:05 +0200 (Mon, 17 Sep 2012) $
-// $Rev: 1832 $
+// $LastChangedDate: 2012-09-18 14:47:51 +0200 (Tue, 18 Sep 2012) $
+// $Rev: 1855 $
class dhcpconf {
var $dhcpdHosts;
@@ -196,18 +196,27 @@
return $found;
}
- public function hostExists($hostname, $mac){
- $this->readHosts();
+ public function hostExists($hostname, $mac, $reread = true ){
+ if ( $reread == true ) {
+ $this->readHosts();
+ }
$match = false;
if ( isset($this->hosts) ) {
foreach($this->hosts as $host){
+ /*
if(strtoupper($hostname) == strtoupper($host["hostname"])){
$match = 1;
}
elseif(strtoupper($mac) == strtoupper($host["mac"])){
$match = 2;
}
-
+ */
+ if ( $hostname == $host["hostname"] ) {
+ $match = 1;
+ }
+ elseif ( $mac == $host["mac"] ) {
+ $match = 2;
+ }
if($match)
break;
}
|