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-devel
Commits
aa96a7dd
Commit
aa96a7dd
authored
Jun 17, 2013
by
Dan Reading
Browse files
Change function readtcminfo so it can take two arguments.
What source to read the info from and which enternal array to fill.
parent
6daf5377
Changes
2
Hide whitespace changes
Inline
Side-by-side
clientside/tmcc/common/checknode/checkutils.sh
View file @
aa96a7dd
...
...
@@ -55,6 +55,7 @@ declare os="" #[Linux|FreeBSD] for now
declare
-a
todo_exit
declare
-A
hwinv
# hwinv from tmcc
declare
-A
hwinvcopy
# a copy of hwinv from tmcc
declare
-A
tmccinfo
# info from tmcc hwinfo
#declare -A tcm_out # hwinv for output
...
...
@@ -80,35 +81,45 @@ err_report() {
trap
'err_report $LINENO'
ERR
# read info from tmcc no args uses the globel array hwinv
# if $1 then use that for a input file else use tmcc
# read info from tmcc or a file. Copy into one of the three global arrays
# hwinv, hwinvcopy, tmccinfo
# $1 is the source $2 is the output array
# error if not both set
readtmcinfo
()
{
local
-A
in
a
local
-A
ref_hw
in
v
local
keyword
local
-i
dcnt
=
0
local
-i
ncnt
=
0
local
ifile
local
source
output
local
rmtmp
# what file to read from, if not set then make tmcc call
ifile
=
${
1
+
$1
}
# use $1 if set otherwise use nothing
if
[
-z
"
$ifile
"
]
;
then
# no input file then use a tmp file to hold data from tmcc
rmtmp
=
"y"
ifile
=
/tmp/.
$$
tmcchwinv
$(
$BINDIR
/tmcc hwinfo
>
$ifile
)
source
=
${
1
+
$1
}
# use $1 if set otherwise use nothing
output
=
${
2
+
$2
}
if
[
$#
-ne
2
]
;
then
printf
"
\n
%s
\n
"
"Script error missing arg source:|
$source
| output:|
$output
|"
printf
"Where %s:%s called from %s
\n
"
$FUNCNAME
$LINENO
"
$(
caller
)
"
exit
1
fi
if
[
"
$source
"
=
"tmcc"
]
;
then
rmtmp
=
"y"
# remove tmp file
source
=
/tmp/.
$$
tmcchwinv
$(
$BINDIR
/tmcc hwinfo
>
$source
)
else
rmtmp
=
""
fi
# initalize array
if
[
-z
"
${
hwinv
[
"hwinvidx"
]+
${
hwinv
[
"hwinvidx"
]
}}
"
]
;
then
hwinv[
"hwinvidx"
]=
""
#start the array
else
for
i
in
${
hwinv
[
"hwinvidx"
]
}
;
do
unset
hwinv[
$i
]
# initalize output array
if
[
-z
"
${
ref_hwinv
[
"hwinvidx"
]+
${
ref_hwinv
[
"hwinvidx"
]
}}
"
]
;
then
ref_hwinv[
"hwinvidx"
]=
""
#start the array
else
# reset the array
for
i
in
${
ref_hwinv
[
"hwinvidx"
]
}
;
do
unset
ref_hwinv[
$i
]
done
hwinv[
"hwinvidx"
]=
""
#restart the array
# hwinvidx is always expected to be set
ref_hwinv[
"hwinvidx"
]=
""
#restart the array
fi
# handle mult-line input for disks and nets
...
...
@@ -125,10 +136,59 @@ readtmcinfo() {
;;
\#
*
)
continue
;;
esac
hwinv[
"hwinvidx"
]
+
=
"
$keyword
"
# keeping the keyword list preserves order
hwinv[
$keyword
]=
$in
done
<
$ifile
[
-n
"
$rmtmp
"
]
&&
rm
$ifile
||
:
# the colon just stops a error being caught by -e
ref_hwinv[
"hwinvidx"
]
+
=
"
$keyword
"
# keeping the keyword list preserves order
ref_hwinv[
$keyword
]=
$in
done
<
$source
[
-n
"
$rmtmp
"
]
&&
rm
$source
||
:
# the colon just stops a error being caught by -e
case
$output
in
tmccinfo
)
if
[
-z
"
${
tmccinfo
[
"hwinvidx"
]+
${
tmccinfo
[
"hwinvidx"
]
}}
"
]
;
then
tmccinfo[
"hwinvidx"
]=
""
#start the array
else
for
i
in
${
tmccinfo
[
"hwinvidx"
]
}
;
do
unset
tmccinfo[
$i
]
done
tmccinfo[
"hwinvidx"
]=
""
#restart the array
fi
tmccinfo[
"hwinvidx"
]=
${
ref_hwinv
[
"hwinvidx"
]
}
for
i
in
${
ref_hwinv
[
"hwinvidx"
]
}
;
do
tmccinfo[
$i
]=
${
ref_hwinv
[
$i
]
}
done
;;
hwinv
)
if
[
-z
"
${
hwinv
[
"hwinvidx"
]+
${
hwinv
[
"hwinvidx"
]
}}
"
]
;
then
hwinv[
"hwinvidx"
]=
""
#start the array
else
for
i
in
${
hwinv
[
"hwinvidx"
]
}
;
do
unset
hwinv[
$i
]
done
hwinv[
"hwinvidx"
]=
""
#restart the array
fi
hwinv[
"hwinvidx"
]=
${
ref_hwinv
[
"hwinvidx"
]
}
for
i
in
${
ref_hwinv
[
"hwinvidx"
]
}
;
do
hwinv[
$i
]=
${
ref_hwinv
[
$i
]
}
done
;;
hwinvcopy
)
if
[
-z
"
${
hwinvcopy
[
"hwinvidx"
]+
${
hwinvcopy
[
"hwinvidx"
]
}}
"
]
;
then
hwinvcopy[
"hwinvidx"
]=
""
#start the array
else
for
i
in
${
hwinvcopy
[
"hwinvidx"
]
}
;
do
unset
hwinvcopy[
$i
]
done
hwinvcopy[
"hwinvidx"
]=
""
#restart the array
fi
hwinvcopy[
"hwinvidx"
]=
${
ref_hwinv
[
"hwinvidx"
]
}
for
i
in
${
ref_hwinv
[
"hwinvidx"
]
}
;
do
hwinvcopy[
$i
]=
${
ref_hwinv
[
$i
]
}
done
;;
*
)
printf
"
\n
%s
\n
"
"Script error illegal output array |
$output
|"
printf
"Where %s:%s called from %s
\n
"
$FUNCNAME
$LINENO
"
$(
caller
)
"
exit
1
esac
}
# copy assoctive array hwinv into hwinvcopy
...
...
@@ -176,6 +236,10 @@ comparetmcinfo() {
tbdbidx
=
${
tbdbidx
//DISKUNIT[[
:digit:]][[:digit:]]/
}
tbdbidx
=
${
tbdbidx
//DISKUNIT[[
:digit:]]/
}
# take the TESTINFO line out
localidx
=
${
localidx
//TESTINFO/
}
tbdbidx
=
${
localidx
//TESTINFO/
}
# contact the two indexs then find get the uniq union
arrayidx
=
"
$localidx
$tbdbidx
"
arrayidx
=
$(
uniqstr
$arrayidx
)
...
...
@@ -575,7 +639,6 @@ getdrivenames() {
return
0
}
# The timesys function terminates its script unless it terminates earlier on its own
# args: max_time output_file command command_args
# does not work....
...
...
@@ -599,3 +662,4 @@ timesys() {
done
}
>
$out
2>&1
}
clientside/tmcc/common/checknode/gatherinv
View file @
aa96a7dd
...
...
@@ -57,7 +57,7 @@ gatherinv_main() {
done
# read in the newly found info
readtmcinfo /tmp/nodecheck.log.tb
readtmcinfo /tmp/nodecheck.log.tb
hwinv
# print it back out for the database
{
printtmcinfo
...
...
@@ -120,10 +120,10 @@ gatherinv_main() {
cd
$owd
# Test what was found locally against what is in the database
readtmcinfo
# info from tmcc.bin hwinv
readtmcinfo
tmcc hwinvcopy
# info from tmcc.bin hwinv
# if testing can do something like readtmcinfo ${INVDIR}/test
copytmcinfo
# copy into hwinvcopy
readtmcinfo /tmp/nodecheck.log.inv
# read full listing of locally found into hwinv, diff for local stuff not in tbdb
#
copytmcinfo # copy into hwinvcopy
readtmcinfo /tmp/nodecheck.log.inv
hwinv
# read full listing of locally found into hwinv, diff for local stuff not in tbdb
comparetmcinfo /tmp/nodecheck.diff
# file for output
# if we ended up with a diff file handle it
...
...
Write
Preview
Markdown
is supported
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