@@ -1,8 +1,8 @@
#!/bin/bash
# Inventory System
# Author: Carsten Schoene
-# $LastChangedDate: 2012-09-17 16:20:59 +0200 (Mon, 17 Sep 2012) $
-# $Rev: 1828 $
+# $LastChangedDate: 2012-09-17 21:53:15 +0200 (Mon, 17 Sep 2012) $
+# $Rev: 1851 $
#
# Default options (can be changed by inventory-system.conf)
DEBUG="yes"
@@ -199,12 +199,12 @@
YUM=`which yum 2>/dev/null`
ZYP=`which zypper 2>/dev/null`
if [ -n "${PKG}" ] ; then
- if [ -n "${YUM}" && -f /etc/redhat-release ] ; then
+ if [ -n "${YUM}" ] && [ -f /etc/redhat-release ] ; then
CUPD="`${YUM} check-update ${PK} | ${TAIL} -n1 | ${AWK} '{print $1}'`"
if [ -n "${CUPD}" ] ; then
${YUM} -q -y update ${PKG}
fi
- elif [ -n "${ZYP}" && -f /etc/SuSE-release ] ; then
+ elif [ -n "${ZYP}" ] && [ -f /etc/SuSE-release ] ; then
CUPD="`${ZYP} -q lu | ${GREP} ${PKG}`"
if [ -n "${CUPD}" ] ; then
${ZYP} -q -n update ${PKG}
|
@@ -4,8 +4,8 @@
// isdf - dhcp generator
// Author: Carsten Schoene
//
-// $LastChangedDate: 2012-09-17 19:24:23 +0200 (Mon, 17 Sep 2012) $
-// $Rev: 1844 $
+// $LastChangedDate: 2012-09-17 21:47:13 +0200 (Mon, 17 Sep 2012) $
+// $Rev: 1850 $
*/
// define our name
@@ -64,7 +64,7 @@
$pxeend = $pxeinet4->broadcast();
// create dhcp entry for host & pxe
-$qrybkvm="SELECT value FROM inv_system_properties WHERE inv_system_id=(SELECT inv_system_id FROM inv_system_properties WHERE datakey='get_system_type_ix' and value='baremetal-kvm') AND datakey='get_system_net_info';";
+$qrybkvm = "SELECT t1.value AS value FROM inv_system_properties t1, inv_system_properties t2 WHERE t1.datakey='get_system_net_info' AND t1.inv_system_id=t2.inv_system_id AND t2.datakey='" . $config["isdf"]["dhcp"]["db_datakey"] . "' AND t2.value='" . $config["isdf"]["dhcp"]["db_datavalue"] . "';";
$dhcpmacs = array();
@@ -103,6 +103,8 @@
//echo " another try with: $revhost\n";
$systemfirst = $systeminet4->increment($systemfirst,$systemend);
$revhost = $config["isdf"]["dhcp"]["system"]["hostnameprefix"] . preg_replace('/\./', '-', $systemfirst);
+ } else {
+ break;
}
}
//echo " while loop ended with: $revhost\n";
@@ -120,6 +122,8 @@
} elseif ( $retval == 1 ) {
$pxefirst = $pxeinet4->increment($pxefirst,$pxeend);
$revhost = $config["isdf"]["dhcp"]["systempxe"]["hostnameprefix"] . preg_replace('/\./', '-', $pxefirst);
+ } else {
+ break;
}
}
$dhcpsystempxe->addHost($revhost,$mac,$pxefirst);
@@ -129,7 +133,8 @@
// create dhcp entry for mgmt
-$qrymgmtbkvm = "SELECT value FROM inv_system_properties WHERE datakey LIKE 'get_system_mgmt_mac' AND inv_system_id=(SELECT inv_system_id FROM inv_system_properties WHERE datakey='get_system_type_ix' AND value='baremetal-kvm');";
+$qrymgmtbkvm = "SELECT t1.value AS value FROM inv_system_properties t1, inv_system_properties t2 WHERE t1.datakey='get_system_mgmt_mac' AND t1.inv_system_id=t2.inv_system_id AND t2.datakey='" . $config["isdf"]["dhcp"]["db_datakey"] . "' AND t2.value='" . $config["isdf"]["dhcp"]["db_datavalue"] . "';";
+
$mgmtaddr = explode("/", $config["isdf"]["dhcp"]["systemmgmt"]["net4"]);
$mgmtinet4 = new IPv4($mgmtaddr[0], $mgmtaddr[1]);
$mgmtend = $mgmtinet4->broadcast();
@@ -161,6 +166,8 @@
} elseif ( $retval == 1 ) {
$mgmtfirst = $mgmtinet4->increment($mgmtfirst,$mgmtend);
$revhost = $config["isdf"]["dhcp"]["systemmgmt"]["hostnameprefix"] . preg_replace('/\./', '-', $mgmtfirst);
+ } else {
+ break;
}
}
$dhcpsystemmgmt->addHost($revhost,$mac,$mgmtfirst);
|