Enable auto-rootdisk growth on gce-backports.

This commit adds the cloud-initramfs-growroot package to the
installation list for GCE images with backports enabled, and updates
the gce tasklist to add the /etc/init.d/expand-root script
(with provider-appropriate touch-ups) to the image.
This commit is contained in:
Tim Smith 2014-10-09 21:06:15 -07:00
parent 3410118250
commit 7944db886f
3 changed files with 39 additions and 0 deletions

View file

@ -3,6 +3,7 @@ import tasks.apt
import tasks.boot import tasks.boot
import tasks.configuration import tasks.configuration
import tasks.image import tasks.image
import tasks.initd
import tasks.host import tasks.host
import tasks.packages import tasks.packages
from bootstrapvz.common.tasks import apt from bootstrapvz.common.tasks import apt
@ -31,6 +32,7 @@ def resolve_tasks(taskset, manifest):
tasks.apt.SetPackageRepositories, tasks.apt.SetPackageRepositories,
tasks.apt.ImportGoogleKey, tasks.apt.ImportGoogleKey,
tasks.packages.DefaultPackages, tasks.packages.DefaultPackages,
tasks.packages.ReleasePackages,
tasks.packages.GooglePackages, tasks.packages.GooglePackages,
tasks.configuration.GatherReleaseInformation, tasks.configuration.GatherReleaseInformation,
@ -38,6 +40,8 @@ def resolve_tasks(taskset, manifest):
tasks.host.DisableIPv6, tasks.host.DisableIPv6,
tasks.host.InstallHostnameHook, tasks.host.InstallHostnameHook,
tasks.boot.ConfigureGrub, tasks.boot.ConfigureGrub,
initd.AddExpandRoot,
tasks.initd.AdjustExpandRootDev,
initd.InstallInitScripts, initd.InstallInitScripts,
ssh.AddSSHKeyGeneration, ssh.AddSSHKeyGeneration,
ssh.DisableSSHPasswordAuthentication, ssh.DisableSSHPasswordAuthentication,
@ -48,6 +52,9 @@ def resolve_tasks(taskset, manifest):
volume.Delete, volume.Delete,
]) ])
if manifest.volume['partitions']['type'] != 'none':
taskset.add(initd.AdjustExpandRootScript)
if 'gcs_destination' in manifest.image: if 'gcs_destination' in manifest.image:
taskset.add(tasks.image.UploadImage) taskset.add(tasks.image.UploadImage)
if 'gce_project' in manifest.image: if 'gce_project' in manifest.image:

View file

@ -0,0 +1,16 @@
from bootstrapvz.base import Task
from bootstrapvz.common import phases
from bootstrapvz.common.tasks import initd
class AdjustExpandRootDev(Task):
description = 'Adjusting the expand-root device'
phase = phases.system_modification
predecessors = [initd.AddExpandRoot, initd.AdjustExpandRootScript]
@classmethod
def run(cls, info):
import os.path
from bootstrapvz.common.tools import sed_i
script = os.path.join(info.root, 'etc/init.d/expand-root')
sed_i(script, '/dev/xvda', '/dev/sda')

View file

@ -1,6 +1,7 @@
from bootstrapvz.base import Task from bootstrapvz.base import Task
from bootstrapvz.common import phases from bootstrapvz.common import phases
from bootstrapvz.common.tasks import apt from bootstrapvz.common.tasks import apt
import logging
import os import os
@ -28,6 +29,21 @@ class DefaultPackages(Task):
info.packages.add(kernel_package) info.packages.add(kernel_package)
class ReleasePackages(Task):
description = 'Adding release-specific packages required for GCE'
phase = phases.preparation
predecessors = [apt.AddDefaultSources, apt.AddBackports, DefaultPackages]
@classmethod
def run(cls, info):
# Add release-specific packages, if available.
if info.source_lists.target_exists('wheezy-backports'):
info.packages.add('cloud-initramfs-growroot')
else:
msg = ('No release-specific packages found for {system.release}').format(**info.manifest_vars)
logging.getLogger(__name__).warning(msg)
class GooglePackages(Task): class GooglePackages(Task):
description = 'Adding image packages required for GCE from Google repositories' description = 'Adding image packages required for GCE from Google repositories'
phase = phases.preparation phase = phases.preparation