Updates to networking in vbox

This commit is contained in:
Anders Ingemann 2013-09-22 15:41:43 +02:00
parent 5dcec10d65
commit 885ace7b48
4 changed files with 30 additions and 18 deletions

View file

@ -12,6 +12,15 @@ class RemoveDNSInfo(Task):
remove(os.path.join(info.root, 'etc/resolv.conf'))
class RemoveHostname(Task):
description = 'Removing the hostname file'
phase = phases.system_modification
def run(self, info):
from os import remove
remove(os.path.join(info.root, 'etc/hostname'))
class ConfigureNetworkIF(Task):
description = 'Configuring network interfaces'
phase = phases.system_modification
@ -26,13 +35,3 @@ class ConfigureNetworkIF(Task):
'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\'')

View file

@ -16,7 +16,8 @@ from common.tasks import apt
from tasks import boot
from common.tasks import boot as common_boot
from common.tasks import security
from common.tasks import network
from tasks import network
from common.tasks import network as common_network
from tasks import initd
from common.tasks import initd as common_initd
from common.tasks import cleanup
@ -56,9 +57,9 @@ def tasks(tasklist, manifest):
security.EnableShadowConfig(),
security.DisableSSHPasswordAuthentication(),
security.DisableSSHDNSLookup(),
network.RemoveDNSInfo(),
network.ConfigureNetworkIF(),
network.ConfigureDHCP(),
common_network.RemoveDNSInfo(),
common_network.ConfigureNetworkIF(),
network.EnableDHCPCDDNS(),
common_initd.ResolveInitScripts(),
initd.AddEC2InitScripts(),
common_initd.InstallInitScripts(),

View file

@ -0,0 +1,15 @@
from base import Task
from common import phases
import os.path
class EnableDHCPCDDNS(Task):
description = 'Configuring the DHCP client to set the nameservers'
phase = phases.system_modification
def run(self, info):
# The dhcp client that ships with debian sets the DNS servers per default.
# For dhcpcd we need to configure it to do that.
from common.tools import sed_i
dhcpcd = os.path.join(info.root, 'etc/default/dhcpcd')
sed_i(dhcpcd, '^#*SET_DNS=.*', 'SET_DNS=\'yes\'')

View file

@ -50,15 +50,12 @@ def tasks(tasklist, manifest):
common_boot.BlackListModules(),
common_boot.DisableGetTTYs(),
security.EnableShadowConfig(),
security.DisableSSHPasswordAuthentication(),
security.DisableSSHDNSLookup(),
network.RemoveDNSInfo(),
network.ConfigureNetworkIF(),
network.ConfigureDHCP(),
network.RemoveHostname(),
initd.ResolveInitScripts(),
initd.InstallInitScripts(),
cleanup.ClearMOTD(),
cleanup.ShredHostkeys(),
cleanup.CleanTMP(),
apt.PurgeUnusedPackages(),
apt.AptClean(),