~smoser/ubuntu/quantal/cloud-init/sru

« back to all changes in this revision

Viewing changes to cloudinit/distros/ubuntu.py

  • Committer: Scott Moser
  • Date: 2012-08-23 05:06:29 UTC
  • mfrom: (1.1.31)
  • Revision ID: smoser@ubuntu.com-20120823050629-jkzdptf45cc88s03
* New upstream snapshot.
  * support creating users on boot. remove requirement for a 'ubuntu'
    user to be previously present in image. (LP: #1028503)
  * add experimental apt_reboot_if_required flag to reboot if necessary
    after upgrade or package install (LP: #1038108)
  * improve mirror selection for a distro: 
    * support arm mirrors (LP: #1028501)
    * support seeding security mirror (LP: #1006963)
    * support dns mirrors including availability-zone reference
      (LP: #1037727)
  * include a "None" datasource so items like ssh host key generation
    occur if there is no other metadata service. (LP: #906669)
  * print authorized_keys for users to the console (LP: #1010582)
  * Add RHEVm and vSphere support as datasource AltCloud [Joseph VLcek]

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
#    Author: Scott Moser <scott.moser@canonical.com>
8
8
#    Author: Juerg Haefliger <juerg.haefliger@hp.com>
9
9
#    Author: Joshua Harlow <harlowja@yahoo-inc.com>
 
10
#    Author: Ben Howard <ben.howard@canonical.com>
10
11
#
11
12
#    This program is free software: you can redistribute it and/or modify
12
13
#    it under the terms of the GNU General Public License version 3, as
21
22
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
23
 
23
24
from cloudinit.distros import debian
24
 
 
25
25
from cloudinit import log as logging
 
26
from cloudinit import util
26
27
 
27
28
LOG = logging.getLogger(__name__)
28
29
 
29
30
 
30
31
class Distro(debian.Distro):
31
 
    pass
 
32
 
 
33
    distro_name = 'ubuntu'
 
34
    default_user = 'ubuntu'
 
35
 
 
36
    def create_user(self, name, **kargs):
 
37
 
 
38
        if not super(Distro, self).create_user(name, **kargs):
 
39
            return False
 
40
 
 
41
        if 'sshimportid' in kargs:
 
42
            cmd = ["sudo", "-Hu", name, "ssh-import-id"] + kargs['sshimportid']
 
43
            LOG.debug("Importing ssh ids for user %s, post user creation."
 
44
                        % name)
 
45
 
 
46
            try:
 
47
                util.subp(cmd, capture=True)
 
48
            except util.ProcessExecutionError as e:
 
49
                util.logexc(LOG, "Failed to import %s ssh ids", name)
 
50
                raise e
 
51
 
 
52
        return True