From a6752e739a0bb9052585b9b043ce1964bd77bb42 Mon Sep 17 00:00:00 2001 From: Ben Howard Date: Wed, 22 Aug 2012 16:32:18 -0600 Subject: Simplified users[0] detection, and ensured compatability with previous user password control code --- cloudinit/config/cc_set_passwords.py | 12 ++++++++++-- cloudinit/config/cc_ssh_import_id.py | 11 ++++++----- cloudinit/config/cc_users_groups.py | 4 ---- 3 files changed, 16 insertions(+), 11 deletions(-) (limited to 'cloudinit/config') diff --git a/cloudinit/config/cc_set_passwords.py b/cloudinit/config/cc_set_passwords.py index ab266741..4bf62aa9 100644 --- a/cloudinit/config/cc_set_passwords.py +++ b/cloudinit/config/cc_set_passwords.py @@ -50,8 +50,16 @@ def handle(_name, cfg, cloud, log, args): expire = util.get_cfg_option_bool(chfg, 'expire', expire) if not plist and password: - user = util.get_cfg_option_str(cfg, "user", "ubuntu") - plist = "%s:%s" % (user, password) + user = cloud.distro.get_default_user() + + if 'users' in cfg: + user_zero = cfg['users'].keys()[0] + + if user_zero != "default": + user = user_zero + + if user: + plist = "%s:%s" % (user, password) errors = [] if plist: diff --git a/cloudinit/config/cc_ssh_import_id.py b/cloudinit/config/cc_ssh_import_id.py index e733d14a..9aee2166 100644 --- a/cloudinit/config/cc_ssh_import_id.py +++ b/cloudinit/config/cc_ssh_import_id.py @@ -32,12 +32,13 @@ def handle(name, cfg, cloud, log, args): if len(args) > 1: ids = args[1:] else: - user = None + user = cloud.distro.get_default_user() - try: - user = cloud.distro.get_configured_user() - except NotImplementedError: - pass + if 'users' in cfg: + user_zero = cfg['users'].keys()[0] + + if user_zero != "default": + user = user_zero ids = util.get_cfg_option_list(cfg, "ssh_import_id", []) diff --git a/cloudinit/config/cc_users_groups.py b/cloudinit/config/cc_users_groups.py index 828b0d94..7e5ecc7b 100644 --- a/cloudinit/config/cc_users_groups.py +++ b/cloudinit/config/cc_users_groups.py @@ -78,7 +78,3 @@ def handle(name, cfg, cloud, log, _args): new_opts[opt.replace('-', '')] = user_config[opt] cloud.distro.create_user(name, **new_opts) - - if user_zero: - cloud.distro.set_configured_user(user_zero) - log.info("Set configured user for this instance to %s" % user_zero) -- cgit v1.2.3