diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-09-28 13:53:56 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-09-28 13:53:56 -0700 |
commit | cf3dd1ba86d4ddde149f451e026c697c07b4d732 (patch) | |
tree | 29092b201054ca6af61c0c2f4ba61a8f28f051b0 /cloudinit/util.py | |
parent | dfa62e70bd9942fd3c82d77217d48615a78bbcfc (diff) | |
download | vyos-cloud-init-cf3dd1ba86d4ddde149f451e026c697c07b4d732.tar.gz vyos-cloud-init-cf3dd1ba86d4ddde149f451e026c697c07b4d732.zip |
Rework the rest of the locations that used
the previous 'user' and make those locations
go through the new distros functions to select
the default user or the user list (depending on usage).
Adjust the tests to check the new 'default' field
that signifies the default user + test the new method
to extract just the default user from a normalized
user dictionary.
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r-- | cloudinit/util.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index 94b17dfa..184b37a4 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -248,6 +248,36 @@ def read_conf(fname): raise +# Merges X lists, and then keeps the +# unique ones, but orders by sort order +# instead of by the original order +def uniq_merge_sorted(*lists): + return sorted(uniq_merge(*lists)) + + +# Merges X lists and then iterates over those +# and only keeps the unique items (order preserving) +# and returns that merged and uniqued list as the +# final result. +# +# Note: if any entry is a string it will be +# split on commas and empty entries will be +# evicted and merged in accordingly. +def uniq_merge(*lists): + combined_list = [] + for a_list in lists: + if isinstance(a_list, (str, basestring)): + a_list = a_list.strip().split(",") + # Kickout the empty ones + a_list = [a for a in a_list if len(a)] + combined_list.extend(a_list) + uniq_list = [] + for i in combined_list: + if i not in uniq_list: + uniq_list.append(i) + return uniq_list + + def clean_filename(fn): for (k, v) in FN_REPLACEMENTS.iteritems(): fn = fn.replace(k, v) |