summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2017-03-02 21:45:47 -0500
committerScott Moser <smoser@brickies.net>2017-03-03 01:30:15 -0500
commitd914ed8e573d464c4d21aa41069beb73fd3ce9be (patch)
tree3fa27e969a979e484c8ae8ee55a620ca1f988651
parent79db2e2436d91510aceb8c036c4a945362c85a52 (diff)
downloadvyos-cloud-init-d914ed8e573d464c4d21aa41069beb73fd3ce9be.tar.gz
vyos-cloud-init-d914ed8e573d464c4d21aa41069beb73fd3ce9be.zip
ds-identify: record not found in cloud.cfg and always add None.
On a 'not found' result, was not being written at all. That had the unintended effect of '--force' not working. Now, on a 'not found' result: - if reporting: write the list as found (with just 'None'). - if not reporting: only report that there was nothing found. this means that the warning cloud-init will write about ds-identify failing to find a datasource will be written, but cloud-init will still search its fully configured list.
-rwxr-xr-xtools/ds-identify21
1 files changed, 19 insertions, 2 deletions
diff --git a/tools/ds-identify b/tools/ds-identify
index fd2a46c8..741cf3ae 100755
--- a/tools/ds-identify
+++ b/tools/ds-identify
@@ -886,10 +886,23 @@ write_result() {
return 0
}
+record_notfound() {
+ # in report mode, report nothing was found.
+ # if not report mode: only report the negative result.
+ # reporting an empty list would mean cloud-init would not search
+ # any datasources.
+ if [ "$DI_REPORT" = "true" ]; then
+ found --
+ else
+ local msg="# reporting not found result. notfound=${DI_ON_NOTFOUND}."
+ local DI_REPORT="true"
+ found -- "$msg"
+ fi
+}
+
found() {
# found(ds1, [ds2 ...], [-- [extra lines]])
local list="" ds=""
- # always we write the None datasource last.
while [ $# -ne 0 ]; do
if [ "$1" = "--" ]; then
shift
@@ -902,6 +915,8 @@ found() {
# do not pass an empty line through.
shift
fi
+ # always write the None datasource last.
+ list="${list:+${list}, }None"
write_result "datasource_list: [ $list ]" "$@"
return
}
@@ -1173,13 +1188,15 @@ _main() {
return
fi
+ # record the empty result.
+ record_notfound
case "$DI_ON_NOTFOUND" in
$DI_DISABLED)
debug 1 "No result. notfound=$DI_DISABLED. returning $ret_dis."
return $ret_dis
;;
$DI_ENABLED)
- debug 1 "notfound=$DI_ENABLED. returning $ret_en"
+ debug 1 "No result. notfound=$DI_ENABLED. returning $ret_en"
return $ret_en;;
esac