Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-stable
Commits
084e9ec7
Commit
084e9ec7
authored
Jul 03, 2013
by
Dan Reading
Browse files
First pass at producing sql commands to update database
parent
ac459e93
Changes
1
Hide whitespace changes
Inline
Side-by-side
clientside/tmcc/common/checknode/gen_sql
View file @
084e9ec7
...
...
@@ -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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment