Compare commits
No commits in common. "5a9d44511ee1c9afba0805b7ff973b6939da314a" and "345b29b84caa1423e9e8ee0bf7f7c9c36d87cff3" have entirely different histories.
5a9d44511e
...
345b29b84c
|
@ -225,19 +225,20 @@ seed_config() {
|
||||||
# detect:INTEL:800GB:1
|
# detect:INTEL:800GB:1
|
||||||
# detect:DELLBOSS:240GB:0
|
# detect:DELLBOSS:240GB:0
|
||||||
# detect:PERC H330 Mini:200GB:0
|
# detect:PERC H330 Mini:200GB:0
|
||||||
echo "Attempting to find disk for detect string '${o_target_disk}'"
|
|
||||||
IFS=: read detect b_name b_size b_id <<<"${target_disk}"
|
IFS=: read detect b_name b_size b_id <<<"${target_disk}"
|
||||||
# Get the lsscsi output (exclude NVMe)
|
# Get the lsscsi output (exclude NVMe)
|
||||||
lsscsi_data_all="$( lsscsi -s -N )"
|
lsscsi_data_all="$( lsscsi -s -N )"
|
||||||
# Get the available sizes, and match to within +/- 3%
|
# Get the available sizes, and match to within +/- 2%
|
||||||
lsscsi_sizes=( $( awk '{ print $NF }' <<<"${lsscsi_data_all}" | sort | uniq ) )
|
lsscsi_sizes=( $( awk '{ print $NF }' <<<"${lsscsi_data_all}" | sort | uniq ) )
|
||||||
# For each size...
|
# For each size...
|
||||||
for size in ${lsscsi_sizes[@]}; do
|
for size in ${lsscsi_sizes[@]}; do
|
||||||
# Get whether we match +3% and -3% sizes to handle human -> real deltas
|
# Get whether we match +2% and -2% sizes to handle human -> real deltas
|
||||||
# The break below is pretty safe. I can think of no two classes of disks
|
# The break below is pretty safe. I can think of no two classes of disks
|
||||||
# where the difference is within 3% of each other. Even the common
|
# where the difference is within 2% of each other. Even the common
|
||||||
# 120GB -> 128GB and 240GB -> 256GB size deltas are well outside of 3%,
|
# 120GB -> 128GB and 240GB -> 256GB size deltas are well outside of 2%,
|
||||||
# so this should be safe in all cases.
|
# so this should be safe in all cases. 1% would be narrower but has more
|
||||||
|
# chance of mis-identifying due to rounding, while 3% gets into more
|
||||||
|
# contentious differences, so 2% seems like the best option.
|
||||||
# We use Python for this due to BASH's problematic handling of floating-
|
# We use Python for this due to BASH's problematic handling of floating-
|
||||||
# point numbers.
|
# point numbers.
|
||||||
is_match="$(
|
is_match="$(
|
||||||
|
@ -248,9 +249,9 @@ try:
|
||||||
t_size = float(sub(r'\D.','','${size}'))
|
t_size = float(sub(r'\D.','','${size}'))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
exit(0)
|
exit(0)
|
||||||
plusthreepct = t_size * 1.03
|
plustwopct = t_size * 1.02
|
||||||
minusthreepct = t_size * 0.97
|
minustwopct = t_size * 0.98
|
||||||
if b_size > minusthreepct and b_size < plusthreepct:
|
if b_size > minustwopct and b_size < plustwopct:
|
||||||
print("match")
|
print("match")
|
||||||
EOF
|
EOF
|
||||||
)"
|
)"
|
||||||
|
@ -274,8 +275,6 @@ EOF
|
||||||
if [[ ! -b ${target_disk} ]]; then
|
if [[ ! -b ${target_disk} ]]; then
|
||||||
echo "Invalid disk or disk not found for '${o_target_disk}'!"
|
echo "Invalid disk or disk not found for '${o_target_disk}'!"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
|
||||||
echo "Found target disk '${target_disk}'"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
|
Loading…
Reference in New Issue