Move parts of packages task module into common tasks

This commit is contained in:
Anders Ingemann 2013-08-10 19:01:54 +02:00
parent 677ec22a04
commit 0785e21ab0
8 changed files with 81 additions and 59 deletions

27
common/tasks/packages.py Normal file
View file

@ -0,0 +1,27 @@
from base import Task
from common import phases
class HostPackages(Task):
description = 'Determining required host packages'
phase = phases.preparation
def run(self, info):
packages = set(['debootstrap'])
info.host_packages = packages
class ImagePackages(Task):
description = 'Determining required image packages'
phase = phases.preparation
def run(self, info):
# Add some basic packages we are going to need
include = set(['udev',
'openssh-server',
# We could bootstrap without locales, but things just suck without them, error messages etc.
'locales',
])
exclude = set()
info.img_packages = include, exclude

View file

@ -1,6 +1,6 @@
from base import Task
from common import phases
from providers.ec2.tasks.packages import ImagePackages
from common.tasks.packages import ImagePackages
from common.tasks.host import CheckPackages
from common.tasks.initd import InstallInitScripts
import os

View file

@ -1,6 +1,6 @@
from base import Task
from common import phases
from providers.ec2.tasks.packages import ImagePackages
from common.tasks.packages import ImagePackages
from common.tasks.host import CheckPackages

View file

@ -1,8 +1,8 @@
from base import Task
from common import phases
import os
from providers.raw.tasks.packages import ImagePackages
from providers.raw.tasks.host import CheckPackages
from common.tasks.packages import ImagePackages
from common.tasks.host import CheckPackages
from providers.raw.tasks.filesystem import MountVolume
@ -18,6 +18,7 @@ class AddUserPackages(Task):
for pkg in info.manifest.plugins['user_packages']['repo']:
info.img_packages[0].add(pkg)
class AddLocalUserPackages(Task):
description = 'Adding user local packages to the image packages'
phase = phases.system_modification
@ -42,4 +43,3 @@ class AddLocalUserPackages(Task):
os.chmod(script_dst, rwxr_xr_x)
log_check_call(['/usr/sbin/chroot', info.root, 'dpkg', '-i', '/tmp/'+os.path.basename(script_src)])

View file

@ -1,6 +1,7 @@
from manifest import Manifest
import logging
from tasks import packages
from common.tasks import packages as common_packages
from tasks import connection
from tasks import host
from common.tasks import host as common_host
@ -27,7 +28,9 @@ def initialize():
def tasks(tasklist, manifest):
tasklist.add(packages.HostPackages(),
common_packages.HostPackages(),
packages.ImagePackages(),
common_packages.ImagePackages(),
common_host.CheckPackages(),
connection.GetCredentials(),
host.GetInfo(),

View file

@ -1,44 +1,37 @@
from base import Task
from common import phases
from common.tasks import packages
from common.tasks.host import CheckPackages
class HostPackages(Task):
description = 'Determining required host packages'
description = 'Adding more required host packages'
phase = phases.preparation
before = [CheckPackages]
after = [packages.HostPackages]
def run(self, info):
packages = set(['debootstrap'])
if info.manifest.volume['filesystem'] == 'xfs':
packages.add('xfsprogs')
info.host_packages.add('xfsprogs')
if info.manifest.volume['backing'] == 's3':
packages.add('euca2ools')
info.host_packages = packages
info.host_packages.add('euca2ools')
class ImagePackages(Task):
description = 'Determining required image packages'
description = 'Adding more required image packages'
phase = phases.preparation
after = [packages.ImagePackages]
def run(self, info):
manifest = info.manifest
# Add some basic packages we are going to need
include = set(['udev',
'openssh-server',
# We could bootstrap without locales, but things just suck without them, error messages etc.
'locales',
# Needed for the init scripts
'file',
# isc-dhcp-client doesn't work properly with ec2
'dhcpcd',
])
include, exclude = info.img_packages
include.add('file') # Needed for the init scripts
include.add('dhcpcd') # isc-dhcp-client doesn't work properly with ec2
if manifest.virtualization == 'pvm':
include.add('grub-pc')
exclude = set(['isc-dhcp-client',
'isc-dhcp-common',
])
exclude.add('isc-dhcp-client')
exclude.add('isc-dhcp-common')
# In squeeze, we need a special kernel flavor for xen
kernels = {'squeeze': {'amd64': 'linux-image-xen-amd64',
@ -46,5 +39,3 @@ class ImagePackages(Task):
'wheezy': {'amd64': 'linux-image-amd64',
'i386': 'linux-image-686', }, }
include.add(kernels.get(manifest.system['release']).get(manifest.system['architecture']))
info.img_packages = include, exclude

View file

@ -1,5 +1,6 @@
from manifest import Manifest
from tasks import packages
from common.tasks import packages as common_packages
from tasks import host
from tasks import filesystem
from common.tasks import filesystem as common_filesystem
@ -21,7 +22,9 @@ def initialize():
def tasks(tasklist, manifest):
tasklist.add(packages.HostPackages(),
common_packages.HostPackages(),
packages.ImagePackages(),
common_packages.ImagePackages(),
host.CheckPackages(),
filesystem.FormatVolume(),

View file

@ -1,31 +1,31 @@
from base import Task
from common import phases
from common.tasks import packages
from common.tasks.host import CheckPackages
class HostPackages(Task):
description = 'Determining required host packages'
phase = phases.preparation
before = [CheckPackages]
after = [packages.HostPackages]
def run(self, info):
packages = set(['debootstrap', 'qemu-utils', 'parted', 'grub2', 'sysv-rc'])
info.host_packages.update(['qemu-utils', 'parted', 'grub2', 'sysv-rc'])
if info.manifest.volume['filesystem'] == 'xfs':
packages.add('xfsprogs')
info.host_packages = packages
info.host_packages.add('xfsprogs')
class ImagePackages(Task):
description = 'Determining required image packages'
phase = phases.preparation
after = [packages.ImagePackages]
def run(self, info):
manifest = info.manifest
include, exclude = info.img_packages
# Add some basic packages we are going to need
include = set(['udev',
'parted',
'openssh-server',
# We could bootstrap without locales, but things just suck without them, error messages etc.
'locales',
include.update(['parted',
# Needed for the init scripts
'file',
# isc-dhcp-client doesn't work properly with ec2
@ -35,7 +35,7 @@ class ImagePackages(Task):
'openssh-client'
])
exclude = set(['isc-dhcp-client',
exclude.update(['isc-dhcp-client',
'isc-dhcp-common',
])
@ -45,5 +45,3 @@ class ImagePackages(Task):
'wheezy': {'amd64': 'linux-image-amd64',
'i386': 'linux-image-686', }, }
include.add(kernels.get(manifest.system['release']).get(manifest.system['architecture']))
info.img_packages = include, exclude