diff --git a/providers/ec2/tasks/locale.py b/common/tasks/locale.py similarity index 100% rename from providers/ec2/tasks/locale.py rename to common/tasks/locale.py diff --git a/providers/ec2/tasks/network.py b/common/tasks/network.py similarity index 100% rename from providers/ec2/tasks/network.py rename to common/tasks/network.py diff --git a/providers/ec2/__init__.py b/providers/ec2/__init__.py index 10c746f..11cde4d 100644 --- a/providers/ec2/__init__.py +++ b/providers/ec2/__init__.py @@ -8,12 +8,12 @@ from tasks import ebs from tasks import loopback from tasks import filesystem from common.tasks import bootstrap -from tasks import locale +from common.tasks import locale from common.tasks import apt from tasks import boot from common.tasks import boot as common_boot from tasks import security -from tasks import network +from common.tasks import network from tasks import initd from common.tasks import cleanup diff --git a/providers/raw/__init__.py b/providers/raw/__init__.py index dacdaca..bda1a99 100644 --- a/providers/raw/__init__.py +++ b/providers/raw/__init__.py @@ -4,12 +4,12 @@ from tasks import packages from tasks import host from tasks import filesystem from common.tasks import bootstrap -from tasks import locale +from common.tasks import locale from common.tasks import apt from tasks import boot from common.tasks import boot as common_boot from tasks import security -from tasks import network +from common.tasks import network from tasks import initd from common.tasks import cleanup diff --git a/providers/raw/tasks/locale.py b/providers/raw/tasks/locale.py deleted file mode 100644 index a0005b4..0000000 --- a/providers/raw/tasks/locale.py +++ /dev/null @@ -1,35 +0,0 @@ -from base import Task -from common import phases -import os.path - - -class GenerateLocale(Task): - description = 'Generating the selected locale' - phase = phases.system_modification - - def run(self, info): - from common.tools import sed_i - from common.tools import log_check_call - locale_gen = os.path.join(info.root, 'etc/locale.gen') - locale_str = '{locale}.{charmap} {charmap}'.format(locale=info.manifest.system['locale'], - charmap=info.manifest.system['charmap']) - search = '# ' + locale_str - sed_i(locale_gen, search, locale_str) - - command = ['/usr/sbin/chroot', info.root, '/usr/sbin/locale-gen'] - log_check_call(command) - - -class SetTimezone(Task): - description = 'Setting the selected timezone' - phase = phases.system_modification - - def run(self, info): - from shutil import copy - tz_path = os.path.join(info.root, 'etc/timezone') - timezone = info.manifest.system['timezone'] - with open(tz_path, 'w') as tz_file: - tz_file.write(timezone) - zoneinfo_path = os.path.join(info.root, '/usr/share/zoneinfo', timezone) - localtime_path = os.path.join(info.root, 'etc/localtime') - copy(zoneinfo_path, localtime_path) diff --git a/providers/raw/tasks/network.py b/providers/raw/tasks/network.py deleted file mode 100644 index 0910608..0000000 --- a/providers/raw/tasks/network.py +++ /dev/null @@ -1,38 +0,0 @@ -from base import Task -from common import phases -import os.path - - -class RemoveDNSInfo(Task): - description = 'Removing resolv.conf' - phase = phases.system_modification - - def run(self, info): - from os import remove - remove(os.path.join(info.root, 'etc/resolv.conf')) - - -class ConfigureNetworkIF(Task): - description = 'Configuring network interfaces' - phase = phases.system_modification - - def run(self, info): - interfaces_path = os.path.join(info.root, 'etc/network/interfaces') - if_config = {'squeeze': ('auto lo\n' - 'iface lo inet loopback\n' - 'auto eth0\n' - 'iface eth0 inet dhcp\n'), - 'wheezy': 'auto eth0\n' - 'iface eth0 inet dhcp\n'} - with open(interfaces_path, 'a') as interfaces: - interfaces.write(if_config.get(info.manifest.system['release'])) - - -class ConfigureDHCP(Task): - description = 'Configuring the DHCP client' - phase = phases.system_modification - - def run(self, info): - from common.tools import sed_i - dhcpcd = os.path.join(info.root, 'etc/default/dhcpcd') - sed_i(dhcpcd, '^#*SET_DNS=.*', 'SET_DNS=\'yes\'')