Merge ~smoser/cloud-init:bug/ds-identify-list-none-twice into cloud-init:master

Proposed by Scott Moser
Status: Merged
Merged at revision: 13673f8d2b815452aa22f8e3811e04481558a731
Proposed branch: ~smoser/cloud-init:bug/ds-identify-list-none-twice
Merge into: cloud-init:master
Diff against target: 38 lines (+12/-4)
2 files modified
tests/unittests/test_ds_identify.py (+7/-0)
tools/ds-identify (+5/-4)
Reviewer Review Type Date Requested Status
Chad Smith Approve
Server Team CI bot continuous-integration Approve
cloud-init Commiters Pending
Review via email: mp+324557@code.launchpad.net

Commit message

fix tools/ds-identify to not write None twice.

If the user configured:
  datasource_list: ["Ec2", "None"]
then ds-identify would write
  datasource_list: ["Ec2", "None", "None"]
which would break the logic to avoid warning.

Description of the change

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) wrote :

+1 LGTM!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/tests/unittests/test_ds_identify.py b/tests/unittests/test_ds_identify.py
index 9e14885..8559e1f 100644
--- a/tests/unittests/test_ds_identify.py
+++ b/tests/unittests/test_ds_identify.py
@@ -210,6 +210,13 @@ class TestDsIdentify(CiTestCase):
210 mydata['files'][cfgpath] = 'datasource_list: ["NoCloud"]\n'210 mydata['files'][cfgpath] = 'datasource_list: ["NoCloud"]\n'
211 self._check_via_dict(mydata, rc=RC_FOUND, dslist=['NoCloud', DS_NONE])211 self._check_via_dict(mydata, rc=RC_FOUND, dslist=['NoCloud', DS_NONE])
212212
213 def test_configured_list_with_none(self):
214 """If user set a datasource_list, that should be used."""
215 mydata = copy.deepcopy(VALID_CFG['GCE'])
216 cfgpath = 'etc/cloud/cloud.cfg.d/myds.cfg'
217 mydata['files'][cfgpath] = 'datasource_list: ["Ec2", "None"]\n'
218 self._check_via_dict(mydata, rc=RC_FOUND, dslist=['Ec2', DS_NONE])
219
213220
214def blkid_out(disks=None):221def blkid_out(disks=None):
215 """Convert a list of disk dictionaries into blkid content."""222 """Convert a list of disk dictionaries into blkid content."""
diff --git a/tools/ds-identify b/tools/ds-identify
index aff26eb..74d2653 100755
--- a/tools/ds-identify
+++ b/tools/ds-identify
@@ -963,10 +963,11 @@ found() {
963 # do not pass an empty line through.963 # do not pass an empty line through.
964 shift964 shift
965 fi965 fi
966 # always write the None datasource last.966 # if None is not already in the list, then add it last.
967 if [ "$list" != "None" ]; then967 case " $list " in
968 list="${list:+${list}, }None"968 *\ None,\ *|*\ None\ ) :;;
969 fi969 *) list=${list:+${list}, None};;
970 esac
970 write_result "datasource_list: [ $list ]" "$@"971 write_result "datasource_list: [ $list ]" "$@"
971 return972 return
972}973}

Subscribers

People subscribed via source and target branches