summaryrefslogtreecommitdiff
path: root/cloudinit/config
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-09-23 12:39:22 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-09-23 12:39:22 -0700
commit1278285241d017affa2d03f8023afaf2d35a9543 (patch)
treec55d8611e4df6c1780f016d185424b9f09e361ee /cloudinit/config
parent009faa0546ffbcadbbcaa9692d6842890e6f2e10 (diff)
downloadvyos-cloud-init-1278285241d017affa2d03f8023afaf2d35a9543.tar.gz
vyos-cloud-init-1278285241d017affa2d03f8023afaf2d35a9543.zip
Make the normalization a module level function
since it has little dependence on the distros class itself. Readjust the using code to use this new module level function instead.
Diffstat (limited to 'cloudinit/config')
-rw-r--r--cloudinit/config/cc_users_groups.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/cloudinit/config/cc_users_groups.py b/cloudinit/config/cc_users_groups.py
index a6ce49ac..13eb1102 100644
--- a/cloudinit/config/cc_users_groups.py
+++ b/cloudinit/config/cc_users_groups.py
@@ -16,6 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+from cloudinit import distros
from cloudinit import util
from cloudinit.settings import PER_INSTANCE
@@ -24,10 +25,20 @@ frequency = PER_INSTANCE
def handle(name, cfg, cloud, log, _args):
- distro = cloud.distro
- ((users, default_user), groups) = distro.normalize_users_groups(cfg)
+ def_u = None
+ def_u_gs = None
+ try:
+ def_u = cloud.distro.get_default_user()
+ def_u_gs = cloud.distro.get_default_user_groups()
+ except NotImplementedError:
+ log.warn(("Distro has not implemented default user "
+ "creation. No default user will be added."))
+
+ ((users, default_user), groups) = distros.normalize_users_groups(cfg,
+ def_u,
+ def_u_gs)
for (name, members) in groups.items():
- distro.create_group(name, members)
+ cloud.distro.create_group(name, members)
if default_user:
user = default_user['name']
@@ -41,8 +52,8 @@ def handle(name, cfg, cloud, log, _args):
'sudo': "ALL=(ALL) NOPASSWD:ALL",
}
u_config = util.mergemanydict([def_base_config, config])
- distro.create_user(user, **u_config)
+ cloud.distro.create_user(user, **u_config)
log.info("Added default '%s' user with passwordless sudo", user)
for (user, config) in users.items():
- distro.create_user(user, **config)
+ cloud.distro.create_user(user, **config)