~vila/uci-engine/enable-nova-and-swift

« back to all changes in this revision

Viewing changes to image-builder/imagebuilder/cloud_image.py

  • Committer: Evan Dandrea
  • Date: 2014-06-30 12:07:54 UTC
  • mfrom: (630 uci-engine)
  • mto: This revision was merged to the branch mainline in revision 655.
  • Revision ID: evan.dandrea@canonical.com-20140630120754-z6x5eqdahpp2qfrt
Merge with trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
    keys = {}
61
61
    for ppa in ppalist:
62
62
        ppamatch = re.match("ppa:(.+)/(.+)", ppa)
63
 
        #This will throw an exception for malformed ppas, intentional for now
 
63
        # This will throw an exception for malformed ppas, intentional for now
64
64
        (team, repo) = ppamatch.groups()
65
65
        ppa = lp.people[team].getPPAByName(name=repo)
66
66
        keys[ppa.name] = ppa.signing_key_fingerprint
67
67
        if ppa.private:
68
 
            #lp.me won't work, you have to get yourself by person
 
68
            # lp.me won't work, you have to get yourself by person
69
69
            user = lp.people[launchpad.get_lp_user_name()]
70
70
            url = user.getArchiveSubscriptionURL(archive=ppa)
71
71
        else:
149
149
    _chrooted(chroot, 'apt-get install -y {}'.format(' '.join(pkglist)))
150
150
    _chrooted(chroot, "/usr/bin/apt-get clean")
151
151
 
152
 
    #create a big null data file and remove it to make it more compressable
 
152
    # create a big null data file and remove it to make it more compressable
153
153
    status_cb('updating chroot to be more compressible...')
154
154
    zerofile = '%s/zero.tmp' % chroot
155
155
    filldata = '\0' * 4096
209
209
        self._umount_image()
210
210
 
211
211
    def _mount_image(self, image_path, tmpdir):
212
 
        #Find all the unused network block devices
 
212
        # Find all the unused network block devices
213
213
        mountpoint = '%s/mountpoint' % tmpdir
214
214
        os.mkdir(mountpoint)
215
215
        nbd_devs = [
227
227
                                 self.nbd_dev)
228
228
        runcmd('udevadm settle')
229
229
        runcmd('mount /dev/%sp1 %s' % (self.nbd_dev, mountpoint))
230
 
        #Mount /proc /sys and /dev in the image
 
230
        # Mount /proc /sys and /dev in the image
231
231
        for bmount in ['/proc', '/sys', '/dev']:
232
232
            runcmd('mount --bind %s %s/%s' % (bmount, mountpoint, bmount))
233
 
        #Backup resolv.conf and copy in the one from the local system
 
233
        # Backup resolv.conf and copy in the one from the local system
234
234
        if os.path.lexists('%s/etc/resolv.conf' % mountpoint):
235
235
            shutil.move('%s/etc/resolv.conf' % mountpoint,
236
236
                        '%s/etc/resolv.conf.orig' % mountpoint)