Commit 084e9ec7 authored by Dan Reading's avatar Dan Reading
Browse files

First pass at producing sql commands to update database

parent ac459e93
......@@ -10,7 +10,36 @@ gentbsql_main() {
allnodes=$(ls -d pc* pg* dbox*)
for host in $allnodes ; do
:
if [ -d $projdir/$host ] ; then
cd $projdir/$host
if [ -z "$(grep "Diff Report" diff)" ] ; then
# echo "$host Inventory Report to old to use"
continue
fi
listofobjs="DISKINFO CPUINFO MEMINFO NETINFO"
for i in $listofobjs ; do
toadd="$(grep $i diff)"
[[ "$toadd" = "${toadd/match}" ]] || continue
if [ -n "$toadd" ] ; then
toadd=${toadd/$i}
printf "mysql -e \"insert into %s set node_id='%s' %s;\" tbdb\n" "$i" "$host" "$toadd"
fi
done
listofdisks=$(grep 'DISKs:' diff)
listofdisks=${listofdisks/DISKs:}
for i in $listofdisks ; do
toadd=$(grep $i node)
toadd=${toadd/DISKUNIT}
printf "mysql -e \"insert into DISKUNIT set node_id='%s' %s;\" tbdb\n" "$host" "$toadd"
done
listofnics=$(grep 'NICs:' diff)
listofnics=${listofnics/NICs:}
for i in $listofnics ; do
toadd=$(grep $i node)
toadd=${toadd/NETUNIT}
printf "mysql -e \"insert into NETUNIT set node_id='%s' %s;\" tbdb\n" "$host" "$toadd"
done
fi
done
}
......@@ -80,7 +109,7 @@ setdirstructure() {
if [ "$0" = "${0/sql}" ] ; then
setdirstructure
else
echo gentbsql_main
gentbsql_main
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment