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
88a199fb
Commit
88a199fb
authored
Jul 09, 2013
by
Dan Reading
Browse files
add node_id arg to getsql. Handle delete from database.
parent
0e18c133
Changes
1
Hide whitespace changes
Inline
Side-by-side
clientside/tmcc/common/checknode/gen_sql
View file @
88a199fb
...
...
@@ -7,13 +7,17 @@ gentbsql_main() {
set
-u
projdir
=
/proj/emulab-ops/nodecheck
cd
$projdir
allnodes
=
$(
ls
-d
pc
*
pg
*
dbox
*
)
if
((
$#
))
;
then
allnodes
=
"
$@
"
else
allnodes
=
$(
ls
-d
pc
*
pg
*
dbox
*
)
fi
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"
echo
"
$host
Inventory Report to old to use"
continue
fi
listofobjs
=
"DISKINFO CPUINFO MEMINFO NETINFO"
...
...
@@ -22,23 +26,35 @@ gentbsql_main() {
[[
"
$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
"
printf
"
\n
mysql -e
\"
insert into %s set node_id='%s' %s;
\"
tbdb
\n
"
"
$i
"
"
$host
"
"
$toadd
"
fi
done
listofdisks
=
$(
grep
'DISKs:'
diff
)
listofdisks
=
${
listofdisks
/DISKs
:
}
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
"
if
[
-n
"
$toadd
"
]
;
then
toadd
=
${
toadd
/DISKUNIT
}
printf
"mysql -e
\"
insert into DISKUNIT set node_id='%s' %s;
\"
tbdb
\n
"
"
$host
"
"
$toadd
"
else
toadd
=
"SN=
\"
$i
\"
"
printf
"mysql -e
\"
delete from DISKUNIT where node_id='%s' and %s;
\"
tbdb
\n
"
"
$host
"
"
$toadd
"
fi
done
listofnics
=
$(
grep
'NICs:'
diff
)
listofnics
=
${
listofnics
/NICs
:
}
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
"
if
[
-n
"
$toadd
"
]
;
then
toadd
=
${
toadd
/NETUNIT
}
printf
"mysql -e
\"
insert into NETUNIT set node_id='%s' %s;
\"
tbdb
\n
"
"
$host
"
"
$toadd
"
else
toadd
=
"ID=
\"
$i
\"
"
printf
"mysql -e
\"
delete from NETUNIT where node_id='%s' and %s;
\"
tbdb
\n
"
"
$host
"
"
$toadd
"
fi
done
else
echo
"No record of node id
\"
$host
\"
."
fi
done
...
...
@@ -109,7 +125,7 @@ setdirstructure() {
if
[
"
$0
"
=
"
${
0
/sql
}
"
]
;
then
setdirstructure
else
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