diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-09-30 09:30:17 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2012-09-30 09:30:17 -0400 |
commit | 497972223afd5193a40e3e9c4e69ce31319a1ebc (patch) | |
tree | bda83abe5575a0d51b01f3e4c04916c667520346 /cloudinit/config/cc_byobu.py | |
parent | a28d7fe46cf8e3277a13c35c5dd0185f65ab1d0c (diff) | |
parent | 72fc1f762e5c5df563380e9ed90bfaba131e811b (diff) | |
download | vyos-cloud-init-497972223afd5193a40e3e9c4e69ce31319a1ebc.tar.gz vyos-cloud-init-497972223afd5193a40e3e9c4e69ce31319a1ebc.zip |
rework the rest of the users of old single 'user' to support lists
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.
"default" user is now marked in the user dict and get_default_user uses
that.
Diffstat (limited to 'cloudinit/config/cc_byobu.py')
-rw-r--r-- | cloudinit/config/cc_byobu.py | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/cloudinit/config/cc_byobu.py b/cloudinit/config/cc_byobu.py index 4e2e06bb..92d428b7 100644 --- a/cloudinit/config/cc_byobu.py +++ b/cloudinit/config/cc_byobu.py @@ -18,12 +18,17 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +# Ensure this is aliased to a name not 'distros' +# since the module attribute 'distros' +# is a list of distros that are supported, not a sub-module +from cloudinit import distros as ds + from cloudinit import util distros = ['ubuntu', 'debian'] -def handle(name, cfg, _cloud, log, args): +def handle(name, cfg, cloud, log, args): if len(args) != 0: value = args[0] else: @@ -56,16 +61,20 @@ def handle(name, cfg, _cloud, log, args): shcmd = "" if mod_user: - user = util.get_cfg_option_str(cfg, "user", "ubuntu") - shcmd += " sudo -Hu \"%s\" byobu-launcher-%s" % (user, bl_inst) - shcmd += " || X=$(($X+1)); " + (users, _groups) = ds.normalize_users_groups(cfg, cloud.distro) + (user, _user_config) = ds.extract_default(users) + if not user: + log.warn(("No default byobu user provided, " + "can not launch %s for the default user"), bl_inst) + else: + shcmd += " sudo -Hu \"%s\" byobu-launcher-%s" % (user, bl_inst) + shcmd += " || X=$(($X+1)); " if mod_sys: shcmd += "echo \"%s\" | debconf-set-selections" % dc_val shcmd += " && dpkg-reconfigure byobu --frontend=noninteractive" shcmd += " || X=$(($X+1)); " - cmd = ["/bin/sh", "-c", "%s %s %s" % ("X=0;", shcmd, "exit $X")] - - log.debug("Setting byobu to %s", value) - - util.subp(cmd, capture=False) + if len(shcmd): + cmd = ["/bin/sh", "-c", "%s %s %s" % ("X=0;", shcmd, "exit $X")] + log.debug("Setting byobu to %s", value) + util.subp(cmd, capture=False) |