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 base import Task
from common import phases 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.host import CheckPackages
from common.tasks.initd import InstallInitScripts from common.tasks.initd import InstallInitScripts
import os import os

View file

@ -1,6 +1,6 @@
from base import Task from base import Task
from common import phases 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.host import CheckPackages

View file

@ -1,8 +1,8 @@
from base import Task from base import Task
from common import phases from common import phases
import os import os
from providers.raw.tasks.packages import ImagePackages from common.tasks.packages import ImagePackages
from providers.raw.tasks.host import CheckPackages from common.tasks.host import CheckPackages
from providers.raw.tasks.filesystem import MountVolume from providers.raw.tasks.filesystem import MountVolume
@ -18,28 +18,28 @@ class AddUserPackages(Task):
for pkg in info.manifest.plugins['user_packages']['repo']: for pkg in info.manifest.plugins['user_packages']['repo']:
info.img_packages[0].add(pkg) info.img_packages[0].add(pkg)
class AddLocalUserPackages(Task): class AddLocalUserPackages(Task):
description = 'Adding user local packages to the image packages' description = 'Adding user local packages to the image packages'
phase = phases.system_modification phase = phases.system_modification
after = [MountVolume] after = [MountVolume]
def run(self, info): def run(self, info):
if 'local' not in info.manifest.plugins['user_packages']: if 'local' not in info.manifest.plugins['user_packages']:
return return
import stat import stat
rwxr_xr_x = (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | rwxr_xr_x = (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
stat.S_IRGRP | stat.S_IXGRP | stat.S_IRGRP | stat.S_IXGRP |
stat.S_IROTH | stat.S_IXOTH) stat.S_IROTH | stat.S_IXOTH)
from shutil import copy from shutil import copy
from common.tools import log_check_call from common.tools import log_check_call
for pkg in info.manifest.plugins['user_packages']['local']: for pkg in info.manifest.plugins['user_packages']['local']:
script_src = os.path.normpath(pkg) script_src = os.path.normpath(pkg)
script_dst = os.path.join(info.root, 'tmp/'+os.path.basename(script_src)) script_dst = os.path.join(info.root, 'tmp/'+os.path.basename(script_src))
copy(script_src, script_dst) copy(script_src, script_dst)
os.chmod(script_dst, rwxr_xr_x) os.chmod(script_dst, rwxr_xr_x)
log_check_call(['/usr/sbin/chroot', info.root, 'dpkg', '-i', '/tmp/'+os.path.basename(script_src)])
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 from manifest import Manifest
import logging import logging
from tasks import packages from tasks import packages
from common.tasks import packages as common_packages
from tasks import connection from tasks import connection
from tasks import host from tasks import host
from common.tasks import host as common_host from common.tasks import host as common_host
@ -27,7 +28,9 @@ def initialize():
def tasks(tasklist, manifest): def tasks(tasklist, manifest):
tasklist.add(packages.HostPackages(), tasklist.add(packages.HostPackages(),
common_packages.HostPackages(),
packages.ImagePackages(), packages.ImagePackages(),
common_packages.ImagePackages(),
common_host.CheckPackages(), common_host.CheckPackages(),
connection.GetCredentials(), connection.GetCredentials(),
host.GetInfo(), host.GetInfo(),

View file

@ -1,44 +1,37 @@
from base import Task from base import Task
from common import phases from common import phases
from common.tasks import packages
from common.tasks.host import CheckPackages
class HostPackages(Task): class HostPackages(Task):
description = 'Determining required host packages' description = 'Adding more required host packages'
phase = phases.preparation phase = phases.preparation
before = [CheckPackages]
after = [packages.HostPackages]
def run(self, info): def run(self, info):
packages = set(['debootstrap'])
if info.manifest.volume['filesystem'] == 'xfs': if info.manifest.volume['filesystem'] == 'xfs':
packages.add('xfsprogs') info.host_packages.add('xfsprogs')
if info.manifest.volume['backing'] == 's3': if info.manifest.volume['backing'] == 's3':
packages.add('euca2ools') info.host_packages.add('euca2ools')
info.host_packages = packages
class ImagePackages(Task): class ImagePackages(Task):
description = 'Determining required image packages' description = 'Adding more required image packages'
phase = phases.preparation phase = phases.preparation
after = [packages.ImagePackages]
def run(self, info): def run(self, info):
manifest = info.manifest manifest = info.manifest
# Add some basic packages we are going to need include, exclude = info.img_packages
include = set(['udev', include.add('file') # Needed for the init scripts
'openssh-server', include.add('dhcpcd') # isc-dhcp-client doesn't work properly with ec2
# 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',
])
if manifest.virtualization == 'pvm': if manifest.virtualization == 'pvm':
include.add('grub-pc') include.add('grub-pc')
exclude = set(['isc-dhcp-client', exclude.add('isc-dhcp-client')
'isc-dhcp-common', exclude.add('isc-dhcp-common')
])
# In squeeze, we need a special kernel flavor for xen # In squeeze, we need a special kernel flavor for xen
kernels = {'squeeze': {'amd64': 'linux-image-xen-amd64', kernels = {'squeeze': {'amd64': 'linux-image-xen-amd64',
@ -46,5 +39,3 @@ class ImagePackages(Task):
'wheezy': {'amd64': 'linux-image-amd64', 'wheezy': {'amd64': 'linux-image-amd64',
'i386': 'linux-image-686', }, } 'i386': 'linux-image-686', }, }
include.add(kernels.get(manifest.system['release']).get(manifest.system['architecture'])) 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 manifest import Manifest
from tasks import packages from tasks import packages
from common.tasks import packages as common_packages
from tasks import host from tasks import host
from tasks import filesystem from tasks import filesystem
from common.tasks import filesystem as common_filesystem from common.tasks import filesystem as common_filesystem
@ -21,7 +22,9 @@ def initialize():
def tasks(tasklist, manifest): def tasks(tasklist, manifest):
tasklist.add(packages.HostPackages(), tasklist.add(packages.HostPackages(),
common_packages.HostPackages(),
packages.ImagePackages(), packages.ImagePackages(),
common_packages.ImagePackages(),
host.CheckPackages(), host.CheckPackages(),
filesystem.FormatVolume(), filesystem.FormatVolume(),

View file

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