Merge pull request #150 from timbot/debian-backports-growroot

Enable auto rootdisk growth on gce-backports
This commit is contained in:
Anders Ingemann 2014-10-13 20:24:03 +02:00
commit 880e13f0d8
4 changed files with 40 additions and 1 deletions

View file

@ -61,4 +61,4 @@ class AdjustExpandRootScript(Task):
script = os.path.join(info.root, 'etc/init.d/expand-root') script = os.path.join(info.root, 'etc/init.d/expand-root')
root_idx = info.volume.partition_map.root.get_index() root_idx = info.volume.partition_map.root.get_index()
device_path = 'device_path="/dev/xvda{idx}"'.format(idx=root_idx) device_path = 'device_path="/dev/xvda{idx}"'.format(idx=root_idx)
sed_i(script, '^device_path="/dev/xvda$', device_path) sed_i(script, '^device_path="/dev/xvda"$', device_path)

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