summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-09-21 14:15:09 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-09-21 14:15:09 -0700
commit62631d30aae55a42b77d326af75d5e476d4baf36 (patch)
tree4b8fb0e8c3317fe6f41ca638235af818804ae3bd /cloudinit/util.py
parent94b9647e4df742982cac8a2c2925fb4894281dbf (diff)
downloadvyos-cloud-init-62631d30aae55a42b77d326af75d5e476d4baf36.tar.gz
vyos-cloud-init-62631d30aae55a42b77d326af75d5e476d4baf36.zip
1. Cleanup the user creation so that the distro class is
responsible only for creating users and groups and normalizing a input configuration into a normalized format that splits up the user list, the group list and the default user listsand let the add user/group config module handle calling those methods to add its own users/groups and the default user (if any). 2. Also add in tests for this normalization process to ensure that it is pretty bug free and works with the different types of formats that users/groups/defaults + options can take.
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 33da73eb..94b17dfa 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -1104,6 +1104,22 @@ def hash_blob(blob, routine, mlen=None):
return digest
+def is_user(name):
+ try:
+ if pwd.getpwnam(name):
+ return True
+ except KeyError:
+ return False
+
+
+def is_group(name):
+ try:
+ if grp.getgrnam(name):
+ return True
+ except KeyError:
+ return False
+
+
def rename(src, dest):
LOG.debug("Renaming %s to %s", src, dest)
# TODO(harlowja) use a se guard here??